babylon.max.js 7.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. /**
  335. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  336. */
  337. this.isRecursive = false;
  338. }
  339. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  340. /**
  341. * Does exist one action manager with at least one trigger
  342. **/
  343. get: function () {
  344. for (var t in AbstractActionManager.Triggers) {
  345. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  346. return true;
  347. }
  348. }
  349. return false;
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  355. /**
  356. * Does exist one action manager with at least one pick trigger
  357. **/
  358. get: function () {
  359. for (var t in AbstractActionManager.Triggers) {
  360. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  361. var t_int = parseInt(t);
  362. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  363. return true;
  364. }
  365. }
  366. }
  367. return false;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * Does exist one action manager that handles actions of a given trigger
  374. * @param trigger defines the trigger to be tested
  375. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  376. **/
  377. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  378. for (var t in AbstractActionManager.Triggers) {
  379. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  380. var t_int = parseInt(t);
  381. if (t_int === trigger) {
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. };
  388. /** Gets the list of active triggers */
  389. AbstractActionManager.Triggers = {};
  390. return AbstractActionManager;
  391. }());
  392. /***/ }),
  393. /***/ "./Actions/action.ts":
  394. /*!***************************!*\
  395. !*** ./Actions/action.ts ***!
  396. \***************************/
  397. /*! exports provided: Action */
  398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  399. "use strict";
  400. __webpack_require__.r(__webpack_exports__);
  401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  402. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  404. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  405. /**
  406. * The action to be carried out following a trigger
  407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  408. */
  409. var Action = /** @class */ (function () {
  410. /**
  411. * Creates a new Action
  412. * @param triggerOptions the trigger, with or without parameters, for the action
  413. * @param condition an optional determinant of action
  414. */
  415. function Action(
  416. /** the trigger, with or without parameters, for the action */
  417. triggerOptions, condition) {
  418. this.triggerOptions = triggerOptions;
  419. /**
  420. * An event triggered prior to action being executed.
  421. */
  422. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  423. if (triggerOptions.parameter) {
  424. this.trigger = triggerOptions.trigger;
  425. this._triggerParameter = triggerOptions.parameter;
  426. }
  427. else if (triggerOptions.trigger) {
  428. this.trigger = triggerOptions.trigger;
  429. }
  430. else {
  431. this.trigger = triggerOptions;
  432. }
  433. this._nextActiveAction = this;
  434. this._condition = condition;
  435. }
  436. /**
  437. * Internal only
  438. * @hidden
  439. */
  440. Action.prototype._prepare = function () {
  441. };
  442. /**
  443. * Gets the trigger parameters
  444. * @returns the trigger parameters
  445. */
  446. Action.prototype.getTriggerParameter = function () {
  447. return this._triggerParameter;
  448. };
  449. /**
  450. * Internal only - executes current action event
  451. * @hidden
  452. */
  453. Action.prototype._executeCurrent = function (evt) {
  454. if (this._nextActiveAction._condition) {
  455. var condition = this._nextActiveAction._condition;
  456. var currentRenderId = this._actionManager.getScene().getRenderId();
  457. // We cache the current evaluation for the current frame
  458. if (condition._evaluationId === currentRenderId) {
  459. if (!condition._currentResult) {
  460. return;
  461. }
  462. }
  463. else {
  464. condition._evaluationId = currentRenderId;
  465. if (!condition.isValid()) {
  466. condition._currentResult = false;
  467. return;
  468. }
  469. condition._currentResult = true;
  470. }
  471. }
  472. this.onBeforeExecuteObservable.notifyObservers(this);
  473. this._nextActiveAction.execute(evt);
  474. this.skipToNextActiveAction();
  475. };
  476. /**
  477. * Execute placeholder for child classes
  478. * @param evt optional action event
  479. */
  480. Action.prototype.execute = function (evt) {
  481. };
  482. /**
  483. * Skips to next active action
  484. */
  485. Action.prototype.skipToNextActiveAction = function () {
  486. if (this._nextActiveAction._child) {
  487. if (!this._nextActiveAction._child._actionManager) {
  488. this._nextActiveAction._child._actionManager = this._actionManager;
  489. }
  490. this._nextActiveAction = this._nextActiveAction._child;
  491. }
  492. else {
  493. this._nextActiveAction = this;
  494. }
  495. };
  496. /**
  497. * Adds action to chain of actions, may be a DoNothingAction
  498. * @param action defines the next action to execute
  499. * @returns The action passed in
  500. * @see https://www.babylonjs-playground.com/#1T30HR#0
  501. */
  502. Action.prototype.then = function (action) {
  503. this._child = action;
  504. action._actionManager = this._actionManager;
  505. action._prepare();
  506. return action;
  507. };
  508. /**
  509. * Internal only
  510. * @hidden
  511. */
  512. Action.prototype._getProperty = function (propertyPath) {
  513. return this._actionManager._getProperty(propertyPath);
  514. };
  515. /**
  516. * Internal only
  517. * @hidden
  518. */
  519. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  520. return this._actionManager._getEffectiveTarget(target, propertyPath);
  521. };
  522. /**
  523. * Serialize placeholder for child classes
  524. * @param parent of child
  525. * @returns the serialized object
  526. */
  527. Action.prototype.serialize = function (parent) {
  528. };
  529. /**
  530. * Internal only called by serialize
  531. * @hidden
  532. */
  533. Action.prototype._serialize = function (serializedAction, parent) {
  534. var serializationObject = {
  535. type: 1,
  536. children: [],
  537. name: serializedAction.name,
  538. properties: serializedAction.properties || []
  539. };
  540. // Serialize child
  541. if (this._child) {
  542. this._child.serialize(serializationObject);
  543. }
  544. // Check if "this" has a condition
  545. if (this._condition) {
  546. var serializedCondition = this._condition.serialize();
  547. serializedCondition.children.push(serializationObject);
  548. if (parent) {
  549. parent.children.push(serializedCondition);
  550. }
  551. return serializedCondition;
  552. }
  553. if (parent) {
  554. parent.children.push(serializationObject);
  555. }
  556. return serializationObject;
  557. };
  558. /**
  559. * Internal only
  560. * @hidden
  561. */
  562. Action._SerializeValueAsString = function (value) {
  563. if (typeof value === "number") {
  564. return value.toString();
  565. }
  566. if (typeof value === "boolean") {
  567. return value ? "true" : "false";
  568. }
  569. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  570. return value.x + ", " + value.y;
  571. }
  572. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  573. return value.x + ", " + value.y + ", " + value.z;
  574. }
  575. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  576. return value.r + ", " + value.g + ", " + value.b;
  577. }
  578. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  579. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  580. }
  581. return value; // string
  582. };
  583. /**
  584. * Internal only
  585. * @hidden
  586. */
  587. Action._GetTargetProperty = function (target) {
  588. return {
  589. name: "target",
  590. targetType: target._isMesh ? "MeshProperties"
  591. : target._isLight ? "LightProperties"
  592. : target._isCamera ? "CameraProperties"
  593. : "SceneProperties",
  594. value: target._isScene ? "Scene" : target.name
  595. };
  596. };
  597. return Action;
  598. }());
  599. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  600. /***/ }),
  601. /***/ "./Actions/actionEvent.ts":
  602. /*!********************************!*\
  603. !*** ./Actions/actionEvent.ts ***!
  604. \********************************/
  605. /*! exports provided: ActionEvent */
  606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  607. "use strict";
  608. __webpack_require__.r(__webpack_exports__);
  609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  610. /**
  611. * ActionEvent is the event being sent when an action is triggered.
  612. */
  613. var ActionEvent = /** @class */ (function () {
  614. /**
  615. * Creates a new ActionEvent
  616. * @param source The mesh or sprite that triggered the action
  617. * @param pointerX The X mouse cursor position at the time of the event
  618. * @param pointerY The Y mouse cursor position at the time of the event
  619. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  620. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  621. * @param additionalData additional data for the event
  622. */
  623. function ActionEvent(
  624. /** The mesh or sprite that triggered the action */
  625. source,
  626. /** The X mouse cursor position at the time of the event */
  627. pointerX,
  628. /** The Y mouse cursor position at the time of the event */
  629. pointerY,
  630. /** The mesh that is currently pointed at (can be null) */
  631. meshUnderPointer,
  632. /** the original (browser) event that triggered the ActionEvent */
  633. sourceEvent,
  634. /** additional data for the event */
  635. additionalData) {
  636. this.source = source;
  637. this.pointerX = pointerX;
  638. this.pointerY = pointerY;
  639. this.meshUnderPointer = meshUnderPointer;
  640. this.sourceEvent = sourceEvent;
  641. this.additionalData = additionalData;
  642. }
  643. /**
  644. * Helper function to auto-create an ActionEvent from a source mesh.
  645. * @param source The source mesh that triggered the event
  646. * @param evt The original (browser) event
  647. * @param additionalData additional data for the event
  648. * @returns the new ActionEvent
  649. */
  650. ActionEvent.CreateNew = function (source, evt, additionalData) {
  651. var scene = source.getScene();
  652. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer || source, evt, additionalData);
  653. };
  654. /**
  655. * Helper function to auto-create an ActionEvent from a source sprite
  656. * @param source The source sprite that triggered the event
  657. * @param scene Scene associated with the sprite
  658. * @param evt The original (browser) event
  659. * @param additionalData additional data for the event
  660. * @returns the new ActionEvent
  661. */
  662. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  663. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  664. };
  665. /**
  666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  667. * @param scene the scene where the event occurred
  668. * @param evt The original (browser) event
  669. * @returns the new ActionEvent
  670. */
  671. ActionEvent.CreateNewFromScene = function (scene, evt) {
  672. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  673. };
  674. /**
  675. * Helper function to auto-create an ActionEvent from a primitive
  676. * @param prim defines the target primitive
  677. * @param pointerPos defines the pointer position
  678. * @param evt The original (browser) event
  679. * @param additionalData additional data for the event
  680. * @returns the new ActionEvent
  681. */
  682. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  683. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  684. };
  685. return ActionEvent;
  686. }());
  687. /***/ }),
  688. /***/ "./Actions/actionManager.ts":
  689. /*!**********************************!*\
  690. !*** ./Actions/actionManager.ts ***!
  691. \**********************************/
  692. /*! exports provided: ActionManager */
  693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  694. "use strict";
  695. __webpack_require__.r(__webpack_exports__);
  696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  699. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  700. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  701. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  703. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  704. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  705. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  706. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  707. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  708. /**
  709. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  710. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  712. */
  713. var ActionManager = /** @class */ (function (_super) {
  714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  715. /**
  716. * Creates a new action manager
  717. * @param scene defines the hosting scene
  718. */
  719. function ActionManager(scene) {
  720. var _this = _super.call(this) || this;
  721. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  722. scene.actionManagers.push(_this);
  723. return _this;
  724. }
  725. // Methods
  726. /**
  727. * Releases all associated resources
  728. */
  729. ActionManager.prototype.dispose = function () {
  730. var index = this._scene.actionManagers.indexOf(this);
  731. for (var i = 0; i < this.actions.length; i++) {
  732. var action = this.actions[i];
  733. ActionManager.Triggers[action.trigger]--;
  734. if (ActionManager.Triggers[action.trigger] === 0) {
  735. delete ActionManager.Triggers[action.trigger];
  736. }
  737. }
  738. if (index > -1) {
  739. this._scene.actionManagers.splice(index, 1);
  740. }
  741. };
  742. /**
  743. * Gets hosting scene
  744. * @returns the hosting scene
  745. */
  746. ActionManager.prototype.getScene = function () {
  747. return this._scene;
  748. };
  749. /**
  750. * Does this action manager handles actions of any of the given triggers
  751. * @param triggers defines the triggers to be tested
  752. * @return a boolean indicating whether one (or more) of the triggers is handled
  753. */
  754. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  755. for (var index = 0; index < this.actions.length; index++) {
  756. var action = this.actions[index];
  757. if (triggers.indexOf(action.trigger) > -1) {
  758. return true;
  759. }
  760. }
  761. return false;
  762. };
  763. /**
  764. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  765. * speed.
  766. * @param triggerA defines the trigger to be tested
  767. * @param triggerB defines the trigger to be tested
  768. * @return a boolean indicating whether one (or more) of the triggers is handled
  769. */
  770. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  771. for (var index = 0; index < this.actions.length; index++) {
  772. var action = this.actions[index];
  773. if (triggerA == action.trigger || triggerB == action.trigger) {
  774. return true;
  775. }
  776. }
  777. return false;
  778. };
  779. /**
  780. * Does this action manager handles actions of a given trigger
  781. * @param trigger defines the trigger to be tested
  782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  783. * @return whether the trigger is handled
  784. */
  785. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  786. for (var index = 0; index < this.actions.length; index++) {
  787. var action = this.actions[index];
  788. if (action.trigger === trigger) {
  789. if (parameterPredicate) {
  790. if (parameterPredicate(action.getTriggerParameter())) {
  791. return true;
  792. }
  793. }
  794. else {
  795. return true;
  796. }
  797. }
  798. }
  799. return false;
  800. };
  801. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  802. /**
  803. * Does this action manager has pointer triggers
  804. */
  805. get: function () {
  806. for (var index = 0; index < this.actions.length; index++) {
  807. var action = this.actions[index];
  808. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  809. return true;
  810. }
  811. }
  812. return false;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  818. /**
  819. * Does this action manager has pick triggers
  820. */
  821. get: function () {
  822. for (var index = 0; index < this.actions.length; index++) {
  823. var action = this.actions[index];
  824. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  825. return true;
  826. }
  827. }
  828. return false;
  829. },
  830. enumerable: true,
  831. configurable: true
  832. });
  833. /**
  834. * Registers an action to this action manager
  835. * @param action defines the action to be registered
  836. * @return the action amended (prepared) after registration
  837. */
  838. ActionManager.prototype.registerAction = function (action) {
  839. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  840. if (this.getScene().actionManager !== this) {
  841. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  842. return null;
  843. }
  844. }
  845. this.actions.push(action);
  846. if (ActionManager.Triggers[action.trigger]) {
  847. ActionManager.Triggers[action.trigger]++;
  848. }
  849. else {
  850. ActionManager.Triggers[action.trigger] = 1;
  851. }
  852. action._actionManager = this;
  853. action._prepare();
  854. return action;
  855. };
  856. /**
  857. * Unregisters an action to this action manager
  858. * @param action defines the action to be unregistered
  859. * @return a boolean indicating whether the action has been unregistered
  860. */
  861. ActionManager.prototype.unregisterAction = function (action) {
  862. var index = this.actions.indexOf(action);
  863. if (index !== -1) {
  864. this.actions.splice(index, 1);
  865. ActionManager.Triggers[action.trigger] -= 1;
  866. if (ActionManager.Triggers[action.trigger] === 0) {
  867. delete ActionManager.Triggers[action.trigger];
  868. }
  869. delete action._actionManager;
  870. return true;
  871. }
  872. return false;
  873. };
  874. /**
  875. * Process a specific trigger
  876. * @param trigger defines the trigger to process
  877. * @param evt defines the event details to be processed
  878. */
  879. ActionManager.prototype.processTrigger = function (trigger, evt) {
  880. for (var index = 0; index < this.actions.length; index++) {
  881. var action = this.actions[index];
  882. if (action.trigger === trigger) {
  883. if (evt) {
  884. if (trigger === ActionManager.OnKeyUpTrigger
  885. || trigger === ActionManager.OnKeyDownTrigger) {
  886. var parameter = action.getTriggerParameter();
  887. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  888. if (!parameter.toLowerCase) {
  889. continue;
  890. }
  891. var lowerCase = parameter.toLowerCase();
  892. if (lowerCase !== evt.sourceEvent.key) {
  893. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  894. var actualkey = String.fromCharCode(unicode).toLowerCase();
  895. if (actualkey !== lowerCase) {
  896. continue;
  897. }
  898. }
  899. }
  900. }
  901. }
  902. action._executeCurrent(evt);
  903. }
  904. }
  905. };
  906. /** @hidden */
  907. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  908. var properties = propertyPath.split(".");
  909. for (var index = 0; index < properties.length - 1; index++) {
  910. target = target[properties[index]];
  911. }
  912. return target;
  913. };
  914. /** @hidden */
  915. ActionManager.prototype._getProperty = function (propertyPath) {
  916. var properties = propertyPath.split(".");
  917. return properties[properties.length - 1];
  918. };
  919. /**
  920. * Serialize this manager to a JSON object
  921. * @param name defines the property name to store this manager
  922. * @returns a JSON representation of this manager
  923. */
  924. ActionManager.prototype.serialize = function (name) {
  925. var root = {
  926. children: new Array(),
  927. name: name,
  928. type: 3,
  929. properties: new Array() // Empty for root but required
  930. };
  931. for (var i = 0; i < this.actions.length; i++) {
  932. var triggerObject = {
  933. type: 0,
  934. children: new Array(),
  935. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  936. properties: new Array()
  937. };
  938. var triggerOptions = this.actions[i].triggerOptions;
  939. if (triggerOptions && typeof triggerOptions !== "number") {
  940. if (triggerOptions.parameter instanceof Node) {
  941. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  942. }
  943. else {
  944. var parameter = {};
  945. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  946. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  947. parameter._meshId = triggerOptions.parameter.mesh.id;
  948. }
  949. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  950. }
  951. }
  952. // Serialize child action, recursively
  953. this.actions[i].serialize(triggerObject);
  954. // Add serialized trigger
  955. root.children.push(triggerObject);
  956. }
  957. return root;
  958. };
  959. /**
  960. * Creates a new ActionManager from a JSON data
  961. * @param parsedActions defines the JSON data to read from
  962. * @param object defines the hosting mesh
  963. * @param scene defines the hosting scene
  964. */
  965. ActionManager.Parse = function (parsedActions, object, scene) {
  966. var actionManager = new ActionManager(scene);
  967. if (object === null) {
  968. scene.actionManager = actionManager;
  969. }
  970. else {
  971. object.actionManager = actionManager;
  972. }
  973. // instanciate a new object
  974. var instanciate = function (name, params) {
  975. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  976. if (internalClassType) {
  977. var newInstance = Object.create(internalClassType.prototype);
  978. newInstance.constructor.apply(newInstance, params);
  979. return newInstance;
  980. }
  981. };
  982. var parseParameter = function (name, value, target, propertyPath) {
  983. if (propertyPath === null) {
  984. // String, boolean or float
  985. var floatValue = parseFloat(value);
  986. if (value === "true" || value === "false") {
  987. return value === "true";
  988. }
  989. else {
  990. return isNaN(floatValue) ? value : floatValue;
  991. }
  992. }
  993. var effectiveTarget = propertyPath.split(".");
  994. var values = value.split(",");
  995. // Get effective Target
  996. for (var i = 0; i < effectiveTarget.length; i++) {
  997. target = target[effectiveTarget[i]];
  998. }
  999. // Return appropriate value with its type
  1000. if (typeof (target) === "boolean") {
  1001. return values[0] === "true";
  1002. }
  1003. if (typeof (target) === "string") {
  1004. return values[0];
  1005. }
  1006. // Parameters with multiple values such as Vector3 etc.
  1007. var split = new Array();
  1008. for (var i = 0; i < values.length; i++) {
  1009. split.push(parseFloat(values[i]));
  1010. }
  1011. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1012. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1013. }
  1014. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1015. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1016. }
  1017. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1018. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1019. }
  1020. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1021. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1022. }
  1023. return parseFloat(values[0]);
  1024. };
  1025. // traverse graph per trigger
  1026. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1027. if (combineArray === void 0) { combineArray = null; }
  1028. if (parsedAction.detached) {
  1029. return;
  1030. }
  1031. var parameters = new Array();
  1032. var target = null;
  1033. var propertyPath = null;
  1034. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1035. // Parameters
  1036. if (parsedAction.type === 2) {
  1037. parameters.push(actionManager);
  1038. }
  1039. else {
  1040. parameters.push(trigger);
  1041. }
  1042. if (combine) {
  1043. var actions = new Array();
  1044. for (var j = 0; j < parsedAction.combine.length; j++) {
  1045. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1046. }
  1047. parameters.push(actions);
  1048. }
  1049. else {
  1050. for (var i = 0; i < parsedAction.properties.length; i++) {
  1051. var value = parsedAction.properties[i].value;
  1052. var name = parsedAction.properties[i].name;
  1053. var targetType = parsedAction.properties[i].targetType;
  1054. if (name === "target") {
  1055. if (targetType !== null && targetType === "SceneProperties") {
  1056. value = target = scene;
  1057. }
  1058. else {
  1059. value = target = scene.getNodeByName(value);
  1060. }
  1061. }
  1062. else if (name === "parent") {
  1063. value = scene.getNodeByName(value);
  1064. }
  1065. else if (name === "sound") {
  1066. // Can not externalize to component, so only checks for the presence off the API.
  1067. if (scene.getSoundByName) {
  1068. value = scene.getSoundByName(value);
  1069. }
  1070. }
  1071. else if (name !== "propertyPath") {
  1072. if (parsedAction.type === 2 && name === "operator") {
  1073. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1074. }
  1075. else {
  1076. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1077. }
  1078. }
  1079. else {
  1080. propertyPath = value;
  1081. }
  1082. parameters.push(value);
  1083. }
  1084. }
  1085. if (combineArray === null) {
  1086. parameters.push(condition);
  1087. }
  1088. else {
  1089. parameters.push(null);
  1090. }
  1091. // If interpolate value action
  1092. if (parsedAction.name === "InterpolateValueAction") {
  1093. var param = parameters[parameters.length - 2];
  1094. parameters[parameters.length - 1] = param;
  1095. parameters[parameters.length - 2] = condition;
  1096. }
  1097. // Action or condition(s) and not CombineAction
  1098. var newAction = instanciate(parsedAction.name, parameters);
  1099. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1100. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1101. if (action) {
  1102. action.then(nothing);
  1103. }
  1104. else {
  1105. actionManager.registerAction(nothing);
  1106. }
  1107. action = nothing;
  1108. }
  1109. if (combineArray === null) {
  1110. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1111. condition = newAction;
  1112. newAction = action;
  1113. }
  1114. else {
  1115. condition = null;
  1116. if (action) {
  1117. action.then(newAction);
  1118. }
  1119. else {
  1120. actionManager.registerAction(newAction);
  1121. }
  1122. }
  1123. }
  1124. else {
  1125. combineArray.push(newAction);
  1126. }
  1127. for (var i = 0; i < parsedAction.children.length; i++) {
  1128. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1129. }
  1130. };
  1131. // triggers
  1132. for (var i = 0; i < parsedActions.children.length; i++) {
  1133. var triggerParams;
  1134. var trigger = parsedActions.children[i];
  1135. if (trigger.properties.length > 0) {
  1136. var param = trigger.properties[0].value;
  1137. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1138. if (value._meshId) {
  1139. value.mesh = scene.getMeshByID(value._meshId);
  1140. }
  1141. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1142. }
  1143. else {
  1144. triggerParams = ActionManager[trigger.name];
  1145. }
  1146. for (var j = 0; j < trigger.children.length; j++) {
  1147. if (!trigger.detached) {
  1148. traverse(trigger.children[j], triggerParams, null, null);
  1149. }
  1150. }
  1151. }
  1152. };
  1153. /**
  1154. * Get a trigger name by index
  1155. * @param trigger defines the trigger index
  1156. * @returns a trigger name
  1157. */
  1158. ActionManager.GetTriggerName = function (trigger) {
  1159. switch (trigger) {
  1160. case 0: return "NothingTrigger";
  1161. case 1: return "OnPickTrigger";
  1162. case 2: return "OnLeftPickTrigger";
  1163. case 3: return "OnRightPickTrigger";
  1164. case 4: return "OnCenterPickTrigger";
  1165. case 5: return "OnPickDownTrigger";
  1166. case 6: return "OnPickUpTrigger";
  1167. case 7: return "OnLongPressTrigger";
  1168. case 8: return "OnPointerOverTrigger";
  1169. case 9: return "OnPointerOutTrigger";
  1170. case 10: return "OnEveryFrameTrigger";
  1171. case 11: return "OnIntersectionEnterTrigger";
  1172. case 12: return "OnIntersectionExitTrigger";
  1173. case 13: return "OnKeyDownTrigger";
  1174. case 14: return "OnKeyUpTrigger";
  1175. case 15: return "OnPickOutTrigger";
  1176. default: return "";
  1177. }
  1178. };
  1179. /**
  1180. * Nothing
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1182. */
  1183. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1184. /**
  1185. * On pick
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1187. */
  1188. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1189. /**
  1190. * On left pick
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1194. /**
  1195. * On right pick
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1199. /**
  1200. * On center pick
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1204. /**
  1205. * On pick down
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1209. /**
  1210. * On double pick
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1214. /**
  1215. * On pick up
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1219. /**
  1220. * On pick out.
  1221. * This trigger will only be raised if you also declared a OnPickDown
  1222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1223. */
  1224. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1225. /**
  1226. * On long press
  1227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1228. */
  1229. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1230. /**
  1231. * On pointer over
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1233. */
  1234. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1235. /**
  1236. * On pointer out
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1238. */
  1239. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1240. /**
  1241. * On every frame
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1243. */
  1244. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1245. /**
  1246. * On intersection enter
  1247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1248. */
  1249. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1250. /**
  1251. * On intersection exit
  1252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1253. */
  1254. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1255. /**
  1256. * On key down
  1257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1258. */
  1259. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1260. /**
  1261. * On key up
  1262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1263. */
  1264. ActionManager.OnKeyUpTrigger = 15;
  1265. return ActionManager;
  1266. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1267. /***/ }),
  1268. /***/ "./Actions/condition.ts":
  1269. /*!******************************!*\
  1270. !*** ./Actions/condition.ts ***!
  1271. \******************************/
  1272. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1274. "use strict";
  1275. __webpack_require__.r(__webpack_exports__);
  1276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1281. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1283. /**
  1284. * A Condition applied to an Action
  1285. */
  1286. var Condition = /** @class */ (function () {
  1287. /**
  1288. * Creates a new Condition
  1289. * @param actionManager the manager of the action the condition is applied to
  1290. */
  1291. function Condition(actionManager) {
  1292. this._actionManager = actionManager;
  1293. }
  1294. /**
  1295. * Check if the current condition is valid
  1296. * @returns a boolean
  1297. */
  1298. Condition.prototype.isValid = function () {
  1299. return true;
  1300. };
  1301. /**
  1302. * Internal only
  1303. * @hidden
  1304. */
  1305. Condition.prototype._getProperty = function (propertyPath) {
  1306. return this._actionManager._getProperty(propertyPath);
  1307. };
  1308. /**
  1309. * Internal only
  1310. * @hidden
  1311. */
  1312. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1313. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1314. };
  1315. /**
  1316. * Serialize placeholder for child classes
  1317. * @returns the serialized object
  1318. */
  1319. Condition.prototype.serialize = function () {
  1320. };
  1321. /**
  1322. * Internal only
  1323. * @hidden
  1324. */
  1325. Condition.prototype._serialize = function (serializedCondition) {
  1326. return {
  1327. type: 2,
  1328. children: [],
  1329. name: serializedCondition.name,
  1330. properties: serializedCondition.properties
  1331. };
  1332. };
  1333. return Condition;
  1334. }());
  1335. /**
  1336. * Defines specific conditional operators as extensions of Condition
  1337. */
  1338. var ValueCondition = /** @class */ (function (_super) {
  1339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1340. /**
  1341. * Creates a new ValueCondition
  1342. * @param actionManager manager for the action the condition applies to
  1343. * @param target for the action
  1344. * @param propertyPath path to specify the property of the target the conditional operator uses
  1345. * @param value the value compared by the conditional operator against the current value of the property
  1346. * @param operator the conditional operator, default ValueCondition.IsEqual
  1347. */
  1348. function ValueCondition(actionManager, target,
  1349. /** path to specify the property of the target the conditional operator uses */
  1350. propertyPath,
  1351. /** the value compared by the conditional operator against the current value of the property */
  1352. value,
  1353. /** the conditional operator, default ValueCondition.IsEqual */
  1354. operator) {
  1355. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1356. var _this = _super.call(this, actionManager) || this;
  1357. _this.propertyPath = propertyPath;
  1358. _this.value = value;
  1359. _this.operator = operator;
  1360. _this._target = target;
  1361. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1362. _this._property = _this._getProperty(_this.propertyPath);
  1363. return _this;
  1364. }
  1365. Object.defineProperty(ValueCondition, "IsEqual", {
  1366. /**
  1367. * returns the number for IsEqual
  1368. */
  1369. get: function () {
  1370. return ValueCondition._IsEqual;
  1371. },
  1372. enumerable: true,
  1373. configurable: true
  1374. });
  1375. Object.defineProperty(ValueCondition, "IsDifferent", {
  1376. /**
  1377. * Returns the number for IsDifferent
  1378. */
  1379. get: function () {
  1380. return ValueCondition._IsDifferent;
  1381. },
  1382. enumerable: true,
  1383. configurable: true
  1384. });
  1385. Object.defineProperty(ValueCondition, "IsGreater", {
  1386. /**
  1387. * Returns the number for IsGreater
  1388. */
  1389. get: function () {
  1390. return ValueCondition._IsGreater;
  1391. },
  1392. enumerable: true,
  1393. configurable: true
  1394. });
  1395. Object.defineProperty(ValueCondition, "IsLesser", {
  1396. /**
  1397. * Returns the number for IsLesser
  1398. */
  1399. get: function () {
  1400. return ValueCondition._IsLesser;
  1401. },
  1402. enumerable: true,
  1403. configurable: true
  1404. });
  1405. /**
  1406. * Compares the given value with the property value for the specified conditional operator
  1407. * @returns the result of the comparison
  1408. */
  1409. ValueCondition.prototype.isValid = function () {
  1410. switch (this.operator) {
  1411. case ValueCondition.IsGreater:
  1412. return this._effectiveTarget[this._property] > this.value;
  1413. case ValueCondition.IsLesser:
  1414. return this._effectiveTarget[this._property] < this.value;
  1415. case ValueCondition.IsEqual:
  1416. case ValueCondition.IsDifferent:
  1417. var check;
  1418. if (this.value.equals) {
  1419. check = this.value.equals(this._effectiveTarget[this._property]);
  1420. }
  1421. else {
  1422. check = this.value === this._effectiveTarget[this._property];
  1423. }
  1424. return this.operator === ValueCondition.IsEqual ? check : !check;
  1425. }
  1426. return false;
  1427. };
  1428. /**
  1429. * Serialize the ValueCondition into a JSON compatible object
  1430. * @returns serialization object
  1431. */
  1432. ValueCondition.prototype.serialize = function () {
  1433. return this._serialize({
  1434. name: "ValueCondition",
  1435. properties: [
  1436. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1437. { name: "propertyPath", value: this.propertyPath },
  1438. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1439. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1440. ]
  1441. });
  1442. };
  1443. /**
  1444. * Gets the name of the conditional operator for the ValueCondition
  1445. * @param operator the conditional operator
  1446. * @returns the name
  1447. */
  1448. ValueCondition.GetOperatorName = function (operator) {
  1449. switch (operator) {
  1450. case ValueCondition._IsEqual: return "IsEqual";
  1451. case ValueCondition._IsDifferent: return "IsDifferent";
  1452. case ValueCondition._IsGreater: return "IsGreater";
  1453. case ValueCondition._IsLesser: return "IsLesser";
  1454. default: return "";
  1455. }
  1456. };
  1457. /**
  1458. * Internal only
  1459. * @hidden
  1460. */
  1461. ValueCondition._IsEqual = 0;
  1462. /**
  1463. * Internal only
  1464. * @hidden
  1465. */
  1466. ValueCondition._IsDifferent = 1;
  1467. /**
  1468. * Internal only
  1469. * @hidden
  1470. */
  1471. ValueCondition._IsGreater = 2;
  1472. /**
  1473. * Internal only
  1474. * @hidden
  1475. */
  1476. ValueCondition._IsLesser = 3;
  1477. return ValueCondition;
  1478. }(Condition));
  1479. /**
  1480. * Defines a predicate condition as an extension of Condition
  1481. */
  1482. var PredicateCondition = /** @class */ (function (_super) {
  1483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1484. /**
  1485. * Creates a new PredicateCondition
  1486. * @param actionManager manager for the action the condition applies to
  1487. * @param predicate defines the predicate function used to validate the condition
  1488. */
  1489. function PredicateCondition(actionManager,
  1490. /** defines the predicate function used to validate the condition */
  1491. predicate) {
  1492. var _this = _super.call(this, actionManager) || this;
  1493. _this.predicate = predicate;
  1494. return _this;
  1495. }
  1496. /**
  1497. * @returns the validity of the predicate condition
  1498. */
  1499. PredicateCondition.prototype.isValid = function () {
  1500. return this.predicate();
  1501. };
  1502. return PredicateCondition;
  1503. }(Condition));
  1504. /**
  1505. * Defines a state condition as an extension of Condition
  1506. */
  1507. var StateCondition = /** @class */ (function (_super) {
  1508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1509. /**
  1510. * Creates a new StateCondition
  1511. * @param actionManager manager for the action the condition applies to
  1512. * @param target of the condition
  1513. * @param value to compare with target state
  1514. */
  1515. function StateCondition(actionManager, target,
  1516. /** Value to compare with target state */
  1517. value) {
  1518. var _this = _super.call(this, actionManager) || this;
  1519. _this.value = value;
  1520. _this._target = target;
  1521. return _this;
  1522. }
  1523. /**
  1524. * Gets a boolean indicating if the current condition is met
  1525. * @returns the validity of the state
  1526. */
  1527. StateCondition.prototype.isValid = function () {
  1528. return this._target.state === this.value;
  1529. };
  1530. /**
  1531. * Serialize the StateCondition into a JSON compatible object
  1532. * @returns serialization object
  1533. */
  1534. StateCondition.prototype.serialize = function () {
  1535. return this._serialize({
  1536. name: "StateCondition",
  1537. properties: [
  1538. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1539. { name: "value", value: this.value }
  1540. ]
  1541. });
  1542. };
  1543. return StateCondition;
  1544. }(Condition));
  1545. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1546. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1547. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1548. /***/ }),
  1549. /***/ "./Actions/directActions.ts":
  1550. /*!**********************************!*\
  1551. !*** ./Actions/directActions.ts ***!
  1552. \**********************************/
  1553. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1555. "use strict";
  1556. __webpack_require__.r(__webpack_exports__);
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1567. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1568. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1569. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1570. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1572. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1573. /**
  1574. * This defines an action responsible to toggle a boolean once triggered.
  1575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1576. */
  1577. var SwitchBooleanAction = /** @class */ (function (_super) {
  1578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1579. /**
  1580. * Instantiate the action
  1581. * @param triggerOptions defines the trigger options
  1582. * @param target defines the object containing the boolean
  1583. * @param propertyPath defines the path to the boolean property in the target object
  1584. * @param condition defines the trigger related conditions
  1585. */
  1586. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1587. var _this = _super.call(this, triggerOptions, condition) || this;
  1588. _this.propertyPath = propertyPath;
  1589. _this._target = _this._effectiveTarget = target;
  1590. return _this;
  1591. }
  1592. /** @hidden */
  1593. SwitchBooleanAction.prototype._prepare = function () {
  1594. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1595. this._property = this._getProperty(this.propertyPath);
  1596. };
  1597. /**
  1598. * Execute the action toggle the boolean value.
  1599. */
  1600. SwitchBooleanAction.prototype.execute = function () {
  1601. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1602. };
  1603. /**
  1604. * Serializes the actions and its related information.
  1605. * @param parent defines the object to serialize in
  1606. * @returns the serialized object
  1607. */
  1608. SwitchBooleanAction.prototype.serialize = function (parent) {
  1609. return _super.prototype._serialize.call(this, {
  1610. name: "SwitchBooleanAction",
  1611. properties: [
  1612. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1613. { name: "propertyPath", value: this.propertyPath }
  1614. ]
  1615. }, parent);
  1616. };
  1617. return SwitchBooleanAction;
  1618. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1619. /**
  1620. * This defines an action responsible to set a the state field of the target
  1621. * to a desired value once triggered.
  1622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1623. */
  1624. var SetStateAction = /** @class */ (function (_super) {
  1625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1626. /**
  1627. * Instantiate the action
  1628. * @param triggerOptions defines the trigger options
  1629. * @param target defines the object containing the state property
  1630. * @param value defines the value to store in the state field
  1631. * @param condition defines the trigger related conditions
  1632. */
  1633. function SetStateAction(triggerOptions, target, value, condition) {
  1634. var _this = _super.call(this, triggerOptions, condition) || this;
  1635. _this.value = value;
  1636. _this._target = target;
  1637. return _this;
  1638. }
  1639. /**
  1640. * Execute the action and store the value on the target state property.
  1641. */
  1642. SetStateAction.prototype.execute = function () {
  1643. this._target.state = this.value;
  1644. };
  1645. /**
  1646. * Serializes the actions and its related information.
  1647. * @param parent defines the object to serialize in
  1648. * @returns the serialized object
  1649. */
  1650. SetStateAction.prototype.serialize = function (parent) {
  1651. return _super.prototype._serialize.call(this, {
  1652. name: "SetStateAction",
  1653. properties: [
  1654. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1655. { name: "value", value: this.value }
  1656. ]
  1657. }, parent);
  1658. };
  1659. return SetStateAction;
  1660. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1661. /**
  1662. * This defines an action responsible to set a property of the target
  1663. * to a desired value once triggered.
  1664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1665. */
  1666. var SetValueAction = /** @class */ (function (_super) {
  1667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1668. /**
  1669. * Instantiate the action
  1670. * @param triggerOptions defines the trigger options
  1671. * @param target defines the object containing the property
  1672. * @param propertyPath defines the path of the property to set in the target
  1673. * @param value defines the value to set in the property
  1674. * @param condition defines the trigger related conditions
  1675. */
  1676. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1677. var _this = _super.call(this, triggerOptions, condition) || this;
  1678. _this.propertyPath = propertyPath;
  1679. _this.value = value;
  1680. _this._target = _this._effectiveTarget = target;
  1681. return _this;
  1682. }
  1683. /** @hidden */
  1684. SetValueAction.prototype._prepare = function () {
  1685. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1686. this._property = this._getProperty(this.propertyPath);
  1687. };
  1688. /**
  1689. * Execute the action and set the targetted property to the desired value.
  1690. */
  1691. SetValueAction.prototype.execute = function () {
  1692. this._effectiveTarget[this._property] = this.value;
  1693. if (this._target.markAsDirty) {
  1694. this._target.markAsDirty(this._property);
  1695. }
  1696. };
  1697. /**
  1698. * Serializes the actions and its related information.
  1699. * @param parent defines the object to serialize in
  1700. * @returns the serialized object
  1701. */
  1702. SetValueAction.prototype.serialize = function (parent) {
  1703. return _super.prototype._serialize.call(this, {
  1704. name: "SetValueAction",
  1705. properties: [
  1706. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1707. { name: "propertyPath", value: this.propertyPath },
  1708. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1709. ]
  1710. }, parent);
  1711. };
  1712. return SetValueAction;
  1713. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1714. /**
  1715. * This defines an action responsible to increment the target value
  1716. * to a desired value once triggered.
  1717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1718. */
  1719. var IncrementValueAction = /** @class */ (function (_super) {
  1720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1721. /**
  1722. * Instantiate the action
  1723. * @param triggerOptions defines the trigger options
  1724. * @param target defines the object containing the property
  1725. * @param propertyPath defines the path of the property to increment in the target
  1726. * @param value defines the value value we should increment the property by
  1727. * @param condition defines the trigger related conditions
  1728. */
  1729. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1730. var _this = _super.call(this, triggerOptions, condition) || this;
  1731. _this.propertyPath = propertyPath;
  1732. _this.value = value;
  1733. _this._target = _this._effectiveTarget = target;
  1734. return _this;
  1735. }
  1736. /** @hidden */
  1737. IncrementValueAction.prototype._prepare = function () {
  1738. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1739. this._property = this._getProperty(this.propertyPath);
  1740. if (typeof this._effectiveTarget[this._property] !== "number") {
  1741. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1742. }
  1743. };
  1744. /**
  1745. * Execute the action and increment the target of the value amount.
  1746. */
  1747. IncrementValueAction.prototype.execute = function () {
  1748. this._effectiveTarget[this._property] += this.value;
  1749. if (this._target.markAsDirty) {
  1750. this._target.markAsDirty(this._property);
  1751. }
  1752. };
  1753. /**
  1754. * Serializes the actions and its related information.
  1755. * @param parent defines the object to serialize in
  1756. * @returns the serialized object
  1757. */
  1758. IncrementValueAction.prototype.serialize = function (parent) {
  1759. return _super.prototype._serialize.call(this, {
  1760. name: "IncrementValueAction",
  1761. properties: [
  1762. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1763. { name: "propertyPath", value: this.propertyPath },
  1764. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1765. ]
  1766. }, parent);
  1767. };
  1768. return IncrementValueAction;
  1769. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1770. /**
  1771. * This defines an action responsible to start an animation once triggered.
  1772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1773. */
  1774. var PlayAnimationAction = /** @class */ (function (_super) {
  1775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1776. /**
  1777. * Instantiate the action
  1778. * @param triggerOptions defines the trigger options
  1779. * @param target defines the target animation or animation name
  1780. * @param from defines from where the animation should start (animation frame)
  1781. * @param end defines where the animation should stop (animation frame)
  1782. * @param loop defines if the animation should loop or stop after the first play
  1783. * @param condition defines the trigger related conditions
  1784. */
  1785. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1786. var _this = _super.call(this, triggerOptions, condition) || this;
  1787. _this.from = from;
  1788. _this.to = to;
  1789. _this.loop = loop;
  1790. _this._target = target;
  1791. return _this;
  1792. }
  1793. /** @hidden */
  1794. PlayAnimationAction.prototype._prepare = function () {
  1795. };
  1796. /**
  1797. * Execute the action and play the animation.
  1798. */
  1799. PlayAnimationAction.prototype.execute = function () {
  1800. var scene = this._actionManager.getScene();
  1801. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1802. };
  1803. /**
  1804. * Serializes the actions and its related information.
  1805. * @param parent defines the object to serialize in
  1806. * @returns the serialized object
  1807. */
  1808. PlayAnimationAction.prototype.serialize = function (parent) {
  1809. return _super.prototype._serialize.call(this, {
  1810. name: "PlayAnimationAction",
  1811. properties: [
  1812. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1813. { name: "from", value: String(this.from) },
  1814. { name: "to", value: String(this.to) },
  1815. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1816. ]
  1817. }, parent);
  1818. };
  1819. return PlayAnimationAction;
  1820. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1821. /**
  1822. * This defines an action responsible to stop an animation once triggered.
  1823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1824. */
  1825. var StopAnimationAction = /** @class */ (function (_super) {
  1826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1827. /**
  1828. * Instantiate the action
  1829. * @param triggerOptions defines the trigger options
  1830. * @param target defines the target animation or animation name
  1831. * @param condition defines the trigger related conditions
  1832. */
  1833. function StopAnimationAction(triggerOptions, target, condition) {
  1834. var _this = _super.call(this, triggerOptions, condition) || this;
  1835. _this._target = target;
  1836. return _this;
  1837. }
  1838. /** @hidden */
  1839. StopAnimationAction.prototype._prepare = function () {
  1840. };
  1841. /**
  1842. * Execute the action and stop the animation.
  1843. */
  1844. StopAnimationAction.prototype.execute = function () {
  1845. var scene = this._actionManager.getScene();
  1846. scene.stopAnimation(this._target);
  1847. };
  1848. /**
  1849. * Serializes the actions and its related information.
  1850. * @param parent defines the object to serialize in
  1851. * @returns the serialized object
  1852. */
  1853. StopAnimationAction.prototype.serialize = function (parent) {
  1854. return _super.prototype._serialize.call(this, {
  1855. name: "StopAnimationAction",
  1856. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1857. }, parent);
  1858. };
  1859. return StopAnimationAction;
  1860. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1861. /**
  1862. * This defines an action responsible that does nothing once triggered.
  1863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1864. */
  1865. var DoNothingAction = /** @class */ (function (_super) {
  1866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1867. /**
  1868. * Instantiate the action
  1869. * @param triggerOptions defines the trigger options
  1870. * @param condition defines the trigger related conditions
  1871. */
  1872. function DoNothingAction(triggerOptions, condition) {
  1873. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1874. return _super.call(this, triggerOptions, condition) || this;
  1875. }
  1876. /**
  1877. * Execute the action and do nothing.
  1878. */
  1879. DoNothingAction.prototype.execute = function () {
  1880. };
  1881. /**
  1882. * Serializes the actions and its related information.
  1883. * @param parent defines the object to serialize in
  1884. * @returns the serialized object
  1885. */
  1886. DoNothingAction.prototype.serialize = function (parent) {
  1887. return _super.prototype._serialize.call(this, {
  1888. name: "DoNothingAction",
  1889. properties: []
  1890. }, parent);
  1891. };
  1892. return DoNothingAction;
  1893. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1894. /**
  1895. * This defines an action responsible to trigger several actions once triggered.
  1896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1897. */
  1898. var CombineAction = /** @class */ (function (_super) {
  1899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1900. /**
  1901. * Instantiate the action
  1902. * @param triggerOptions defines the trigger options
  1903. * @param children defines the list of aggregated animations to run
  1904. * @param condition defines the trigger related conditions
  1905. */
  1906. function CombineAction(triggerOptions, children, condition) {
  1907. var _this = _super.call(this, triggerOptions, condition) || this;
  1908. _this.children = children;
  1909. return _this;
  1910. }
  1911. /** @hidden */
  1912. CombineAction.prototype._prepare = function () {
  1913. for (var index = 0; index < this.children.length; index++) {
  1914. this.children[index]._actionManager = this._actionManager;
  1915. this.children[index]._prepare();
  1916. }
  1917. };
  1918. /**
  1919. * Execute the action and executes all the aggregated actions.
  1920. */
  1921. CombineAction.prototype.execute = function (evt) {
  1922. for (var index = 0; index < this.children.length; index++) {
  1923. this.children[index].execute(evt);
  1924. }
  1925. };
  1926. /**
  1927. * Serializes the actions and its related information.
  1928. * @param parent defines the object to serialize in
  1929. * @returns the serialized object
  1930. */
  1931. CombineAction.prototype.serialize = function (parent) {
  1932. var serializationObject = _super.prototype._serialize.call(this, {
  1933. name: "CombineAction",
  1934. properties: [],
  1935. combine: []
  1936. }, parent);
  1937. for (var i = 0; i < this.children.length; i++) {
  1938. serializationObject.combine.push(this.children[i].serialize(null));
  1939. }
  1940. return serializationObject;
  1941. };
  1942. return CombineAction;
  1943. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1944. /**
  1945. * This defines an action responsible to run code (external event) once triggered.
  1946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1947. */
  1948. var ExecuteCodeAction = /** @class */ (function (_super) {
  1949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1950. /**
  1951. * Instantiate the action
  1952. * @param triggerOptions defines the trigger options
  1953. * @param func defines the callback function to run
  1954. * @param condition defines the trigger related conditions
  1955. */
  1956. function ExecuteCodeAction(triggerOptions, func, condition) {
  1957. var _this = _super.call(this, triggerOptions, condition) || this;
  1958. _this.func = func;
  1959. return _this;
  1960. }
  1961. /**
  1962. * Execute the action and run the attached code.
  1963. */
  1964. ExecuteCodeAction.prototype.execute = function (evt) {
  1965. this.func(evt);
  1966. };
  1967. return ExecuteCodeAction;
  1968. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1969. /**
  1970. * This defines an action responsible to set the parent property of the target once triggered.
  1971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1972. */
  1973. var SetParentAction = /** @class */ (function (_super) {
  1974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1975. /**
  1976. * Instantiate the action
  1977. * @param triggerOptions defines the trigger options
  1978. * @param target defines the target containing the parent property
  1979. * @param parent defines from where the animation should start (animation frame)
  1980. * @param condition defines the trigger related conditions
  1981. */
  1982. function SetParentAction(triggerOptions, target, parent, condition) {
  1983. var _this = _super.call(this, triggerOptions, condition) || this;
  1984. _this._target = target;
  1985. _this._parent = parent;
  1986. return _this;
  1987. }
  1988. /** @hidden */
  1989. SetParentAction.prototype._prepare = function () {
  1990. };
  1991. /**
  1992. * Execute the action and set the parent property.
  1993. */
  1994. SetParentAction.prototype.execute = function () {
  1995. if (this._target.parent === this._parent) {
  1996. return;
  1997. }
  1998. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1999. invertParentWorldMatrix.invert();
  2000. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  2001. this._target.parent = this._parent;
  2002. };
  2003. /**
  2004. * Serializes the actions and its related information.
  2005. * @param parent defines the object to serialize in
  2006. * @returns the serialized object
  2007. */
  2008. SetParentAction.prototype.serialize = function (parent) {
  2009. return _super.prototype._serialize.call(this, {
  2010. name: "SetParentAction",
  2011. properties: [
  2012. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2013. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2014. ]
  2015. }, parent);
  2016. };
  2017. return SetParentAction;
  2018. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2024. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2025. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2026. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2027. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2028. /***/ }),
  2029. /***/ "./Actions/directAudioActions.ts":
  2030. /*!***************************************!*\
  2031. !*** ./Actions/directAudioActions.ts ***!
  2032. \***************************************/
  2033. /*! exports provided: PlaySoundAction, StopSoundAction */
  2034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2035. "use strict";
  2036. __webpack_require__.r(__webpack_exports__);
  2037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2040. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2041. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2042. /**
  2043. * This defines an action helpful to play a defined sound on a triggered action.
  2044. */
  2045. var PlaySoundAction = /** @class */ (function (_super) {
  2046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2047. /**
  2048. * Instantiate the action
  2049. * @param triggerOptions defines the trigger options
  2050. * @param sound defines the sound to play
  2051. * @param condition defines the trigger related conditions
  2052. */
  2053. function PlaySoundAction(triggerOptions, sound, condition) {
  2054. var _this = _super.call(this, triggerOptions, condition) || this;
  2055. _this._sound = sound;
  2056. return _this;
  2057. }
  2058. /** @hidden */
  2059. PlaySoundAction.prototype._prepare = function () {
  2060. };
  2061. /**
  2062. * Execute the action and play the sound.
  2063. */
  2064. PlaySoundAction.prototype.execute = function () {
  2065. if (this._sound !== undefined) {
  2066. this._sound.play();
  2067. }
  2068. };
  2069. /**
  2070. * Serializes the actions and its related information.
  2071. * @param parent defines the object to serialize in
  2072. * @returns the serialized object
  2073. */
  2074. PlaySoundAction.prototype.serialize = function (parent) {
  2075. return _super.prototype._serialize.call(this, {
  2076. name: "PlaySoundAction",
  2077. properties: [{ name: "sound", value: this._sound.name }]
  2078. }, parent);
  2079. };
  2080. return PlaySoundAction;
  2081. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2082. /**
  2083. * This defines an action helpful to stop a defined sound on a triggered action.
  2084. */
  2085. var StopSoundAction = /** @class */ (function (_super) {
  2086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2087. /**
  2088. * Instantiate the action
  2089. * @param triggerOptions defines the trigger options
  2090. * @param sound defines the sound to stop
  2091. * @param condition defines the trigger related conditions
  2092. */
  2093. function StopSoundAction(triggerOptions, sound, condition) {
  2094. var _this = _super.call(this, triggerOptions, condition) || this;
  2095. _this._sound = sound;
  2096. return _this;
  2097. }
  2098. /** @hidden */
  2099. StopSoundAction.prototype._prepare = function () {
  2100. };
  2101. /**
  2102. * Execute the action and stop the sound.
  2103. */
  2104. StopSoundAction.prototype.execute = function () {
  2105. if (this._sound !== undefined) {
  2106. this._sound.stop();
  2107. }
  2108. };
  2109. /**
  2110. * Serializes the actions and its related information.
  2111. * @param parent defines the object to serialize in
  2112. * @returns the serialized object
  2113. */
  2114. StopSoundAction.prototype.serialize = function (parent) {
  2115. return _super.prototype._serialize.call(this, {
  2116. name: "StopSoundAction",
  2117. properties: [{ name: "sound", value: this._sound.name }]
  2118. }, parent);
  2119. };
  2120. return StopSoundAction;
  2121. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2122. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2123. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2124. /***/ }),
  2125. /***/ "./Actions/index.ts":
  2126. /*!**************************!*\
  2127. !*** ./Actions/index.ts ***!
  2128. \**************************/
  2129. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2131. "use strict";
  2132. __webpack_require__.r(__webpack_exports__);
  2133. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2135. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2137. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2139. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2144. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2155. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2158. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2160. /***/ }),
  2161. /***/ "./Actions/interpolateValueAction.ts":
  2162. /*!*******************************************!*\
  2163. !*** ./Actions/interpolateValueAction.ts ***!
  2164. \*******************************************/
  2165. /*! exports provided: InterpolateValueAction */
  2166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2167. "use strict";
  2168. __webpack_require__.r(__webpack_exports__);
  2169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2171. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2172. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2173. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2174. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2175. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2176. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2177. /**
  2178. * This defines an action responsible to change the value of a property
  2179. * by interpolating between its current value and the newly set one once triggered.
  2180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2181. */
  2182. var InterpolateValueAction = /** @class */ (function (_super) {
  2183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2184. /**
  2185. * Instantiate the action
  2186. * @param triggerOptions defines the trigger options
  2187. * @param target defines the object containing the value to interpolate
  2188. * @param propertyPath defines the path to the property in the target object
  2189. * @param value defines the target value at the end of the interpolation
  2190. * @param duration deines the time it will take for the property to interpolate to the value.
  2191. * @param condition defines the trigger related conditions
  2192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2194. */
  2195. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2196. if (duration === void 0) { duration = 1000; }
  2197. var _this = _super.call(this, triggerOptions, condition) || this;
  2198. /**
  2199. * Defines the time it will take for the property to interpolate to the value.
  2200. */
  2201. _this.duration = 1000;
  2202. /**
  2203. * Observable triggered once the interpolation animation has been done.
  2204. */
  2205. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2206. _this.propertyPath = propertyPath;
  2207. _this.value = value;
  2208. _this.duration = duration;
  2209. _this.stopOtherAnimations = stopOtherAnimations;
  2210. _this.onInterpolationDone = onInterpolationDone;
  2211. _this._target = _this._effectiveTarget = target;
  2212. return _this;
  2213. }
  2214. /** @hidden */
  2215. InterpolateValueAction.prototype._prepare = function () {
  2216. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2217. this._property = this._getProperty(this.propertyPath);
  2218. };
  2219. /**
  2220. * Execute the action starts the value interpolation.
  2221. */
  2222. InterpolateValueAction.prototype.execute = function () {
  2223. var _this = this;
  2224. var scene = this._actionManager.getScene();
  2225. var keys = [
  2226. {
  2227. frame: 0,
  2228. value: this._effectiveTarget[this._property]
  2229. }, {
  2230. frame: 100,
  2231. value: this.value
  2232. }
  2233. ];
  2234. var dataType;
  2235. if (typeof this.value === "number") {
  2236. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2237. }
  2238. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2239. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2240. }
  2241. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2242. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2243. }
  2244. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2245. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2246. }
  2247. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2248. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2249. }
  2250. else {
  2251. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2252. return;
  2253. }
  2254. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2255. animation.setKeys(keys);
  2256. if (this.stopOtherAnimations) {
  2257. scene.stopAnimation(this._effectiveTarget);
  2258. }
  2259. var wrapper = function () {
  2260. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2261. if (_this.onInterpolationDone) {
  2262. _this.onInterpolationDone();
  2263. }
  2264. };
  2265. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2266. };
  2267. /**
  2268. * Serializes the actions and its related information.
  2269. * @param parent defines the object to serialize in
  2270. * @returns the serialized object
  2271. */
  2272. InterpolateValueAction.prototype.serialize = function (parent) {
  2273. return _super.prototype._serialize.call(this, {
  2274. name: "InterpolateValueAction",
  2275. properties: [
  2276. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2277. { name: "propertyPath", value: this.propertyPath },
  2278. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2279. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2280. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2281. ]
  2282. }, parent);
  2283. };
  2284. return InterpolateValueAction;
  2285. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2286. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = InterpolateValueAction;
  2287. /***/ }),
  2288. /***/ "./Animations/animatable.ts":
  2289. /*!**********************************!*\
  2290. !*** ./Animations/animatable.ts ***!
  2291. \**********************************/
  2292. /*! exports provided: Animatable */
  2293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2294. "use strict";
  2295. __webpack_require__.r(__webpack_exports__);
  2296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2297. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2298. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2300. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2302. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2303. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2304. /**
  2305. * Class used to store an actual running animation
  2306. */
  2307. var Animatable = /** @class */ (function () {
  2308. /**
  2309. * Creates a new Animatable
  2310. * @param scene defines the hosting scene
  2311. * @param target defines the target object
  2312. * @param fromFrame defines the starting frame number (default is 0)
  2313. * @param toFrame defines the ending frame number (default is 100)
  2314. * @param loopAnimation defines if the animation must loop (default is false)
  2315. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2316. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2317. * @param animations defines a group of animation to add to the new Animatable
  2318. * @param onAnimationLoop defines a callback to call when animation loops
  2319. */
  2320. function Animatable(scene,
  2321. /** defines the target object */
  2322. target,
  2323. /** defines the starting frame number (default is 0) */
  2324. fromFrame,
  2325. /** defines the ending frame number (default is 100) */
  2326. toFrame,
  2327. /** defines if the animation must loop (default is false) */
  2328. loopAnimation, speedRatio,
  2329. /** defines a callback to call when animation ends if it is not looping */
  2330. onAnimationEnd, animations,
  2331. /** defines a callback to call when animation loops */
  2332. onAnimationLoop) {
  2333. if (fromFrame === void 0) { fromFrame = 0; }
  2334. if (toFrame === void 0) { toFrame = 100; }
  2335. if (loopAnimation === void 0) { loopAnimation = false; }
  2336. if (speedRatio === void 0) { speedRatio = 1.0; }
  2337. this.target = target;
  2338. this.fromFrame = fromFrame;
  2339. this.toFrame = toFrame;
  2340. this.loopAnimation = loopAnimation;
  2341. this.onAnimationEnd = onAnimationEnd;
  2342. this.onAnimationLoop = onAnimationLoop;
  2343. this._localDelayOffset = null;
  2344. this._pausedDelay = null;
  2345. this._runtimeAnimations = new Array();
  2346. this._paused = false;
  2347. this._speedRatio = 1;
  2348. this._weight = -1.0;
  2349. this._syncRoot = null;
  2350. /**
  2351. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2352. * This will only apply for non looping animation (default is true)
  2353. */
  2354. this.disposeOnEnd = true;
  2355. /**
  2356. * Gets a boolean indicating if the animation has started
  2357. */
  2358. this.animationStarted = false;
  2359. /**
  2360. * Observer raised when the animation ends
  2361. */
  2362. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2363. /**
  2364. * Observer raised when the animation loops
  2365. */
  2366. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2367. this._scene = scene;
  2368. if (animations) {
  2369. this.appendAnimations(target, animations);
  2370. }
  2371. this._speedRatio = speedRatio;
  2372. scene._activeAnimatables.push(this);
  2373. }
  2374. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2375. /**
  2376. * Gets the root Animatable used to synchronize and normalize animations
  2377. */
  2378. get: function () {
  2379. return this._syncRoot;
  2380. },
  2381. enumerable: true,
  2382. configurable: true
  2383. });
  2384. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2385. /**
  2386. * Gets the current frame of the first RuntimeAnimation
  2387. * Used to synchronize Animatables
  2388. */
  2389. get: function () {
  2390. if (this._runtimeAnimations.length === 0) {
  2391. return 0;
  2392. }
  2393. return this._runtimeAnimations[0].currentFrame;
  2394. },
  2395. enumerable: true,
  2396. configurable: true
  2397. });
  2398. Object.defineProperty(Animatable.prototype, "weight", {
  2399. /**
  2400. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2401. */
  2402. get: function () {
  2403. return this._weight;
  2404. },
  2405. set: function (value) {
  2406. if (value === -1) { // -1 is ok and means no weight
  2407. this._weight = -1;
  2408. return;
  2409. }
  2410. // Else weight must be in [0, 1] range
  2411. this._weight = Math.min(Math.max(value, 0), 1.0);
  2412. },
  2413. enumerable: true,
  2414. configurable: true
  2415. });
  2416. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2417. /**
  2418. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2419. */
  2420. get: function () {
  2421. return this._speedRatio;
  2422. },
  2423. set: function (value) {
  2424. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2425. var animation = this._runtimeAnimations[index];
  2426. animation._prepareForSpeedRatioChange(value);
  2427. }
  2428. this._speedRatio = value;
  2429. },
  2430. enumerable: true,
  2431. configurable: true
  2432. });
  2433. // Methods
  2434. /**
  2435. * Synchronize and normalize current Animatable with a source Animatable
  2436. * This is useful when using animation weights and when animations are not of the same length
  2437. * @param root defines the root Animatable to synchronize with
  2438. * @returns the current Animatable
  2439. */
  2440. Animatable.prototype.syncWith = function (root) {
  2441. this._syncRoot = root;
  2442. if (root) {
  2443. // Make sure this animatable will animate after the root
  2444. var index = this._scene._activeAnimatables.indexOf(this);
  2445. if (index > -1) {
  2446. this._scene._activeAnimatables.splice(index, 1);
  2447. this._scene._activeAnimatables.push(this);
  2448. }
  2449. }
  2450. return this;
  2451. };
  2452. /**
  2453. * Gets the list of runtime animations
  2454. * @returns an array of RuntimeAnimation
  2455. */
  2456. Animatable.prototype.getAnimations = function () {
  2457. return this._runtimeAnimations;
  2458. };
  2459. /**
  2460. * Adds more animations to the current animatable
  2461. * @param target defines the target of the animations
  2462. * @param animations defines the new animations to add
  2463. */
  2464. Animatable.prototype.appendAnimations = function (target, animations) {
  2465. var _this = this;
  2466. for (var index = 0; index < animations.length; index++) {
  2467. var animation = animations[index];
  2468. var newRuntimeAnimation = new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this);
  2469. newRuntimeAnimation._onLoop = function () {
  2470. _this.onAnimationLoopObservable.notifyObservers(_this);
  2471. if (_this.onAnimationLoop) {
  2472. _this.onAnimationLoop();
  2473. }
  2474. };
  2475. this._runtimeAnimations.push(newRuntimeAnimation);
  2476. }
  2477. };
  2478. /**
  2479. * Gets the source animation for a specific property
  2480. * @param property defines the propertyu to look for
  2481. * @returns null or the source animation for the given property
  2482. */
  2483. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2484. var runtimeAnimations = this._runtimeAnimations;
  2485. for (var index = 0; index < runtimeAnimations.length; index++) {
  2486. if (runtimeAnimations[index].animation.targetProperty === property) {
  2487. return runtimeAnimations[index].animation;
  2488. }
  2489. }
  2490. return null;
  2491. };
  2492. /**
  2493. * Gets the runtime animation for a specific property
  2494. * @param property defines the propertyu to look for
  2495. * @returns null or the runtime animation for the given property
  2496. */
  2497. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2498. var runtimeAnimations = this._runtimeAnimations;
  2499. for (var index = 0; index < runtimeAnimations.length; index++) {
  2500. if (runtimeAnimations[index].animation.targetProperty === property) {
  2501. return runtimeAnimations[index];
  2502. }
  2503. }
  2504. return null;
  2505. };
  2506. /**
  2507. * Resets the animatable to its original state
  2508. */
  2509. Animatable.prototype.reset = function () {
  2510. var runtimeAnimations = this._runtimeAnimations;
  2511. for (var index = 0; index < runtimeAnimations.length; index++) {
  2512. runtimeAnimations[index].reset(true);
  2513. }
  2514. this._localDelayOffset = null;
  2515. this._pausedDelay = null;
  2516. };
  2517. /**
  2518. * Allows the animatable to blend with current running animations
  2519. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2520. * @param blendingSpeed defines the blending speed to use
  2521. */
  2522. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2523. var runtimeAnimations = this._runtimeAnimations;
  2524. for (var index = 0; index < runtimeAnimations.length; index++) {
  2525. runtimeAnimations[index].animation.enableBlending = true;
  2526. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2527. }
  2528. };
  2529. /**
  2530. * Disable animation blending
  2531. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2532. */
  2533. Animatable.prototype.disableBlending = function () {
  2534. var runtimeAnimations = this._runtimeAnimations;
  2535. for (var index = 0; index < runtimeAnimations.length; index++) {
  2536. runtimeAnimations[index].animation.enableBlending = false;
  2537. }
  2538. };
  2539. /**
  2540. * Jump directly to a given frame
  2541. * @param frame defines the frame to jump to
  2542. */
  2543. Animatable.prototype.goToFrame = function (frame) {
  2544. var runtimeAnimations = this._runtimeAnimations;
  2545. if (runtimeAnimations[0]) {
  2546. var fps = runtimeAnimations[0].animation.framePerSecond;
  2547. var currentFrame = runtimeAnimations[0].currentFrame;
  2548. var adjustTime = frame - currentFrame;
  2549. var delay = this.speedRatio !== 0 ? adjustTime * 1000 / (fps * this.speedRatio) : 0;
  2550. if (this._localDelayOffset === null) {
  2551. this._localDelayOffset = 0;
  2552. }
  2553. this._localDelayOffset -= delay;
  2554. }
  2555. for (var index = 0; index < runtimeAnimations.length; index++) {
  2556. runtimeAnimations[index].goToFrame(frame);
  2557. }
  2558. };
  2559. /**
  2560. * Pause the animation
  2561. */
  2562. Animatable.prototype.pause = function () {
  2563. if (this._paused) {
  2564. return;
  2565. }
  2566. this._paused = true;
  2567. };
  2568. /**
  2569. * Restart the animation
  2570. */
  2571. Animatable.prototype.restart = function () {
  2572. this._paused = false;
  2573. };
  2574. Animatable.prototype._raiseOnAnimationEnd = function () {
  2575. if (this.onAnimationEnd) {
  2576. this.onAnimationEnd();
  2577. }
  2578. this.onAnimationEndObservable.notifyObservers(this);
  2579. };
  2580. /**
  2581. * Stop and delete the current animation
  2582. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2583. * @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)
  2584. */
  2585. Animatable.prototype.stop = function (animationName, targetMask) {
  2586. if (animationName || targetMask) {
  2587. var idx = this._scene._activeAnimatables.indexOf(this);
  2588. if (idx > -1) {
  2589. var runtimeAnimations = this._runtimeAnimations;
  2590. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2591. var runtimeAnimation = runtimeAnimations[index];
  2592. if (animationName && runtimeAnimation.animation.name != animationName) {
  2593. continue;
  2594. }
  2595. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2596. continue;
  2597. }
  2598. runtimeAnimation.dispose();
  2599. runtimeAnimations.splice(index, 1);
  2600. }
  2601. if (runtimeAnimations.length == 0) {
  2602. this._scene._activeAnimatables.splice(idx, 1);
  2603. this._raiseOnAnimationEnd();
  2604. }
  2605. }
  2606. }
  2607. else {
  2608. var index = this._scene._activeAnimatables.indexOf(this);
  2609. if (index > -1) {
  2610. this._scene._activeAnimatables.splice(index, 1);
  2611. var runtimeAnimations = this._runtimeAnimations;
  2612. for (var index = 0; index < runtimeAnimations.length; index++) {
  2613. runtimeAnimations[index].dispose();
  2614. }
  2615. this._raiseOnAnimationEnd();
  2616. }
  2617. }
  2618. };
  2619. /**
  2620. * Wait asynchronously for the animation to end
  2621. * @returns a promise which will be fullfilled when the animation ends
  2622. */
  2623. Animatable.prototype.waitAsync = function () {
  2624. var _this = this;
  2625. return new Promise(function (resolve, reject) {
  2626. _this.onAnimationEndObservable.add(function () {
  2627. resolve(_this);
  2628. }, undefined, undefined, _this, true);
  2629. });
  2630. };
  2631. /** @hidden */
  2632. Animatable.prototype._animate = function (delay) {
  2633. if (this._paused) {
  2634. this.animationStarted = false;
  2635. if (this._pausedDelay === null) {
  2636. this._pausedDelay = delay;
  2637. }
  2638. return true;
  2639. }
  2640. if (this._localDelayOffset === null) {
  2641. this._localDelayOffset = delay;
  2642. this._pausedDelay = null;
  2643. }
  2644. else if (this._pausedDelay !== null) {
  2645. this._localDelayOffset += delay - this._pausedDelay;
  2646. this._pausedDelay = null;
  2647. }
  2648. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2649. return true;
  2650. }
  2651. // Animating
  2652. var running = false;
  2653. var runtimeAnimations = this._runtimeAnimations;
  2654. var index;
  2655. for (index = 0; index < runtimeAnimations.length; index++) {
  2656. var animation = runtimeAnimations[index];
  2657. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight);
  2658. running = running || isRunning;
  2659. }
  2660. this.animationStarted = running;
  2661. if (!running) {
  2662. if (this.disposeOnEnd) {
  2663. // Remove from active animatables
  2664. index = this._scene._activeAnimatables.indexOf(this);
  2665. this._scene._activeAnimatables.splice(index, 1);
  2666. // Dispose all runtime animations
  2667. for (index = 0; index < runtimeAnimations.length; index++) {
  2668. runtimeAnimations[index].dispose();
  2669. }
  2670. }
  2671. this._raiseOnAnimationEnd();
  2672. if (this.disposeOnEnd) {
  2673. this.onAnimationEnd = null;
  2674. this.onAnimationLoop = null;
  2675. this.onAnimationLoopObservable.clear();
  2676. this.onAnimationEndObservable.clear();
  2677. }
  2678. }
  2679. return running;
  2680. };
  2681. return Animatable;
  2682. }());
  2683. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2684. if (!this.animationsEnabled) {
  2685. return;
  2686. }
  2687. var animatables = this._activeAnimatables;
  2688. if (animatables.length === 0) {
  2689. return;
  2690. }
  2691. // Getting time
  2692. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2693. if (!this._animationTimeLast) {
  2694. if (this._pendingData.length > 0) {
  2695. return;
  2696. }
  2697. this._animationTimeLast = now;
  2698. }
  2699. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2700. this._animationTime += deltaTime;
  2701. var animationTime = this._animationTime;
  2702. this._animationTimeLast = now;
  2703. for (var index = 0; index < animatables.length; index++) {
  2704. animatables[index]._animate(animationTime);
  2705. }
  2706. // Late animation bindings
  2707. this._processLateAnimationBindings();
  2708. };
  2709. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2710. if (weight === void 0) { weight = 1.0; }
  2711. if (speedRatio === void 0) { speedRatio = 1.0; }
  2712. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2713. returnedAnimatable.weight = weight;
  2714. return returnedAnimatable;
  2715. };
  2716. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2717. if (speedRatio === void 0) { speedRatio = 1.0; }
  2718. if (stopCurrent === void 0) { stopCurrent = true; }
  2719. if (from > to && speedRatio > 0) {
  2720. speedRatio *= -1;
  2721. }
  2722. if (stopCurrent) {
  2723. this.stopAnimation(target, undefined, targetMask);
  2724. }
  2725. if (!animatable) {
  2726. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2727. }
  2728. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2729. // Local animations
  2730. if (target.animations && shouldRunTargetAnimations) {
  2731. animatable.appendAnimations(target, target.animations);
  2732. }
  2733. // Children animations
  2734. if (target.getAnimatables) {
  2735. var animatables = target.getAnimatables();
  2736. for (var index = 0; index < animatables.length; index++) {
  2737. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2738. }
  2739. }
  2740. animatable.reset();
  2741. return animatable;
  2742. };
  2743. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2744. if (speedRatio === void 0) { speedRatio = 1.0; }
  2745. if (stopCurrent === void 0) { stopCurrent = true; }
  2746. var children = target.getDescendants(directDescendantsOnly);
  2747. var result = [];
  2748. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2749. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2750. var child = children_1[_i];
  2751. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2752. }
  2753. return result;
  2754. };
  2755. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2756. if (speedRatio === undefined) {
  2757. speedRatio = 1.0;
  2758. }
  2759. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2760. return animatable;
  2761. };
  2762. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2763. var children = target.getDescendants(directDescendantsOnly);
  2764. var result = [];
  2765. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2766. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2767. var child = children_2[_i];
  2768. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2769. }
  2770. return result;
  2771. };
  2772. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2773. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2774. if (this._activeAnimatables[index].target === target) {
  2775. return this._activeAnimatables[index];
  2776. }
  2777. }
  2778. return null;
  2779. };
  2780. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2781. var result = [];
  2782. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2783. if (this._activeAnimatables[index].target === target) {
  2784. result.push(this._activeAnimatables[index]);
  2785. }
  2786. }
  2787. return result;
  2788. };
  2789. /**
  2790. * Will stop the animation of the given target
  2791. * @param target - the target
  2792. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2793. * @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)
  2794. */
  2795. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2796. var animatables = this.getAllAnimatablesByTarget(target);
  2797. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2798. var animatable = animatables_1[_i];
  2799. animatable.stop(animationName, targetMask);
  2800. }
  2801. };
  2802. /**
  2803. * Stops and removes all animations that have been applied to the scene
  2804. */
  2805. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2806. if (this._activeAnimatables) {
  2807. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2808. this._activeAnimatables[i].stop();
  2809. }
  2810. this._activeAnimatables = [];
  2811. }
  2812. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2813. var group = _a[_i];
  2814. group.stop();
  2815. }
  2816. };
  2817. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2818. var target = runtimeAnimation.target;
  2819. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2820. if (!target._lateAnimationHolders) {
  2821. target._lateAnimationHolders = {};
  2822. }
  2823. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2824. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2825. totalWeight: 0,
  2826. animations: [],
  2827. originalValue: originalValue
  2828. };
  2829. }
  2830. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2831. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2832. };
  2833. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2834. var normalizer = 1.0;
  2835. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2836. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2837. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2838. var startIndex = 0;
  2839. var originalAnimation = holder.animations[0];
  2840. var originalValue = holder.originalValue;
  2841. var scale = 1;
  2842. if (holder.totalWeight < 1.0) {
  2843. // We need to mix the original value in
  2844. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2845. scale = 1.0 - holder.totalWeight;
  2846. }
  2847. else {
  2848. startIndex = 1;
  2849. // We need to normalize the weights
  2850. normalizer = holder.totalWeight;
  2851. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2852. scale = originalAnimation.weight / normalizer;
  2853. if (scale == 1) {
  2854. return originalAnimation.currentValue;
  2855. }
  2856. }
  2857. finalScaling.scaleInPlace(scale);
  2858. finalPosition.scaleInPlace(scale);
  2859. finalQuaternion.scaleInPlace(scale);
  2860. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2861. var runtimeAnimation = holder.animations[animIndex];
  2862. var scale = runtimeAnimation.weight / normalizer;
  2863. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2864. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2865. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2866. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2867. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2868. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2869. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2870. }
  2871. var workValue = originalAnimation._animationState.workValue;
  2872. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, workValue);
  2873. return workValue;
  2874. };
  2875. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2876. var originalAnimation = holder.animations[0];
  2877. var originalValue = holder.originalValue;
  2878. if (holder.animations.length === 1) {
  2879. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2880. return refQuaternion;
  2881. }
  2882. var normalizer = 1.0;
  2883. var quaternions;
  2884. var weights;
  2885. if (holder.totalWeight < 1.0) {
  2886. var scale = 1.0 - holder.totalWeight;
  2887. quaternions = [];
  2888. weights = [];
  2889. quaternions.push(originalValue);
  2890. weights.push(scale);
  2891. }
  2892. else {
  2893. if (holder.animations.length === 2) { // Slerp as soon as we can
  2894. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2895. return refQuaternion;
  2896. }
  2897. quaternions = [];
  2898. weights = [];
  2899. normalizer = holder.totalWeight;
  2900. }
  2901. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2902. var runtimeAnimation = holder.animations[animIndex];
  2903. quaternions.push(runtimeAnimation.currentValue);
  2904. weights.push(runtimeAnimation.weight / normalizer);
  2905. }
  2906. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2907. var cumulativeAmount = 0;
  2908. var cumulativeQuaternion = null;
  2909. for (var index = 0; index < quaternions.length;) {
  2910. if (!cumulativeQuaternion) {
  2911. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2912. cumulativeQuaternion = refQuaternion;
  2913. cumulativeAmount = weights[index] + weights[index + 1];
  2914. index += 2;
  2915. continue;
  2916. }
  2917. cumulativeAmount += weights[index];
  2918. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2919. index++;
  2920. }
  2921. return cumulativeQuaternion;
  2922. };
  2923. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2924. if (!this._registeredForLateAnimationBindings.length) {
  2925. return;
  2926. }
  2927. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2928. var target = this._registeredForLateAnimationBindings.data[index];
  2929. for (var path in target._lateAnimationHolders) {
  2930. var holder = target._lateAnimationHolders[path];
  2931. var originalAnimation = holder.animations[0];
  2932. var originalValue = holder.originalValue;
  2933. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2934. var finalValue = target[path];
  2935. if (matrixDecomposeMode) {
  2936. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2937. }
  2938. else {
  2939. var quaternionMode = originalValue.w !== undefined;
  2940. if (quaternionMode) {
  2941. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2942. }
  2943. else {
  2944. var startIndex = 0;
  2945. var normalizer = 1.0;
  2946. if (holder.totalWeight < 1.0) {
  2947. // We need to mix the original value in
  2948. if (originalValue.scale) {
  2949. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2950. }
  2951. else {
  2952. finalValue = originalValue * (1.0 - holder.totalWeight);
  2953. }
  2954. }
  2955. else {
  2956. // We need to normalize the weights
  2957. normalizer = holder.totalWeight;
  2958. var scale_1 = originalAnimation.weight / normalizer;
  2959. if (scale_1 !== 1) {
  2960. if (originalAnimation.currentValue.scale) {
  2961. finalValue = originalAnimation.currentValue.scale(scale_1);
  2962. }
  2963. else {
  2964. finalValue = originalAnimation.currentValue * scale_1;
  2965. }
  2966. }
  2967. else {
  2968. finalValue = originalAnimation.currentValue;
  2969. }
  2970. startIndex = 1;
  2971. }
  2972. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2973. var runtimeAnimation = holder.animations[animIndex];
  2974. var scale = runtimeAnimation.weight / normalizer;
  2975. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2976. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2977. }
  2978. else {
  2979. finalValue += runtimeAnimation.currentValue * scale;
  2980. }
  2981. }
  2982. }
  2983. }
  2984. target[path] = finalValue;
  2985. }
  2986. target._lateAnimationHolders = {};
  2987. }
  2988. this._registeredForLateAnimationBindings.reset();
  2989. };
  2990. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2991. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2992. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2993. // all animation may be coming from a library skeleton, so may need to create animation
  2994. if (this.animations.length === 0) {
  2995. 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));
  2996. this.animations[0].setKeys([]);
  2997. }
  2998. // get animation info / verify there is such a range from the source bone
  2999. var sourceRange = source.animations[0].getRange(rangeName);
  3000. if (!sourceRange) {
  3001. return false;
  3002. }
  3003. var from = sourceRange.from;
  3004. var to = sourceRange.to;
  3005. var sourceKeys = source.animations[0].getKeys();
  3006. // rescaling prep
  3007. var sourceBoneLength = source.length;
  3008. var sourceParent = source.getParent();
  3009. var parent = this.getParent();
  3010. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3011. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3012. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3013. var destKeys = this.animations[0].getKeys();
  3014. // loop vars declaration
  3015. var orig;
  3016. var origTranslation;
  3017. var mat;
  3018. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3019. orig = sourceKeys[key];
  3020. if (orig.frame >= from && orig.frame <= to) {
  3021. if (rescaleAsRequired) {
  3022. mat = orig.value.clone();
  3023. // scale based on parent ratio, when bone has parent
  3024. if (parentScalingReqd) {
  3025. origTranslation = mat.getTranslation();
  3026. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3027. // scale based on skeleton dimension ratio when root bone, and value is passed
  3028. }
  3029. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3030. origTranslation = mat.getTranslation();
  3031. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3032. // use original when root bone, and no data for skelDimensionsRatio
  3033. }
  3034. else {
  3035. mat = orig.value;
  3036. }
  3037. }
  3038. else {
  3039. mat = orig.value;
  3040. }
  3041. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3042. }
  3043. }
  3044. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3045. return true;
  3046. };
  3047. /***/ }),
  3048. /***/ "./Animations/animation.ts":
  3049. /*!*********************************!*\
  3050. !*** ./Animations/animation.ts ***!
  3051. \*********************************/
  3052. /*! exports provided: _IAnimationState, Animation */
  3053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3054. "use strict";
  3055. __webpack_require__.r(__webpack_exports__);
  3056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _IAnimationState; });
  3057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3058. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3059. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3060. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3061. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3062. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3063. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3064. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3065. /**
  3066. * @hidden
  3067. */
  3068. var _IAnimationState = /** @class */ (function () {
  3069. function _IAnimationState() {
  3070. }
  3071. return _IAnimationState;
  3072. }());
  3073. /**
  3074. * Class used to store any kind of animation
  3075. */
  3076. var Animation = /** @class */ (function () {
  3077. /**
  3078. * Initializes the animation
  3079. * @param name Name of the animation
  3080. * @param targetProperty Property to animate
  3081. * @param framePerSecond The frames per second of the animation
  3082. * @param dataType The data type of the animation
  3083. * @param loopMode The loop mode of the animation
  3084. * @param enableBlending Specifies if blending should be enabled
  3085. */
  3086. function Animation(
  3087. /**Name of the animation */
  3088. name,
  3089. /**Property to animate */
  3090. targetProperty,
  3091. /**The frames per second of the animation */
  3092. framePerSecond,
  3093. /**The data type of the animation */
  3094. dataType,
  3095. /**The loop mode of the animation */
  3096. loopMode,
  3097. /**Specifies if blending should be enabled */
  3098. enableBlending) {
  3099. this.name = name;
  3100. this.targetProperty = targetProperty;
  3101. this.framePerSecond = framePerSecond;
  3102. this.dataType = dataType;
  3103. this.loopMode = loopMode;
  3104. this.enableBlending = enableBlending;
  3105. /**
  3106. * @hidden Internal use only
  3107. */
  3108. this._runtimeAnimations = new Array();
  3109. /**
  3110. * The set of event that will be linked to this animation
  3111. */
  3112. this._events = new Array();
  3113. /**
  3114. * Stores the blending speed of the animation
  3115. */
  3116. this.blendingSpeed = 0.01;
  3117. /**
  3118. * Stores the animation ranges for the animation
  3119. */
  3120. this._ranges = {};
  3121. this.targetPropertyPath = targetProperty.split(".");
  3122. this.dataType = dataType;
  3123. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3124. }
  3125. /**
  3126. * @hidden Internal use
  3127. */
  3128. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3129. var dataType = undefined;
  3130. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3131. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3132. }
  3133. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3134. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3135. }
  3136. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3137. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3138. }
  3139. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3140. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3141. }
  3142. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3143. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3144. }
  3145. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3146. dataType = Animation.ANIMATIONTYPE_SIZE;
  3147. }
  3148. if (dataType == undefined) {
  3149. return null;
  3150. }
  3151. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3152. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3153. animation.setKeys(keys);
  3154. if (easingFunction !== undefined) {
  3155. animation.setEasingFunction(easingFunction);
  3156. }
  3157. return animation;
  3158. };
  3159. /**
  3160. * Sets up an animation
  3161. * @param property The property to animate
  3162. * @param animationType The animation type to apply
  3163. * @param framePerSecond The frames per second of the animation
  3164. * @param easingFunction The easing function used in the animation
  3165. * @returns The created animation
  3166. */
  3167. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3168. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3169. animation.setEasingFunction(easingFunction);
  3170. return animation;
  3171. };
  3172. /**
  3173. * Create and start an animation on a node
  3174. * @param name defines the name of the global animation that will be run on all nodes
  3175. * @param node defines the root node where the animation will take place
  3176. * @param targetProperty defines property to animate
  3177. * @param framePerSecond defines the number of frame per second yo use
  3178. * @param totalFrame defines the number of frames in total
  3179. * @param from defines the initial value
  3180. * @param to defines the final value
  3181. * @param loopMode defines which loop mode you want to use (off by default)
  3182. * @param easingFunction defines the easing function to use (linear by default)
  3183. * @param onAnimationEnd defines the callback to call when animation end
  3184. * @returns the animatable created for this animation
  3185. */
  3186. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3187. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3188. if (!animation) {
  3189. return null;
  3190. }
  3191. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3192. };
  3193. /**
  3194. * Create and start an animation on a node and its descendants
  3195. * @param name defines the name of the global animation that will be run on all nodes
  3196. * @param node defines the root node where the animation will take place
  3197. * @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
  3198. * @param targetProperty defines property to animate
  3199. * @param framePerSecond defines the number of frame per second to use
  3200. * @param totalFrame defines the number of frames in total
  3201. * @param from defines the initial value
  3202. * @param to defines the final value
  3203. * @param loopMode defines which loop mode you want to use (off by default)
  3204. * @param easingFunction defines the easing function to use (linear by default)
  3205. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3206. * @returns the list of animatables created for all nodes
  3207. * @example https://www.babylonjs-playground.com/#MH0VLI
  3208. */
  3209. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3210. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3211. if (!animation) {
  3212. return null;
  3213. }
  3214. var scene = node.getScene();
  3215. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3216. };
  3217. /**
  3218. * Creates a new animation, merges it with the existing animations and starts it
  3219. * @param name Name of the animation
  3220. * @param node Node which contains the scene that begins the animations
  3221. * @param targetProperty Specifies which property to animate
  3222. * @param framePerSecond The frames per second of the animation
  3223. * @param totalFrame The total number of frames
  3224. * @param from The frame at the beginning of the animation
  3225. * @param to The frame at the end of the animation
  3226. * @param loopMode Specifies the loop mode of the animation
  3227. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3228. * @param onAnimationEnd Callback to run once the animation is complete
  3229. * @returns Nullable animation
  3230. */
  3231. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3232. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3233. if (!animation) {
  3234. return null;
  3235. }
  3236. node.animations.push(animation);
  3237. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3238. };
  3239. /**
  3240. * Transition property of an host to the target Value
  3241. * @param property The property to transition
  3242. * @param targetValue The target Value of the property
  3243. * @param host The object where the property to animate belongs
  3244. * @param scene Scene used to run the animation
  3245. * @param frameRate Framerate (in frame/s) to use
  3246. * @param transition The transition type we want to use
  3247. * @param duration The duration of the animation, in milliseconds
  3248. * @param onAnimationEnd Callback trigger at the end of the animation
  3249. * @returns Nullable animation
  3250. */
  3251. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3252. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3253. if (duration <= 0) {
  3254. host[property] = targetValue;
  3255. if (onAnimationEnd) {
  3256. onAnimationEnd();
  3257. }
  3258. return null;
  3259. }
  3260. var endFrame = frameRate * (duration / 1000);
  3261. transition.setKeys([{
  3262. frame: 0,
  3263. value: host[property].clone ? host[property].clone() : host[property]
  3264. },
  3265. {
  3266. frame: endFrame,
  3267. value: targetValue
  3268. }]);
  3269. if (!host.animations) {
  3270. host.animations = [];
  3271. }
  3272. host.animations.push(transition);
  3273. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3274. animation.onAnimationEnd = onAnimationEnd;
  3275. return animation;
  3276. };
  3277. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3278. /**
  3279. * Return the array of runtime animations currently using this animation
  3280. */
  3281. get: function () {
  3282. return this._runtimeAnimations;
  3283. },
  3284. enumerable: true,
  3285. configurable: true
  3286. });
  3287. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3288. /**
  3289. * Specifies if any of the runtime animations are currently running
  3290. */
  3291. get: function () {
  3292. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3293. var runtimeAnimation = _a[_i];
  3294. if (!runtimeAnimation.isStopped) {
  3295. return true;
  3296. }
  3297. }
  3298. return false;
  3299. },
  3300. enumerable: true,
  3301. configurable: true
  3302. });
  3303. // Methods
  3304. /**
  3305. * Converts the animation to a string
  3306. * @param fullDetails support for multiple levels of logging within scene loading
  3307. * @returns String form of the animation
  3308. */
  3309. Animation.prototype.toString = function (fullDetails) {
  3310. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3311. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3312. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3313. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3314. if (fullDetails) {
  3315. ret += ", Ranges: {";
  3316. var first = true;
  3317. for (var name in this._ranges) {
  3318. if (first) {
  3319. ret += ", ";
  3320. first = false;
  3321. }
  3322. ret += name;
  3323. }
  3324. ret += "}";
  3325. }
  3326. return ret;
  3327. };
  3328. /**
  3329. * Add an event to this animation
  3330. * @param event Event to add
  3331. */
  3332. Animation.prototype.addEvent = function (event) {
  3333. this._events.push(event);
  3334. };
  3335. /**
  3336. * Remove all events found at the given frame
  3337. * @param frame The frame to remove events from
  3338. */
  3339. Animation.prototype.removeEvents = function (frame) {
  3340. for (var index = 0; index < this._events.length; index++) {
  3341. if (this._events[index].frame === frame) {
  3342. this._events.splice(index, 1);
  3343. index--;
  3344. }
  3345. }
  3346. };
  3347. /**
  3348. * Retrieves all the events from the animation
  3349. * @returns Events from the animation
  3350. */
  3351. Animation.prototype.getEvents = function () {
  3352. return this._events;
  3353. };
  3354. /**
  3355. * Creates an animation range
  3356. * @param name Name of the animation range
  3357. * @param from Starting frame of the animation range
  3358. * @param to Ending frame of the animation
  3359. */
  3360. Animation.prototype.createRange = function (name, from, to) {
  3361. // check name not already in use; could happen for bones after serialized
  3362. if (!this._ranges[name]) {
  3363. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3364. }
  3365. };
  3366. /**
  3367. * Deletes an animation range by name
  3368. * @param name Name of the animation range to delete
  3369. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3370. */
  3371. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3372. if (deleteFrames === void 0) { deleteFrames = true; }
  3373. var range = this._ranges[name];
  3374. if (!range) {
  3375. return;
  3376. }
  3377. if (deleteFrames) {
  3378. var from = range.from;
  3379. var to = range.to;
  3380. // this loop MUST go high to low for multiple splices to work
  3381. for (var key = this._keys.length - 1; key >= 0; key--) {
  3382. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3383. this._keys.splice(key, 1);
  3384. }
  3385. }
  3386. }
  3387. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3388. };
  3389. /**
  3390. * Gets the animation range by name, or null if not defined
  3391. * @param name Name of the animation range
  3392. * @returns Nullable animation range
  3393. */
  3394. Animation.prototype.getRange = function (name) {
  3395. return this._ranges[name];
  3396. };
  3397. /**
  3398. * Gets the key frames from the animation
  3399. * @returns The key frames of the animation
  3400. */
  3401. Animation.prototype.getKeys = function () {
  3402. return this._keys;
  3403. };
  3404. /**
  3405. * Gets the highest frame rate of the animation
  3406. * @returns Highest frame rate of the animation
  3407. */
  3408. Animation.prototype.getHighestFrame = function () {
  3409. var ret = 0;
  3410. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3411. if (ret < this._keys[key].frame) {
  3412. ret = this._keys[key].frame;
  3413. }
  3414. }
  3415. return ret;
  3416. };
  3417. /**
  3418. * Gets the easing function of the animation
  3419. * @returns Easing function of the animation
  3420. */
  3421. Animation.prototype.getEasingFunction = function () {
  3422. return this._easingFunction;
  3423. };
  3424. /**
  3425. * Sets the easing function of the animation
  3426. * @param easingFunction A custom mathematical formula for animation
  3427. */
  3428. Animation.prototype.setEasingFunction = function (easingFunction) {
  3429. this._easingFunction = easingFunction;
  3430. };
  3431. /**
  3432. * Interpolates a scalar linearly
  3433. * @param startValue Start value of the animation curve
  3434. * @param endValue End value of the animation curve
  3435. * @param gradient Scalar amount to interpolate
  3436. * @returns Interpolated scalar value
  3437. */
  3438. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3439. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3440. };
  3441. /**
  3442. * Interpolates a scalar cubically
  3443. * @param startValue Start value of the animation curve
  3444. * @param outTangent End tangent of the animation
  3445. * @param endValue End value of the animation curve
  3446. * @param inTangent Start tangent of the animation curve
  3447. * @param gradient Scalar amount to interpolate
  3448. * @returns Interpolated scalar value
  3449. */
  3450. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3451. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3452. };
  3453. /**
  3454. * Interpolates a quaternion using a spherical linear interpolation
  3455. * @param startValue Start value of the animation curve
  3456. * @param endValue End value of the animation curve
  3457. * @param gradient Scalar amount to interpolate
  3458. * @returns Interpolated quaternion value
  3459. */
  3460. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3461. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3462. };
  3463. /**
  3464. * Interpolates a quaternion cubically
  3465. * @param startValue Start value of the animation curve
  3466. * @param outTangent End tangent of the animation curve
  3467. * @param endValue End value of the animation curve
  3468. * @param inTangent Start tangent of the animation curve
  3469. * @param gradient Scalar amount to interpolate
  3470. * @returns Interpolated quaternion value
  3471. */
  3472. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3473. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3474. };
  3475. /**
  3476. * Interpolates a Vector3 linearl
  3477. * @param startValue Start value of the animation curve
  3478. * @param endValue End value of the animation curve
  3479. * @param gradient Scalar amount to interpolate
  3480. * @returns Interpolated scalar value
  3481. */
  3482. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3483. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3484. };
  3485. /**
  3486. * Interpolates a Vector3 cubically
  3487. * @param startValue Start value of the animation curve
  3488. * @param outTangent End tangent of the animation
  3489. * @param endValue End value of the animation curve
  3490. * @param inTangent Start tangent of the animation curve
  3491. * @param gradient Scalar amount to interpolate
  3492. * @returns InterpolatedVector3 value
  3493. */
  3494. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3495. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3496. };
  3497. /**
  3498. * Interpolates a Vector2 linearly
  3499. * @param startValue Start value of the animation curve
  3500. * @param endValue End value of the animation curve
  3501. * @param gradient Scalar amount to interpolate
  3502. * @returns Interpolated Vector2 value
  3503. */
  3504. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3505. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3506. };
  3507. /**
  3508. * Interpolates a Vector2 cubically
  3509. * @param startValue Start value of the animation curve
  3510. * @param outTangent End tangent of the animation
  3511. * @param endValue End value of the animation curve
  3512. * @param inTangent Start tangent of the animation curve
  3513. * @param gradient Scalar amount to interpolate
  3514. * @returns Interpolated Vector2 value
  3515. */
  3516. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3517. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3518. };
  3519. /**
  3520. * Interpolates a size linearly
  3521. * @param startValue Start value of the animation curve
  3522. * @param endValue End value of the animation curve
  3523. * @param gradient Scalar amount to interpolate
  3524. * @returns Interpolated Size value
  3525. */
  3526. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3527. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3528. };
  3529. /**
  3530. * Interpolates a Color3 linearly
  3531. * @param startValue Start value of the animation curve
  3532. * @param endValue End value of the animation curve
  3533. * @param gradient Scalar amount to interpolate
  3534. * @returns Interpolated Color3 value
  3535. */
  3536. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3537. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3538. };
  3539. /**
  3540. * @hidden Internal use only
  3541. */
  3542. Animation.prototype._getKeyValue = function (value) {
  3543. if (typeof value === "function") {
  3544. return value();
  3545. }
  3546. return value;
  3547. };
  3548. /**
  3549. * @hidden Internal use only
  3550. */
  3551. Animation.prototype._interpolate = function (currentFrame, state) {
  3552. if (state.loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && state.repeatCount > 0) {
  3553. return state.highLimitValue.clone ? state.highLimitValue.clone() : state.highLimitValue;
  3554. }
  3555. var keys = this._keys;
  3556. if (keys.length === 1) {
  3557. return this._getKeyValue(keys[0].value);
  3558. }
  3559. var startKeyIndex = state.key;
  3560. if (keys[startKeyIndex].frame >= currentFrame) {
  3561. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3562. startKeyIndex--;
  3563. }
  3564. }
  3565. for (var key = startKeyIndex; key < keys.length; key++) {
  3566. var endKey = keys[key + 1];
  3567. if (endKey.frame >= currentFrame) {
  3568. state.key = key;
  3569. var startKey = keys[key];
  3570. var startValue = this._getKeyValue(startKey.value);
  3571. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3572. return startValue;
  3573. }
  3574. var endValue = this._getKeyValue(endKey.value);
  3575. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3576. var frameDelta = endKey.frame - startKey.frame;
  3577. // gradient : percent of currentFrame between the frame inf and the frame sup
  3578. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3579. // check for easingFunction and correction of gradient
  3580. var easingFunction = this.getEasingFunction();
  3581. if (easingFunction != null) {
  3582. gradient = easingFunction.ease(gradient);
  3583. }
  3584. switch (this.dataType) {
  3585. // Float
  3586. case Animation.ANIMATIONTYPE_FLOAT:
  3587. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3588. switch (state.loopMode) {
  3589. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3590. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3591. return floatValue;
  3592. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3593. return state.offsetValue * state.repeatCount + floatValue;
  3594. }
  3595. break;
  3596. // Quaternion
  3597. case Animation.ANIMATIONTYPE_QUATERNION:
  3598. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3599. switch (state.loopMode) {
  3600. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3601. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3602. return quatValue;
  3603. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3604. return quatValue.addInPlace(state.offsetValue.scale(state.repeatCount));
  3605. }
  3606. return quatValue;
  3607. // Vector3
  3608. case Animation.ANIMATIONTYPE_VECTOR3:
  3609. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3610. switch (state.loopMode) {
  3611. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3612. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3613. return vec3Value;
  3614. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3615. return vec3Value.add(state.offsetValue.scale(state.repeatCount));
  3616. }
  3617. // Vector2
  3618. case Animation.ANIMATIONTYPE_VECTOR2:
  3619. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3620. switch (state.loopMode) {
  3621. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3622. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3623. return vec2Value;
  3624. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3625. return vec2Value.add(state.offsetValue.scale(state.repeatCount));
  3626. }
  3627. // Size
  3628. case Animation.ANIMATIONTYPE_SIZE:
  3629. switch (state.loopMode) {
  3630. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3631. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3632. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3633. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3634. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
  3635. }
  3636. // Color3
  3637. case Animation.ANIMATIONTYPE_COLOR3:
  3638. switch (state.loopMode) {
  3639. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3640. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3641. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3642. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3643. return this.color3InterpolateFunction(startValue, endValue, gradient).add(state.offsetValue.scale(state.repeatCount));
  3644. }
  3645. // Matrix
  3646. case Animation.ANIMATIONTYPE_MATRIX:
  3647. switch (state.loopMode) {
  3648. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3649. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3650. if (Animation.AllowMatricesInterpolation) {
  3651. return this.matrixInterpolateFunction(startValue, endValue, gradient, state.workValue);
  3652. }
  3653. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3654. return startValue;
  3655. }
  3656. default:
  3657. break;
  3658. }
  3659. break;
  3660. }
  3661. }
  3662. return this._getKeyValue(keys[keys.length - 1].value);
  3663. };
  3664. /**
  3665. * Defines the function to use to interpolate matrices
  3666. * @param startValue defines the start matrix
  3667. * @param endValue defines the end matrix
  3668. * @param gradient defines the gradient between both matrices
  3669. * @param result defines an optional target matrix where to store the interpolation
  3670. * @returns the interpolated matrix
  3671. */
  3672. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3673. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3674. if (result) {
  3675. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3676. return result;
  3677. }
  3678. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3679. }
  3680. if (result) {
  3681. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3682. return result;
  3683. }
  3684. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3685. };
  3686. /**
  3687. * Makes a copy of the animation
  3688. * @returns Cloned animation
  3689. */
  3690. Animation.prototype.clone = function () {
  3691. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3692. clone.enableBlending = this.enableBlending;
  3693. clone.blendingSpeed = this.blendingSpeed;
  3694. if (this._keys) {
  3695. clone.setKeys(this._keys);
  3696. }
  3697. if (this._ranges) {
  3698. clone._ranges = {};
  3699. for (var name in this._ranges) {
  3700. var range = this._ranges[name];
  3701. if (!range) {
  3702. continue;
  3703. }
  3704. clone._ranges[name] = range.clone();
  3705. }
  3706. }
  3707. return clone;
  3708. };
  3709. /**
  3710. * Sets the key frames of the animation
  3711. * @param values The animation key frames to set
  3712. */
  3713. Animation.prototype.setKeys = function (values) {
  3714. this._keys = values.slice(0);
  3715. };
  3716. /**
  3717. * Serializes the animation to an object
  3718. * @returns Serialized object
  3719. */
  3720. Animation.prototype.serialize = function () {
  3721. var serializationObject = {};
  3722. serializationObject.name = this.name;
  3723. serializationObject.property = this.targetProperty;
  3724. serializationObject.framePerSecond = this.framePerSecond;
  3725. serializationObject.dataType = this.dataType;
  3726. serializationObject.loopBehavior = this.loopMode;
  3727. serializationObject.enableBlending = this.enableBlending;
  3728. serializationObject.blendingSpeed = this.blendingSpeed;
  3729. var dataType = this.dataType;
  3730. serializationObject.keys = [];
  3731. var keys = this.getKeys();
  3732. for (var index = 0; index < keys.length; index++) {
  3733. var animationKey = keys[index];
  3734. var key = {};
  3735. key.frame = animationKey.frame;
  3736. switch (dataType) {
  3737. case Animation.ANIMATIONTYPE_FLOAT:
  3738. key.values = [animationKey.value];
  3739. break;
  3740. case Animation.ANIMATIONTYPE_QUATERNION:
  3741. case Animation.ANIMATIONTYPE_MATRIX:
  3742. case Animation.ANIMATIONTYPE_VECTOR3:
  3743. case Animation.ANIMATIONTYPE_COLOR3:
  3744. key.values = animationKey.value.asArray();
  3745. break;
  3746. }
  3747. serializationObject.keys.push(key);
  3748. }
  3749. serializationObject.ranges = [];
  3750. for (var name in this._ranges) {
  3751. var source = this._ranges[name];
  3752. if (!source) {
  3753. continue;
  3754. }
  3755. var range = {};
  3756. range.name = name;
  3757. range.from = source.from;
  3758. range.to = source.to;
  3759. serializationObject.ranges.push(range);
  3760. }
  3761. return serializationObject;
  3762. };
  3763. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3764. /**
  3765. * Get the float animation type
  3766. */
  3767. get: function () {
  3768. return Animation._ANIMATIONTYPE_FLOAT;
  3769. },
  3770. enumerable: true,
  3771. configurable: true
  3772. });
  3773. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3774. /**
  3775. * Get the Vector3 animation type
  3776. */
  3777. get: function () {
  3778. return Animation._ANIMATIONTYPE_VECTOR3;
  3779. },
  3780. enumerable: true,
  3781. configurable: true
  3782. });
  3783. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3784. /**
  3785. * Get the Vector2 animation type
  3786. */
  3787. get: function () {
  3788. return Animation._ANIMATIONTYPE_VECTOR2;
  3789. },
  3790. enumerable: true,
  3791. configurable: true
  3792. });
  3793. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3794. /**
  3795. * Get the Size animation type
  3796. */
  3797. get: function () {
  3798. return Animation._ANIMATIONTYPE_SIZE;
  3799. },
  3800. enumerable: true,
  3801. configurable: true
  3802. });
  3803. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3804. /**
  3805. * Get the Quaternion animation type
  3806. */
  3807. get: function () {
  3808. return Animation._ANIMATIONTYPE_QUATERNION;
  3809. },
  3810. enumerable: true,
  3811. configurable: true
  3812. });
  3813. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3814. /**
  3815. * Get the Matrix animation type
  3816. */
  3817. get: function () {
  3818. return Animation._ANIMATIONTYPE_MATRIX;
  3819. },
  3820. enumerable: true,
  3821. configurable: true
  3822. });
  3823. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3824. /**
  3825. * Get the Color3 animation type
  3826. */
  3827. get: function () {
  3828. return Animation._ANIMATIONTYPE_COLOR3;
  3829. },
  3830. enumerable: true,
  3831. configurable: true
  3832. });
  3833. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3834. /**
  3835. * Get the Relative Loop Mode
  3836. */
  3837. get: function () {
  3838. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3839. },
  3840. enumerable: true,
  3841. configurable: true
  3842. });
  3843. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3844. /**
  3845. * Get the Cycle Loop Mode
  3846. */
  3847. get: function () {
  3848. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3849. },
  3850. enumerable: true,
  3851. configurable: true
  3852. });
  3853. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3854. /**
  3855. * Get the Constant Loop Mode
  3856. */
  3857. get: function () {
  3858. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. /** @hidden */
  3864. Animation._UniversalLerp = function (left, right, amount) {
  3865. var constructor = left.constructor;
  3866. if (constructor.Lerp) { // Lerp supported
  3867. return constructor.Lerp(left, right, amount);
  3868. }
  3869. else if (constructor.Slerp) { // Slerp supported
  3870. return constructor.Slerp(left, right, amount);
  3871. }
  3872. else if (left.toFixed) { // Number
  3873. return left * (1.0 - amount) + amount * right;
  3874. }
  3875. else { // Blending not supported
  3876. return right;
  3877. }
  3878. };
  3879. /**
  3880. * Parses an animation object and creates an animation
  3881. * @param parsedAnimation Parsed animation object
  3882. * @returns Animation object
  3883. */
  3884. Animation.Parse = function (parsedAnimation) {
  3885. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3886. var dataType = parsedAnimation.dataType;
  3887. var keys = [];
  3888. var data;
  3889. var index;
  3890. if (parsedAnimation.enableBlending) {
  3891. animation.enableBlending = parsedAnimation.enableBlending;
  3892. }
  3893. if (parsedAnimation.blendingSpeed) {
  3894. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3895. }
  3896. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3897. var key = parsedAnimation.keys[index];
  3898. var inTangent;
  3899. var outTangent;
  3900. switch (dataType) {
  3901. case Animation.ANIMATIONTYPE_FLOAT:
  3902. data = key.values[0];
  3903. if (key.values.length >= 1) {
  3904. inTangent = key.values[1];
  3905. }
  3906. if (key.values.length >= 2) {
  3907. outTangent = key.values[2];
  3908. }
  3909. break;
  3910. case Animation.ANIMATIONTYPE_QUATERNION:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3912. if (key.values.length >= 8) {
  3913. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3914. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3915. inTangent = _inTangent;
  3916. }
  3917. }
  3918. if (key.values.length >= 12) {
  3919. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3920. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3921. outTangent = _outTangent;
  3922. }
  3923. }
  3924. break;
  3925. case Animation.ANIMATIONTYPE_MATRIX:
  3926. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3927. break;
  3928. case Animation.ANIMATIONTYPE_COLOR3:
  3929. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3930. break;
  3931. case Animation.ANIMATIONTYPE_VECTOR3:
  3932. default:
  3933. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3934. break;
  3935. }
  3936. var keyData = {};
  3937. keyData.frame = key.frame;
  3938. keyData.value = data;
  3939. if (inTangent != undefined) {
  3940. keyData.inTangent = inTangent;
  3941. }
  3942. if (outTangent != undefined) {
  3943. keyData.outTangent = outTangent;
  3944. }
  3945. keys.push(keyData);
  3946. }
  3947. animation.setKeys(keys);
  3948. if (parsedAnimation.ranges) {
  3949. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3950. data = parsedAnimation.ranges[index];
  3951. animation.createRange(data.name, data.from, data.to);
  3952. }
  3953. }
  3954. return animation;
  3955. };
  3956. /**
  3957. * Appends the serialized animations from the source animations
  3958. * @param source Source containing the animations
  3959. * @param destination Target to store the animations
  3960. */
  3961. Animation.AppendSerializedAnimations = function (source, destination) {
  3962. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3963. };
  3964. /**
  3965. * Use matrix interpolation instead of using direct key value when animating matrices
  3966. */
  3967. Animation.AllowMatricesInterpolation = false;
  3968. /**
  3969. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3970. */
  3971. Animation.AllowMatrixDecomposeForInterpolation = true;
  3972. // Statics
  3973. /**
  3974. * Float animation type
  3975. */
  3976. Animation._ANIMATIONTYPE_FLOAT = 0;
  3977. /**
  3978. * Vector3 animation type
  3979. */
  3980. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3981. /**
  3982. * Quaternion animation type
  3983. */
  3984. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3985. /**
  3986. * Matrix animation type
  3987. */
  3988. Animation._ANIMATIONTYPE_MATRIX = 3;
  3989. /**
  3990. * Color3 animation type
  3991. */
  3992. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3993. /**
  3994. * Vector2 animation type
  3995. */
  3996. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3997. /**
  3998. * Size animation type
  3999. */
  4000. Animation._ANIMATIONTYPE_SIZE = 6;
  4001. /**
  4002. * Relative Loop Mode
  4003. */
  4004. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  4005. /**
  4006. * Cycle Loop Mode
  4007. */
  4008. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  4009. /**
  4010. * Constant Loop Mode
  4011. */
  4012. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  4013. return Animation;
  4014. }());
  4015. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  4016. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  4017. /***/ }),
  4018. /***/ "./Animations/animationEvent.ts":
  4019. /*!**************************************!*\
  4020. !*** ./Animations/animationEvent.ts ***!
  4021. \**************************************/
  4022. /*! exports provided: AnimationEvent */
  4023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4024. "use strict";
  4025. __webpack_require__.r(__webpack_exports__);
  4026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4027. /**
  4028. * Composed of a frame, and an action function
  4029. */
  4030. var AnimationEvent = /** @class */ (function () {
  4031. /**
  4032. * Initializes the animation event
  4033. * @param frame The frame for which the event is triggered
  4034. * @param action The event to perform when triggered
  4035. * @param onlyOnce Specifies if the event should be triggered only once
  4036. */
  4037. function AnimationEvent(
  4038. /** The frame for which the event is triggered **/
  4039. frame,
  4040. /** The event to perform when triggered **/
  4041. action,
  4042. /** Specifies if the event should be triggered only once**/
  4043. onlyOnce) {
  4044. this.frame = frame;
  4045. this.action = action;
  4046. this.onlyOnce = onlyOnce;
  4047. /**
  4048. * Specifies if the animation event is done
  4049. */
  4050. this.isDone = false;
  4051. }
  4052. /** @hidden */
  4053. AnimationEvent.prototype._clone = function () {
  4054. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4055. };
  4056. return AnimationEvent;
  4057. }());
  4058. /***/ }),
  4059. /***/ "./Animations/animationGroup.ts":
  4060. /*!**************************************!*\
  4061. !*** ./Animations/animationGroup.ts ***!
  4062. \**************************************/
  4063. /*! exports provided: TargetedAnimation, AnimationGroup */
  4064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4065. "use strict";
  4066. __webpack_require__.r(__webpack_exports__);
  4067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4069. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4070. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4071. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4072. /**
  4073. * This class defines the direct association between an animation and a target
  4074. */
  4075. var TargetedAnimation = /** @class */ (function () {
  4076. function TargetedAnimation() {
  4077. }
  4078. return TargetedAnimation;
  4079. }());
  4080. /**
  4081. * Use this class to create coordinated animations on multiple targets
  4082. */
  4083. var AnimationGroup = /** @class */ (function () {
  4084. /**
  4085. * Instantiates a new Animation Group.
  4086. * This helps managing several animations at once.
  4087. * @see http://doc.babylonjs.com/how_to/group
  4088. * @param name Defines the name of the group
  4089. * @param scene Defines the scene the group belongs to
  4090. */
  4091. function AnimationGroup(
  4092. /** The name of the animation group */
  4093. name, scene) {
  4094. if (scene === void 0) { scene = null; }
  4095. this.name = name;
  4096. this._targetedAnimations = new Array();
  4097. this._animatables = new Array();
  4098. this._from = Number.MAX_VALUE;
  4099. this._to = -Number.MAX_VALUE;
  4100. this._speedRatio = 1;
  4101. /**
  4102. * This observable will notify when one animation have ended
  4103. */
  4104. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4105. /**
  4106. * Observer raised when one animation loops
  4107. */
  4108. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4109. /**
  4110. * This observable will notify when all animations have ended.
  4111. */
  4112. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4113. /**
  4114. * This observable will notify when all animations have paused.
  4115. */
  4116. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4117. /**
  4118. * This observable will notify when all animations are playing.
  4119. */
  4120. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4121. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4122. this.uniqueId = this._scene.getUniqueId();
  4123. this._scene.animationGroups.push(this);
  4124. }
  4125. Object.defineProperty(AnimationGroup.prototype, "from", {
  4126. /**
  4127. * Gets the first frame
  4128. */
  4129. get: function () {
  4130. return this._from;
  4131. },
  4132. enumerable: true,
  4133. configurable: true
  4134. });
  4135. Object.defineProperty(AnimationGroup.prototype, "to", {
  4136. /**
  4137. * Gets the last frame
  4138. */
  4139. get: function () {
  4140. return this._to;
  4141. },
  4142. enumerable: true,
  4143. configurable: true
  4144. });
  4145. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4146. /**
  4147. * Define if the animations are started
  4148. */
  4149. get: function () {
  4150. return this._isStarted;
  4151. },
  4152. enumerable: true,
  4153. configurable: true
  4154. });
  4155. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4156. /**
  4157. * Gets a value indicating that the current group is playing
  4158. */
  4159. get: function () {
  4160. return this._isStarted && !this._isPaused;
  4161. },
  4162. enumerable: true,
  4163. configurable: true
  4164. });
  4165. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4166. /**
  4167. * Gets or sets the speed ratio to use for all animations
  4168. */
  4169. get: function () {
  4170. return this._speedRatio;
  4171. },
  4172. /**
  4173. * Gets or sets the speed ratio to use for all animations
  4174. */
  4175. set: function (value) {
  4176. if (this._speedRatio === value) {
  4177. return;
  4178. }
  4179. this._speedRatio = value;
  4180. for (var index = 0; index < this._animatables.length; index++) {
  4181. var animatable = this._animatables[index];
  4182. animatable.speedRatio = this._speedRatio;
  4183. }
  4184. },
  4185. enumerable: true,
  4186. configurable: true
  4187. });
  4188. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4189. /**
  4190. * Gets the targeted animations for this animation group
  4191. */
  4192. get: function () {
  4193. return this._targetedAnimations;
  4194. },
  4195. enumerable: true,
  4196. configurable: true
  4197. });
  4198. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4199. /**
  4200. * returning the list of animatables controlled by this animation group.
  4201. */
  4202. get: function () {
  4203. return this._animatables;
  4204. },
  4205. enumerable: true,
  4206. configurable: true
  4207. });
  4208. /**
  4209. * Add an animation (with its target) in the group
  4210. * @param animation defines the animation we want to add
  4211. * @param target defines the target of the animation
  4212. * @returns the TargetedAnimation object
  4213. */
  4214. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4215. var targetedAnimation = {
  4216. animation: animation,
  4217. target: target
  4218. };
  4219. var keys = animation.getKeys();
  4220. if (this._from > keys[0].frame) {
  4221. this._from = keys[0].frame;
  4222. }
  4223. if (this._to < keys[keys.length - 1].frame) {
  4224. this._to = keys[keys.length - 1].frame;
  4225. }
  4226. this._targetedAnimations.push(targetedAnimation);
  4227. return targetedAnimation;
  4228. };
  4229. /**
  4230. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4231. * It can add constant keys at begin or end
  4232. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4233. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4234. * @returns the animation group
  4235. */
  4236. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4237. if (beginFrame === void 0) { beginFrame = null; }
  4238. if (endFrame === void 0) { endFrame = null; }
  4239. if (beginFrame == null) {
  4240. beginFrame = this._from;
  4241. }
  4242. if (endFrame == null) {
  4243. endFrame = this._to;
  4244. }
  4245. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4246. var targetedAnimation = this._targetedAnimations[index];
  4247. var keys = targetedAnimation.animation.getKeys();
  4248. var startKey = keys[0];
  4249. var endKey = keys[keys.length - 1];
  4250. if (startKey.frame > beginFrame) {
  4251. var newKey = {
  4252. frame: beginFrame,
  4253. value: startKey.value,
  4254. inTangent: startKey.inTangent,
  4255. outTangent: startKey.outTangent,
  4256. interpolation: startKey.interpolation
  4257. };
  4258. keys.splice(0, 0, newKey);
  4259. }
  4260. if (endKey.frame < endFrame) {
  4261. var newKey = {
  4262. frame: endFrame,
  4263. value: endKey.value,
  4264. inTangent: endKey.outTangent,
  4265. outTangent: endKey.outTangent,
  4266. interpolation: endKey.interpolation
  4267. };
  4268. keys.push(newKey);
  4269. }
  4270. }
  4271. this._from = beginFrame;
  4272. this._to = endFrame;
  4273. return this;
  4274. };
  4275. /**
  4276. * Start all animations on given targets
  4277. * @param loop defines if animations must loop
  4278. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4279. * @param from defines the from key (optional)
  4280. * @param to defines the to key (optional)
  4281. * @returns the current animation group
  4282. */
  4283. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4284. var _this = this;
  4285. if (loop === void 0) { loop = false; }
  4286. if (speedRatio === void 0) { speedRatio = 1; }
  4287. if (this._isStarted || this._targetedAnimations.length === 0) {
  4288. return this;
  4289. }
  4290. var _loop_1 = function (targetedAnimation) {
  4291. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4292. animatable.onAnimationEnd = function () {
  4293. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4294. _this._checkAnimationGroupEnded(animatable);
  4295. };
  4296. animatable.onAnimationLoop = function () {
  4297. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4298. };
  4299. this_1._animatables.push(animatable);
  4300. };
  4301. var this_1 = this;
  4302. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4303. var targetedAnimation = _a[_i];
  4304. _loop_1(targetedAnimation);
  4305. }
  4306. this._speedRatio = speedRatio;
  4307. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4308. this._speedRatio = -speedRatio;
  4309. }
  4310. this._isStarted = true;
  4311. this._isPaused = false;
  4312. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4313. return this;
  4314. };
  4315. /**
  4316. * Pause all animations
  4317. * @returns the animation group
  4318. */
  4319. AnimationGroup.prototype.pause = function () {
  4320. if (!this._isStarted) {
  4321. return this;
  4322. }
  4323. this._isPaused = true;
  4324. for (var index = 0; index < this._animatables.length; index++) {
  4325. var animatable = this._animatables[index];
  4326. animatable.pause();
  4327. }
  4328. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4329. return this;
  4330. };
  4331. /**
  4332. * Play all animations to initial state
  4333. * This function will start() the animations if they were not started or will restart() them if they were paused
  4334. * @param loop defines if animations must loop
  4335. * @returns the animation group
  4336. */
  4337. AnimationGroup.prototype.play = function (loop) {
  4338. // only if all animatables are ready and exist
  4339. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4340. if (loop !== undefined) {
  4341. for (var index = 0; index < this._animatables.length; index++) {
  4342. var animatable = this._animatables[index];
  4343. animatable.loopAnimation = loop;
  4344. }
  4345. }
  4346. this.restart();
  4347. }
  4348. else {
  4349. this.stop();
  4350. this.start(loop, this._speedRatio);
  4351. }
  4352. this._isPaused = false;
  4353. return this;
  4354. };
  4355. /**
  4356. * Reset all animations to initial state
  4357. * @returns the animation group
  4358. */
  4359. AnimationGroup.prototype.reset = function () {
  4360. if (!this._isStarted) {
  4361. return this;
  4362. }
  4363. for (var index = 0; index < this._animatables.length; index++) {
  4364. var animatable = this._animatables[index];
  4365. animatable.reset();
  4366. }
  4367. return this;
  4368. };
  4369. /**
  4370. * Restart animations from key 0
  4371. * @returns the animation group
  4372. */
  4373. AnimationGroup.prototype.restart = function () {
  4374. if (!this._isStarted) {
  4375. return this;
  4376. }
  4377. for (var index = 0; index < this._animatables.length; index++) {
  4378. var animatable = this._animatables[index];
  4379. animatable.restart();
  4380. }
  4381. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4382. return this;
  4383. };
  4384. /**
  4385. * Stop all animations
  4386. * @returns the animation group
  4387. */
  4388. AnimationGroup.prototype.stop = function () {
  4389. if (!this._isStarted) {
  4390. return this;
  4391. }
  4392. var list = this._animatables.slice();
  4393. for (var index = 0; index < list.length; index++) {
  4394. list[index].stop();
  4395. }
  4396. this._isStarted = false;
  4397. return this;
  4398. };
  4399. /**
  4400. * Set animation weight for all animatables
  4401. * @param weight defines the weight to use
  4402. * @return the animationGroup
  4403. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4404. */
  4405. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4406. for (var index = 0; index < this._animatables.length; index++) {
  4407. var animatable = this._animatables[index];
  4408. animatable.weight = weight;
  4409. }
  4410. return this;
  4411. };
  4412. /**
  4413. * Synchronize and normalize all animatables with a source animatable
  4414. * @param root defines the root animatable to synchronize with
  4415. * @return the animationGroup
  4416. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4417. */
  4418. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4419. for (var index = 0; index < this._animatables.length; index++) {
  4420. var animatable = this._animatables[index];
  4421. animatable.syncWith(root);
  4422. }
  4423. return this;
  4424. };
  4425. /**
  4426. * Goes to a specific frame in this animation group
  4427. * @param frame the frame number to go to
  4428. * @return the animationGroup
  4429. */
  4430. AnimationGroup.prototype.goToFrame = function (frame) {
  4431. if (!this._isStarted) {
  4432. return this;
  4433. }
  4434. for (var index = 0; index < this._animatables.length; index++) {
  4435. var animatable = this._animatables[index];
  4436. animatable.goToFrame(frame);
  4437. }
  4438. return this;
  4439. };
  4440. /**
  4441. * Dispose all associated resources
  4442. */
  4443. AnimationGroup.prototype.dispose = function () {
  4444. this._targetedAnimations = [];
  4445. this._animatables = [];
  4446. var index = this._scene.animationGroups.indexOf(this);
  4447. if (index > -1) {
  4448. this._scene.animationGroups.splice(index, 1);
  4449. }
  4450. this.onAnimationEndObservable.clear();
  4451. this.onAnimationGroupEndObservable.clear();
  4452. this.onAnimationGroupPauseObservable.clear();
  4453. this.onAnimationGroupPlayObservable.clear();
  4454. this.onAnimationLoopObservable.clear();
  4455. };
  4456. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4457. // animatable should be taken out of the array
  4458. var idx = this._animatables.indexOf(animatable);
  4459. if (idx > -1) {
  4460. this._animatables.splice(idx, 1);
  4461. }
  4462. // all animatables were removed? animation group ended!
  4463. if (this._animatables.length === 0) {
  4464. this._isStarted = false;
  4465. this.onAnimationGroupEndObservable.notifyObservers(this);
  4466. }
  4467. };
  4468. /**
  4469. * Clone the current animation group and returns a copy
  4470. * @param newName defines the name of the new group
  4471. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4472. * @returns the new aniamtion group
  4473. */
  4474. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4475. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4476. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4477. var targetAnimation = _a[_i];
  4478. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4479. }
  4480. return newGroup;
  4481. };
  4482. // Statics
  4483. /**
  4484. * Returns a new AnimationGroup object parsed from the source provided.
  4485. * @param parsedAnimationGroup defines the source
  4486. * @param scene defines the scene that will receive the animationGroup
  4487. * @returns a new AnimationGroup
  4488. */
  4489. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4490. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4491. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4492. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4493. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4494. var id = targetedAnimation.targetId;
  4495. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4496. var morphTarget = scene.getMorphTargetById(id);
  4497. if (morphTarget) {
  4498. animationGroup.addTargetedAnimation(animation, morphTarget);
  4499. }
  4500. }
  4501. else {
  4502. var targetNode = scene.getNodeByID(id);
  4503. if (targetNode != null) {
  4504. animationGroup.addTargetedAnimation(animation, targetNode);
  4505. }
  4506. }
  4507. }
  4508. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4509. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4510. }
  4511. return animationGroup;
  4512. };
  4513. /**
  4514. * Returns the string "AnimationGroup"
  4515. * @returns "AnimationGroup"
  4516. */
  4517. AnimationGroup.prototype.getClassName = function () {
  4518. return "AnimationGroup";
  4519. };
  4520. /**
  4521. * Creates a detailled string about the object
  4522. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4523. * @returns a string representing the object
  4524. */
  4525. AnimationGroup.prototype.toString = function (fullDetails) {
  4526. var ret = "Name: " + this.name;
  4527. ret += ", type: " + this.getClassName();
  4528. if (fullDetails) {
  4529. ret += ", from: " + this._from;
  4530. ret += ", to: " + this._to;
  4531. ret += ", isStarted: " + this._isStarted;
  4532. ret += ", speedRatio: " + this._speedRatio;
  4533. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4534. ret += ", animatables length: " + this._animatables;
  4535. }
  4536. return ret;
  4537. };
  4538. return AnimationGroup;
  4539. }());
  4540. /***/ }),
  4541. /***/ "./Animations/animationKey.ts":
  4542. /*!************************************!*\
  4543. !*** ./Animations/animationKey.ts ***!
  4544. \************************************/
  4545. /*! exports provided: AnimationKeyInterpolation */
  4546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4547. "use strict";
  4548. __webpack_require__.r(__webpack_exports__);
  4549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4550. /**
  4551. * Enum for the animation key frame interpolation type
  4552. */
  4553. var AnimationKeyInterpolation;
  4554. (function (AnimationKeyInterpolation) {
  4555. /**
  4556. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4557. */
  4558. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4559. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4560. /***/ }),
  4561. /***/ "./Animations/animationPropertiesOverride.ts":
  4562. /*!***************************************************!*\
  4563. !*** ./Animations/animationPropertiesOverride.ts ***!
  4564. \***************************************************/
  4565. /*! exports provided: AnimationPropertiesOverride */
  4566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4567. "use strict";
  4568. __webpack_require__.r(__webpack_exports__);
  4569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4570. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4571. /**
  4572. * Class used to override all child animations of a given target
  4573. */
  4574. var AnimationPropertiesOverride = /** @class */ (function () {
  4575. function AnimationPropertiesOverride() {
  4576. /**
  4577. * Gets or sets a value indicating if animation blending must be used
  4578. */
  4579. this.enableBlending = false;
  4580. /**
  4581. * Gets or sets the blending speed to use when enableBlending is true
  4582. */
  4583. this.blendingSpeed = 0.01;
  4584. /**
  4585. * Gets or sets the default loop mode to use
  4586. */
  4587. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4588. }
  4589. return AnimationPropertiesOverride;
  4590. }());
  4591. /***/ }),
  4592. /***/ "./Animations/animationRange.ts":
  4593. /*!**************************************!*\
  4594. !*** ./Animations/animationRange.ts ***!
  4595. \**************************************/
  4596. /*! exports provided: AnimationRange */
  4597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4598. "use strict";
  4599. __webpack_require__.r(__webpack_exports__);
  4600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4601. /**
  4602. * Represents the range of an animation
  4603. */
  4604. var AnimationRange = /** @class */ (function () {
  4605. /**
  4606. * Initializes the range of an animation
  4607. * @param name The name of the animation range
  4608. * @param from The starting frame of the animation
  4609. * @param to The ending frame of the animation
  4610. */
  4611. function AnimationRange(
  4612. /**The name of the animation range**/
  4613. name,
  4614. /**The starting frame of the animation */
  4615. from,
  4616. /**The ending frame of the animation*/
  4617. to) {
  4618. this.name = name;
  4619. this.from = from;
  4620. this.to = to;
  4621. }
  4622. /**
  4623. * Makes a copy of the animation range
  4624. * @returns A copy of the animation range
  4625. */
  4626. AnimationRange.prototype.clone = function () {
  4627. return new AnimationRange(this.name, this.from, this.to);
  4628. };
  4629. return AnimationRange;
  4630. }());
  4631. /***/ }),
  4632. /***/ "./Animations/easing.ts":
  4633. /*!******************************!*\
  4634. !*** ./Animations/easing.ts ***!
  4635. \******************************/
  4636. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4638. "use strict";
  4639. __webpack_require__.r(__webpack_exports__);
  4640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4651. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4653. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4654. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4655. /**
  4656. * Base class used for every default easing function.
  4657. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4658. */
  4659. var EasingFunction = /** @class */ (function () {
  4660. function EasingFunction() {
  4661. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4662. }
  4663. /**
  4664. * Sets the easing mode of the current function.
  4665. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4666. */
  4667. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4668. var n = Math.min(Math.max(easingMode, 0), 2);
  4669. this._easingMode = n;
  4670. };
  4671. /**
  4672. * Gets the current easing mode.
  4673. * @returns the easing mode
  4674. */
  4675. EasingFunction.prototype.getEasingMode = function () {
  4676. return this._easingMode;
  4677. };
  4678. /**
  4679. * @hidden
  4680. */
  4681. EasingFunction.prototype.easeInCore = function (gradient) {
  4682. throw new Error('You must implement this method');
  4683. };
  4684. /**
  4685. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4686. * of the easing function.
  4687. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4688. * @returns the corresponding value on the curve defined by the easing function
  4689. */
  4690. EasingFunction.prototype.ease = function (gradient) {
  4691. switch (this._easingMode) {
  4692. case EasingFunction.EASINGMODE_EASEIN:
  4693. return this.easeInCore(gradient);
  4694. case EasingFunction.EASINGMODE_EASEOUT:
  4695. return (1 - this.easeInCore(1 - gradient));
  4696. }
  4697. if (gradient >= 0.5) {
  4698. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4699. }
  4700. return (this.easeInCore(gradient * 2) * 0.5);
  4701. };
  4702. /**
  4703. * Interpolation follows the mathematical formula associated with the easing function.
  4704. */
  4705. EasingFunction.EASINGMODE_EASEIN = 0;
  4706. /**
  4707. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4708. */
  4709. EasingFunction.EASINGMODE_EASEOUT = 1;
  4710. /**
  4711. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4712. */
  4713. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4714. return EasingFunction;
  4715. }());
  4716. /**
  4717. * Easing function with a circle shape (see link below).
  4718. * @see https://easings.net/#easeInCirc
  4719. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4720. */
  4721. var CircleEase = /** @class */ (function (_super) {
  4722. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4723. function CircleEase() {
  4724. return _super !== null && _super.apply(this, arguments) || this;
  4725. }
  4726. /** @hidden */
  4727. CircleEase.prototype.easeInCore = function (gradient) {
  4728. gradient = Math.max(0, Math.min(1, gradient));
  4729. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4730. };
  4731. return CircleEase;
  4732. }(EasingFunction));
  4733. /**
  4734. * Easing function with a ease back shape (see link below).
  4735. * @see https://easings.net/#easeInBack
  4736. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4737. */
  4738. var BackEase = /** @class */ (function (_super) {
  4739. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4740. /**
  4741. * Instantiates a back ease easing
  4742. * @see https://easings.net/#easeInBack
  4743. * @param amplitude Defines the amplitude of the function
  4744. */
  4745. function BackEase(
  4746. /** Defines the amplitude of the function */
  4747. amplitude) {
  4748. if (amplitude === void 0) { amplitude = 1; }
  4749. var _this = _super.call(this) || this;
  4750. _this.amplitude = amplitude;
  4751. return _this;
  4752. }
  4753. /** @hidden */
  4754. BackEase.prototype.easeInCore = function (gradient) {
  4755. var num = Math.max(0, this.amplitude);
  4756. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4757. };
  4758. return BackEase;
  4759. }(EasingFunction));
  4760. /**
  4761. * Easing function with a bouncing shape (see link below).
  4762. * @see https://easings.net/#easeInBounce
  4763. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4764. */
  4765. var BounceEase = /** @class */ (function (_super) {
  4766. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4767. /**
  4768. * Instantiates a bounce easing
  4769. * @see https://easings.net/#easeInBounce
  4770. * @param bounces Defines the number of bounces
  4771. * @param bounciness Defines the amplitude of the bounce
  4772. */
  4773. function BounceEase(
  4774. /** Defines the number of bounces */
  4775. bounces,
  4776. /** Defines the amplitude of the bounce */
  4777. bounciness) {
  4778. if (bounces === void 0) { bounces = 3; }
  4779. if (bounciness === void 0) { bounciness = 2; }
  4780. var _this = _super.call(this) || this;
  4781. _this.bounces = bounces;
  4782. _this.bounciness = bounciness;
  4783. return _this;
  4784. }
  4785. /** @hidden */
  4786. BounceEase.prototype.easeInCore = function (gradient) {
  4787. var y = Math.max(0.0, this.bounces);
  4788. var bounciness = this.bounciness;
  4789. if (bounciness <= 1.0) {
  4790. bounciness = 1.001;
  4791. }
  4792. var num9 = Math.pow(bounciness, y);
  4793. var num5 = 1.0 - bounciness;
  4794. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4795. var num15 = gradient * num4;
  4796. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4797. var num3 = Math.floor(num65);
  4798. var num13 = num3 + 1.0;
  4799. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4800. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4801. var num7 = (num8 + num12) * 0.5;
  4802. var num6 = gradient - num7;
  4803. var num2 = num7 - num8;
  4804. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4805. };
  4806. return BounceEase;
  4807. }(EasingFunction));
  4808. /**
  4809. * Easing function with a power of 3 shape (see link below).
  4810. * @see https://easings.net/#easeInCubic
  4811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4812. */
  4813. var CubicEase = /** @class */ (function (_super) {
  4814. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4815. function CubicEase() {
  4816. return _super !== null && _super.apply(this, arguments) || this;
  4817. }
  4818. /** @hidden */
  4819. CubicEase.prototype.easeInCore = function (gradient) {
  4820. return (gradient * gradient * gradient);
  4821. };
  4822. return CubicEase;
  4823. }(EasingFunction));
  4824. /**
  4825. * Easing function with an elastic shape (see link below).
  4826. * @see https://easings.net/#easeInElastic
  4827. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4828. */
  4829. var ElasticEase = /** @class */ (function (_super) {
  4830. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4831. /**
  4832. * Instantiates an elastic easing function
  4833. * @see https://easings.net/#easeInElastic
  4834. * @param oscillations Defines the number of oscillations
  4835. * @param springiness Defines the amplitude of the oscillations
  4836. */
  4837. function ElasticEase(
  4838. /** Defines the number of oscillations*/
  4839. oscillations,
  4840. /** Defines the amplitude of the oscillations*/
  4841. springiness) {
  4842. if (oscillations === void 0) { oscillations = 3; }
  4843. if (springiness === void 0) { springiness = 3; }
  4844. var _this = _super.call(this) || this;
  4845. _this.oscillations = oscillations;
  4846. _this.springiness = springiness;
  4847. return _this;
  4848. }
  4849. /** @hidden */
  4850. ElasticEase.prototype.easeInCore = function (gradient) {
  4851. var num2;
  4852. var num3 = Math.max(0.0, this.oscillations);
  4853. var num = Math.max(0.0, this.springiness);
  4854. if (num == 0) {
  4855. num2 = gradient;
  4856. }
  4857. else {
  4858. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4859. }
  4860. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4861. };
  4862. return ElasticEase;
  4863. }(EasingFunction));
  4864. /**
  4865. * Easing function with an exponential shape (see link below).
  4866. * @see https://easings.net/#easeInExpo
  4867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4868. */
  4869. var ExponentialEase = /** @class */ (function (_super) {
  4870. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4871. /**
  4872. * Instantiates an exponential easing function
  4873. * @see https://easings.net/#easeInExpo
  4874. * @param exponent Defines the exponent of the function
  4875. */
  4876. function ExponentialEase(
  4877. /** Defines the exponent of the function */
  4878. exponent) {
  4879. if (exponent === void 0) { exponent = 2; }
  4880. var _this = _super.call(this) || this;
  4881. _this.exponent = exponent;
  4882. return _this;
  4883. }
  4884. /** @hidden */
  4885. ExponentialEase.prototype.easeInCore = function (gradient) {
  4886. if (this.exponent <= 0) {
  4887. return gradient;
  4888. }
  4889. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4890. };
  4891. return ExponentialEase;
  4892. }(EasingFunction));
  4893. /**
  4894. * Easing function with a power shape (see link below).
  4895. * @see https://easings.net/#easeInQuad
  4896. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4897. */
  4898. var PowerEase = /** @class */ (function (_super) {
  4899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4900. /**
  4901. * Instantiates an power base easing function
  4902. * @see https://easings.net/#easeInQuad
  4903. * @param power Defines the power of the function
  4904. */
  4905. function PowerEase(
  4906. /** Defines the power of the function */
  4907. power) {
  4908. if (power === void 0) { power = 2; }
  4909. var _this = _super.call(this) || this;
  4910. _this.power = power;
  4911. return _this;
  4912. }
  4913. /** @hidden */
  4914. PowerEase.prototype.easeInCore = function (gradient) {
  4915. var y = Math.max(0.0, this.power);
  4916. return Math.pow(gradient, y);
  4917. };
  4918. return PowerEase;
  4919. }(EasingFunction));
  4920. /**
  4921. * Easing function with a power of 2 shape (see link below).
  4922. * @see https://easings.net/#easeInQuad
  4923. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4924. */
  4925. var QuadraticEase = /** @class */ (function (_super) {
  4926. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4927. function QuadraticEase() {
  4928. return _super !== null && _super.apply(this, arguments) || this;
  4929. }
  4930. /** @hidden */
  4931. QuadraticEase.prototype.easeInCore = function (gradient) {
  4932. return (gradient * gradient);
  4933. };
  4934. return QuadraticEase;
  4935. }(EasingFunction));
  4936. /**
  4937. * Easing function with a power of 4 shape (see link below).
  4938. * @see https://easings.net/#easeInQuart
  4939. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4940. */
  4941. var QuarticEase = /** @class */ (function (_super) {
  4942. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4943. function QuarticEase() {
  4944. return _super !== null && _super.apply(this, arguments) || this;
  4945. }
  4946. /** @hidden */
  4947. QuarticEase.prototype.easeInCore = function (gradient) {
  4948. return (gradient * gradient * gradient * gradient);
  4949. };
  4950. return QuarticEase;
  4951. }(EasingFunction));
  4952. /**
  4953. * Easing function with a power of 5 shape (see link below).
  4954. * @see https://easings.net/#easeInQuint
  4955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4956. */
  4957. var QuinticEase = /** @class */ (function (_super) {
  4958. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4959. function QuinticEase() {
  4960. return _super !== null && _super.apply(this, arguments) || this;
  4961. }
  4962. /** @hidden */
  4963. QuinticEase.prototype.easeInCore = function (gradient) {
  4964. return (gradient * gradient * gradient * gradient * gradient);
  4965. };
  4966. return QuinticEase;
  4967. }(EasingFunction));
  4968. /**
  4969. * Easing function with a sin shape (see link below).
  4970. * @see https://easings.net/#easeInSine
  4971. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4972. */
  4973. var SineEase = /** @class */ (function (_super) {
  4974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4975. function SineEase() {
  4976. return _super !== null && _super.apply(this, arguments) || this;
  4977. }
  4978. /** @hidden */
  4979. SineEase.prototype.easeInCore = function (gradient) {
  4980. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4981. };
  4982. return SineEase;
  4983. }(EasingFunction));
  4984. /**
  4985. * Easing function with a bezier shape (see link below).
  4986. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4987. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4988. */
  4989. var BezierCurveEase = /** @class */ (function (_super) {
  4990. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4991. /**
  4992. * Instantiates a bezier function
  4993. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4994. * @param x1 Defines the x component of the start tangent in the bezier curve
  4995. * @param y1 Defines the y component of the start tangent in the bezier curve
  4996. * @param x2 Defines the x component of the end tangent in the bezier curve
  4997. * @param y2 Defines the y component of the end tangent in the bezier curve
  4998. */
  4999. function BezierCurveEase(
  5000. /** Defines the x component of the start tangent in the bezier curve */
  5001. x1,
  5002. /** Defines the y component of the start tangent in the bezier curve */
  5003. y1,
  5004. /** Defines the x component of the end tangent in the bezier curve */
  5005. x2,
  5006. /** Defines the y component of the end tangent in the bezier curve */
  5007. y2) {
  5008. if (x1 === void 0) { x1 = 0; }
  5009. if (y1 === void 0) { y1 = 0; }
  5010. if (x2 === void 0) { x2 = 1; }
  5011. if (y2 === void 0) { y2 = 1; }
  5012. var _this = _super.call(this) || this;
  5013. _this.x1 = x1;
  5014. _this.y1 = y1;
  5015. _this.x2 = x2;
  5016. _this.y2 = y2;
  5017. return _this;
  5018. }
  5019. /** @hidden */
  5020. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5021. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5022. };
  5023. return BezierCurveEase;
  5024. }(EasingFunction));
  5025. /***/ }),
  5026. /***/ "./Animations/index.ts":
  5027. /*!*****************************!*\
  5028. !*** ./Animations/index.ts ***!
  5029. \*****************************/
  5030. /*! exports provided: Animatable, _IAnimationState, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5032. "use strict";
  5033. __webpack_require__.r(__webpack_exports__);
  5034. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5036. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["_IAnimationState"]; });
  5038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5039. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5042. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5044. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5058. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5060. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5062. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5064. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5066. /***/ }),
  5067. /***/ "./Animations/runtimeAnimation.ts":
  5068. /*!****************************************!*\
  5069. !*** ./Animations/runtimeAnimation.ts ***!
  5070. \****************************************/
  5071. /*! exports provided: RuntimeAnimation */
  5072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5073. "use strict";
  5074. __webpack_require__.r(__webpack_exports__);
  5075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5076. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5077. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5078. // Static values to help the garbage collector
  5079. // Quaternion
  5080. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5081. // Vector3
  5082. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5083. // Vector2
  5084. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5085. // Size
  5086. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5087. // Color3
  5088. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5089. /**
  5090. * Defines a runtime animation
  5091. */
  5092. var RuntimeAnimation = /** @class */ (function () {
  5093. /**
  5094. * Create a new RuntimeAnimation object
  5095. * @param target defines the target of the animation
  5096. * @param animation defines the source animation object
  5097. * @param scene defines the hosting scene
  5098. * @param host defines the initiating Animatable
  5099. */
  5100. function RuntimeAnimation(target, animation, scene, host) {
  5101. var _this = this;
  5102. this._events = new Array();
  5103. /**
  5104. * The current frame of the runtime animation
  5105. */
  5106. this._currentFrame = 0;
  5107. /**
  5108. * The original value of the runtime animation
  5109. */
  5110. this._originalValue = new Array();
  5111. /**
  5112. * The original blend value of the runtime animation
  5113. */
  5114. this._originalBlendValue = null;
  5115. /**
  5116. * The offsets cache of the runtime animation
  5117. */
  5118. this._offsetsCache = {};
  5119. /**
  5120. * The high limits cache of the runtime animation
  5121. */
  5122. this._highLimitsCache = {};
  5123. /**
  5124. * Specifies if the runtime animation has been stopped
  5125. */
  5126. this._stopped = false;
  5127. /**
  5128. * The blending factor of the runtime animation
  5129. */
  5130. this._blendingFactor = 0;
  5131. /**
  5132. * The current value of the runtime animation
  5133. */
  5134. this._currentValue = null;
  5135. this._currentActiveTarget = null;
  5136. this._directTarget = null;
  5137. /**
  5138. * The target path of the runtime animation
  5139. */
  5140. this._targetPath = "";
  5141. /**
  5142. * The weight of the runtime animation
  5143. */
  5144. this._weight = 1.0;
  5145. /**
  5146. * The ratio offset of the runtime animation
  5147. */
  5148. this._ratioOffset = 0;
  5149. /**
  5150. * The previous delay of the runtime animation
  5151. */
  5152. this._previousDelay = 0;
  5153. /**
  5154. * The previous ratio of the runtime animation
  5155. */
  5156. this._previousRatio = 0;
  5157. this._targetIsArray = false;
  5158. this._animation = animation;
  5159. this._target = target;
  5160. this._scene = scene;
  5161. this._host = host;
  5162. this._activeTargets = [];
  5163. animation._runtimeAnimations.push(this);
  5164. // State
  5165. this._animationState = {
  5166. key: 0,
  5167. repeatCount: 0,
  5168. loopMode: this._getCorrectLoopMode()
  5169. };
  5170. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX) {
  5171. this._animationState.workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5172. }
  5173. // Limits
  5174. this._keys = this._animation.getKeys();
  5175. this._minFrame = this._keys[0].frame;
  5176. this._maxFrame = this._keys[this._keys.length - 1].frame;
  5177. this._minValue = this._keys[0].value;
  5178. this._maxValue = this._keys[this._keys.length - 1].value;
  5179. // Add a start key at frame 0 if missing
  5180. if (this._minFrame !== 0) {
  5181. var newKey = { frame: 0, value: this._minValue };
  5182. this._keys.splice(0, 0, newKey);
  5183. }
  5184. // Check data
  5185. if (this._target instanceof Array) {
  5186. var index = 0;
  5187. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5188. var target_1 = _a[_i];
  5189. this._preparePath(target_1, index);
  5190. this._getOriginalValues(index);
  5191. index++;
  5192. }
  5193. this._targetIsArray = true;
  5194. }
  5195. else {
  5196. this._preparePath(this._target);
  5197. this._getOriginalValues();
  5198. this._targetIsArray = false;
  5199. this._directTarget = this._activeTargets[0];
  5200. }
  5201. // Cloning events locally
  5202. var events = animation.getEvents();
  5203. if (events && events.length > 0) {
  5204. events.forEach(function (e) {
  5205. _this._events.push(e._clone());
  5206. });
  5207. }
  5208. this._enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5209. }
  5210. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5211. /**
  5212. * Gets the current frame of the runtime animation
  5213. */
  5214. get: function () {
  5215. return this._currentFrame;
  5216. },
  5217. enumerable: true,
  5218. configurable: true
  5219. });
  5220. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5221. /**
  5222. * Gets the weight of the runtime animation
  5223. */
  5224. get: function () {
  5225. return this._weight;
  5226. },
  5227. enumerable: true,
  5228. configurable: true
  5229. });
  5230. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5231. /**
  5232. * Gets the current value of the runtime animation
  5233. */
  5234. get: function () {
  5235. return this._currentValue;
  5236. },
  5237. enumerable: true,
  5238. configurable: true
  5239. });
  5240. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5241. /**
  5242. * Gets the target path of the runtime animation
  5243. */
  5244. get: function () {
  5245. return this._targetPath;
  5246. },
  5247. enumerable: true,
  5248. configurable: true
  5249. });
  5250. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5251. /**
  5252. * Gets the actual target of the runtime animation
  5253. */
  5254. get: function () {
  5255. return this._currentActiveTarget;
  5256. },
  5257. enumerable: true,
  5258. configurable: true
  5259. });
  5260. RuntimeAnimation.prototype._preparePath = function (target, targetIndex) {
  5261. if (targetIndex === void 0) { targetIndex = 0; }
  5262. var targetPropertyPath = this._animation.targetPropertyPath;
  5263. if (targetPropertyPath.length > 1) {
  5264. var property = target[targetPropertyPath[0]];
  5265. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5266. property = property[targetPropertyPath[index]];
  5267. }
  5268. this._targetPath = targetPropertyPath[targetPropertyPath.length - 1];
  5269. this._activeTargets[targetIndex] = property;
  5270. }
  5271. else {
  5272. this._targetPath = targetPropertyPath[0];
  5273. this._activeTargets[targetIndex] = target;
  5274. }
  5275. };
  5276. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5277. /**
  5278. * Gets the animation from the runtime animation
  5279. */
  5280. get: function () {
  5281. return this._animation;
  5282. },
  5283. enumerable: true,
  5284. configurable: true
  5285. });
  5286. /**
  5287. * Resets the runtime animation to the beginning
  5288. * @param restoreOriginal defines whether to restore the target property to the original value
  5289. */
  5290. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5291. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5292. if (restoreOriginal) {
  5293. if (this._target instanceof Array) {
  5294. var index = 0;
  5295. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5296. var target = _a[_i];
  5297. if (this._originalValue[index] !== undefined) {
  5298. this._setValue(target, this._activeTargets[index], this._originalValue[index], -1, index);
  5299. }
  5300. index++;
  5301. }
  5302. }
  5303. else {
  5304. if (this._originalValue[0] !== undefined) {
  5305. this._setValue(this._target, this._directTarget, this._originalValue[0], -1, 0);
  5306. }
  5307. }
  5308. }
  5309. this._offsetsCache = {};
  5310. this._highLimitsCache = {};
  5311. this._currentFrame = 0;
  5312. this._blendingFactor = 0;
  5313. // Events
  5314. for (var index = 0; index < this._events.length; index++) {
  5315. this._events[index].isDone = false;
  5316. }
  5317. };
  5318. /**
  5319. * Specifies if the runtime animation is stopped
  5320. * @returns Boolean specifying if the runtime animation is stopped
  5321. */
  5322. RuntimeAnimation.prototype.isStopped = function () {
  5323. return this._stopped;
  5324. };
  5325. /**
  5326. * Disposes of the runtime animation
  5327. */
  5328. RuntimeAnimation.prototype.dispose = function () {
  5329. var index = this._animation.runtimeAnimations.indexOf(this);
  5330. if (index > -1) {
  5331. this._animation.runtimeAnimations.splice(index, 1);
  5332. }
  5333. };
  5334. /**
  5335. * Apply the interpolated value to the target
  5336. * @param currentValue defines the value computed by the animation
  5337. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5338. */
  5339. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5340. if (this._targetIsArray) {
  5341. for (var index = 0; index < this._target.length; index++) {
  5342. var target = this._target[index];
  5343. this._setValue(target, this._activeTargets[index], currentValue, weight, index);
  5344. }
  5345. return;
  5346. }
  5347. this._setValue(this._target, this._directTarget, currentValue, weight, 0);
  5348. };
  5349. RuntimeAnimation.prototype._getOriginalValues = function (targetIndex) {
  5350. if (targetIndex === void 0) { targetIndex = 0; }
  5351. var originalValue;
  5352. var target = this._activeTargets[targetIndex];
  5353. if (target.getRestPose && this._targetPath === "_matrix") { // For bones
  5354. originalValue = target.getRestPose();
  5355. }
  5356. else {
  5357. originalValue = target[this._targetPath];
  5358. }
  5359. if (originalValue && originalValue.clone) {
  5360. this._originalValue[targetIndex] = originalValue.clone();
  5361. }
  5362. else {
  5363. this._originalValue[targetIndex] = originalValue;
  5364. }
  5365. };
  5366. RuntimeAnimation.prototype._setValue = function (target, destination, currentValue, weight, targetIndex) {
  5367. // Set value
  5368. this._currentActiveTarget = destination;
  5369. this._weight = weight;
  5370. if (this._enableBlending && this._blendingFactor <= 1.0) {
  5371. if (!this._originalBlendValue) {
  5372. var originalValue = destination[this._targetPath];
  5373. if (originalValue.clone) {
  5374. this._originalBlendValue = originalValue.clone();
  5375. }
  5376. else {
  5377. this._originalBlendValue = originalValue;
  5378. }
  5379. }
  5380. if (this._originalBlendValue.m) { // Matrix
  5381. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5382. if (this._currentValue) {
  5383. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5384. }
  5385. else {
  5386. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5387. }
  5388. }
  5389. else {
  5390. if (this._currentValue) {
  5391. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5392. }
  5393. else {
  5394. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5395. }
  5396. }
  5397. }
  5398. else {
  5399. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5400. }
  5401. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5402. this._blendingFactor += blendingSpeed;
  5403. }
  5404. else {
  5405. this._currentValue = currentValue;
  5406. }
  5407. if (weight !== -1.0) {
  5408. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5409. }
  5410. else {
  5411. destination[this._targetPath] = this._currentValue;
  5412. }
  5413. if (target.markAsDirty) {
  5414. target.markAsDirty(this._animation.targetProperty);
  5415. }
  5416. };
  5417. /**
  5418. * Gets the loop pmode of the runtime animation
  5419. * @returns Loop Mode
  5420. */
  5421. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5422. if (this._target && this._target.animationPropertiesOverride) {
  5423. return this._target.animationPropertiesOverride.loopMode;
  5424. }
  5425. return this._animation.loopMode;
  5426. };
  5427. /**
  5428. * Move the current animation to a given frame
  5429. * @param frame defines the frame to move to
  5430. */
  5431. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5432. var keys = this._animation.getKeys();
  5433. if (frame < keys[0].frame) {
  5434. frame = keys[0].frame;
  5435. }
  5436. else if (frame > keys[keys.length - 1].frame) {
  5437. frame = keys[keys.length - 1].frame;
  5438. }
  5439. var currentValue = this._animation._interpolate(frame, this._animationState);
  5440. this.setValue(currentValue, -1);
  5441. };
  5442. /**
  5443. * @hidden Internal use only
  5444. */
  5445. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5446. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5447. this._ratioOffset = this._previousRatio - newRatio;
  5448. };
  5449. /**
  5450. * Execute the current animation
  5451. * @param delay defines the delay to add to the current frame
  5452. * @param from defines the lower bound of the animation range
  5453. * @param to defines the upper bound of the animation range
  5454. * @param loop defines if the current animation must loop
  5455. * @param speedRatio defines the current speed ratio
  5456. * @param weight defines the weight of the animation (default is -1 so no weight)
  5457. * @param onLoop optional callback called when animation loops
  5458. * @returns a boolean indicating if the animation is running
  5459. */
  5460. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight) {
  5461. if (weight === void 0) { weight = -1.0; }
  5462. var animation = this._animation;
  5463. var targetPropertyPath = animation.targetPropertyPath;
  5464. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5465. this._stopped = true;
  5466. return false;
  5467. }
  5468. var returnValue = true;
  5469. // Check limits
  5470. if (from < this._minFrame || from > this._maxFrame) {
  5471. from = this._minFrame;
  5472. }
  5473. if (to < this._minFrame || to > this._maxFrame) {
  5474. to = this._maxFrame;
  5475. }
  5476. var range = to - from;
  5477. var offsetValue;
  5478. // Compute ratio which represents the frame delta between from and to
  5479. var ratio = (delay * (animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5480. var highLimitValue = 0;
  5481. this._previousDelay = delay;
  5482. this._previousRatio = ratio;
  5483. if (!loop && (to > from && ratio >= range)) { // If we are out of range and not looping get back to caller
  5484. returnValue = false;
  5485. highLimitValue = animation._getKeyValue(this._maxValue);
  5486. }
  5487. else if (!loop && (from > to && ratio <= range)) {
  5488. returnValue = false;
  5489. highLimitValue = animation._getKeyValue(this._minValue);
  5490. }
  5491. else if (this._animationState.loopMode !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5492. var keyOffset = to.toString() + from.toString();
  5493. if (!this._offsetsCache[keyOffset]) {
  5494. this._animationState.repeatCount = 0;
  5495. this._animationState.loopMode = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  5496. var fromValue = animation._interpolate(from, this._animationState);
  5497. var toValue = animation._interpolate(to, this._animationState);
  5498. this._animationState.loopMode = this._getCorrectLoopMode();
  5499. switch (animation.dataType) {
  5500. // Float
  5501. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5502. this._offsetsCache[keyOffset] = toValue - fromValue;
  5503. break;
  5504. // Quaternion
  5505. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5506. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5507. break;
  5508. // Vector3
  5509. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5510. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5511. // Vector2
  5512. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5513. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5514. // Size
  5515. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5516. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5517. // Color3
  5518. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5519. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5520. default:
  5521. break;
  5522. }
  5523. this._highLimitsCache[keyOffset] = toValue;
  5524. }
  5525. highLimitValue = this._highLimitsCache[keyOffset];
  5526. offsetValue = this._offsetsCache[keyOffset];
  5527. }
  5528. if (offsetValue === undefined) {
  5529. switch (animation.dataType) {
  5530. // Float
  5531. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5532. offsetValue = 0;
  5533. break;
  5534. // Quaternion
  5535. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5536. offsetValue = _staticOffsetValueQuaternion;
  5537. break;
  5538. // Vector3
  5539. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5540. offsetValue = _staticOffsetValueVector3;
  5541. break;
  5542. // Vector2
  5543. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5544. offsetValue = _staticOffsetValueVector2;
  5545. break;
  5546. // Size
  5547. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5548. offsetValue = _staticOffsetValueSize;
  5549. break;
  5550. // Color3
  5551. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5552. offsetValue = _staticOffsetValueColor3;
  5553. }
  5554. }
  5555. // Compute value
  5556. var currentFrame;
  5557. if (this._host && this._host.syncRoot) {
  5558. var syncRoot = this._host.syncRoot;
  5559. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5560. currentFrame = from + (to - from) * hostNormalizedFrame;
  5561. }
  5562. else {
  5563. currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5564. }
  5565. // Reset events if looping
  5566. var events = this._events;
  5567. if (range > 0 && this.currentFrame > currentFrame ||
  5568. range < 0 && this.currentFrame < currentFrame) {
  5569. this._onLoop();
  5570. // Need to reset animation events
  5571. if (events.length) {
  5572. for (var index = 0; index < events.length; index++) {
  5573. if (!events[index].onlyOnce) {
  5574. // reset event, the animation is looping
  5575. events[index].isDone = false;
  5576. }
  5577. }
  5578. }
  5579. }
  5580. this._currentFrame = currentFrame;
  5581. this._animationState.repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5582. this._animationState.highLimitValue = highLimitValue;
  5583. this._animationState.offsetValue = offsetValue;
  5584. var currentValue = animation._interpolate(currentFrame, this._animationState);
  5585. // Set value
  5586. this.setValue(currentValue, weight);
  5587. // Check events
  5588. if (events.length) {
  5589. for (var index = 0; index < events.length; index++) {
  5590. // Make sure current frame has passed event frame and that event frame is within the current range
  5591. // Also, handle both forward and reverse animations
  5592. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5593. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5594. var event = events[index];
  5595. if (!event.isDone) {
  5596. // If event should be done only once, remove it.
  5597. if (event.onlyOnce) {
  5598. events.splice(index, 1);
  5599. index--;
  5600. }
  5601. event.isDone = true;
  5602. event.action(currentFrame);
  5603. } // Don't do anything if the event has already be done.
  5604. }
  5605. }
  5606. }
  5607. if (!returnValue) {
  5608. this._stopped = true;
  5609. }
  5610. return returnValue;
  5611. };
  5612. return RuntimeAnimation;
  5613. }());
  5614. /***/ }),
  5615. /***/ "./Audio/analyser.ts":
  5616. /*!***************************!*\
  5617. !*** ./Audio/analyser.ts ***!
  5618. \***************************/
  5619. /*! exports provided: Analyser */
  5620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5621. "use strict";
  5622. __webpack_require__.r(__webpack_exports__);
  5623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5624. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5625. /**
  5626. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5628. */
  5629. var Analyser = /** @class */ (function () {
  5630. /**
  5631. * Creates a new analyser
  5632. * @param scene defines hosting scene
  5633. */
  5634. function Analyser(scene) {
  5635. /**
  5636. * Gets or sets the smoothing
  5637. * @ignorenaming
  5638. */
  5639. this.SMOOTHING = 0.75;
  5640. /**
  5641. * Gets or sets the FFT table size
  5642. * @ignorenaming
  5643. */
  5644. this.FFT_SIZE = 512;
  5645. /**
  5646. * Gets or sets the bar graph amplitude
  5647. * @ignorenaming
  5648. */
  5649. this.BARGRAPHAMPLITUDE = 256;
  5650. /**
  5651. * Gets or sets the position of the debug canvas
  5652. * @ignorenaming
  5653. */
  5654. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5655. /**
  5656. * Gets or sets the debug canvas size
  5657. * @ignorenaming
  5658. */
  5659. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5660. this._scene = scene;
  5661. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5662. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5663. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5664. this._webAudioAnalyser.minDecibels = -140;
  5665. this._webAudioAnalyser.maxDecibels = 0;
  5666. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5667. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5668. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5669. }
  5670. }
  5671. /**
  5672. * Get the number of data values you will have to play with for the visualization
  5673. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5674. * @returns a number
  5675. */
  5676. Analyser.prototype.getFrequencyBinCount = function () {
  5677. if (this._audioEngine.canUseWebAudio) {
  5678. return this._webAudioAnalyser.frequencyBinCount;
  5679. }
  5680. else {
  5681. return 0;
  5682. }
  5683. };
  5684. /**
  5685. * Gets the current frequency data as a byte array
  5686. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5687. * @returns a Uint8Array
  5688. */
  5689. Analyser.prototype.getByteFrequencyData = function () {
  5690. if (this._audioEngine.canUseWebAudio) {
  5691. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5692. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5693. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5694. }
  5695. return this._byteFreqs;
  5696. };
  5697. /**
  5698. * Gets the current waveform as a byte array
  5699. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5700. * @returns a Uint8Array
  5701. */
  5702. Analyser.prototype.getByteTimeDomainData = function () {
  5703. if (this._audioEngine.canUseWebAudio) {
  5704. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5705. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5706. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5707. }
  5708. return this._byteTime;
  5709. };
  5710. /**
  5711. * Gets the current frequency data as a float array
  5712. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5713. * @returns a Float32Array
  5714. */
  5715. Analyser.prototype.getFloatFrequencyData = function () {
  5716. if (this._audioEngine.canUseWebAudio) {
  5717. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5718. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5719. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5720. }
  5721. return this._floatFreqs;
  5722. };
  5723. /**
  5724. * Renders the debug canvas
  5725. */
  5726. Analyser.prototype.drawDebugCanvas = function () {
  5727. var _this = this;
  5728. if (this._audioEngine.canUseWebAudio) {
  5729. if (!this._debugCanvas) {
  5730. this._debugCanvas = document.createElement("canvas");
  5731. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5732. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5733. this._debugCanvas.style.position = "absolute";
  5734. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5735. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5736. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5737. document.body.appendChild(this._debugCanvas);
  5738. this._registerFunc = function () {
  5739. _this.drawDebugCanvas();
  5740. };
  5741. this._scene.registerBeforeRender(this._registerFunc);
  5742. }
  5743. if (this._registerFunc && this._debugCanvasContext) {
  5744. var workingArray = this.getByteFrequencyData();
  5745. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5746. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5747. // Draw the frequency domain chart.
  5748. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5749. var value = workingArray[i];
  5750. var percent = value / this.BARGRAPHAMPLITUDE;
  5751. var height = this.DEBUGCANVASSIZE.height * percent;
  5752. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5753. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5754. var hue = i / this.getFrequencyBinCount() * 360;
  5755. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5756. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5757. }
  5758. }
  5759. }
  5760. };
  5761. /**
  5762. * Stops rendering the debug canvas and removes it
  5763. */
  5764. Analyser.prototype.stopDebugCanvas = function () {
  5765. if (this._debugCanvas) {
  5766. if (this._registerFunc) {
  5767. this._scene.unregisterBeforeRender(this._registerFunc);
  5768. this._registerFunc = null;
  5769. }
  5770. document.body.removeChild(this._debugCanvas);
  5771. this._debugCanvas = null;
  5772. this._debugCanvasContext = null;
  5773. }
  5774. };
  5775. /**
  5776. * Connects two audio nodes
  5777. * @param inputAudioNode defines first node to connect
  5778. * @param outputAudioNode defines second node to connect
  5779. */
  5780. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5781. if (this._audioEngine.canUseWebAudio) {
  5782. inputAudioNode.connect(this._webAudioAnalyser);
  5783. this._webAudioAnalyser.connect(outputAudioNode);
  5784. }
  5785. };
  5786. /**
  5787. * Releases all associated resources
  5788. */
  5789. Analyser.prototype.dispose = function () {
  5790. if (this._audioEngine.canUseWebAudio) {
  5791. this._webAudioAnalyser.disconnect();
  5792. }
  5793. };
  5794. return Analyser;
  5795. }());
  5796. /***/ }),
  5797. /***/ "./Audio/audioEngine.ts":
  5798. /*!******************************!*\
  5799. !*** ./Audio/audioEngine.ts ***!
  5800. \******************************/
  5801. /*! exports provided: AudioEngine */
  5802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5803. "use strict";
  5804. __webpack_require__.r(__webpack_exports__);
  5805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5806. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5807. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5808. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5809. // Sets the default audio engine to Babylon.js
  5810. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5811. /**
  5812. * This represents the default audio engine used in babylon.
  5813. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5815. */
  5816. var AudioEngine = /** @class */ (function () {
  5817. /**
  5818. * Instantiates a new audio engine.
  5819. *
  5820. * There should be only one per page as some browsers restrict the number
  5821. * of audio contexts you can create.
  5822. * @param hostElement defines the host element where to display the mute icon if necessary
  5823. */
  5824. function AudioEngine(hostElement) {
  5825. if (hostElement === void 0) { hostElement = null; }
  5826. var _this = this;
  5827. this._audioContext = null;
  5828. this._audioContextInitialized = false;
  5829. this._muteButton = null;
  5830. /**
  5831. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5832. */
  5833. this.canUseWebAudio = false;
  5834. /**
  5835. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5836. * @ignoreNaming
  5837. */
  5838. this.WarnedWebAudioUnsupported = false;
  5839. /**
  5840. * Gets whether or not mp3 are supported by your browser.
  5841. */
  5842. this.isMP3supported = false;
  5843. /**
  5844. * Gets whether or not ogg are supported by your browser.
  5845. */
  5846. this.isOGGsupported = false;
  5847. /**
  5848. * Gets whether audio has been unlocked on the device.
  5849. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5850. * a user interaction has happened.
  5851. */
  5852. this.unlocked = true;
  5853. /**
  5854. * Defines if the audio engine relies on a custom unlocked button.
  5855. * In this case, the embedded button will not be displayed.
  5856. */
  5857. this.useCustomUnlockedButton = false;
  5858. /**
  5859. * Event raised when audio has been unlocked on the browser.
  5860. */
  5861. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5862. /**
  5863. * Event raised when audio has been locked on the browser.
  5864. */
  5865. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5866. this._tryToRun = false;
  5867. this._onResize = function () {
  5868. _this._moveButtonToTopLeft();
  5869. };
  5870. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5871. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5872. this.canUseWebAudio = true;
  5873. }
  5874. var audioElem = document.createElement('audio');
  5875. this._hostElement = hostElement;
  5876. try {
  5877. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5878. this.isMP3supported = true;
  5879. }
  5880. }
  5881. catch (e) {
  5882. // protect error during capability check.
  5883. }
  5884. try {
  5885. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5886. this.isOGGsupported = true;
  5887. }
  5888. }
  5889. catch (e) {
  5890. // protect error during capability check.
  5891. }
  5892. }
  5893. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5894. /**
  5895. * Gets the current AudioContext if available.
  5896. */
  5897. get: function () {
  5898. if (!this._audioContextInitialized) {
  5899. this._initializeAudioContext();
  5900. }
  5901. else {
  5902. if (!this.unlocked && !this._muteButton) {
  5903. this._displayMuteButton();
  5904. }
  5905. }
  5906. return this._audioContext;
  5907. },
  5908. enumerable: true,
  5909. configurable: true
  5910. });
  5911. /**
  5912. * Flags the audio engine in Locked state.
  5913. * This happens due to new browser policies preventing audio to autoplay.
  5914. */
  5915. AudioEngine.prototype.lock = function () {
  5916. this._triggerSuspendedState();
  5917. };
  5918. /**
  5919. * Unlocks the audio engine once a user action has been done on the dom.
  5920. * This is helpful to resume play once browser policies have been satisfied.
  5921. */
  5922. AudioEngine.prototype.unlock = function () {
  5923. this._triggerRunningState();
  5924. };
  5925. AudioEngine.prototype._resumeAudioContext = function () {
  5926. var result;
  5927. if (this._audioContext.resume) {
  5928. result = this._audioContext.resume();
  5929. }
  5930. return result || Promise.resolve();
  5931. };
  5932. AudioEngine.prototype._initializeAudioContext = function () {
  5933. try {
  5934. if (this.canUseWebAudio) {
  5935. this._audioContext = new AudioContext();
  5936. // create a global volume gain node
  5937. this.masterGain = this._audioContext.createGain();
  5938. this.masterGain.gain.value = 1;
  5939. this.masterGain.connect(this._audioContext.destination);
  5940. this._audioContextInitialized = true;
  5941. if (this._audioContext.state === "running") {
  5942. // Do not wait for the promise to unlock.
  5943. this._triggerRunningState();
  5944. }
  5945. }
  5946. }
  5947. catch (e) {
  5948. this.canUseWebAudio = false;
  5949. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5950. }
  5951. };
  5952. AudioEngine.prototype._triggerRunningState = function () {
  5953. var _this = this;
  5954. if (this._tryToRun) {
  5955. return;
  5956. }
  5957. this._tryToRun = true;
  5958. this._resumeAudioContext()
  5959. .then(function () {
  5960. _this._tryToRun = false;
  5961. if (_this._muteButton) {
  5962. _this._hideMuteButton();
  5963. }
  5964. }).catch(function () {
  5965. _this._tryToRun = false;
  5966. _this.unlocked = false;
  5967. });
  5968. // Notify users that the audio stack is unlocked/unmuted
  5969. this.unlocked = true;
  5970. this.onAudioUnlockedObservable.notifyObservers(this);
  5971. };
  5972. AudioEngine.prototype._triggerSuspendedState = function () {
  5973. this.unlocked = false;
  5974. this.onAudioLockedObservable.notifyObservers(this);
  5975. this._displayMuteButton();
  5976. };
  5977. AudioEngine.prototype._displayMuteButton = function () {
  5978. var _this = this;
  5979. if (this.useCustomUnlockedButton || this._muteButton) {
  5980. return;
  5981. }
  5982. this._muteButton = document.createElement("BUTTON");
  5983. this._muteButton.className = "babylonUnmuteIcon";
  5984. this._muteButton.id = "babylonUnmuteIconBtn";
  5985. this._muteButton.title = "Unmute";
  5986. 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) }";
  5987. var style = document.createElement('style');
  5988. style.appendChild(document.createTextNode(css));
  5989. document.getElementsByTagName('head')[0].appendChild(style);
  5990. document.body.appendChild(this._muteButton);
  5991. this._moveButtonToTopLeft();
  5992. this._muteButton.addEventListener('touchend', function () {
  5993. _this._triggerRunningState();
  5994. }, true);
  5995. this._muteButton.addEventListener('click', function () {
  5996. _this._triggerRunningState();
  5997. }, true);
  5998. window.addEventListener("resize", this._onResize);
  5999. };
  6000. AudioEngine.prototype._moveButtonToTopLeft = function () {
  6001. if (this._hostElement && this._muteButton) {
  6002. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  6003. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  6004. }
  6005. };
  6006. AudioEngine.prototype._hideMuteButton = function () {
  6007. if (this._muteButton) {
  6008. document.body.removeChild(this._muteButton);
  6009. this._muteButton = null;
  6010. }
  6011. };
  6012. /**
  6013. * Destroy and release the resources associated with the audio ccontext.
  6014. */
  6015. AudioEngine.prototype.dispose = function () {
  6016. if (this.canUseWebAudio && this._audioContextInitialized) {
  6017. if (this._connectedAnalyser && this._audioContext) {
  6018. this._connectedAnalyser.stopDebugCanvas();
  6019. this._connectedAnalyser.dispose();
  6020. this.masterGain.disconnect();
  6021. this.masterGain.connect(this._audioContext.destination);
  6022. this._connectedAnalyser = null;
  6023. }
  6024. this.masterGain.gain.value = 1;
  6025. }
  6026. this.WarnedWebAudioUnsupported = false;
  6027. this._hideMuteButton();
  6028. window.removeEventListener("resize", this._onResize);
  6029. this.onAudioUnlockedObservable.clear();
  6030. this.onAudioLockedObservable.clear();
  6031. };
  6032. /**
  6033. * Gets the global volume sets on the master gain.
  6034. * @returns the global volume if set or -1 otherwise
  6035. */
  6036. AudioEngine.prototype.getGlobalVolume = function () {
  6037. if (this.canUseWebAudio && this._audioContextInitialized) {
  6038. return this.masterGain.gain.value;
  6039. }
  6040. else {
  6041. return -1;
  6042. }
  6043. };
  6044. /**
  6045. * Sets the global volume of your experience (sets on the master gain).
  6046. * @param newVolume Defines the new global volume of the application
  6047. */
  6048. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  6049. if (this.canUseWebAudio && this._audioContextInitialized) {
  6050. this.masterGain.gain.value = newVolume;
  6051. }
  6052. };
  6053. /**
  6054. * Connect the audio engine to an audio analyser allowing some amazing
  6055. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6057. * @param analyser The analyser to connect to the engine
  6058. */
  6059. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6060. if (this._connectedAnalyser) {
  6061. this._connectedAnalyser.stopDebugCanvas();
  6062. }
  6063. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6064. this._connectedAnalyser = analyser;
  6065. this.masterGain.disconnect();
  6066. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6067. }
  6068. };
  6069. return AudioEngine;
  6070. }());
  6071. /***/ }),
  6072. /***/ "./Audio/audioSceneComponent.ts":
  6073. /*!**************************************!*\
  6074. !*** ./Audio/audioSceneComponent.ts ***!
  6075. \**************************************/
  6076. /*! exports provided: AudioSceneComponent */
  6077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6078. "use strict";
  6079. __webpack_require__.r(__webpack_exports__);
  6080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6081. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6082. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6083. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6084. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6085. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6086. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6087. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6088. // Adds the parser to the scene parsers.
  6089. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6090. // TODO: add sound
  6091. var loadedSounds = [];
  6092. var loadedSound;
  6093. container.sounds = container.sounds || [];
  6094. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6095. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6096. var parsedSound = parsedData.sounds[index];
  6097. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6098. if (!parsedSound.url) {
  6099. parsedSound.url = parsedSound.name;
  6100. }
  6101. if (!loadedSounds[parsedSound.url]) {
  6102. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6103. loadedSounds[parsedSound.url] = loadedSound;
  6104. container.sounds.push(loadedSound);
  6105. }
  6106. else {
  6107. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6108. }
  6109. }
  6110. else {
  6111. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6112. }
  6113. }
  6114. }
  6115. loadedSounds = [];
  6116. });
  6117. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6118. get: function () {
  6119. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6120. if (!compo) {
  6121. compo = new AudioSceneComponent(this);
  6122. this._addComponent(compo);
  6123. }
  6124. if (!this._mainSoundTrack) {
  6125. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6126. }
  6127. return this._mainSoundTrack;
  6128. },
  6129. enumerable: true,
  6130. configurable: true
  6131. });
  6132. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6133. var index;
  6134. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6135. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6136. return this.mainSoundTrack.soundCollection[index];
  6137. }
  6138. }
  6139. if (this.soundTracks) {
  6140. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6141. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6142. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6143. return this.soundTracks[sdIndex].soundCollection[index];
  6144. }
  6145. }
  6146. }
  6147. }
  6148. return null;
  6149. };
  6150. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6151. get: function () {
  6152. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6153. if (!compo) {
  6154. compo = new AudioSceneComponent(this);
  6155. this._addComponent(compo);
  6156. }
  6157. return compo.audioEnabled;
  6158. },
  6159. set: function (value) {
  6160. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6161. if (!compo) {
  6162. compo = new AudioSceneComponent(this);
  6163. this._addComponent(compo);
  6164. }
  6165. if (value) {
  6166. compo.enableAudio();
  6167. }
  6168. else {
  6169. compo.disableAudio();
  6170. }
  6171. },
  6172. enumerable: true,
  6173. configurable: true
  6174. });
  6175. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6176. get: function () {
  6177. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6178. if (!compo) {
  6179. compo = new AudioSceneComponent(this);
  6180. this._addComponent(compo);
  6181. }
  6182. return compo.headphone;
  6183. },
  6184. set: function (value) {
  6185. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6186. if (!compo) {
  6187. compo = new AudioSceneComponent(this);
  6188. this._addComponent(compo);
  6189. }
  6190. if (value) {
  6191. compo.switchAudioModeForHeadphones();
  6192. }
  6193. else {
  6194. compo.switchAudioModeForNormalSpeakers();
  6195. }
  6196. },
  6197. enumerable: true,
  6198. configurable: true
  6199. });
  6200. /**
  6201. * Defines the sound scene component responsible to manage any sounds
  6202. * in a given scene.
  6203. */
  6204. var AudioSceneComponent = /** @class */ (function () {
  6205. /**
  6206. * Creates a new instance of the component for the given scene
  6207. * @param scene Defines the scene to register the component in
  6208. */
  6209. function AudioSceneComponent(scene) {
  6210. /**
  6211. * The component name helpfull to identify the component in the list of scene components.
  6212. */
  6213. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6214. this._audioEnabled = true;
  6215. this._headphone = false;
  6216. this.scene = scene;
  6217. scene.soundTracks = new Array();
  6218. scene.sounds = new Array();
  6219. }
  6220. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6221. /**
  6222. * Gets whether audio is enabled or not.
  6223. * Please use related enable/disable method to switch state.
  6224. */
  6225. get: function () {
  6226. return this._audioEnabled;
  6227. },
  6228. enumerable: true,
  6229. configurable: true
  6230. });
  6231. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6232. /**
  6233. * Gets whether audio is outputing to headphone or not.
  6234. * Please use the according Switch methods to change output.
  6235. */
  6236. get: function () {
  6237. return this._headphone;
  6238. },
  6239. enumerable: true,
  6240. configurable: true
  6241. });
  6242. /**
  6243. * Registers the component in a given scene
  6244. */
  6245. AudioSceneComponent.prototype.register = function () {
  6246. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6247. };
  6248. /**
  6249. * Rebuilds the elements related to this component in case of
  6250. * context lost for instance.
  6251. */
  6252. AudioSceneComponent.prototype.rebuild = function () {
  6253. // Nothing to do here. (Not rendering related)
  6254. };
  6255. /**
  6256. * Serializes the component data to the specified json object
  6257. * @param serializationObject The object to serialize to
  6258. */
  6259. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6260. serializationObject.sounds = [];
  6261. if (this.scene.soundTracks) {
  6262. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6263. var soundtrack = this.scene.soundTracks[index];
  6264. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6265. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6266. }
  6267. }
  6268. }
  6269. };
  6270. /**
  6271. * Adds all the element from the container to the scene
  6272. * @param container the container holding the elements
  6273. */
  6274. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6275. var _this = this;
  6276. if (!container.sounds) {
  6277. return;
  6278. }
  6279. container.sounds.forEach(function (sound) {
  6280. sound.play();
  6281. sound.autoplay = true;
  6282. _this.scene.mainSoundTrack.AddSound(sound);
  6283. });
  6284. };
  6285. /**
  6286. * Removes all the elements in the container from the scene
  6287. * @param container contains the elements to remove
  6288. * @param dispose if the removed element should be disposed (default: false)
  6289. */
  6290. AudioSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  6291. var _this = this;
  6292. if (dispose === void 0) { dispose = false; }
  6293. if (!container.sounds) {
  6294. return;
  6295. }
  6296. container.sounds.forEach(function (sound) {
  6297. sound.stop();
  6298. sound.autoplay = false;
  6299. _this.scene.mainSoundTrack.RemoveSound(sound);
  6300. if (dispose) {
  6301. sound.dispose();
  6302. }
  6303. });
  6304. };
  6305. /**
  6306. * Disposes the component and the associated ressources.
  6307. */
  6308. AudioSceneComponent.prototype.dispose = function () {
  6309. var scene = this.scene;
  6310. if (scene._mainSoundTrack) {
  6311. scene.mainSoundTrack.dispose();
  6312. }
  6313. if (scene.soundTracks) {
  6314. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6315. scene.soundTracks[scIndex].dispose();
  6316. }
  6317. }
  6318. };
  6319. /**
  6320. * Disables audio in the associated scene.
  6321. */
  6322. AudioSceneComponent.prototype.disableAudio = function () {
  6323. var scene = this.scene;
  6324. this._audioEnabled = false;
  6325. var i;
  6326. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6327. scene.mainSoundTrack.soundCollection[i].pause();
  6328. }
  6329. if (scene.soundTracks) {
  6330. for (i = 0; i < scene.soundTracks.length; i++) {
  6331. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6332. scene.soundTracks[i].soundCollection[j].pause();
  6333. }
  6334. }
  6335. }
  6336. };
  6337. /**
  6338. * Enables audio in the associated scene.
  6339. */
  6340. AudioSceneComponent.prototype.enableAudio = function () {
  6341. var scene = this.scene;
  6342. this._audioEnabled = true;
  6343. var i;
  6344. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6345. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6346. scene.mainSoundTrack.soundCollection[i].play();
  6347. }
  6348. }
  6349. if (scene.soundTracks) {
  6350. for (i = 0; i < scene.soundTracks.length; i++) {
  6351. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6352. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6353. scene.soundTracks[i].soundCollection[j].play();
  6354. }
  6355. }
  6356. }
  6357. }
  6358. };
  6359. /**
  6360. * Switch audio to headphone output.
  6361. */
  6362. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6363. var scene = this.scene;
  6364. this._headphone = true;
  6365. scene.mainSoundTrack.switchPanningModelToHRTF();
  6366. if (scene.soundTracks) {
  6367. for (var i = 0; i < scene.soundTracks.length; i++) {
  6368. scene.soundTracks[i].switchPanningModelToHRTF();
  6369. }
  6370. }
  6371. };
  6372. /**
  6373. * Switch audio to normal speakers.
  6374. */
  6375. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6376. var scene = this.scene;
  6377. this._headphone = false;
  6378. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6379. if (scene.soundTracks) {
  6380. for (var i = 0; i < scene.soundTracks.length; i++) {
  6381. scene.soundTracks[i].switchPanningModelToEqualPower();
  6382. }
  6383. }
  6384. };
  6385. AudioSceneComponent.prototype._afterRender = function () {
  6386. var scene = this.scene;
  6387. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6388. return;
  6389. }
  6390. var listeningCamera;
  6391. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6392. if (scene.activeCameras.length > 0) {
  6393. listeningCamera = scene.activeCameras[0];
  6394. }
  6395. else {
  6396. listeningCamera = scene.activeCamera;
  6397. }
  6398. if (listeningCamera && audioEngine.audioContext) {
  6399. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6400. // for VR cameras
  6401. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6402. listeningCamera = listeningCamera.rigCameras[0];
  6403. }
  6404. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6405. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6406. cameraDirection.normalize();
  6407. // To avoid some errors on GearVR
  6408. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6409. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6410. }
  6411. var i;
  6412. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6413. var sound = scene.mainSoundTrack.soundCollection[i];
  6414. if (sound.useCustomAttenuation) {
  6415. sound.updateDistanceFromListener();
  6416. }
  6417. }
  6418. if (scene.soundTracks) {
  6419. for (i = 0; i < scene.soundTracks.length; i++) {
  6420. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6421. sound = scene.soundTracks[i].soundCollection[j];
  6422. if (sound.useCustomAttenuation) {
  6423. sound.updateDistanceFromListener();
  6424. }
  6425. }
  6426. }
  6427. }
  6428. }
  6429. };
  6430. return AudioSceneComponent;
  6431. }());
  6432. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6433. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6434. if (!compo) {
  6435. compo = new AudioSceneComponent(scene);
  6436. scene._addComponent(compo);
  6437. }
  6438. };
  6439. /***/ }),
  6440. /***/ "./Audio/index.ts":
  6441. /*!************************!*\
  6442. !*** ./Audio/index.ts ***!
  6443. \************************/
  6444. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6446. "use strict";
  6447. __webpack_require__.r(__webpack_exports__);
  6448. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6450. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6452. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6454. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6456. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6458. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6460. /***/ }),
  6461. /***/ "./Audio/sound.ts":
  6462. /*!************************!*\
  6463. !*** ./Audio/sound.ts ***!
  6464. \************************/
  6465. /*! exports provided: Sound */
  6466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6467. "use strict";
  6468. __webpack_require__.r(__webpack_exports__);
  6469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6470. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6471. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6472. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6473. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6474. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6475. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6476. /**
  6477. * Defines a sound that can be played in the application.
  6478. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6480. */
  6481. var Sound = /** @class */ (function () {
  6482. /**
  6483. * Create a sound and attach it to a scene
  6484. * @param name Name of your sound
  6485. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6486. * @param scene defines the scene the sound belongs to
  6487. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6488. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6489. */
  6490. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6491. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6492. var _this = this;
  6493. /**
  6494. * Does the sound autoplay once loaded.
  6495. */
  6496. this.autoplay = false;
  6497. /**
  6498. * Does the sound loop after it finishes playing once.
  6499. */
  6500. this.loop = false;
  6501. /**
  6502. * Does the sound use a custom attenuation curve to simulate the falloff
  6503. * happening when the source gets further away from the camera.
  6504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6505. */
  6506. this.useCustomAttenuation = false;
  6507. /**
  6508. * Is this sound currently played.
  6509. */
  6510. this.isPlaying = false;
  6511. /**
  6512. * Is this sound currently paused.
  6513. */
  6514. this.isPaused = false;
  6515. /**
  6516. * Does this sound enables spatial sound.
  6517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6518. */
  6519. this.spatialSound = false;
  6520. /**
  6521. * Define the reference distance the sound should be heard perfectly.
  6522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6523. */
  6524. this.refDistance = 1;
  6525. /**
  6526. * Define the roll off factor of spatial sounds.
  6527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6528. */
  6529. this.rolloffFactor = 1;
  6530. /**
  6531. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6533. */
  6534. this.maxDistance = 100;
  6535. /**
  6536. * Define the distance attenuation model the sound will follow.
  6537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6538. */
  6539. this.distanceModel = "linear";
  6540. /**
  6541. * Observable event when the current playing sound finishes.
  6542. */
  6543. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6544. this._panningModel = "equalpower";
  6545. this._playbackRate = 1;
  6546. this._streaming = false;
  6547. this._startTime = 0;
  6548. this._startOffset = 0;
  6549. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6550. /** @hidden */
  6551. this._positionInEmitterSpace = false;
  6552. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6553. this._volume = 1;
  6554. this._isReadyToPlay = false;
  6555. this._isDirectional = false;
  6556. // Used if you'd like to create a directional sound.
  6557. // If not set, the sound will be omnidirectional
  6558. this._coneInnerAngle = 360;
  6559. this._coneOuterAngle = 360;
  6560. this._coneOuterGain = 0;
  6561. this._isOutputConnected = false;
  6562. this._urlType = "Unknown";
  6563. this.name = name;
  6564. this._scene = scene;
  6565. Sound._SceneComponentInitialization(scene);
  6566. this._readyToPlayCallback = readyToPlayCallback;
  6567. // Default custom attenuation function is a linear attenuation
  6568. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6569. if (currentDistance < maxDistance) {
  6570. return currentVolume * (1 - currentDistance / maxDistance);
  6571. }
  6572. else {
  6573. return 0;
  6574. }
  6575. };
  6576. if (options) {
  6577. this.autoplay = options.autoplay || false;
  6578. this.loop = options.loop || false;
  6579. // if volume === 0, we need another way to check this option
  6580. if (options.volume !== undefined) {
  6581. this._volume = options.volume;
  6582. }
  6583. this.spatialSound = options.spatialSound || false;
  6584. this.maxDistance = options.maxDistance || 100;
  6585. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6586. this.rolloffFactor = options.rolloffFactor || 1;
  6587. this.refDistance = options.refDistance || 1;
  6588. this.distanceModel = options.distanceModel || "linear";
  6589. this._playbackRate = options.playbackRate || 1;
  6590. this._streaming = options.streaming || false;
  6591. }
  6592. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6593. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6594. this._soundGain.gain.value = this._volume;
  6595. this._inputAudioNode = this._soundGain;
  6596. this._outputAudioNode = this._soundGain;
  6597. if (this.spatialSound) {
  6598. this._createSpatialParameters();
  6599. }
  6600. this._scene.mainSoundTrack.AddSound(this);
  6601. var validParameter = true;
  6602. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6603. if (urlOrArrayBuffer) {
  6604. try {
  6605. if (typeof (urlOrArrayBuffer) === "string") {
  6606. this._urlType = "String";
  6607. }
  6608. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6609. this._urlType = "ArrayBuffer";
  6610. }
  6611. else if (urlOrArrayBuffer instanceof MediaStream) {
  6612. this._urlType = "MediaStream";
  6613. }
  6614. else if (Array.isArray(urlOrArrayBuffer)) {
  6615. this._urlType = "Array";
  6616. }
  6617. var urls = [];
  6618. var codecSupportedFound = false;
  6619. switch (this._urlType) {
  6620. case "MediaStream":
  6621. this._streaming = true;
  6622. this._isReadyToPlay = true;
  6623. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6624. if (this.autoplay) {
  6625. this.play();
  6626. }
  6627. if (this._readyToPlayCallback) {
  6628. this._readyToPlayCallback();
  6629. }
  6630. break;
  6631. case "ArrayBuffer":
  6632. if (urlOrArrayBuffer.byteLength > 0) {
  6633. codecSupportedFound = true;
  6634. this._soundLoaded(urlOrArrayBuffer);
  6635. }
  6636. break;
  6637. case "String":
  6638. urls.push(urlOrArrayBuffer);
  6639. case "Array":
  6640. if (urls.length === 0) {
  6641. urls = urlOrArrayBuffer;
  6642. }
  6643. // If we found a supported format, we load it immediately and stop the loop
  6644. for (var i = 0; i < urls.length; i++) {
  6645. var url = urls[i];
  6646. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6647. codecSupportedFound = true;
  6648. }
  6649. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6650. codecSupportedFound = true;
  6651. }
  6652. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6653. codecSupportedFound = true;
  6654. }
  6655. if (url.indexOf("blob:") !== -1) {
  6656. codecSupportedFound = true;
  6657. }
  6658. if (codecSupportedFound) {
  6659. // Loading sound using XHR2
  6660. if (!this._streaming) {
  6661. this._scene._loadFile(url, function (data) {
  6662. _this._soundLoaded(data);
  6663. }, undefined, true, true, function (exception) {
  6664. if (exception) {
  6665. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6666. }
  6667. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6668. _this._scene.mainSoundTrack.RemoveSound(_this);
  6669. });
  6670. }
  6671. // Streaming sound using HTML5 Audio tag
  6672. else {
  6673. this._htmlAudioElement = new Audio(url);
  6674. this._htmlAudioElement.controls = false;
  6675. this._htmlAudioElement.loop = this.loop;
  6676. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6677. this._htmlAudioElement.preload = "auto";
  6678. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6679. _this._isReadyToPlay = true;
  6680. if (_this.autoplay) {
  6681. _this.play();
  6682. }
  6683. if (_this._readyToPlayCallback) {
  6684. _this._readyToPlayCallback();
  6685. }
  6686. });
  6687. document.body.appendChild(this._htmlAudioElement);
  6688. this._htmlAudioElement.load();
  6689. }
  6690. break;
  6691. }
  6692. }
  6693. break;
  6694. default:
  6695. validParameter = false;
  6696. break;
  6697. }
  6698. if (!validParameter) {
  6699. _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.");
  6700. }
  6701. else {
  6702. if (!codecSupportedFound) {
  6703. this._isReadyToPlay = true;
  6704. // Simulating a ready to play event to avoid breaking code path
  6705. if (this._readyToPlayCallback) {
  6706. window.setTimeout(function () {
  6707. if (_this._readyToPlayCallback) {
  6708. _this._readyToPlayCallback();
  6709. }
  6710. }, 1000);
  6711. }
  6712. }
  6713. }
  6714. }
  6715. catch (ex) {
  6716. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6717. this._scene.mainSoundTrack.RemoveSound(this);
  6718. }
  6719. }
  6720. }
  6721. else {
  6722. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6723. this._scene.mainSoundTrack.AddSound(this);
  6724. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6725. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6726. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6727. }
  6728. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6729. if (this._readyToPlayCallback) {
  6730. window.setTimeout(function () {
  6731. if (_this._readyToPlayCallback) {
  6732. _this._readyToPlayCallback();
  6733. }
  6734. }, 1000);
  6735. }
  6736. }
  6737. }
  6738. /**
  6739. * Release the sound and its associated resources
  6740. */
  6741. Sound.prototype.dispose = function () {
  6742. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6743. if (this.isPlaying) {
  6744. this.stop();
  6745. }
  6746. this._isReadyToPlay = false;
  6747. if (this.soundTrackId === -1) {
  6748. this._scene.mainSoundTrack.RemoveSound(this);
  6749. }
  6750. else if (this._scene.soundTracks) {
  6751. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6752. }
  6753. if (this._soundGain) {
  6754. this._soundGain.disconnect();
  6755. this._soundGain = null;
  6756. }
  6757. if (this._soundPanner) {
  6758. this._soundPanner.disconnect();
  6759. this._soundPanner = null;
  6760. }
  6761. if (this._soundSource) {
  6762. this._soundSource.disconnect();
  6763. this._soundSource = null;
  6764. }
  6765. this._audioBuffer = null;
  6766. if (this._htmlAudioElement) {
  6767. this._htmlAudioElement.pause();
  6768. this._htmlAudioElement.src = "";
  6769. document.body.removeChild(this._htmlAudioElement);
  6770. }
  6771. if (this._streamingSource) {
  6772. this._streamingSource.disconnect();
  6773. }
  6774. if (this._connectedTransformNode && this._registerFunc) {
  6775. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6776. this._connectedTransformNode = null;
  6777. }
  6778. }
  6779. };
  6780. /**
  6781. * Gets if the sounds is ready to be played or not.
  6782. * @returns true if ready, otherwise false
  6783. */
  6784. Sound.prototype.isReady = function () {
  6785. return this._isReadyToPlay;
  6786. };
  6787. Sound.prototype._soundLoaded = function (audioData) {
  6788. var _this = this;
  6789. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6790. return;
  6791. }
  6792. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6793. _this._audioBuffer = buffer;
  6794. _this._isReadyToPlay = true;
  6795. if (_this.autoplay) {
  6796. _this.play();
  6797. }
  6798. if (_this._readyToPlayCallback) {
  6799. _this._readyToPlayCallback();
  6800. }
  6801. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6802. };
  6803. /**
  6804. * Sets the data of the sound from an audiobuffer
  6805. * @param audioBuffer The audioBuffer containing the data
  6806. */
  6807. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6808. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6809. this._audioBuffer = audioBuffer;
  6810. this._isReadyToPlay = true;
  6811. }
  6812. };
  6813. /**
  6814. * Updates the current sounds options such as maxdistance, loop...
  6815. * @param options A JSON object containing values named as the object properties
  6816. */
  6817. Sound.prototype.updateOptions = function (options) {
  6818. if (options) {
  6819. this.loop = options.loop || this.loop;
  6820. this.maxDistance = options.maxDistance || this.maxDistance;
  6821. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6822. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6823. this.refDistance = options.refDistance || this.refDistance;
  6824. this.distanceModel = options.distanceModel || this.distanceModel;
  6825. this._playbackRate = options.playbackRate || this._playbackRate;
  6826. this._updateSpatialParameters();
  6827. if (this.isPlaying) {
  6828. if (this._streaming && this._htmlAudioElement) {
  6829. this._htmlAudioElement.playbackRate = this._playbackRate;
  6830. }
  6831. else {
  6832. if (this._soundSource) {
  6833. this._soundSource.playbackRate.value = this._playbackRate;
  6834. }
  6835. }
  6836. }
  6837. }
  6838. };
  6839. Sound.prototype._createSpatialParameters = function () {
  6840. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6841. if (this._scene.headphone) {
  6842. this._panningModel = "HRTF";
  6843. }
  6844. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6845. this._updateSpatialParameters();
  6846. this._soundPanner.connect(this._outputAudioNode);
  6847. this._inputAudioNode = this._soundPanner;
  6848. }
  6849. };
  6850. Sound.prototype._updateSpatialParameters = function () {
  6851. if (this.spatialSound && this._soundPanner) {
  6852. if (this.useCustomAttenuation) {
  6853. // Tricks to disable in a way embedded Web Audio attenuation
  6854. this._soundPanner.distanceModel = "linear";
  6855. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6856. this._soundPanner.refDistance = 1;
  6857. this._soundPanner.rolloffFactor = 1;
  6858. this._soundPanner.panningModel = this._panningModel;
  6859. }
  6860. else {
  6861. this._soundPanner.distanceModel = this.distanceModel;
  6862. this._soundPanner.maxDistance = this.maxDistance;
  6863. this._soundPanner.refDistance = this.refDistance;
  6864. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6865. this._soundPanner.panningModel = this._panningModel;
  6866. }
  6867. }
  6868. };
  6869. /**
  6870. * Switch the panning model to HRTF:
  6871. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6873. */
  6874. Sound.prototype.switchPanningModelToHRTF = function () {
  6875. this._panningModel = "HRTF";
  6876. this._switchPanningModel();
  6877. };
  6878. /**
  6879. * Switch the panning model to Equal Power:
  6880. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6882. */
  6883. Sound.prototype.switchPanningModelToEqualPower = function () {
  6884. this._panningModel = "equalpower";
  6885. this._switchPanningModel();
  6886. };
  6887. Sound.prototype._switchPanningModel = function () {
  6888. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6889. this._soundPanner.panningModel = this._panningModel;
  6890. }
  6891. };
  6892. /**
  6893. * Connect this sound to a sound track audio node like gain...
  6894. * @param soundTrackAudioNode the sound track audio node to connect to
  6895. */
  6896. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6897. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6898. if (this._isOutputConnected) {
  6899. this._outputAudioNode.disconnect();
  6900. }
  6901. this._outputAudioNode.connect(soundTrackAudioNode);
  6902. this._isOutputConnected = true;
  6903. }
  6904. };
  6905. /**
  6906. * Transform this sound into a directional source
  6907. * @param coneInnerAngle Size of the inner cone in degree
  6908. * @param coneOuterAngle Size of the outer cone in degree
  6909. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6910. */
  6911. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6912. if (coneOuterAngle < coneInnerAngle) {
  6913. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6914. return;
  6915. }
  6916. this._coneInnerAngle = coneInnerAngle;
  6917. this._coneOuterAngle = coneOuterAngle;
  6918. this._coneOuterGain = coneOuterGain;
  6919. this._isDirectional = true;
  6920. if (this.isPlaying && this.loop) {
  6921. this.stop();
  6922. this.play();
  6923. }
  6924. };
  6925. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6926. /**
  6927. * Gets or sets the inner angle for the directional cone.
  6928. */
  6929. get: function () {
  6930. return this._coneInnerAngle;
  6931. },
  6932. /**
  6933. * Gets or sets the inner angle for the directional cone.
  6934. */
  6935. set: function (value) {
  6936. if (value != this._coneInnerAngle) {
  6937. if (this._coneOuterAngle < value) {
  6938. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6939. return;
  6940. }
  6941. this._coneInnerAngle = value;
  6942. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6943. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6944. }
  6945. }
  6946. },
  6947. enumerable: true,
  6948. configurable: true
  6949. });
  6950. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6951. /**
  6952. * Gets or sets the outer angle for the directional cone.
  6953. */
  6954. get: function () {
  6955. return this._coneOuterAngle;
  6956. },
  6957. /**
  6958. * Gets or sets the outer angle for the directional cone.
  6959. */
  6960. set: function (value) {
  6961. if (value != this._coneOuterAngle) {
  6962. if (value < this._coneInnerAngle) {
  6963. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6964. return;
  6965. }
  6966. this._coneOuterAngle = value;
  6967. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6968. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6969. }
  6970. }
  6971. },
  6972. enumerable: true,
  6973. configurable: true
  6974. });
  6975. /**
  6976. * Sets the position of the emitter if spatial sound is enabled
  6977. * @param newPosition Defines the new posisiton
  6978. */
  6979. Sound.prototype.setPosition = function (newPosition) {
  6980. this._position = newPosition;
  6981. 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)) {
  6982. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6983. }
  6984. };
  6985. /**
  6986. * Sets the local direction of the emitter if spatial sound is enabled
  6987. * @param newLocalDirection Defines the new local direction
  6988. */
  6989. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6990. this._localDirection = newLocalDirection;
  6991. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6992. this._updateDirection();
  6993. }
  6994. };
  6995. Sound.prototype._updateDirection = function () {
  6996. if (!this._connectedTransformNode || !this._soundPanner) {
  6997. return;
  6998. }
  6999. var mat = this._connectedTransformNode.getWorldMatrix();
  7000. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  7001. direction.normalize();
  7002. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  7003. };
  7004. /** @hidden */
  7005. Sound.prototype.updateDistanceFromListener = function () {
  7006. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  7007. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  7008. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  7009. }
  7010. };
  7011. /**
  7012. * Sets a new custom attenuation function for the sound.
  7013. * @param callback Defines the function used for the attenuation
  7014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  7015. */
  7016. Sound.prototype.setAttenuationFunction = function (callback) {
  7017. this._customAttenuationFunction = callback;
  7018. };
  7019. /**
  7020. * Play the sound
  7021. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  7022. * @param offset (optional) Start the sound setting it at a specific time
  7023. */
  7024. Sound.prototype.play = function (time, offset) {
  7025. var _this = this;
  7026. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7027. try {
  7028. if (this._startOffset < 0) {
  7029. time = -this._startOffset;
  7030. this._startOffset = 0;
  7031. }
  7032. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7033. if (!this._soundSource || !this._streamingSource) {
  7034. if (this.spatialSound && this._soundPanner) {
  7035. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  7036. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  7037. }
  7038. if (this._isDirectional) {
  7039. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  7040. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  7041. this._soundPanner.coneOuterGain = this._coneOuterGain;
  7042. if (this._connectedTransformNode) {
  7043. this._updateDirection();
  7044. }
  7045. else {
  7046. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  7047. }
  7048. }
  7049. }
  7050. }
  7051. if (this._streaming) {
  7052. if (!this._streamingSource) {
  7053. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  7054. this._htmlAudioElement.onended = function () { _this._onended(); };
  7055. this._htmlAudioElement.playbackRate = this._playbackRate;
  7056. }
  7057. this._streamingSource.disconnect();
  7058. this._streamingSource.connect(this._inputAudioNode);
  7059. if (this._htmlAudioElement) {
  7060. // required to manage properly the new suspended default state of Chrome
  7061. // When the option 'streaming: true' is used, we need first to wait for
  7062. // the audio engine to be unlocked by a user gesture before trying to play
  7063. // an HTML Audio elememt
  7064. var tryToPlay = function () {
  7065. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7066. var playPromise = _this._htmlAudioElement.play();
  7067. // In browsers that don’t yet support this functionality,
  7068. // playPromise won’t be defined.
  7069. if (playPromise !== undefined) {
  7070. playPromise.catch(function (error) {
  7071. // Automatic playback failed.
  7072. // Waiting for the audio engine to be unlocked by user click on unmute
  7073. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7074. if (_this.loop || _this.autoplay) {
  7075. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7076. }
  7077. });
  7078. }
  7079. }
  7080. else {
  7081. if (_this.loop || _this.autoplay) {
  7082. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7083. }
  7084. }
  7085. };
  7086. tryToPlay();
  7087. }
  7088. }
  7089. else {
  7090. var tryToPlay = function () {
  7091. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7092. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7093. _this._soundSource.buffer = _this._audioBuffer;
  7094. _this._soundSource.connect(_this._inputAudioNode);
  7095. _this._soundSource.loop = _this.loop;
  7096. _this._soundSource.playbackRate.value = _this._playbackRate;
  7097. _this._soundSource.onended = function () { _this._onended(); };
  7098. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7099. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7100. }
  7101. };
  7102. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7103. // Wait a bit for FF as context seems late to be ready.
  7104. setTimeout(function () {
  7105. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7106. // Automatic playback failed.
  7107. // Waiting for the audio engine to be unlocked by user click on unmute
  7108. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7109. if (_this.loop || _this.autoplay) {
  7110. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7111. }
  7112. }
  7113. else {
  7114. tryToPlay();
  7115. }
  7116. }, 500);
  7117. }
  7118. else {
  7119. tryToPlay();
  7120. }
  7121. }
  7122. this._startTime = startTime;
  7123. this.isPlaying = true;
  7124. this.isPaused = false;
  7125. }
  7126. catch (ex) {
  7127. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7128. }
  7129. }
  7130. };
  7131. Sound.prototype._onended = function () {
  7132. this.isPlaying = false;
  7133. if (this.onended) {
  7134. this.onended();
  7135. }
  7136. this.onEndedObservable.notifyObservers(this);
  7137. };
  7138. /**
  7139. * Stop the sound
  7140. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7141. */
  7142. Sound.prototype.stop = function (time) {
  7143. var _this = this;
  7144. if (this.isPlaying) {
  7145. if (this._streaming) {
  7146. if (this._htmlAudioElement) {
  7147. this._htmlAudioElement.pause();
  7148. // Test needed for Firefox or it will generate an Invalid State Error
  7149. if (this._htmlAudioElement.currentTime > 0) {
  7150. this._htmlAudioElement.currentTime = 0;
  7151. }
  7152. }
  7153. else {
  7154. this._streamingSource.disconnect();
  7155. }
  7156. this.isPlaying = false;
  7157. }
  7158. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7159. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7160. this._soundSource.stop(stopTime);
  7161. this._soundSource.onended = function () { _this.isPlaying = false; };
  7162. if (!this.isPaused) {
  7163. this._startOffset = 0;
  7164. }
  7165. }
  7166. }
  7167. };
  7168. /**
  7169. * Put the sound in pause
  7170. */
  7171. Sound.prototype.pause = function () {
  7172. if (this.isPlaying) {
  7173. this.isPaused = true;
  7174. if (this._streaming) {
  7175. if (this._htmlAudioElement) {
  7176. this._htmlAudioElement.pause();
  7177. }
  7178. else {
  7179. this._streamingSource.disconnect();
  7180. }
  7181. }
  7182. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7183. this.stop(0);
  7184. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7185. }
  7186. }
  7187. };
  7188. /**
  7189. * Sets a dedicated volume for this sounds
  7190. * @param newVolume Define the new volume of the sound
  7191. * @param time Define in how long the sound should be at this value
  7192. */
  7193. Sound.prototype.setVolume = function (newVolume, time) {
  7194. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7195. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7196. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7197. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7198. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7199. }
  7200. else {
  7201. this._soundGain.gain.value = newVolume;
  7202. }
  7203. }
  7204. this._volume = newVolume;
  7205. };
  7206. /**
  7207. * Set the sound play back rate
  7208. * @param newPlaybackRate Define the playback rate the sound should be played at
  7209. */
  7210. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7211. this._playbackRate = newPlaybackRate;
  7212. if (this.isPlaying) {
  7213. if (this._streaming && this._htmlAudioElement) {
  7214. this._htmlAudioElement.playbackRate = this._playbackRate;
  7215. }
  7216. else if (this._soundSource) {
  7217. this._soundSource.playbackRate.value = this._playbackRate;
  7218. }
  7219. }
  7220. };
  7221. /**
  7222. * Gets the volume of the sound.
  7223. * @returns the volume of the sound
  7224. */
  7225. Sound.prototype.getVolume = function () {
  7226. return this._volume;
  7227. };
  7228. /**
  7229. * Attach the sound to a dedicated mesh
  7230. * @param transformNode The transform node to connect the sound with
  7231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7232. */
  7233. Sound.prototype.attachToMesh = function (transformNode) {
  7234. var _this = this;
  7235. if (this._connectedTransformNode && this._registerFunc) {
  7236. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7237. this._registerFunc = null;
  7238. }
  7239. this._connectedTransformNode = transformNode;
  7240. if (!this.spatialSound) {
  7241. this.spatialSound = true;
  7242. this._createSpatialParameters();
  7243. if (this.isPlaying && this.loop) {
  7244. this.stop();
  7245. this.play();
  7246. }
  7247. }
  7248. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7249. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7250. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7251. };
  7252. /**
  7253. * Detach the sound from the previously attached mesh
  7254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7255. */
  7256. Sound.prototype.detachFromMesh = function () {
  7257. if (this._connectedTransformNode && this._registerFunc) {
  7258. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7259. this._registerFunc = null;
  7260. this._connectedTransformNode = null;
  7261. }
  7262. };
  7263. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7264. if (!node.getBoundingInfo) {
  7265. return;
  7266. }
  7267. var mesh = node;
  7268. if (this._positionInEmitterSpace) {
  7269. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7270. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7271. }
  7272. else {
  7273. var boundingInfo = mesh.getBoundingInfo();
  7274. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7275. }
  7276. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7277. this._updateDirection();
  7278. }
  7279. };
  7280. /**
  7281. * Clone the current sound in the scene.
  7282. * @returns the new sound clone
  7283. */
  7284. Sound.prototype.clone = function () {
  7285. var _this = this;
  7286. if (!this._streaming) {
  7287. var setBufferAndRun = function () {
  7288. if (_this._isReadyToPlay) {
  7289. clonedSound._audioBuffer = _this.getAudioBuffer();
  7290. clonedSound._isReadyToPlay = true;
  7291. if (clonedSound.autoplay) {
  7292. clonedSound.play();
  7293. }
  7294. }
  7295. else {
  7296. window.setTimeout(setBufferAndRun, 300);
  7297. }
  7298. };
  7299. var currentOptions = {
  7300. autoplay: this.autoplay, loop: this.loop,
  7301. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7302. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7303. refDistance: this.refDistance, distanceModel: this.distanceModel
  7304. };
  7305. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7306. if (this.useCustomAttenuation) {
  7307. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7308. }
  7309. clonedSound.setPosition(this._position);
  7310. clonedSound.setPlaybackRate(this._playbackRate);
  7311. setBufferAndRun();
  7312. return clonedSound;
  7313. }
  7314. // Can't clone a streaming sound
  7315. else {
  7316. return null;
  7317. }
  7318. };
  7319. /**
  7320. * Gets the current underlying audio buffer containing the data
  7321. * @returns the audio buffer
  7322. */
  7323. Sound.prototype.getAudioBuffer = function () {
  7324. return this._audioBuffer;
  7325. };
  7326. /**
  7327. * Serializes the Sound in a JSON representation
  7328. * @returns the JSON representation of the sound
  7329. */
  7330. Sound.prototype.serialize = function () {
  7331. var serializationObject = {
  7332. name: this.name,
  7333. url: this.name,
  7334. autoplay: this.autoplay,
  7335. loop: this.loop,
  7336. volume: this._volume,
  7337. spatialSound: this.spatialSound,
  7338. maxDistance: this.maxDistance,
  7339. rolloffFactor: this.rolloffFactor,
  7340. refDistance: this.refDistance,
  7341. distanceModel: this.distanceModel,
  7342. playbackRate: this._playbackRate,
  7343. panningModel: this._panningModel,
  7344. soundTrackId: this.soundTrackId
  7345. };
  7346. if (this.spatialSound) {
  7347. if (this._connectedTransformNode) {
  7348. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7349. }
  7350. serializationObject.position = this._position.asArray();
  7351. serializationObject.refDistance = this.refDistance;
  7352. serializationObject.distanceModel = this.distanceModel;
  7353. serializationObject.isDirectional = this._isDirectional;
  7354. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7355. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7356. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7357. serializationObject.coneOuterGain = this._coneOuterGain;
  7358. }
  7359. return serializationObject;
  7360. };
  7361. /**
  7362. * Parse a JSON representation of a sound to innstantiate in a given scene
  7363. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7364. * @param scene Define the scene the new parsed sound should be created in
  7365. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7366. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7367. * @returns the newly parsed sound
  7368. */
  7369. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7370. var soundName = parsedSound.name;
  7371. var soundUrl;
  7372. if (parsedSound.url) {
  7373. soundUrl = rootUrl + parsedSound.url;
  7374. }
  7375. else {
  7376. soundUrl = rootUrl + soundName;
  7377. }
  7378. var options = {
  7379. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7380. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7381. rolloffFactor: parsedSound.rolloffFactor,
  7382. refDistance: parsedSound.refDistance,
  7383. distanceModel: parsedSound.distanceModel,
  7384. playbackRate: parsedSound.playbackRate
  7385. };
  7386. var newSound;
  7387. if (!sourceSound) {
  7388. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7389. scene._addPendingData(newSound);
  7390. }
  7391. else {
  7392. var setBufferAndRun = function () {
  7393. if (sourceSound._isReadyToPlay) {
  7394. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7395. newSound._isReadyToPlay = true;
  7396. if (newSound.autoplay) {
  7397. newSound.play();
  7398. }
  7399. }
  7400. else {
  7401. window.setTimeout(setBufferAndRun, 300);
  7402. }
  7403. };
  7404. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7405. setBufferAndRun();
  7406. }
  7407. if (parsedSound.position) {
  7408. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7409. newSound.setPosition(soundPosition);
  7410. }
  7411. if (parsedSound.isDirectional) {
  7412. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7413. if (parsedSound.localDirectionToMesh) {
  7414. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7415. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7416. }
  7417. }
  7418. if (parsedSound.connectedMeshId) {
  7419. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7420. if (connectedMesh) {
  7421. newSound.attachToMesh(connectedMesh);
  7422. }
  7423. }
  7424. return newSound;
  7425. };
  7426. /** @hidden */
  7427. Sound._SceneComponentInitialization = function (_) {
  7428. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7429. };
  7430. return Sound;
  7431. }());
  7432. /***/ }),
  7433. /***/ "./Audio/soundTrack.ts":
  7434. /*!*****************************!*\
  7435. !*** ./Audio/soundTrack.ts ***!
  7436. \*****************************/
  7437. /*! exports provided: SoundTrack */
  7438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7439. "use strict";
  7440. __webpack_require__.r(__webpack_exports__);
  7441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7442. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7443. /**
  7444. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7445. * It will be also used in a future release to apply effects on a specific track.
  7446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7447. */
  7448. var SoundTrack = /** @class */ (function () {
  7449. /**
  7450. * Creates a new sound track.
  7451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7452. * @param scene Define the scene the sound track belongs to
  7453. * @param options
  7454. */
  7455. function SoundTrack(scene, options) {
  7456. if (options === void 0) { options = {}; }
  7457. /**
  7458. * The unique identifier of the sound track in the scene.
  7459. */
  7460. this.id = -1;
  7461. this._isMainTrack = false;
  7462. this._isInitialized = false;
  7463. this._scene = scene;
  7464. this.soundCollection = new Array();
  7465. this._options = options;
  7466. if (!this._isMainTrack && this._scene.soundTracks) {
  7467. this._scene.soundTracks.push(this);
  7468. this.id = this._scene.soundTracks.length - 1;
  7469. }
  7470. }
  7471. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7472. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7473. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7474. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7475. if (this._options) {
  7476. if (this._options.volume) {
  7477. this._outputAudioNode.gain.value = this._options.volume;
  7478. }
  7479. if (this._options.mainTrack) {
  7480. this._isMainTrack = this._options.mainTrack;
  7481. }
  7482. }
  7483. this._isInitialized = true;
  7484. }
  7485. };
  7486. /**
  7487. * Release the sound track and its associated resources
  7488. */
  7489. SoundTrack.prototype.dispose = function () {
  7490. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7491. if (this._connectedAnalyser) {
  7492. this._connectedAnalyser.stopDebugCanvas();
  7493. }
  7494. while (this.soundCollection.length) {
  7495. this.soundCollection[0].dispose();
  7496. }
  7497. if (this._outputAudioNode) {
  7498. this._outputAudioNode.disconnect();
  7499. }
  7500. this._outputAudioNode = null;
  7501. }
  7502. };
  7503. /**
  7504. * Adds a sound to this sound track
  7505. * @param sound define the cound to add
  7506. * @ignoreNaming
  7507. */
  7508. SoundTrack.prototype.AddSound = function (sound) {
  7509. if (!this._isInitialized) {
  7510. this._initializeSoundTrackAudioGraph();
  7511. }
  7512. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7513. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7514. }
  7515. if (sound.soundTrackId) {
  7516. if (sound.soundTrackId === -1) {
  7517. this._scene.mainSoundTrack.RemoveSound(sound);
  7518. }
  7519. else if (this._scene.soundTracks) {
  7520. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7521. }
  7522. }
  7523. this.soundCollection.push(sound);
  7524. sound.soundTrackId = this.id;
  7525. };
  7526. /**
  7527. * Removes a sound to this sound track
  7528. * @param sound define the cound to remove
  7529. * @ignoreNaming
  7530. */
  7531. SoundTrack.prototype.RemoveSound = function (sound) {
  7532. var index = this.soundCollection.indexOf(sound);
  7533. if (index !== -1) {
  7534. this.soundCollection.splice(index, 1);
  7535. }
  7536. };
  7537. /**
  7538. * Set a global volume for the full sound track.
  7539. * @param newVolume Define the new volume of the sound track
  7540. */
  7541. SoundTrack.prototype.setVolume = function (newVolume) {
  7542. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7543. this._outputAudioNode.gain.value = newVolume;
  7544. }
  7545. };
  7546. /**
  7547. * Switch the panning model to HRTF:
  7548. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7550. */
  7551. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7552. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7553. for (var i = 0; i < this.soundCollection.length; i++) {
  7554. this.soundCollection[i].switchPanningModelToHRTF();
  7555. }
  7556. }
  7557. };
  7558. /**
  7559. * Switch the panning model to Equal Power:
  7560. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7562. */
  7563. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7564. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7565. for (var i = 0; i < this.soundCollection.length; i++) {
  7566. this.soundCollection[i].switchPanningModelToEqualPower();
  7567. }
  7568. }
  7569. };
  7570. /**
  7571. * Connect the sound track to an audio analyser allowing some amazing
  7572. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7574. * @param analyser The analyser to connect to the engine
  7575. */
  7576. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7577. if (this._connectedAnalyser) {
  7578. this._connectedAnalyser.stopDebugCanvas();
  7579. }
  7580. this._connectedAnalyser = analyser;
  7581. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7582. this._outputAudioNode.disconnect();
  7583. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7584. }
  7585. };
  7586. return SoundTrack;
  7587. }());
  7588. /***/ }),
  7589. /***/ "./Audio/weightedsound.ts":
  7590. /*!********************************!*\
  7591. !*** ./Audio/weightedsound.ts ***!
  7592. \********************************/
  7593. /*! exports provided: WeightedSound */
  7594. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7595. "use strict";
  7596. __webpack_require__.r(__webpack_exports__);
  7597. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7598. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7599. /**
  7600. * Wraps one or more Sound objects and selects one with random weight for playback.
  7601. */
  7602. var WeightedSound = /** @class */ (function () {
  7603. /**
  7604. * Creates a new WeightedSound from the list of sounds given.
  7605. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7606. * @param sounds Array of Sounds that will be selected from.
  7607. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7608. */
  7609. function WeightedSound(loop, sounds, weights) {
  7610. var _this = this;
  7611. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7612. this.loop = false;
  7613. this._coneInnerAngle = 360;
  7614. this._coneOuterAngle = 360;
  7615. this._volume = 1;
  7616. /** A Sound is currently playing. */
  7617. this.isPlaying = false;
  7618. /** A Sound is currently paused. */
  7619. this.isPaused = false;
  7620. this._sounds = [];
  7621. this._weights = [];
  7622. if (sounds.length !== weights.length) {
  7623. throw new Error('Sounds length does not equal weights length');
  7624. }
  7625. this.loop = loop;
  7626. this._weights = weights;
  7627. // Normalize the weights
  7628. var weightSum = 0;
  7629. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7630. var weight = weights_1[_i];
  7631. weightSum += weight;
  7632. }
  7633. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7634. for (var i = 0; i < this._weights.length; i++) {
  7635. this._weights[i] *= invWeightSum;
  7636. }
  7637. this._sounds = sounds;
  7638. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7639. var sound = _b[_a];
  7640. sound.onEndedObservable.add(function () { _this._onended(); });
  7641. }
  7642. }
  7643. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7644. /**
  7645. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7646. */
  7647. get: function () {
  7648. return this._coneInnerAngle;
  7649. },
  7650. /**
  7651. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7652. */
  7653. set: function (value) {
  7654. if (value !== this._coneInnerAngle) {
  7655. if (this._coneOuterAngle < value) {
  7656. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7657. return;
  7658. }
  7659. this._coneInnerAngle = value;
  7660. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7661. var sound = _a[_i];
  7662. sound.directionalConeInnerAngle = value;
  7663. }
  7664. }
  7665. },
  7666. enumerable: true,
  7667. configurable: true
  7668. });
  7669. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7670. /**
  7671. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7672. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7673. */
  7674. get: function () {
  7675. return this._coneOuterAngle;
  7676. },
  7677. /**
  7678. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7679. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7680. */
  7681. set: function (value) {
  7682. if (value !== this._coneOuterAngle) {
  7683. if (value < this._coneInnerAngle) {
  7684. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7685. return;
  7686. }
  7687. this._coneOuterAngle = value;
  7688. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7689. var sound = _a[_i];
  7690. sound.directionalConeOuterAngle = value;
  7691. }
  7692. }
  7693. },
  7694. enumerable: true,
  7695. configurable: true
  7696. });
  7697. Object.defineProperty(WeightedSound.prototype, "volume", {
  7698. /**
  7699. * Playback volume.
  7700. */
  7701. get: function () {
  7702. return this._volume;
  7703. },
  7704. /**
  7705. * Playback volume.
  7706. */
  7707. set: function (value) {
  7708. if (value !== this._volume) {
  7709. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7710. var sound = _a[_i];
  7711. sound.setVolume(value);
  7712. }
  7713. }
  7714. },
  7715. enumerable: true,
  7716. configurable: true
  7717. });
  7718. WeightedSound.prototype._onended = function () {
  7719. if (this._currentIndex !== undefined) {
  7720. this._sounds[this._currentIndex].autoplay = false;
  7721. }
  7722. if (this.loop && this.isPlaying) {
  7723. this.play();
  7724. }
  7725. else {
  7726. this.isPlaying = false;
  7727. }
  7728. };
  7729. /**
  7730. * Suspend playback
  7731. */
  7732. WeightedSound.prototype.pause = function () {
  7733. this.isPaused = true;
  7734. if (this._currentIndex !== undefined) {
  7735. this._sounds[this._currentIndex].pause();
  7736. }
  7737. };
  7738. /**
  7739. * Stop playback
  7740. */
  7741. WeightedSound.prototype.stop = function () {
  7742. this.isPlaying = false;
  7743. if (this._currentIndex !== undefined) {
  7744. this._sounds[this._currentIndex].stop();
  7745. }
  7746. };
  7747. /**
  7748. * Start playback.
  7749. * @param startOffset Position the clip head at a specific time in seconds.
  7750. */
  7751. WeightedSound.prototype.play = function (startOffset) {
  7752. if (!this.isPaused) {
  7753. this.stop();
  7754. var randomValue = Math.random();
  7755. var total = 0;
  7756. for (var i = 0; i < this._weights.length; i++) {
  7757. total += this._weights[i];
  7758. if (randomValue <= total) {
  7759. this._currentIndex = i;
  7760. break;
  7761. }
  7762. }
  7763. }
  7764. var sound = this._sounds[this._currentIndex];
  7765. if (sound.isReady()) {
  7766. sound.play(0, this.isPaused ? undefined : startOffset);
  7767. }
  7768. else {
  7769. sound.autoplay = true;
  7770. }
  7771. this.isPlaying = true;
  7772. this.isPaused = false;
  7773. };
  7774. return WeightedSound;
  7775. }());
  7776. /***/ }),
  7777. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7778. /*!***************************************************!*\
  7779. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7780. \***************************************************/
  7781. /*! exports provided: AutoRotationBehavior */
  7782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7783. "use strict";
  7784. __webpack_require__.r(__webpack_exports__);
  7785. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7786. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7787. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7788. /**
  7789. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7790. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7791. */
  7792. var AutoRotationBehavior = /** @class */ (function () {
  7793. function AutoRotationBehavior() {
  7794. this._zoomStopsAnimation = false;
  7795. this._idleRotationSpeed = 0.05;
  7796. this._idleRotationWaitTime = 2000;
  7797. this._idleRotationSpinupTime = 2000;
  7798. this._isPointerDown = false;
  7799. this._lastFrameTime = null;
  7800. this._lastInteractionTime = -Infinity;
  7801. this._cameraRotationSpeed = 0;
  7802. this._lastFrameRadius = 0;
  7803. }
  7804. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7805. /**
  7806. * Gets the name of the behavior.
  7807. */
  7808. get: function () {
  7809. return "AutoRotation";
  7810. },
  7811. enumerable: true,
  7812. configurable: true
  7813. });
  7814. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7815. /**
  7816. * Gets the flag that indicates if user zooming should stop animation.
  7817. */
  7818. get: function () {
  7819. return this._zoomStopsAnimation;
  7820. },
  7821. /**
  7822. * Sets the flag that indicates if user zooming should stop animation.
  7823. */
  7824. set: function (flag) {
  7825. this._zoomStopsAnimation = flag;
  7826. },
  7827. enumerable: true,
  7828. configurable: true
  7829. });
  7830. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7831. /**
  7832. * Gets the default speed at which the camera rotates around the model.
  7833. */
  7834. get: function () {
  7835. return this._idleRotationSpeed;
  7836. },
  7837. /**
  7838. * Sets the default speed at which the camera rotates around the model.
  7839. */
  7840. set: function (speed) {
  7841. this._idleRotationSpeed = speed;
  7842. },
  7843. enumerable: true,
  7844. configurable: true
  7845. });
  7846. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7847. /**
  7848. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7849. */
  7850. get: function () {
  7851. return this._idleRotationWaitTime;
  7852. },
  7853. /**
  7854. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7855. */
  7856. set: function (time) {
  7857. this._idleRotationWaitTime = time;
  7858. },
  7859. enumerable: true,
  7860. configurable: true
  7861. });
  7862. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7863. /**
  7864. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7865. */
  7866. get: function () {
  7867. return this._idleRotationSpinupTime;
  7868. },
  7869. /**
  7870. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7871. */
  7872. set: function (time) {
  7873. this._idleRotationSpinupTime = time;
  7874. },
  7875. enumerable: true,
  7876. configurable: true
  7877. });
  7878. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7879. /**
  7880. * Gets a value indicating if the camera is currently rotating because of this behavior
  7881. */
  7882. get: function () {
  7883. return Math.abs(this._cameraRotationSpeed) > 0;
  7884. },
  7885. enumerable: true,
  7886. configurable: true
  7887. });
  7888. /**
  7889. * Initializes the behavior.
  7890. */
  7891. AutoRotationBehavior.prototype.init = function () {
  7892. // Do notihng
  7893. };
  7894. /**
  7895. * Attaches the behavior to its arc rotate camera.
  7896. * @param camera Defines the camera to attach the behavior to
  7897. */
  7898. AutoRotationBehavior.prototype.attach = function (camera) {
  7899. var _this = this;
  7900. this._attachedCamera = camera;
  7901. var scene = this._attachedCamera.getScene();
  7902. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7903. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7904. _this._isPointerDown = true;
  7905. return;
  7906. }
  7907. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7908. _this._isPointerDown = false;
  7909. }
  7910. });
  7911. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7912. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7913. var dt = 0;
  7914. if (_this._lastFrameTime != null) {
  7915. dt = now - _this._lastFrameTime;
  7916. }
  7917. _this._lastFrameTime = now;
  7918. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7919. _this._applyUserInteraction();
  7920. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7921. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7922. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7923. // Step camera rotation by rotation speed
  7924. if (_this._attachedCamera) {
  7925. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7926. }
  7927. });
  7928. };
  7929. /**
  7930. * Detaches the behavior from its current arc rotate camera.
  7931. */
  7932. AutoRotationBehavior.prototype.detach = function () {
  7933. if (!this._attachedCamera) {
  7934. return;
  7935. }
  7936. var scene = this._attachedCamera.getScene();
  7937. if (this._onPrePointerObservableObserver) {
  7938. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7939. }
  7940. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7941. this._attachedCamera = null;
  7942. };
  7943. /**
  7944. * Returns true if user is scrolling.
  7945. * @return true if user is scrolling.
  7946. */
  7947. AutoRotationBehavior.prototype._userIsZooming = function () {
  7948. if (!this._attachedCamera) {
  7949. return false;
  7950. }
  7951. return this._attachedCamera.inertialRadiusOffset !== 0;
  7952. };
  7953. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7954. if (!this._attachedCamera) {
  7955. return false;
  7956. }
  7957. var zoomHasHitLimit = false;
  7958. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7959. zoomHasHitLimit = true;
  7960. }
  7961. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7962. this._lastFrameRadius = this._attachedCamera.radius;
  7963. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7964. };
  7965. /**
  7966. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7967. */
  7968. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7969. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7970. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7971. }
  7972. };
  7973. // Tools
  7974. AutoRotationBehavior.prototype._userIsMoving = function () {
  7975. if (!this._attachedCamera) {
  7976. return false;
  7977. }
  7978. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7979. this._attachedCamera.inertialBetaOffset !== 0 ||
  7980. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7981. this._attachedCamera.inertialPanningX !== 0 ||
  7982. this._attachedCamera.inertialPanningY !== 0 ||
  7983. this._isPointerDown;
  7984. };
  7985. return AutoRotationBehavior;
  7986. }());
  7987. /***/ }),
  7988. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7989. /*!***********************************************!*\
  7990. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7991. \***********************************************/
  7992. /*! exports provided: BouncingBehavior */
  7993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7994. "use strict";
  7995. __webpack_require__.r(__webpack_exports__);
  7996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7997. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7998. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7999. /**
  8000. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  8001. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  8002. */
  8003. var BouncingBehavior = /** @class */ (function () {
  8004. function BouncingBehavior() {
  8005. /**
  8006. * The duration of the animation, in milliseconds
  8007. */
  8008. this.transitionDuration = 450;
  8009. /**
  8010. * Length of the distance animated by the transition when lower radius is reached
  8011. */
  8012. this.lowerRadiusTransitionRange = 2;
  8013. /**
  8014. * Length of the distance animated by the transition when upper radius is reached
  8015. */
  8016. this.upperRadiusTransitionRange = -2;
  8017. this._autoTransitionRange = false;
  8018. // Animations
  8019. this._radiusIsAnimating = false;
  8020. this._radiusBounceTransition = null;
  8021. this._animatables = new Array();
  8022. }
  8023. Object.defineProperty(BouncingBehavior.prototype, "name", {
  8024. /**
  8025. * Gets the name of the behavior.
  8026. */
  8027. get: function () {
  8028. return "Bouncing";
  8029. },
  8030. enumerable: true,
  8031. configurable: true
  8032. });
  8033. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  8034. /**
  8035. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8036. */
  8037. get: function () {
  8038. return this._autoTransitionRange;
  8039. },
  8040. /**
  8041. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8042. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  8043. */
  8044. set: function (value) {
  8045. var _this = this;
  8046. if (this._autoTransitionRange === value) {
  8047. return;
  8048. }
  8049. this._autoTransitionRange = value;
  8050. var camera = this._attachedCamera;
  8051. if (!camera) {
  8052. return;
  8053. }
  8054. if (value) {
  8055. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8056. if (!mesh) {
  8057. return;
  8058. }
  8059. mesh.computeWorldMatrix(true);
  8060. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8061. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8062. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8063. });
  8064. }
  8065. else if (this._onMeshTargetChangedObserver) {
  8066. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8067. }
  8068. },
  8069. enumerable: true,
  8070. configurable: true
  8071. });
  8072. /**
  8073. * Initializes the behavior.
  8074. */
  8075. BouncingBehavior.prototype.init = function () {
  8076. // Do notihng
  8077. };
  8078. /**
  8079. * Attaches the behavior to its arc rotate camera.
  8080. * @param camera Defines the camera to attach the behavior to
  8081. */
  8082. BouncingBehavior.prototype.attach = function (camera) {
  8083. var _this = this;
  8084. this._attachedCamera = camera;
  8085. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8086. if (!_this._attachedCamera) {
  8087. return;
  8088. }
  8089. // Add the bounce animation to the lower radius limit
  8090. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8091. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8092. }
  8093. // Add the bounce animation to the upper radius limit
  8094. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8095. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8096. }
  8097. });
  8098. };
  8099. /**
  8100. * Detaches the behavior from its current arc rotate camera.
  8101. */
  8102. BouncingBehavior.prototype.detach = function () {
  8103. if (!this._attachedCamera) {
  8104. return;
  8105. }
  8106. if (this._onAfterCheckInputsObserver) {
  8107. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8108. }
  8109. if (this._onMeshTargetChangedObserver) {
  8110. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8111. }
  8112. this._attachedCamera = null;
  8113. };
  8114. /**
  8115. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8116. * @param radiusLimit The limit to check against.
  8117. * @return Bool to indicate if at limit.
  8118. */
  8119. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8120. if (!this._attachedCamera) {
  8121. return false;
  8122. }
  8123. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8124. return true;
  8125. }
  8126. return false;
  8127. };
  8128. /**
  8129. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8130. * @param radiusDelta The delta by which to animate to. Can be negative.
  8131. */
  8132. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8133. var _this = this;
  8134. if (!this._attachedCamera) {
  8135. return;
  8136. }
  8137. if (!this._radiusBounceTransition) {
  8138. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8139. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8140. }
  8141. // Prevent zoom until bounce has completed
  8142. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8143. this._attachedCamera.wheelPrecision = Infinity;
  8144. this._attachedCamera.inertialRadiusOffset = 0;
  8145. // Animate to the radius limit
  8146. this.stopAllAnimations();
  8147. this._radiusIsAnimating = true;
  8148. 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(); });
  8149. if (animatable) {
  8150. this._animatables.push(animatable);
  8151. }
  8152. };
  8153. /**
  8154. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8155. */
  8156. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8157. this._radiusIsAnimating = false;
  8158. if (this._attachedCamera) {
  8159. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8160. }
  8161. };
  8162. /**
  8163. * Stops and removes all animations that have been applied to the camera
  8164. */
  8165. BouncingBehavior.prototype.stopAllAnimations = function () {
  8166. if (this._attachedCamera) {
  8167. this._attachedCamera.animations = [];
  8168. }
  8169. while (this._animatables.length) {
  8170. this._animatables[0].onAnimationEnd = null;
  8171. this._animatables[0].stop();
  8172. this._animatables.shift();
  8173. }
  8174. };
  8175. /**
  8176. * The easing function used by animations
  8177. */
  8178. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8179. /**
  8180. * The easing mode used by animations
  8181. */
  8182. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8183. return BouncingBehavior;
  8184. }());
  8185. /***/ }),
  8186. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8187. /*!**********************************************!*\
  8188. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8189. \**********************************************/
  8190. /*! exports provided: FramingBehavior */
  8191. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8192. "use strict";
  8193. __webpack_require__.r(__webpack_exports__);
  8194. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8195. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8196. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8197. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8198. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8199. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8200. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8201. /**
  8202. * 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.
  8203. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8204. */
  8205. var FramingBehavior = /** @class */ (function () {
  8206. function FramingBehavior() {
  8207. this._mode = FramingBehavior.FitFrustumSidesMode;
  8208. this._radiusScale = 1.0;
  8209. this._positionScale = 0.5;
  8210. this._defaultElevation = 0.3;
  8211. this._elevationReturnTime = 1500;
  8212. this._elevationReturnWaitTime = 1000;
  8213. this._zoomStopsAnimation = false;
  8214. this._framingTime = 1500;
  8215. /**
  8216. * Define if the behavior should automatically change the configured
  8217. * camera limits and sensibilities.
  8218. */
  8219. this.autoCorrectCameraLimitsAndSensibility = true;
  8220. this._isPointerDown = false;
  8221. this._lastInteractionTime = -Infinity;
  8222. // Framing control
  8223. this._animatables = new Array();
  8224. this._betaIsAnimating = false;
  8225. }
  8226. Object.defineProperty(FramingBehavior.prototype, "name", {
  8227. /**
  8228. * Gets the name of the behavior.
  8229. */
  8230. get: function () {
  8231. return "Framing";
  8232. },
  8233. enumerable: true,
  8234. configurable: true
  8235. });
  8236. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8237. /**
  8238. * Gets current mode used by the behavior.
  8239. */
  8240. get: function () {
  8241. return this._mode;
  8242. },
  8243. /**
  8244. * Sets the current mode used by the behavior
  8245. */
  8246. set: function (mode) {
  8247. this._mode = mode;
  8248. },
  8249. enumerable: true,
  8250. configurable: true
  8251. });
  8252. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8253. /**
  8254. * Gets the scale applied to the radius
  8255. */
  8256. get: function () {
  8257. return this._radiusScale;
  8258. },
  8259. /**
  8260. * Sets the scale applied to the radius (1 by default)
  8261. */
  8262. set: function (radius) {
  8263. this._radiusScale = radius;
  8264. },
  8265. enumerable: true,
  8266. configurable: true
  8267. });
  8268. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8269. /**
  8270. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8271. */
  8272. get: function () {
  8273. return this._positionScale;
  8274. },
  8275. /**
  8276. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8277. */
  8278. set: function (scale) {
  8279. this._positionScale = scale;
  8280. },
  8281. enumerable: true,
  8282. configurable: true
  8283. });
  8284. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8285. /**
  8286. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8287. * behaviour is triggered, in radians.
  8288. */
  8289. get: function () {
  8290. return this._defaultElevation;
  8291. },
  8292. /**
  8293. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8294. * behaviour is triggered, in radians.
  8295. */
  8296. set: function (elevation) {
  8297. this._defaultElevation = elevation;
  8298. },
  8299. enumerable: true,
  8300. configurable: true
  8301. });
  8302. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8303. /**
  8304. * Gets the time (in milliseconds) taken to return to the default beta position.
  8305. * Negative value indicates camera should not return to default.
  8306. */
  8307. get: function () {
  8308. return this._elevationReturnTime;
  8309. },
  8310. /**
  8311. * Sets the time (in milliseconds) taken to return to the default beta position.
  8312. * Negative value indicates camera should not return to default.
  8313. */
  8314. set: function (speed) {
  8315. this._elevationReturnTime = speed;
  8316. },
  8317. enumerable: true,
  8318. configurable: true
  8319. });
  8320. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8321. /**
  8322. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8323. */
  8324. get: function () {
  8325. return this._elevationReturnWaitTime;
  8326. },
  8327. /**
  8328. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8329. */
  8330. set: function (time) {
  8331. this._elevationReturnWaitTime = time;
  8332. },
  8333. enumerable: true,
  8334. configurable: true
  8335. });
  8336. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8337. /**
  8338. * Gets the flag that indicates if user zooming should stop animation.
  8339. */
  8340. get: function () {
  8341. return this._zoomStopsAnimation;
  8342. },
  8343. /**
  8344. * Sets the flag that indicates if user zooming should stop animation.
  8345. */
  8346. set: function (flag) {
  8347. this._zoomStopsAnimation = flag;
  8348. },
  8349. enumerable: true,
  8350. configurable: true
  8351. });
  8352. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8353. /**
  8354. * Gets the transition time when framing the mesh, in milliseconds
  8355. */
  8356. get: function () {
  8357. return this._framingTime;
  8358. },
  8359. /**
  8360. * Sets the transition time when framing the mesh, in milliseconds
  8361. */
  8362. set: function (time) {
  8363. this._framingTime = time;
  8364. },
  8365. enumerable: true,
  8366. configurable: true
  8367. });
  8368. /**
  8369. * Initializes the behavior.
  8370. */
  8371. FramingBehavior.prototype.init = function () {
  8372. // Do notihng
  8373. };
  8374. /**
  8375. * Attaches the behavior to its arc rotate camera.
  8376. * @param camera Defines the camera to attach the behavior to
  8377. */
  8378. FramingBehavior.prototype.attach = function (camera) {
  8379. var _this = this;
  8380. this._attachedCamera = camera;
  8381. var scene = this._attachedCamera.getScene();
  8382. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8383. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8384. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8385. _this._isPointerDown = true;
  8386. return;
  8387. }
  8388. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8389. _this._isPointerDown = false;
  8390. }
  8391. });
  8392. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8393. if (mesh) {
  8394. _this.zoomOnMesh(mesh);
  8395. }
  8396. });
  8397. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8398. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8399. _this._applyUserInteraction();
  8400. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8401. // back to the default position after a given timeout
  8402. _this._maintainCameraAboveGround();
  8403. });
  8404. };
  8405. /**
  8406. * Detaches the behavior from its current arc rotate camera.
  8407. */
  8408. FramingBehavior.prototype.detach = function () {
  8409. if (!this._attachedCamera) {
  8410. return;
  8411. }
  8412. var scene = this._attachedCamera.getScene();
  8413. if (this._onPrePointerObservableObserver) {
  8414. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8415. }
  8416. if (this._onAfterCheckInputsObserver) {
  8417. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8418. }
  8419. if (this._onMeshTargetChangedObserver) {
  8420. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8421. }
  8422. this._attachedCamera = null;
  8423. };
  8424. /**
  8425. * Targets the given mesh and updates zoom level accordingly.
  8426. * @param mesh The mesh to target.
  8427. * @param radius Optional. If a cached radius position already exists, overrides default.
  8428. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8429. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8430. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8431. */
  8432. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8433. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8434. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8435. mesh.computeWorldMatrix(true);
  8436. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8437. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8438. };
  8439. /**
  8440. * Targets the given mesh with its children and updates zoom level accordingly.
  8441. * @param mesh The mesh to target.
  8442. * @param radius Optional. If a cached radius position already exists, overrides default.
  8443. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8444. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8445. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8446. */
  8447. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8448. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8449. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8450. mesh.computeWorldMatrix(true);
  8451. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8452. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8453. };
  8454. /**
  8455. * Targets the given meshes with their children and updates zoom level accordingly.
  8456. * @param meshes The mesh to target.
  8457. * @param radius Optional. If a cached radius position already exists, overrides default.
  8458. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8459. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8460. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8461. */
  8462. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8463. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8464. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8465. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8466. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8467. for (var i = 0; i < meshes.length; i++) {
  8468. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8469. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8470. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8471. }
  8472. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8473. };
  8474. /**
  8475. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8476. * @param minimumWorld Determines the smaller position of the bounding box extend
  8477. * @param maximumWorld Determines the bigger position of the bounding box extend
  8478. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8479. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8480. */
  8481. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8482. var _this = this;
  8483. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8484. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8485. var zoomTarget;
  8486. if (!this._attachedCamera) {
  8487. return;
  8488. }
  8489. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8490. var bottom = minimumWorld.y;
  8491. var top = maximumWorld.y;
  8492. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8493. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8494. if (focusOnOriginXZ) {
  8495. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8496. }
  8497. else {
  8498. var centerWorld = minimumWorld.add(radiusWorld);
  8499. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8500. }
  8501. if (!this._vectorTransition) {
  8502. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8503. }
  8504. this._betaIsAnimating = true;
  8505. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8506. if (animatable) {
  8507. this._animatables.push(animatable);
  8508. }
  8509. // sets the radius and lower radius bounds
  8510. // Small delta ensures camera is not always at lower zoom limit.
  8511. var radius = 0;
  8512. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8513. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8514. if (this.autoCorrectCameraLimitsAndSensibility) {
  8515. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8516. }
  8517. radius = position;
  8518. }
  8519. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8520. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8521. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8522. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8523. }
  8524. }
  8525. // Set sensibilities
  8526. if (this.autoCorrectCameraLimitsAndSensibility) {
  8527. var extend = maximumWorld.subtract(minimumWorld).length();
  8528. this._attachedCamera.panningSensibility = 5000 / extend;
  8529. this._attachedCamera.wheelPrecision = 100 / radius;
  8530. }
  8531. // transition to new radius
  8532. if (!this._radiusTransition) {
  8533. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8534. }
  8535. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8536. _this.stopAllAnimations();
  8537. if (onAnimationEnd) {
  8538. onAnimationEnd();
  8539. }
  8540. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8541. _this._attachedCamera.storeState();
  8542. }
  8543. });
  8544. if (animatable) {
  8545. this._animatables.push(animatable);
  8546. }
  8547. };
  8548. /**
  8549. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8550. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8551. * frustum width.
  8552. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8553. * to fully enclose the mesh in the viewing frustum.
  8554. */
  8555. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8556. var size = maximumWorld.subtract(minimumWorld);
  8557. var boxVectorGlobalDiagonal = size.length();
  8558. var frustumSlope = this._getFrustumSlope();
  8559. // Formula for setting distance
  8560. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8561. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8562. // Horizon distance
  8563. var radius = radiusWithoutFraming * this._radiusScale;
  8564. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8565. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8566. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8567. var camera = this._attachedCamera;
  8568. if (!camera) {
  8569. return 0;
  8570. }
  8571. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8572. // Don't exceed the requested limit
  8573. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8574. }
  8575. // Don't exceed the upper radius limit
  8576. if (camera.upperRadiusLimit) {
  8577. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8578. }
  8579. return distance;
  8580. };
  8581. /**
  8582. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8583. * is automatically returned to its default position (expected to be above ground plane).
  8584. */
  8585. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8586. var _this = this;
  8587. if (this._elevationReturnTime < 0) {
  8588. return;
  8589. }
  8590. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8591. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8592. var limitBeta = Math.PI * 0.5;
  8593. // Bring the camera back up if below the ground plane
  8594. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8595. this._betaIsAnimating = true;
  8596. //Transition to new position
  8597. this.stopAllAnimations();
  8598. if (!this._betaTransition) {
  8599. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8600. }
  8601. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8602. _this._clearAnimationLocks();
  8603. _this.stopAllAnimations();
  8604. });
  8605. if (animatabe) {
  8606. this._animatables.push(animatabe);
  8607. }
  8608. }
  8609. };
  8610. /**
  8611. * Returns the frustum slope based on the canvas ratio and camera FOV
  8612. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8613. */
  8614. FramingBehavior.prototype._getFrustumSlope = function () {
  8615. // Calculate the viewport ratio
  8616. // Aspect Ratio is Height/Width.
  8617. var camera = this._attachedCamera;
  8618. if (!camera) {
  8619. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8620. }
  8621. var engine = camera.getScene().getEngine();
  8622. var aspectRatio = engine.getAspectRatio(camera);
  8623. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8624. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8625. var frustumSlopeY = Math.tan(camera.fov / 2);
  8626. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8627. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8628. // along the forward vector.
  8629. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8630. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8631. };
  8632. /**
  8633. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8634. */
  8635. FramingBehavior.prototype._clearAnimationLocks = function () {
  8636. this._betaIsAnimating = false;
  8637. };
  8638. /**
  8639. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8640. */
  8641. FramingBehavior.prototype._applyUserInteraction = function () {
  8642. if (this.isUserIsMoving) {
  8643. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8644. this.stopAllAnimations();
  8645. this._clearAnimationLocks();
  8646. }
  8647. };
  8648. /**
  8649. * Stops and removes all animations that have been applied to the camera
  8650. */
  8651. FramingBehavior.prototype.stopAllAnimations = function () {
  8652. if (this._attachedCamera) {
  8653. this._attachedCamera.animations = [];
  8654. }
  8655. while (this._animatables.length) {
  8656. if (this._animatables[0]) {
  8657. this._animatables[0].onAnimationEnd = null;
  8658. this._animatables[0].stop();
  8659. }
  8660. this._animatables.shift();
  8661. }
  8662. };
  8663. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8664. /**
  8665. * Gets a value indicating if the user is moving the camera
  8666. */
  8667. get: function () {
  8668. if (!this._attachedCamera) {
  8669. return false;
  8670. }
  8671. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8672. this._attachedCamera.inertialBetaOffset !== 0 ||
  8673. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8674. this._attachedCamera.inertialPanningX !== 0 ||
  8675. this._attachedCamera.inertialPanningY !== 0 ||
  8676. this._isPointerDown;
  8677. },
  8678. enumerable: true,
  8679. configurable: true
  8680. });
  8681. /**
  8682. * The easing function used by animations
  8683. */
  8684. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8685. /**
  8686. * The easing mode used by animations
  8687. */
  8688. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8689. // Statics
  8690. /**
  8691. * The camera can move all the way towards the mesh.
  8692. */
  8693. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8694. /**
  8695. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8696. */
  8697. FramingBehavior.FitFrustumSidesMode = 1;
  8698. return FramingBehavior;
  8699. }());
  8700. /***/ }),
  8701. /***/ "./Behaviors/Cameras/index.ts":
  8702. /*!************************************!*\
  8703. !*** ./Behaviors/Cameras/index.ts ***!
  8704. \************************************/
  8705. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8707. "use strict";
  8708. __webpack_require__.r(__webpack_exports__);
  8709. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8711. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8713. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8715. /***/ }),
  8716. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8717. /*!*************************************************!*\
  8718. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8719. \*************************************************/
  8720. /*! exports provided: AttachToBoxBehavior */
  8721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8722. "use strict";
  8723. __webpack_require__.r(__webpack_exports__);
  8724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8725. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8726. /**
  8727. * @hidden
  8728. */
  8729. var FaceDirectionInfo = /** @class */ (function () {
  8730. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8731. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8732. if (diff === void 0) { diff = 0; }
  8733. if (ignore === void 0) { ignore = false; }
  8734. this.direction = direction;
  8735. this.rotatedDirection = rotatedDirection;
  8736. this.diff = diff;
  8737. this.ignore = ignore;
  8738. }
  8739. return FaceDirectionInfo;
  8740. }());
  8741. /**
  8742. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8743. */
  8744. var AttachToBoxBehavior = /** @class */ (function () {
  8745. /**
  8746. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8747. * @param ui The transform node that should be attched to the mesh
  8748. */
  8749. function AttachToBoxBehavior(ui) {
  8750. this.ui = ui;
  8751. /**
  8752. * The name of the behavior
  8753. */
  8754. this.name = "AttachToBoxBehavior";
  8755. /**
  8756. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8757. */
  8758. this.distanceAwayFromFace = 0.15;
  8759. /**
  8760. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8761. */
  8762. this.distanceAwayFromBottomOfFace = 0.15;
  8763. 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))];
  8764. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8765. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8766. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8767. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8768. /* Does nothing */
  8769. }
  8770. /**
  8771. * Initializes the behavior
  8772. */
  8773. AttachToBoxBehavior.prototype.init = function () {
  8774. /* Does nothing */
  8775. };
  8776. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8777. var _this = this;
  8778. // Go over each face and calculate the angle between the face's normal and targetDirection
  8779. this._faceVectors.forEach(function (v) {
  8780. if (!_this._target.rotationQuaternion) {
  8781. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8782. }
  8783. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8784. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8785. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8786. });
  8787. // Return the face information of the one with the normal closeset to target direction
  8788. return this._faceVectors.reduce(function (min, p) {
  8789. if (min.ignore) {
  8790. return p;
  8791. }
  8792. else if (p.ignore) {
  8793. return min;
  8794. }
  8795. else {
  8796. return min.diff < p.diff ? min : p;
  8797. }
  8798. }, this._faceVectors[0]);
  8799. };
  8800. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8801. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8802. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8803. this._lookAtTmpMatrix.invert();
  8804. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8805. };
  8806. /**
  8807. * Attaches the AttachToBoxBehavior to the passed in mesh
  8808. * @param target The mesh that the specified node will be attached to
  8809. */
  8810. AttachToBoxBehavior.prototype.attach = function (target) {
  8811. var _this = this;
  8812. this._target = target;
  8813. this._scene = this._target.getScene();
  8814. // Every frame, update the app bars position
  8815. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8816. if (!_this._scene.activeCamera) {
  8817. return;
  8818. }
  8819. // Find the face closest to the cameras position
  8820. var cameraPos = _this._scene.activeCamera.position;
  8821. if (_this._scene.activeCamera.devicePosition) {
  8822. cameraPos = _this._scene.activeCamera.devicePosition;
  8823. }
  8824. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8825. if (_this._scene.activeCamera.leftCamera) {
  8826. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8827. }
  8828. else {
  8829. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8830. }
  8831. // Get camera up direction
  8832. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8833. // Ignore faces to not select a parrelel face for the up vector of the UI
  8834. _this._faceVectors.forEach(function (v) {
  8835. if (facing.direction.x && v.direction.x) {
  8836. v.ignore = true;
  8837. }
  8838. if (facing.direction.y && v.direction.y) {
  8839. v.ignore = true;
  8840. }
  8841. if (facing.direction.z && v.direction.z) {
  8842. v.ignore = true;
  8843. }
  8844. });
  8845. var facingUp = _this._closestFace(_this._tmpVector);
  8846. // Unignore faces
  8847. _this._faceVectors.forEach(function (v) {
  8848. v.ignore = false;
  8849. });
  8850. // Position the app bar on that face
  8851. _this.ui.position.copyFrom(target.position);
  8852. if (facing.direction.x) {
  8853. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8854. _this.ui.position.addInPlace(_this._tmpVector);
  8855. }
  8856. if (facing.direction.y) {
  8857. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8858. _this.ui.position.addInPlace(_this._tmpVector);
  8859. }
  8860. if (facing.direction.z) {
  8861. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8862. _this.ui.position.addInPlace(_this._tmpVector);
  8863. }
  8864. // Rotate to be oriented properly to the camera
  8865. if (!_this.ui.rotationQuaternion) {
  8866. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8867. }
  8868. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8869. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8870. // Place ui the correct distance from the bottom of the mesh
  8871. if (facingUp.direction.x) {
  8872. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8873. }
  8874. if (facingUp.direction.y) {
  8875. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8876. }
  8877. if (facingUp.direction.z) {
  8878. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8879. }
  8880. _this.ui.position.addInPlace(_this._tmpVector);
  8881. });
  8882. };
  8883. /**
  8884. * Detaches the behavior from the mesh
  8885. */
  8886. AttachToBoxBehavior.prototype.detach = function () {
  8887. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8888. };
  8889. return AttachToBoxBehavior;
  8890. }());
  8891. /***/ }),
  8892. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8893. /*!***********************************************!*\
  8894. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8895. \***********************************************/
  8896. /*! exports provided: FadeInOutBehavior */
  8897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8898. "use strict";
  8899. __webpack_require__.r(__webpack_exports__);
  8900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8901. /**
  8902. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8903. */
  8904. var FadeInOutBehavior = /** @class */ (function () {
  8905. /**
  8906. * Instatiates the FadeInOutBehavior
  8907. */
  8908. function FadeInOutBehavior() {
  8909. var _this = this;
  8910. /**
  8911. * Time in milliseconds to delay before fading in (Default: 0)
  8912. */
  8913. this.delay = 0;
  8914. /**
  8915. * Time in milliseconds for the mesh to fade in (Default: 300)
  8916. */
  8917. this.fadeInTime = 300;
  8918. this._millisecondsPerFrame = 1000 / 60;
  8919. this._hovered = false;
  8920. this._hoverValue = 0;
  8921. this._ownerNode = null;
  8922. this._update = function () {
  8923. if (_this._ownerNode) {
  8924. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8925. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8926. if (_this._ownerNode.visibility > 1) {
  8927. _this._setAllVisibility(_this._ownerNode, 1);
  8928. _this._hoverValue = _this.fadeInTime + _this.delay;
  8929. return;
  8930. }
  8931. else if (_this._ownerNode.visibility < 0) {
  8932. _this._setAllVisibility(_this._ownerNode, 0);
  8933. if (_this._hoverValue < 0) {
  8934. _this._hoverValue = 0;
  8935. return;
  8936. }
  8937. }
  8938. setTimeout(_this._update, _this._millisecondsPerFrame);
  8939. }
  8940. };
  8941. }
  8942. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8943. /**
  8944. * The name of the behavior
  8945. */
  8946. get: function () {
  8947. return "FadeInOut";
  8948. },
  8949. enumerable: true,
  8950. configurable: true
  8951. });
  8952. /**
  8953. * Initializes the behavior
  8954. */
  8955. FadeInOutBehavior.prototype.init = function () {
  8956. };
  8957. /**
  8958. * Attaches the fade behavior on the passed in mesh
  8959. * @param ownerNode The mesh that will be faded in/out once attached
  8960. */
  8961. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8962. this._ownerNode = ownerNode;
  8963. this._setAllVisibility(this._ownerNode, 0);
  8964. };
  8965. /**
  8966. * Detaches the behavior from the mesh
  8967. */
  8968. FadeInOutBehavior.prototype.detach = function () {
  8969. this._ownerNode = null;
  8970. };
  8971. /**
  8972. * Triggers the mesh to begin fading in or out
  8973. * @param value if the object should fade in or out (true to fade in)
  8974. */
  8975. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8976. this._hovered = value;
  8977. this._update();
  8978. };
  8979. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8980. var _this = this;
  8981. mesh.visibility = value;
  8982. mesh.getChildMeshes().forEach(function (c) {
  8983. _this._setAllVisibility(c, value);
  8984. });
  8985. };
  8986. return FadeInOutBehavior;
  8987. }());
  8988. /***/ }),
  8989. /***/ "./Behaviors/Meshes/index.ts":
  8990. /*!***********************************!*\
  8991. !*** ./Behaviors/Meshes/index.ts ***!
  8992. \***********************************/
  8993. /*! exports provided: PointerDragBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior */
  8994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8995. "use strict";
  8996. __webpack_require__.r(__webpack_exports__);
  8997. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8999. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  9000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9001. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  9002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  9003. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  9004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  9005. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  9006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  9007. /***/ }),
  9008. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  9009. /*!*******************************************************!*\
  9010. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  9011. \*******************************************************/
  9012. /*! exports provided: MultiPointerScaleBehavior */
  9013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9014. "use strict";
  9015. __webpack_require__.r(__webpack_exports__);
  9016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  9017. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  9018. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9019. /**
  9020. * A behavior that when attached to a mesh will allow the mesh to be scaled
  9021. */
  9022. var MultiPointerScaleBehavior = /** @class */ (function () {
  9023. /**
  9024. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  9025. */
  9026. function MultiPointerScaleBehavior() {
  9027. this._startDistance = 0;
  9028. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9029. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9030. this._sceneRenderObserver = null;
  9031. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9032. this._dragBehaviorA.moveAttached = false;
  9033. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9034. this._dragBehaviorB.moveAttached = false;
  9035. }
  9036. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  9037. /**
  9038. * The name of the behavior
  9039. */
  9040. get: function () {
  9041. return "MultiPointerScale";
  9042. },
  9043. enumerable: true,
  9044. configurable: true
  9045. });
  9046. /**
  9047. * Initializes the behavior
  9048. */
  9049. MultiPointerScaleBehavior.prototype.init = function () { };
  9050. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  9051. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  9052. };
  9053. /**
  9054. * Attaches the scale behavior the passed in mesh
  9055. * @param ownerNode The mesh that will be scaled around once attached
  9056. */
  9057. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9058. var _this = this;
  9059. this._ownerNode = ownerNode;
  9060. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9061. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9062. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9063. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9064. _this._dragBehaviorA.releaseDrag();
  9065. }
  9066. else {
  9067. _this._initialScale.copyFrom(ownerNode.scaling);
  9068. _this._startDistance = _this._getCurrentDistance();
  9069. }
  9070. }
  9071. });
  9072. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9073. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9074. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9075. _this._dragBehaviorB.releaseDrag();
  9076. }
  9077. else {
  9078. _this._initialScale.copyFrom(ownerNode.scaling);
  9079. _this._startDistance = _this._getCurrentDistance();
  9080. }
  9081. }
  9082. });
  9083. // Once both drag behaviors are active scale based on the distance between the two pointers
  9084. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9085. behavior.onDragObservable.add(function () {
  9086. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9087. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9088. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9089. }
  9090. });
  9091. });
  9092. ownerNode.addBehavior(this._dragBehaviorA);
  9093. ownerNode.addBehavior(this._dragBehaviorB);
  9094. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9095. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9096. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9097. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9098. if (change.length() > 0.01) {
  9099. ownerNode.scaling.addInPlace(change);
  9100. }
  9101. }
  9102. });
  9103. };
  9104. /**
  9105. * Detaches the behavior from the mesh
  9106. */
  9107. MultiPointerScaleBehavior.prototype.detach = function () {
  9108. var _this = this;
  9109. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9110. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9111. behavior.onDragStartObservable.clear();
  9112. behavior.onDragObservable.clear();
  9113. _this._ownerNode.removeBehavior(behavior);
  9114. });
  9115. };
  9116. return MultiPointerScaleBehavior;
  9117. }());
  9118. /***/ }),
  9119. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9120. /*!*************************************************!*\
  9121. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9122. \*************************************************/
  9123. /*! exports provided: PointerDragBehavior */
  9124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9125. "use strict";
  9126. __webpack_require__.r(__webpack_exports__);
  9127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9128. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9129. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9130. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9131. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9132. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9133. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9134. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9135. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9136. /**
  9137. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9138. */
  9139. var PointerDragBehavior = /** @class */ (function () {
  9140. /**
  9141. * Creates a pointer drag behavior that can be attached to a mesh
  9142. * @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)
  9143. */
  9144. function PointerDragBehavior(options) {
  9145. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9146. /**
  9147. * 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)
  9148. */
  9149. this.maxDragAngle = 0;
  9150. /**
  9151. * @hidden
  9152. */
  9153. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9154. /**
  9155. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9156. */
  9157. this.currentDraggingPointerID = -1;
  9158. /**
  9159. * If the behavior is currently in a dragging state
  9160. */
  9161. this.dragging = false;
  9162. /**
  9163. * 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)
  9164. */
  9165. this.dragDeltaRatio = 0.2;
  9166. /**
  9167. * If the drag plane orientation should be updated during the dragging (Default: true)
  9168. */
  9169. this.updateDragPlane = true;
  9170. // Debug mode will display drag planes to help visualize behavior
  9171. this._debugMode = false;
  9172. this._moving = false;
  9173. /**
  9174. * Fires each time the attached mesh is dragged with the pointer
  9175. * * delta between last drag position and current drag position in world space
  9176. * * dragDistance along the drag axis
  9177. * * dragPlaneNormal normal of the current drag plane used during the drag
  9178. * * dragPlanePoint in world space where the drag intersects the drag plane
  9179. */
  9180. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9181. /**
  9182. * Fires each time a drag begins (eg. mouse down on mesh)
  9183. */
  9184. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9185. /**
  9186. * Fires each time a drag ends (eg. mouse release after drag)
  9187. */
  9188. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9189. /**
  9190. * If the attached mesh should be moved when dragged
  9191. */
  9192. this.moveAttached = true;
  9193. /**
  9194. * If the drag behavior will react to drag events (Default: true)
  9195. */
  9196. this.enabled = true;
  9197. /**
  9198. * If camera controls should be detached during the drag
  9199. */
  9200. this.detachCameraControls = true;
  9201. /**
  9202. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9203. */
  9204. this.useObjectOrienationForDragging = true;
  9205. /**
  9206. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9207. */
  9208. this.validateDrag = function (targetPosition) { return true; };
  9209. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9210. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9211. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9212. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9213. this._attachedElement = null;
  9214. 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"]());
  9215. this._lastPointerRay = {};
  9216. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9217. // Variables to avoid instantiation in the below method
  9218. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9219. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9220. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9221. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9222. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9223. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9224. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9225. this._options = options ? options : {};
  9226. var optionCount = 0;
  9227. if (this._options.dragAxis) {
  9228. optionCount++;
  9229. }
  9230. if (this._options.dragPlaneNormal) {
  9231. optionCount++;
  9232. }
  9233. if (optionCount > 1) {
  9234. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9235. }
  9236. }
  9237. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9238. /**
  9239. * The name of the behavior
  9240. */
  9241. get: function () {
  9242. return "PointerDrag";
  9243. },
  9244. enumerable: true,
  9245. configurable: true
  9246. });
  9247. /**
  9248. * Initializes the behavior
  9249. */
  9250. PointerDragBehavior.prototype.init = function () { };
  9251. /**
  9252. * Attaches the drag behavior the passed in mesh
  9253. * @param ownerNode The mesh that will be dragged around once attached
  9254. */
  9255. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9256. var _this = this;
  9257. this._scene = ownerNode.getScene();
  9258. this._attachedNode = ownerNode;
  9259. // Initialize drag plane to not interfere with existing scene
  9260. if (!PointerDragBehavior._planeScene) {
  9261. if (this._debugMode) {
  9262. PointerDragBehavior._planeScene = this._scene;
  9263. }
  9264. else {
  9265. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9266. PointerDragBehavior._planeScene.detachControl();
  9267. this._scene.getEngine().scenes.pop();
  9268. this._scene.onDisposeObservable.addOnce(function () {
  9269. PointerDragBehavior._planeScene.dispose();
  9270. PointerDragBehavior._planeScene = null;
  9271. });
  9272. }
  9273. }
  9274. 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);
  9275. // State of the drag
  9276. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9277. var pickPredicate = function (m) {
  9278. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9279. };
  9280. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9281. if (!_this.enabled) {
  9282. return;
  9283. }
  9284. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9285. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9286. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9287. }
  9288. }
  9289. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9290. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9291. _this.releaseDrag();
  9292. }
  9293. }
  9294. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9295. var pointerId = pointerInfo.event.pointerId;
  9296. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9297. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9298. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9299. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9300. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9301. }
  9302. _this.currentDraggingPointerID = pointerId;
  9303. }
  9304. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9305. if (!_this._lastPointerRay[pointerId]) {
  9306. _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"]());
  9307. }
  9308. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9309. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9310. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9311. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9312. _this._moveDrag(pointerInfo.pickInfo.ray);
  9313. }
  9314. }
  9315. }
  9316. });
  9317. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9318. if (_this._moving && _this.moveAttached) {
  9319. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9320. // Slowly move mesh to avoid jitter
  9321. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9322. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9323. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9324. if (_this.validateDrag(_this._tmpVector)) {
  9325. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9326. }
  9327. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9328. }
  9329. });
  9330. };
  9331. /**
  9332. * Force relase the drag action by code.
  9333. */
  9334. PointerDragBehavior.prototype.releaseDrag = function () {
  9335. this.dragging = false;
  9336. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9337. this.currentDraggingPointerID = -1;
  9338. this._moving = false;
  9339. // Reattach camera controls
  9340. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9341. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9342. }
  9343. };
  9344. /**
  9345. * Simulates the start of a pointer drag event on the behavior
  9346. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9347. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9348. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9349. */
  9350. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9351. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9352. this._startDrag(pointerId, fromRay, startPickedPoint);
  9353. var lastRay = this._lastPointerRay[pointerId];
  9354. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9355. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9356. }
  9357. if (lastRay) {
  9358. // if there was a last pointer ray drag the object there
  9359. this._moveDrag(lastRay);
  9360. }
  9361. };
  9362. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9363. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9364. return;
  9365. }
  9366. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9367. // Create start ray from the camera to the object
  9368. if (fromRay) {
  9369. this._startDragRay.direction.copyFrom(fromRay.direction);
  9370. this._startDragRay.origin.copyFrom(fromRay.origin);
  9371. }
  9372. else {
  9373. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9374. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9375. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9376. }
  9377. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9378. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9379. if (pickedPoint) {
  9380. this.dragging = true;
  9381. this.currentDraggingPointerID = pointerId;
  9382. this.lastDragPosition.copyFrom(pickedPoint);
  9383. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9384. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9385. // Detatch camera controls
  9386. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9387. if (this._scene.activeCamera.inputs.attachedElement) {
  9388. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9389. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9390. }
  9391. else {
  9392. this._attachedElement = null;
  9393. }
  9394. }
  9395. }
  9396. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9397. };
  9398. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9399. this._moving = true;
  9400. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9401. if (pickedPoint) {
  9402. if (this.updateDragPlane) {
  9403. this._updateDragPlanePosition(ray, pickedPoint);
  9404. }
  9405. var dragLength = 0;
  9406. // depending on the drag mode option drag accordingly
  9407. if (this._options.dragAxis) {
  9408. // Convert local drag axis to world
  9409. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9410. // Project delta drag from the drag plane onto the drag axis
  9411. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9412. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9413. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9414. }
  9415. else {
  9416. dragLength = this._dragDelta.length();
  9417. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9418. }
  9419. this._targetPosition.addInPlace(this._dragDelta);
  9420. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9421. this.lastDragPosition.copyFrom(pickedPoint);
  9422. }
  9423. };
  9424. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9425. var _this = this;
  9426. if (!ray) {
  9427. return null;
  9428. }
  9429. // Calculate angle between plane normal and ray
  9430. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9431. // Correct if ray is casted from oposite side
  9432. if (angle > Math.PI / 2) {
  9433. angle = Math.PI - angle;
  9434. }
  9435. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9436. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9437. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9438. // Invert ray direction along the towards object axis
  9439. this._tmpVector.copyFrom(ray.direction);
  9440. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9441. this._alternatePickedPoint.normalize();
  9442. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9443. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9444. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9445. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9446. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9447. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9448. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9449. return this._alternatePickedPoint;
  9450. }
  9451. else {
  9452. return null;
  9453. }
  9454. }
  9455. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9456. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9457. return pickResult.pickedPoint;
  9458. }
  9459. else {
  9460. return null;
  9461. }
  9462. };
  9463. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9464. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9465. this._pointA.copyFrom(dragPlanePosition);
  9466. if (this._options.dragAxis) {
  9467. 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);
  9468. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9469. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9470. ray.origin.subtractToRef(this._pointA, this._pointC);
  9471. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9472. // Get perpendicular line from direction to camera and drag axis
  9473. this._pointB.subtractToRef(this._pointA, this._lineA);
  9474. this._pointC.subtractToRef(this._pointA, this._lineB);
  9475. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9476. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9477. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9478. this._lookAt.normalize();
  9479. this._dragPlane.position.copyFrom(this._pointA);
  9480. this._pointA.addToRef(this._lookAt, this._lookAt);
  9481. this._dragPlane.lookAt(this._lookAt);
  9482. }
  9483. else if (this._options.dragPlaneNormal) {
  9484. 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);
  9485. this._dragPlane.position.copyFrom(this._pointA);
  9486. this._pointA.addToRef(this._localAxis, this._lookAt);
  9487. this._dragPlane.lookAt(this._lookAt);
  9488. }
  9489. else {
  9490. this._dragPlane.position.copyFrom(this._pointA);
  9491. this._dragPlane.lookAt(ray.origin);
  9492. }
  9493. // 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)
  9494. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9495. this._dragPlane.computeWorldMatrix(true);
  9496. };
  9497. /**
  9498. * Detaches the behavior from the mesh
  9499. */
  9500. PointerDragBehavior.prototype.detach = function () {
  9501. if (this._pointerObserver) {
  9502. this._scene.onPointerObservable.remove(this._pointerObserver);
  9503. }
  9504. if (this._beforeRenderObserver) {
  9505. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9506. }
  9507. this.releaseDrag();
  9508. };
  9509. PointerDragBehavior._AnyMouseID = -2;
  9510. return PointerDragBehavior;
  9511. }());
  9512. /***/ }),
  9513. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9514. /*!************************************************!*\
  9515. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9516. \************************************************/
  9517. /*! exports provided: SixDofDragBehavior */
  9518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9519. "use strict";
  9520. __webpack_require__.r(__webpack_exports__);
  9521. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9522. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9523. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9524. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9525. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9526. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9527. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9528. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9529. /**
  9530. * 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
  9531. */
  9532. var SixDofDragBehavior = /** @class */ (function () {
  9533. /**
  9534. * 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
  9535. */
  9536. function SixDofDragBehavior() {
  9537. this._sceneRenderObserver = null;
  9538. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9539. this._moving = false;
  9540. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9541. /**
  9542. * 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)
  9543. */
  9544. this.zDragFactor = 3;
  9545. /**
  9546. * If the object should rotate to face the drag origin
  9547. */
  9548. this.rotateDraggedObject = true;
  9549. /**
  9550. * If the behavior is currently in a dragging state
  9551. */
  9552. this.dragging = false;
  9553. /**
  9554. * 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)
  9555. */
  9556. this.dragDeltaRatio = 0.2;
  9557. /**
  9558. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9559. */
  9560. this.currentDraggingPointerID = -1;
  9561. /**
  9562. * If camera controls should be detached during the drag
  9563. */
  9564. this.detachCameraControls = true;
  9565. /**
  9566. * Fires each time a drag starts
  9567. */
  9568. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9569. /**
  9570. * Fires each time a drag ends (eg. mouse release after drag)
  9571. */
  9572. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9573. }
  9574. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9575. /**
  9576. * The name of the behavior
  9577. */
  9578. get: function () {
  9579. return "SixDofDrag";
  9580. },
  9581. enumerable: true,
  9582. configurable: true
  9583. });
  9584. /**
  9585. * Initializes the behavior
  9586. */
  9587. SixDofDragBehavior.prototype.init = function () { };
  9588. /**
  9589. * Attaches the scale behavior the passed in mesh
  9590. * @param ownerNode The mesh that will be scaled around once attached
  9591. */
  9592. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9593. var _this = this;
  9594. this._ownerNode = ownerNode;
  9595. this._scene = this._ownerNode.getScene();
  9596. if (!SixDofDragBehavior._virtualScene) {
  9597. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9598. SixDofDragBehavior._virtualScene.detachControl();
  9599. this._scene.getEngine().scenes.pop();
  9600. }
  9601. var pickedMesh = null;
  9602. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9603. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9604. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9605. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9606. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9607. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9608. var pickPredicate = function (m) {
  9609. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9610. };
  9611. var attachedElement = null;
  9612. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9613. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9614. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9615. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9616. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9617. }
  9618. pickedMesh = _this._ownerNode;
  9619. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9620. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9621. // Set position and orientation of the controller
  9622. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9623. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9624. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9625. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9626. pickedMesh.computeWorldMatrix();
  9627. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9628. if (!pickedMesh.rotationQuaternion) {
  9629. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9630. }
  9631. var oldParent = pickedMesh.parent;
  9632. pickedMesh.setParent(null);
  9633. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9634. pickedMesh.setParent(oldParent);
  9635. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9636. // Update state
  9637. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9638. _this.dragging = true;
  9639. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9640. // Detatch camera controls
  9641. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9642. if (_this._scene.activeCamera.inputs.attachedElement) {
  9643. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9644. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9645. }
  9646. else {
  9647. attachedElement = null;
  9648. }
  9649. }
  9650. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9651. _this.onDragStartObservable.notifyObservers({});
  9652. }
  9653. }
  9654. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9655. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9656. _this.dragging = false;
  9657. _this._moving = false;
  9658. _this.currentDraggingPointerID = -1;
  9659. pickedMesh = null;
  9660. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9661. // Reattach camera controls
  9662. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9663. _this._scene.activeCamera.attachControl(attachedElement, true);
  9664. }
  9665. _this.onDragEndObservable.notifyObservers({});
  9666. }
  9667. }
  9668. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9669. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9670. var zDragFactor = _this.zDragFactor;
  9671. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9672. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9673. zDragFactor = 0;
  9674. }
  9675. // Calculate controller drag distance in controller space
  9676. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9677. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9678. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9679. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9680. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9681. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9682. if (_this._virtualDragMesh.position.z < 0) {
  9683. _this._virtualDragMesh.position.z = 0;
  9684. }
  9685. // Update the controller position
  9686. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9687. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9688. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9689. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9690. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9691. if (pickedMesh.parent) {
  9692. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9693. }
  9694. if (!_this._moving) {
  9695. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9696. }
  9697. _this._moving = true;
  9698. }
  9699. }
  9700. });
  9701. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9702. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9703. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9704. if (_this.dragging && _this._moving && pickedMesh) {
  9705. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9706. // Slowly move mesh to avoid jitter
  9707. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9708. if (_this.rotateDraggedObject) {
  9709. // Get change in rotation
  9710. tmpQuaternion.copyFrom(_this._startingOrientation);
  9711. tmpQuaternion.x = -tmpQuaternion.x;
  9712. tmpQuaternion.y = -tmpQuaternion.y;
  9713. tmpQuaternion.z = -tmpQuaternion.z;
  9714. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9715. // Convert change in rotation to only y axis rotation
  9716. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9717. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9718. // Slowly move mesh to avoid jitter
  9719. var oldParent = pickedMesh.parent;
  9720. // Only rotate the mesh if it's parent has uniform scaling
  9721. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9722. pickedMesh.setParent(null);
  9723. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9724. pickedMesh.setParent(oldParent);
  9725. }
  9726. }
  9727. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9728. }
  9729. });
  9730. };
  9731. /**
  9732. * Detaches the behavior from the mesh
  9733. */
  9734. SixDofDragBehavior.prototype.detach = function () {
  9735. if (this._scene) {
  9736. this._scene.onPointerObservable.remove(this._pointerObserver);
  9737. }
  9738. if (this._ownerNode) {
  9739. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9740. }
  9741. if (this._virtualOriginMesh) {
  9742. this._virtualOriginMesh.dispose();
  9743. }
  9744. if (this._virtualDragMesh) {
  9745. this._virtualDragMesh.dispose();
  9746. }
  9747. this.onDragEndObservable.clear();
  9748. this.onDragStartObservable.clear();
  9749. };
  9750. return SixDofDragBehavior;
  9751. }());
  9752. /***/ }),
  9753. /***/ "./Behaviors/index.ts":
  9754. /*!****************************!*\
  9755. !*** ./Behaviors/index.ts ***!
  9756. \****************************/
  9757. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior */
  9758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9759. "use strict";
  9760. __webpack_require__.r(__webpack_exports__);
  9761. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9765. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9771. /***/ }),
  9772. /***/ "./Bones/bone.ts":
  9773. /*!***********************!*\
  9774. !*** ./Bones/bone.ts ***!
  9775. \***********************/
  9776. /*! exports provided: Bone */
  9777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9778. "use strict";
  9779. __webpack_require__.r(__webpack_exports__);
  9780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9781. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9782. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9783. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9784. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9785. /**
  9786. * Class used to store bone information
  9787. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9788. */
  9789. var Bone = /** @class */ (function (_super) {
  9790. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9791. /**
  9792. * Create a new bone
  9793. * @param name defines the bone name
  9794. * @param skeleton defines the parent skeleton
  9795. * @param parentBone defines the parent (can be null if the bone is the root)
  9796. * @param localMatrix defines the local matrix
  9797. * @param restPose defines the rest pose matrix
  9798. * @param baseMatrix defines the base matrix
  9799. * @param index defines index of the bone in the hiearchy
  9800. */
  9801. function Bone(
  9802. /**
  9803. * defines the bone name
  9804. */
  9805. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9806. if (parentBone === void 0) { parentBone = null; }
  9807. if (localMatrix === void 0) { localMatrix = null; }
  9808. if (restPose === void 0) { restPose = null; }
  9809. if (baseMatrix === void 0) { baseMatrix = null; }
  9810. if (index === void 0) { index = null; }
  9811. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9812. _this.name = name;
  9813. /**
  9814. * Gets the list of child bones
  9815. */
  9816. _this.children = new Array();
  9817. /** Gets the animations associated with this bone */
  9818. _this.animations = new Array();
  9819. /**
  9820. * @hidden Internal only
  9821. * Set this value to map this bone to a different index in the transform matrices
  9822. * Set this value to -1 to exclude the bone from the transform matrices
  9823. */
  9824. _this._index = null;
  9825. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9826. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9827. _this._scalingDeterminant = 1;
  9828. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9829. _this._needToDecompose = true;
  9830. _this._needToCompose = false;
  9831. /** @hidden */
  9832. _this._linkedTransformNode = null;
  9833. _this._skeleton = skeleton;
  9834. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9835. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9836. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9837. _this._index = index;
  9838. skeleton.bones.push(_this);
  9839. _this.setParent(parentBone, false);
  9840. if (baseMatrix || localMatrix) {
  9841. _this._updateDifferenceMatrix();
  9842. }
  9843. return _this;
  9844. }
  9845. Object.defineProperty(Bone.prototype, "_matrix", {
  9846. /** @hidden */
  9847. get: function () {
  9848. this._compose();
  9849. return this._localMatrix;
  9850. },
  9851. /** @hidden */
  9852. set: function (value) {
  9853. this._localMatrix.copyFrom(value);
  9854. this._needToDecompose = true;
  9855. },
  9856. enumerable: true,
  9857. configurable: true
  9858. });
  9859. /**
  9860. * Gets the current object class name.
  9861. * @return the class name
  9862. */
  9863. Bone.prototype.getClassName = function () {
  9864. return "Bone";
  9865. };
  9866. // Members
  9867. /**
  9868. * Gets the parent skeleton
  9869. * @returns a skeleton
  9870. */
  9871. Bone.prototype.getSkeleton = function () {
  9872. return this._skeleton;
  9873. };
  9874. /**
  9875. * Gets parent bone
  9876. * @returns a bone or null if the bone is the root of the bone hierarchy
  9877. */
  9878. Bone.prototype.getParent = function () {
  9879. return this._parent;
  9880. };
  9881. /**
  9882. * Returns an array containing the root bones
  9883. * @returns an array containing the root bones
  9884. */
  9885. Bone.prototype.getChildren = function () {
  9886. return this.children;
  9887. };
  9888. /**
  9889. * Sets the parent bone
  9890. * @param parent defines the parent (can be null if the bone is the root)
  9891. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9892. */
  9893. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9894. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9895. if (this._parent === parent) {
  9896. return;
  9897. }
  9898. if (this._parent) {
  9899. var index = this._parent.children.indexOf(this);
  9900. if (index !== -1) {
  9901. this._parent.children.splice(index, 1);
  9902. }
  9903. }
  9904. this._parent = parent;
  9905. if (this._parent) {
  9906. this._parent.children.push(this);
  9907. }
  9908. if (updateDifferenceMatrix) {
  9909. this._updateDifferenceMatrix();
  9910. }
  9911. this.markAsDirty();
  9912. };
  9913. /**
  9914. * Gets the local matrix
  9915. * @returns a matrix
  9916. */
  9917. Bone.prototype.getLocalMatrix = function () {
  9918. this._compose();
  9919. return this._localMatrix;
  9920. };
  9921. /**
  9922. * Gets the base matrix (initial matrix which remains unchanged)
  9923. * @returns a matrix
  9924. */
  9925. Bone.prototype.getBaseMatrix = function () {
  9926. return this._baseMatrix;
  9927. };
  9928. /**
  9929. * Gets the rest pose matrix
  9930. * @returns a matrix
  9931. */
  9932. Bone.prototype.getRestPose = function () {
  9933. return this._restPose;
  9934. };
  9935. /**
  9936. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9937. */
  9938. Bone.prototype.getWorldMatrix = function () {
  9939. return this._worldTransform;
  9940. };
  9941. /**
  9942. * Sets the local matrix to rest pose matrix
  9943. */
  9944. Bone.prototype.returnToRest = function () {
  9945. this.updateMatrix(this._restPose.clone());
  9946. };
  9947. /**
  9948. * Gets the inverse of the absolute transform matrix.
  9949. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9950. * @returns a matrix
  9951. */
  9952. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9953. return this._invertedAbsoluteTransform;
  9954. };
  9955. /**
  9956. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9957. * @returns a matrix
  9958. */
  9959. Bone.prototype.getAbsoluteTransform = function () {
  9960. return this._absoluteTransform;
  9961. };
  9962. /**
  9963. * Links with the given transform node.
  9964. * The local matrix of this bone is copied from the transform node every frame.
  9965. * @param transformNode defines the transform node to link to
  9966. */
  9967. Bone.prototype.linkTransformNode = function (transformNode) {
  9968. if (this._linkedTransformNode) {
  9969. this._skeleton._numBonesWithLinkedTransformNode--;
  9970. }
  9971. this._linkedTransformNode = transformNode;
  9972. if (this._linkedTransformNode) {
  9973. this._skeleton._numBonesWithLinkedTransformNode++;
  9974. }
  9975. };
  9976. Object.defineProperty(Bone.prototype, "position", {
  9977. // Properties (matches AbstractMesh properties)
  9978. /** Gets or sets current position (in local space) */
  9979. get: function () {
  9980. this._decompose();
  9981. return this._localPosition;
  9982. },
  9983. set: function (newPosition) {
  9984. this._decompose();
  9985. this._localPosition.copyFrom(newPosition);
  9986. this._markAsDirtyAndCompose();
  9987. },
  9988. enumerable: true,
  9989. configurable: true
  9990. });
  9991. Object.defineProperty(Bone.prototype, "rotation", {
  9992. /** Gets or sets current rotation (in local space) */
  9993. get: function () {
  9994. return this.getRotation();
  9995. },
  9996. set: function (newRotation) {
  9997. this.setRotation(newRotation);
  9998. },
  9999. enumerable: true,
  10000. configurable: true
  10001. });
  10002. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  10003. /** Gets or sets current rotation quaternion (in local space) */
  10004. get: function () {
  10005. this._decompose();
  10006. return this._localRotation;
  10007. },
  10008. set: function (newRotation) {
  10009. this.setRotationQuaternion(newRotation);
  10010. },
  10011. enumerable: true,
  10012. configurable: true
  10013. });
  10014. Object.defineProperty(Bone.prototype, "scaling", {
  10015. /** Gets or sets current scaling (in local space) */
  10016. get: function () {
  10017. return this.getScale();
  10018. },
  10019. set: function (newScaling) {
  10020. this.setScale(newScaling);
  10021. },
  10022. enumerable: true,
  10023. configurable: true
  10024. });
  10025. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  10026. /**
  10027. * Gets the animation properties override
  10028. */
  10029. get: function () {
  10030. return this._skeleton.animationPropertiesOverride;
  10031. },
  10032. enumerable: true,
  10033. configurable: true
  10034. });
  10035. // Methods
  10036. Bone.prototype._decompose = function () {
  10037. if (!this._needToDecompose) {
  10038. return;
  10039. }
  10040. this._needToDecompose = false;
  10041. if (!this._localScaling) {
  10042. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10043. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  10044. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10045. }
  10046. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  10047. };
  10048. Bone.prototype._compose = function () {
  10049. if (!this._needToCompose) {
  10050. return;
  10051. }
  10052. this._needToCompose = false;
  10053. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  10054. };
  10055. /**
  10056. * Update the base and local matrices
  10057. * @param matrix defines the new base or local matrix
  10058. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10059. * @param updateLocalMatrix defines if the local matrix should be updated
  10060. */
  10061. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10062. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10063. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10064. this._baseMatrix.copyFrom(matrix);
  10065. if (updateDifferenceMatrix) {
  10066. this._updateDifferenceMatrix();
  10067. }
  10068. if (updateLocalMatrix) {
  10069. this._localMatrix.copyFrom(matrix);
  10070. this._markAsDirtyAndDecompose();
  10071. }
  10072. else {
  10073. this.markAsDirty();
  10074. }
  10075. };
  10076. /** @hidden */
  10077. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10078. if (updateChildren === void 0) { updateChildren = true; }
  10079. if (!rootMatrix) {
  10080. rootMatrix = this._baseMatrix;
  10081. }
  10082. if (this._parent) {
  10083. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10084. }
  10085. else {
  10086. this._absoluteTransform.copyFrom(rootMatrix);
  10087. }
  10088. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10089. if (updateChildren) {
  10090. for (var index = 0; index < this.children.length; index++) {
  10091. this.children[index]._updateDifferenceMatrix();
  10092. }
  10093. }
  10094. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10095. };
  10096. /**
  10097. * Flag the bone as dirty (Forcing it to update everything)
  10098. */
  10099. Bone.prototype.markAsDirty = function () {
  10100. this._currentRenderId++;
  10101. this._childUpdateId++;
  10102. this._skeleton._markAsDirty();
  10103. };
  10104. Bone.prototype._markAsDirtyAndCompose = function () {
  10105. this.markAsDirty();
  10106. this._needToCompose = true;
  10107. };
  10108. Bone.prototype._markAsDirtyAndDecompose = function () {
  10109. this.markAsDirty();
  10110. this._needToDecompose = true;
  10111. };
  10112. /**
  10113. * Translate the bone in local or world space
  10114. * @param vec The amount to translate the bone
  10115. * @param space The space that the translation is in
  10116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10117. */
  10118. Bone.prototype.translate = function (vec, space, mesh) {
  10119. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10120. var lm = this.getLocalMatrix();
  10121. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10122. lm.addAtIndex(12, vec.x);
  10123. lm.addAtIndex(13, vec.y);
  10124. lm.addAtIndex(14, vec.z);
  10125. }
  10126. else {
  10127. var wm = null;
  10128. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10129. if (mesh) {
  10130. wm = mesh.getWorldMatrix();
  10131. }
  10132. this._skeleton.computeAbsoluteTransforms();
  10133. var tmat = Bone._tmpMats[0];
  10134. var tvec = Bone._tmpVecs[0];
  10135. if (this._parent) {
  10136. if (mesh && wm) {
  10137. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10138. tmat.multiplyToRef(wm, tmat);
  10139. }
  10140. else {
  10141. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10142. }
  10143. }
  10144. tmat.setTranslationFromFloats(0, 0, 0);
  10145. tmat.invert();
  10146. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10147. lm.addAtIndex(12, tvec.x);
  10148. lm.addAtIndex(13, tvec.y);
  10149. lm.addAtIndex(14, tvec.z);
  10150. }
  10151. this._markAsDirtyAndDecompose();
  10152. };
  10153. /**
  10154. * Set the postion of the bone in local or world space
  10155. * @param position The position to set the bone
  10156. * @param space The space that the position is in
  10157. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10158. */
  10159. Bone.prototype.setPosition = function (position, space, mesh) {
  10160. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10161. var lm = this.getLocalMatrix();
  10162. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10163. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10164. }
  10165. else {
  10166. var wm = null;
  10167. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10168. if (mesh) {
  10169. wm = mesh.getWorldMatrix();
  10170. }
  10171. this._skeleton.computeAbsoluteTransforms();
  10172. var tmat = Bone._tmpMats[0];
  10173. var vec = Bone._tmpVecs[0];
  10174. if (this._parent) {
  10175. if (mesh && wm) {
  10176. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10177. tmat.multiplyToRef(wm, tmat);
  10178. }
  10179. else {
  10180. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10181. }
  10182. }
  10183. tmat.invert();
  10184. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10185. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10186. }
  10187. this._markAsDirtyAndDecompose();
  10188. };
  10189. /**
  10190. * Set the absolute position of the bone (world space)
  10191. * @param position The position to set the bone
  10192. * @param mesh The mesh that this bone is attached to
  10193. */
  10194. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10195. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10196. };
  10197. /**
  10198. * Scale the bone on the x, y and z axes (in local space)
  10199. * @param x The amount to scale the bone on the x axis
  10200. * @param y The amount to scale the bone on the y axis
  10201. * @param z The amount to scale the bone on the z axis
  10202. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10203. */
  10204. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10205. if (scaleChildren === void 0) { scaleChildren = false; }
  10206. var locMat = this.getLocalMatrix();
  10207. // Apply new scaling on top of current local matrix
  10208. var scaleMat = Bone._tmpMats[0];
  10209. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10210. scaleMat.multiplyToRef(locMat, locMat);
  10211. // Invert scaling matrix and apply the inverse to all children
  10212. scaleMat.invert();
  10213. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10214. var child = _a[_i];
  10215. var cm = child.getLocalMatrix();
  10216. cm.multiplyToRef(scaleMat, cm);
  10217. cm.multiplyAtIndex(12, x);
  10218. cm.multiplyAtIndex(13, y);
  10219. cm.multiplyAtIndex(14, z);
  10220. child._markAsDirtyAndDecompose();
  10221. }
  10222. this._markAsDirtyAndDecompose();
  10223. if (scaleChildren) {
  10224. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10225. var child = _c[_b];
  10226. child.scale(x, y, z, scaleChildren);
  10227. }
  10228. }
  10229. };
  10230. /**
  10231. * Set the bone scaling in local space
  10232. * @param scale defines the scaling vector
  10233. */
  10234. Bone.prototype.setScale = function (scale) {
  10235. this._decompose();
  10236. this._localScaling.copyFrom(scale);
  10237. this._markAsDirtyAndCompose();
  10238. };
  10239. /**
  10240. * Gets the current scaling in local space
  10241. * @returns the current scaling vector
  10242. */
  10243. Bone.prototype.getScale = function () {
  10244. this._decompose();
  10245. return this._localScaling;
  10246. };
  10247. /**
  10248. * Gets the current scaling in local space and stores it in a target vector
  10249. * @param result defines the target vector
  10250. */
  10251. Bone.prototype.getScaleToRef = function (result) {
  10252. this._decompose();
  10253. result.copyFrom(this._localScaling);
  10254. };
  10255. /**
  10256. * Set the yaw, pitch, and roll of the bone in local or world space
  10257. * @param yaw The rotation of the bone on the y axis
  10258. * @param pitch The rotation of the bone on the x axis
  10259. * @param roll The rotation of the bone on the z axis
  10260. * @param space The space that the axes of rotation are in
  10261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10262. */
  10263. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10264. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10265. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10266. var quat = Bone._tmpQuat;
  10267. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10268. this.setRotationQuaternion(quat, space, mesh);
  10269. return;
  10270. }
  10271. var rotMatInv = Bone._tmpMats[0];
  10272. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10273. return;
  10274. }
  10275. var rotMat = Bone._tmpMats[1];
  10276. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10277. rotMatInv.multiplyToRef(rotMat, rotMat);
  10278. this._rotateWithMatrix(rotMat, space, mesh);
  10279. };
  10280. /**
  10281. * Add a rotation to the bone on an axis in local or world space
  10282. * @param axis The axis to rotate the bone on
  10283. * @param amount The amount to rotate the bone
  10284. * @param space The space that the axis is in
  10285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10286. */
  10287. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10288. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10289. var rmat = Bone._tmpMats[0];
  10290. rmat.setTranslationFromFloats(0, 0, 0);
  10291. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10292. this._rotateWithMatrix(rmat, space, mesh);
  10293. };
  10294. /**
  10295. * Set the rotation of the bone to a particular axis angle in local or world space
  10296. * @param axis The axis to rotate the bone on
  10297. * @param angle The angle that the bone should be rotated to
  10298. * @param space The space that the axis is in
  10299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10300. */
  10301. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10302. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10303. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10304. var quat = Bone._tmpQuat;
  10305. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10306. this.setRotationQuaternion(quat, space, mesh);
  10307. return;
  10308. }
  10309. var rotMatInv = Bone._tmpMats[0];
  10310. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10311. return;
  10312. }
  10313. var rotMat = Bone._tmpMats[1];
  10314. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10315. rotMatInv.multiplyToRef(rotMat, rotMat);
  10316. this._rotateWithMatrix(rotMat, space, mesh);
  10317. };
  10318. /**
  10319. * Set the euler rotation of the bone in local of world space
  10320. * @param rotation The euler rotation that the bone should be set to
  10321. * @param space The space that the rotation is in
  10322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10323. */
  10324. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10325. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10326. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10327. };
  10328. /**
  10329. * Set the quaternion rotation of the bone in local of world space
  10330. * @param quat The quaternion rotation that the bone should be set to
  10331. * @param space The space that the rotation is in
  10332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10333. */
  10334. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10335. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10336. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10337. this._decompose();
  10338. this._localRotation.copyFrom(quat);
  10339. this._markAsDirtyAndCompose();
  10340. return;
  10341. }
  10342. var rotMatInv = Bone._tmpMats[0];
  10343. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10344. return;
  10345. }
  10346. var rotMat = Bone._tmpMats[1];
  10347. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10348. rotMatInv.multiplyToRef(rotMat, rotMat);
  10349. this._rotateWithMatrix(rotMat, space, mesh);
  10350. };
  10351. /**
  10352. * Set the rotation matrix of the bone in local of world space
  10353. * @param rotMat The rotation matrix that the bone should be set to
  10354. * @param space The space that the rotation is in
  10355. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10356. */
  10357. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10358. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10359. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10360. var quat = Bone._tmpQuat;
  10361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10362. this.setRotationQuaternion(quat, space, mesh);
  10363. return;
  10364. }
  10365. var rotMatInv = Bone._tmpMats[0];
  10366. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10367. return;
  10368. }
  10369. var rotMat2 = Bone._tmpMats[1];
  10370. rotMat2.copyFrom(rotMat);
  10371. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10372. this._rotateWithMatrix(rotMat2, space, mesh);
  10373. };
  10374. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10375. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10376. var lmat = this.getLocalMatrix();
  10377. var lx = lmat.m[12];
  10378. var ly = lmat.m[13];
  10379. var lz = lmat.m[14];
  10380. var parent = this.getParent();
  10381. var parentScale = Bone._tmpMats[3];
  10382. var parentScaleInv = Bone._tmpMats[4];
  10383. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10384. if (mesh) {
  10385. parentScale.copyFrom(mesh.getWorldMatrix());
  10386. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10387. }
  10388. else {
  10389. parentScale.copyFrom(parent.getAbsoluteTransform());
  10390. }
  10391. parentScaleInv.copyFrom(parentScale);
  10392. parentScaleInv.invert();
  10393. lmat.multiplyToRef(parentScale, lmat);
  10394. lmat.multiplyToRef(rmat, lmat);
  10395. lmat.multiplyToRef(parentScaleInv, lmat);
  10396. }
  10397. else {
  10398. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10399. parentScale.copyFrom(mesh.getWorldMatrix());
  10400. parentScaleInv.copyFrom(parentScale);
  10401. parentScaleInv.invert();
  10402. lmat.multiplyToRef(parentScale, lmat);
  10403. lmat.multiplyToRef(rmat, lmat);
  10404. lmat.multiplyToRef(parentScaleInv, lmat);
  10405. }
  10406. else {
  10407. lmat.multiplyToRef(rmat, lmat);
  10408. }
  10409. }
  10410. lmat.setTranslationFromFloats(lx, ly, lz);
  10411. this.computeAbsoluteTransforms();
  10412. this._markAsDirtyAndDecompose();
  10413. };
  10414. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10415. var scaleMatrix = Bone._tmpMats[2];
  10416. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10417. if (mesh) {
  10418. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10419. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10420. }
  10421. rotMatInv.invert();
  10422. if (isNaN(rotMatInv.m[0])) {
  10423. // Matrix failed to invert.
  10424. // This can happen if scale is zero for example.
  10425. return false;
  10426. }
  10427. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10428. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10429. return true;
  10430. };
  10431. /**
  10432. * Get the position of the bone in local or world space
  10433. * @param space The space that the returned position is in
  10434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10435. * @returns The position of the bone
  10436. */
  10437. Bone.prototype.getPosition = function (space, mesh) {
  10438. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10439. if (mesh === void 0) { mesh = null; }
  10440. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10441. this.getPositionToRef(space, mesh, pos);
  10442. return pos;
  10443. };
  10444. /**
  10445. * Copy the position of the bone to a vector3 in local or world space
  10446. * @param space The space that the returned position is in
  10447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10448. * @param result The vector3 to copy the position to
  10449. */
  10450. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10451. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10452. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10453. var lm = this.getLocalMatrix();
  10454. result.x = lm.m[12];
  10455. result.y = lm.m[13];
  10456. result.z = lm.m[14];
  10457. }
  10458. else {
  10459. var wm = null;
  10460. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10461. if (mesh) {
  10462. wm = mesh.getWorldMatrix();
  10463. }
  10464. this._skeleton.computeAbsoluteTransforms();
  10465. var tmat = Bone._tmpMats[0];
  10466. if (mesh && wm) {
  10467. tmat.copyFrom(this.getAbsoluteTransform());
  10468. tmat.multiplyToRef(wm, tmat);
  10469. }
  10470. else {
  10471. tmat = this.getAbsoluteTransform();
  10472. }
  10473. result.x = tmat.m[12];
  10474. result.y = tmat.m[13];
  10475. result.z = tmat.m[14];
  10476. }
  10477. };
  10478. /**
  10479. * Get the absolute position of the bone (world space)
  10480. * @param mesh The mesh that this bone is attached to
  10481. * @returns The absolute position of the bone
  10482. */
  10483. Bone.prototype.getAbsolutePosition = function (mesh) {
  10484. if (mesh === void 0) { mesh = null; }
  10485. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10486. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10487. return pos;
  10488. };
  10489. /**
  10490. * Copy the absolute position of the bone (world space) to the result param
  10491. * @param mesh The mesh that this bone is attached to
  10492. * @param result The vector3 to copy the absolute position to
  10493. */
  10494. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10495. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10496. };
  10497. /**
  10498. * Compute the absolute transforms of this bone and its children
  10499. */
  10500. Bone.prototype.computeAbsoluteTransforms = function () {
  10501. this._compose();
  10502. if (this._parent) {
  10503. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10504. }
  10505. else {
  10506. this._absoluteTransform.copyFrom(this._localMatrix);
  10507. var poseMatrix = this._skeleton.getPoseMatrix();
  10508. if (poseMatrix) {
  10509. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10510. }
  10511. }
  10512. var children = this.children;
  10513. var len = children.length;
  10514. for (var i = 0; i < len; i++) {
  10515. children[i].computeAbsoluteTransforms();
  10516. }
  10517. };
  10518. /**
  10519. * Get the world direction from an axis that is in the local space of the bone
  10520. * @param localAxis The local direction that is used to compute the world direction
  10521. * @param mesh The mesh that this bone is attached to
  10522. * @returns The world direction
  10523. */
  10524. Bone.prototype.getDirection = function (localAxis, mesh) {
  10525. if (mesh === void 0) { mesh = null; }
  10526. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10527. this.getDirectionToRef(localAxis, mesh, result);
  10528. return result;
  10529. };
  10530. /**
  10531. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10532. * @param localAxis The local direction that is used to compute the world direction
  10533. * @param mesh The mesh that this bone is attached to
  10534. * @param result The vector3 that the world direction will be copied to
  10535. */
  10536. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10537. if (mesh === void 0) { mesh = null; }
  10538. var wm = null;
  10539. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10540. if (mesh) {
  10541. wm = mesh.getWorldMatrix();
  10542. }
  10543. this._skeleton.computeAbsoluteTransforms();
  10544. var mat = Bone._tmpMats[0];
  10545. mat.copyFrom(this.getAbsoluteTransform());
  10546. if (mesh && wm) {
  10547. mat.multiplyToRef(wm, mat);
  10548. }
  10549. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10550. result.normalize();
  10551. };
  10552. /**
  10553. * Get the euler rotation of the bone in local or world space
  10554. * @param space The space that the rotation should be in
  10555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10556. * @returns The euler rotation
  10557. */
  10558. Bone.prototype.getRotation = function (space, mesh) {
  10559. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10560. if (mesh === void 0) { mesh = null; }
  10561. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10562. this.getRotationToRef(space, mesh, result);
  10563. return result;
  10564. };
  10565. /**
  10566. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10567. * @param space The space that the rotation should be in
  10568. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10569. * @param result The vector3 that the rotation should be copied to
  10570. */
  10571. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10572. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10573. if (mesh === void 0) { mesh = null; }
  10574. var quat = Bone._tmpQuat;
  10575. this.getRotationQuaternionToRef(space, mesh, quat);
  10576. quat.toEulerAnglesToRef(result);
  10577. };
  10578. /**
  10579. * Get the quaternion rotation of the bone in either local or world space
  10580. * @param space The space that the rotation should be in
  10581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10582. * @returns The quaternion rotation
  10583. */
  10584. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10585. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10586. if (mesh === void 0) { mesh = null; }
  10587. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10588. this.getRotationQuaternionToRef(space, mesh, result);
  10589. return result;
  10590. };
  10591. /**
  10592. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10593. * @param space The space that the rotation should be in
  10594. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10595. * @param result The quaternion that the rotation should be copied to
  10596. */
  10597. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10598. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10599. if (mesh === void 0) { mesh = null; }
  10600. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10601. this._decompose();
  10602. result.copyFrom(this._localRotation);
  10603. }
  10604. else {
  10605. var mat = Bone._tmpMats[0];
  10606. var amat = this.getAbsoluteTransform();
  10607. if (mesh) {
  10608. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10609. }
  10610. else {
  10611. mat.copyFrom(amat);
  10612. }
  10613. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10614. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10615. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10616. mat.decompose(undefined, result, undefined);
  10617. }
  10618. };
  10619. /**
  10620. * Get the rotation matrix of the bone in local or world space
  10621. * @param space The space that the rotation should be in
  10622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10623. * @returns The rotation matrix
  10624. */
  10625. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10626. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10627. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10628. this.getRotationMatrixToRef(space, mesh, result);
  10629. return result;
  10630. };
  10631. /**
  10632. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10633. * @param space The space that the rotation should be in
  10634. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10635. * @param result The quaternion that the rotation should be copied to
  10636. */
  10637. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10638. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10639. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10640. this.getLocalMatrix().getRotationMatrixToRef(result);
  10641. }
  10642. else {
  10643. var mat = Bone._tmpMats[0];
  10644. var amat = this.getAbsoluteTransform();
  10645. if (mesh) {
  10646. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10647. }
  10648. else {
  10649. mat.copyFrom(amat);
  10650. }
  10651. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10652. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10653. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10654. mat.getRotationMatrixToRef(result);
  10655. }
  10656. };
  10657. /**
  10658. * Get the world position of a point that is in the local space of the bone
  10659. * @param position The local position
  10660. * @param mesh The mesh that this bone is attached to
  10661. * @returns The world position
  10662. */
  10663. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10664. if (mesh === void 0) { mesh = null; }
  10665. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10666. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10667. return result;
  10668. };
  10669. /**
  10670. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10671. * @param position The local position
  10672. * @param mesh The mesh that this bone is attached to
  10673. * @param result The vector3 that the world position should be copied to
  10674. */
  10675. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10676. if (mesh === void 0) { mesh = null; }
  10677. var wm = null;
  10678. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10679. if (mesh) {
  10680. wm = mesh.getWorldMatrix();
  10681. }
  10682. this._skeleton.computeAbsoluteTransforms();
  10683. var tmat = Bone._tmpMats[0];
  10684. if (mesh && wm) {
  10685. tmat.copyFrom(this.getAbsoluteTransform());
  10686. tmat.multiplyToRef(wm, tmat);
  10687. }
  10688. else {
  10689. tmat = this.getAbsoluteTransform();
  10690. }
  10691. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10692. };
  10693. /**
  10694. * Get the local position of a point that is in world space
  10695. * @param position The world position
  10696. * @param mesh The mesh that this bone is attached to
  10697. * @returns The local position
  10698. */
  10699. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10700. if (mesh === void 0) { mesh = null; }
  10701. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10702. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10703. return result;
  10704. };
  10705. /**
  10706. * Get the local position of a point that is in world space and copy it to the result param
  10707. * @param position The world position
  10708. * @param mesh The mesh that this bone is attached to
  10709. * @param result The vector3 that the local position should be copied to
  10710. */
  10711. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10712. if (mesh === void 0) { mesh = null; }
  10713. var wm = null;
  10714. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10715. if (mesh) {
  10716. wm = mesh.getWorldMatrix();
  10717. }
  10718. this._skeleton.computeAbsoluteTransforms();
  10719. var tmat = Bone._tmpMats[0];
  10720. tmat.copyFrom(this.getAbsoluteTransform());
  10721. if (mesh && wm) {
  10722. tmat.multiplyToRef(wm, tmat);
  10723. }
  10724. tmat.invert();
  10725. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10726. };
  10727. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10728. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10729. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10730. return Bone;
  10731. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10732. /***/ }),
  10733. /***/ "./Bones/boneIKController.ts":
  10734. /*!***********************************!*\
  10735. !*** ./Bones/boneIKController.ts ***!
  10736. \***********************************/
  10737. /*! exports provided: BoneIKController */
  10738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10739. "use strict";
  10740. __webpack_require__.r(__webpack_exports__);
  10741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10742. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10743. /**
  10744. * Class used to apply inverse kinematics to bones
  10745. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10746. */
  10747. var BoneIKController = /** @class */ (function () {
  10748. /**
  10749. * Creates a new BoneIKController
  10750. * @param mesh defines the mesh to control
  10751. * @param bone defines the bone to control
  10752. * @param options defines options to set up the controller
  10753. */
  10754. function BoneIKController(mesh, bone, options) {
  10755. /**
  10756. * Gets or sets the target position
  10757. */
  10758. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10759. /**
  10760. * Gets or sets the pole target position
  10761. */
  10762. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10763. /**
  10764. * Gets or sets the pole target local offset
  10765. */
  10766. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10767. /**
  10768. * Gets or sets the pole angle
  10769. */
  10770. this.poleAngle = 0;
  10771. /**
  10772. * 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)
  10773. */
  10774. this.slerpAmount = 1;
  10775. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10776. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10777. this._bone2Ang = Math.PI;
  10778. this._maxAngle = Math.PI;
  10779. this._rightHandedSystem = false;
  10780. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10781. this._slerping = false;
  10782. this._adjustRoll = 0;
  10783. this._bone2 = bone;
  10784. this._bone1 = bone.getParent();
  10785. if (!this._bone1) {
  10786. return;
  10787. }
  10788. this.mesh = mesh;
  10789. var bonePos = bone.getPosition();
  10790. if (bone.getAbsoluteTransform().determinant() > 0) {
  10791. this._rightHandedSystem = true;
  10792. this._bendAxis.x = 0;
  10793. this._bendAxis.y = 0;
  10794. this._bendAxis.z = -1;
  10795. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10796. this._adjustRoll = Math.PI * .5;
  10797. this._bendAxis.z = 1;
  10798. }
  10799. }
  10800. if (this._bone1.length) {
  10801. var boneScale1 = this._bone1.getScale();
  10802. var boneScale2 = this._bone2.getScale();
  10803. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10804. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10805. }
  10806. else if (this._bone1.children[0]) {
  10807. mesh.computeWorldMatrix(true);
  10808. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10809. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10810. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10811. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10812. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10813. }
  10814. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10815. this.maxAngle = Math.PI;
  10816. if (options) {
  10817. if (options.targetMesh) {
  10818. this.targetMesh = options.targetMesh;
  10819. this.targetMesh.computeWorldMatrix(true);
  10820. }
  10821. if (options.poleTargetMesh) {
  10822. this.poleTargetMesh = options.poleTargetMesh;
  10823. this.poleTargetMesh.computeWorldMatrix(true);
  10824. }
  10825. else if (options.poleTargetBone) {
  10826. this.poleTargetBone = options.poleTargetBone;
  10827. }
  10828. else if (this._bone1.getParent()) {
  10829. this.poleTargetBone = this._bone1.getParent();
  10830. }
  10831. if (options.poleTargetLocalOffset) {
  10832. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10833. }
  10834. if (options.poleAngle) {
  10835. this.poleAngle = options.poleAngle;
  10836. }
  10837. if (options.bendAxis) {
  10838. this._bendAxis.copyFrom(options.bendAxis);
  10839. }
  10840. if (options.maxAngle) {
  10841. this.maxAngle = options.maxAngle;
  10842. }
  10843. if (options.slerpAmount) {
  10844. this.slerpAmount = options.slerpAmount;
  10845. }
  10846. }
  10847. }
  10848. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10849. /**
  10850. * Gets or sets maximum allowed angle
  10851. */
  10852. get: function () {
  10853. return this._maxAngle;
  10854. },
  10855. set: function (value) {
  10856. this._setMaxAngle(value);
  10857. },
  10858. enumerable: true,
  10859. configurable: true
  10860. });
  10861. BoneIKController.prototype._setMaxAngle = function (ang) {
  10862. if (ang < 0) {
  10863. ang = 0;
  10864. }
  10865. if (ang > Math.PI || ang == undefined) {
  10866. ang = Math.PI;
  10867. }
  10868. this._maxAngle = ang;
  10869. var a = this._bone1Length;
  10870. var b = this._bone2Length;
  10871. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10872. };
  10873. /**
  10874. * Force the controller to update the bones
  10875. */
  10876. BoneIKController.prototype.update = function () {
  10877. var bone1 = this._bone1;
  10878. if (!bone1) {
  10879. return;
  10880. }
  10881. var target = this.targetPosition;
  10882. var poleTarget = this.poleTargetPosition;
  10883. var mat1 = BoneIKController._tmpMats[0];
  10884. var mat2 = BoneIKController._tmpMats[1];
  10885. if (this.targetMesh) {
  10886. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10887. }
  10888. if (this.poleTargetBone) {
  10889. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10890. }
  10891. else if (this.poleTargetMesh) {
  10892. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10893. }
  10894. var bonePos = BoneIKController._tmpVecs[0];
  10895. var zaxis = BoneIKController._tmpVecs[1];
  10896. var xaxis = BoneIKController._tmpVecs[2];
  10897. var yaxis = BoneIKController._tmpVecs[3];
  10898. var upAxis = BoneIKController._tmpVecs[4];
  10899. var _tmpQuat = BoneIKController._tmpQuat;
  10900. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10901. poleTarget.subtractToRef(bonePos, upAxis);
  10902. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10903. upAxis.y = 1;
  10904. }
  10905. else {
  10906. upAxis.normalize();
  10907. }
  10908. target.subtractToRef(bonePos, yaxis);
  10909. yaxis.normalize();
  10910. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10911. zaxis.normalize();
  10912. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10913. xaxis.normalize();
  10914. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10915. var a = this._bone1Length;
  10916. var b = this._bone2Length;
  10917. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10918. if (this._maxReach > 0) {
  10919. c = Math.min(this._maxReach, c);
  10920. }
  10921. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10922. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10923. if (acosa > 1) {
  10924. acosa = 1;
  10925. }
  10926. if (acosb > 1) {
  10927. acosb = 1;
  10928. }
  10929. if (acosa < -1) {
  10930. acosa = -1;
  10931. }
  10932. if (acosb < -1) {
  10933. acosb = -1;
  10934. }
  10935. var angA = Math.acos(acosa);
  10936. var angB = Math.acos(acosb);
  10937. var angC = -angA - angB;
  10938. if (this._rightHandedSystem) {
  10939. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10940. mat2.multiplyToRef(mat1, mat1);
  10941. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10942. mat2.multiplyToRef(mat1, mat1);
  10943. }
  10944. else {
  10945. var _tmpVec = BoneIKController._tmpVecs[5];
  10946. _tmpVec.copyFrom(this._bendAxis);
  10947. _tmpVec.x *= -1;
  10948. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10949. mat2.multiplyToRef(mat1, mat1);
  10950. }
  10951. if (this.poleAngle) {
  10952. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10953. mat1.multiplyToRef(mat2, mat1);
  10954. }
  10955. if (this._bone1) {
  10956. if (this.slerpAmount < 1) {
  10957. if (!this._slerping) {
  10958. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10959. }
  10960. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10961. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10962. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10963. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10964. this._slerping = true;
  10965. }
  10966. else {
  10967. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10968. this._bone1Mat.copyFrom(mat1);
  10969. this._slerping = false;
  10970. }
  10971. }
  10972. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10973. this._bone2Ang = angC;
  10974. };
  10975. 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()];
  10976. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10977. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10978. return BoneIKController;
  10979. }());
  10980. /***/ }),
  10981. /***/ "./Bones/boneLookController.ts":
  10982. /*!*************************************!*\
  10983. !*** ./Bones/boneLookController.ts ***!
  10984. \*************************************/
  10985. /*! exports provided: BoneLookController */
  10986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10987. "use strict";
  10988. __webpack_require__.r(__webpack_exports__);
  10989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10990. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10991. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10992. /**
  10993. * Class used to make a bone look toward a point in space
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10995. */
  10996. var BoneLookController = /** @class */ (function () {
  10997. /**
  10998. * Create a BoneLookController
  10999. * @param mesh the mesh that the bone belongs to
  11000. * @param bone the bone that will be looking to the target
  11001. * @param target the target Vector3 to look at
  11002. * @param options optional settings:
  11003. * * maxYaw: the maximum angle the bone will yaw to
  11004. * * minYaw: the minimum angle the bone will yaw to
  11005. * * maxPitch: the maximum angle the bone will pitch to
  11006. * * minPitch: the minimum angle the bone will yaw to
  11007. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  11008. * * upAxis: the up axis of the coordinate system
  11009. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  11010. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  11011. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  11012. * * adjustYaw: used to make an adjustment to the yaw of the bone
  11013. * * adjustPitch: used to make an adjustment to the pitch of the bone
  11014. * * adjustRoll: used to make an adjustment to the roll of the bone
  11015. **/
  11016. function BoneLookController(mesh, bone, target, options) {
  11017. /**
  11018. * The up axis of the coordinate system that is used when the bone is rotated
  11019. */
  11020. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  11021. /**
  11022. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  11023. */
  11024. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11025. /**
  11026. * Used to make an adjustment to the yaw of the bone
  11027. */
  11028. this.adjustYaw = 0;
  11029. /**
  11030. * Used to make an adjustment to the pitch of the bone
  11031. */
  11032. this.adjustPitch = 0;
  11033. /**
  11034. * Used to make an adjustment to the roll of the bone
  11035. */
  11036. this.adjustRoll = 0;
  11037. /**
  11038. * 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)
  11039. */
  11040. this.slerpAmount = 1;
  11041. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11042. this._slerping = false;
  11043. this._firstFrameSkipped = false;
  11044. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  11045. this.mesh = mesh;
  11046. this.bone = bone;
  11047. this.target = target;
  11048. if (options) {
  11049. if (options.adjustYaw) {
  11050. this.adjustYaw = options.adjustYaw;
  11051. }
  11052. if (options.adjustPitch) {
  11053. this.adjustPitch = options.adjustPitch;
  11054. }
  11055. if (options.adjustRoll) {
  11056. this.adjustRoll = options.adjustRoll;
  11057. }
  11058. if (options.maxYaw != null) {
  11059. this.maxYaw = options.maxYaw;
  11060. }
  11061. else {
  11062. this.maxYaw = Math.PI;
  11063. }
  11064. if (options.minYaw != null) {
  11065. this.minYaw = options.minYaw;
  11066. }
  11067. else {
  11068. this.minYaw = -Math.PI;
  11069. }
  11070. if (options.maxPitch != null) {
  11071. this.maxPitch = options.maxPitch;
  11072. }
  11073. else {
  11074. this.maxPitch = Math.PI;
  11075. }
  11076. if (options.minPitch != null) {
  11077. this.minPitch = options.minPitch;
  11078. }
  11079. else {
  11080. this.minPitch = -Math.PI;
  11081. }
  11082. if (options.slerpAmount != null) {
  11083. this.slerpAmount = options.slerpAmount;
  11084. }
  11085. if (options.upAxis != null) {
  11086. this.upAxis = options.upAxis;
  11087. }
  11088. if (options.upAxisSpace != null) {
  11089. this.upAxisSpace = options.upAxisSpace;
  11090. }
  11091. if (options.yawAxis != null || options.pitchAxis != null) {
  11092. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11093. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11094. if (options.yawAxis != null) {
  11095. newYawAxis = options.yawAxis.clone();
  11096. newYawAxis.normalize();
  11097. }
  11098. if (options.pitchAxis != null) {
  11099. newPitchAxis = options.pitchAxis.clone();
  11100. newPitchAxis.normalize();
  11101. }
  11102. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11103. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11104. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11105. this._transformYawPitchInv = this._transformYawPitch.clone();
  11106. this._transformYawPitch.invert();
  11107. }
  11108. }
  11109. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11110. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11111. }
  11112. }
  11113. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11114. /**
  11115. * Gets or sets the minimum yaw angle that the bone can look to
  11116. */
  11117. get: function () {
  11118. return this._minYaw;
  11119. },
  11120. set: function (value) {
  11121. this._minYaw = value;
  11122. this._minYawSin = Math.sin(value);
  11123. this._minYawCos = Math.cos(value);
  11124. if (this._maxYaw != null) {
  11125. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11126. this._yawRange = this._maxYaw - this._minYaw;
  11127. }
  11128. },
  11129. enumerable: true,
  11130. configurable: true
  11131. });
  11132. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11133. /**
  11134. * Gets or sets the maximum yaw angle that the bone can look to
  11135. */
  11136. get: function () {
  11137. return this._maxYaw;
  11138. },
  11139. set: function (value) {
  11140. this._maxYaw = value;
  11141. this._maxYawSin = Math.sin(value);
  11142. this._maxYawCos = Math.cos(value);
  11143. if (this._minYaw != null) {
  11144. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11145. this._yawRange = this._maxYaw - this._minYaw;
  11146. }
  11147. },
  11148. enumerable: true,
  11149. configurable: true
  11150. });
  11151. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11152. /**
  11153. * Gets or sets the minimum pitch angle that the bone can look to
  11154. */
  11155. get: function () {
  11156. return this._minPitch;
  11157. },
  11158. set: function (value) {
  11159. this._minPitch = value;
  11160. this._minPitchTan = Math.tan(value);
  11161. },
  11162. enumerable: true,
  11163. configurable: true
  11164. });
  11165. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11166. /**
  11167. * Gets or sets the maximum pitch angle that the bone can look to
  11168. */
  11169. get: function () {
  11170. return this._maxPitch;
  11171. },
  11172. set: function (value) {
  11173. this._maxPitch = value;
  11174. this._maxPitchTan = Math.tan(value);
  11175. },
  11176. enumerable: true,
  11177. configurable: true
  11178. });
  11179. /**
  11180. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11181. */
  11182. BoneLookController.prototype.update = function () {
  11183. //skip the first frame when slerping so that the mesh rotation is correct
  11184. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11185. this._firstFrameSkipped = true;
  11186. return;
  11187. }
  11188. var bone = this.bone;
  11189. var bonePos = BoneLookController._tmpVecs[0];
  11190. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11191. var target = this.target;
  11192. var _tmpMat1 = BoneLookController._tmpMats[0];
  11193. var _tmpMat2 = BoneLookController._tmpMats[1];
  11194. var mesh = this.mesh;
  11195. var parentBone = bone.getParent();
  11196. var upAxis = BoneLookController._tmpVecs[1];
  11197. upAxis.copyFrom(this.upAxis);
  11198. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11199. if (this._transformYawPitch) {
  11200. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11201. }
  11202. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11203. }
  11204. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11205. mesh.getDirectionToRef(upAxis, upAxis);
  11206. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11207. upAxis.normalize();
  11208. }
  11209. }
  11210. var checkYaw = false;
  11211. var checkPitch = false;
  11212. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11213. checkYaw = true;
  11214. }
  11215. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11216. checkPitch = true;
  11217. }
  11218. if (checkYaw || checkPitch) {
  11219. var spaceMat = BoneLookController._tmpMats[2];
  11220. var spaceMatInv = BoneLookController._tmpMats[3];
  11221. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11222. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11223. }
  11224. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11225. spaceMat.copyFrom(mesh.getWorldMatrix());
  11226. }
  11227. else {
  11228. var forwardAxis = BoneLookController._tmpVecs[2];
  11229. forwardAxis.copyFrom(this._fowardAxis);
  11230. if (this._transformYawPitch) {
  11231. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11232. }
  11233. if (parentBone) {
  11234. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11235. }
  11236. else {
  11237. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11238. }
  11239. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11240. rightAxis.normalize();
  11241. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11242. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11243. }
  11244. spaceMat.invertToRef(spaceMatInv);
  11245. var xzlen = null;
  11246. if (checkPitch) {
  11247. var localTarget = BoneLookController._tmpVecs[3];
  11248. target.subtractToRef(bonePos, localTarget);
  11249. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11250. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11251. var pitch = Math.atan2(localTarget.y, xzlen);
  11252. var newPitch = pitch;
  11253. if (pitch > this._maxPitch) {
  11254. localTarget.y = this._maxPitchTan * xzlen;
  11255. newPitch = this._maxPitch;
  11256. }
  11257. else if (pitch < this._minPitch) {
  11258. localTarget.y = this._minPitchTan * xzlen;
  11259. newPitch = this._minPitch;
  11260. }
  11261. if (pitch != newPitch) {
  11262. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11263. localTarget.addInPlace(bonePos);
  11264. target = localTarget;
  11265. }
  11266. }
  11267. if (checkYaw) {
  11268. var localTarget = BoneLookController._tmpVecs[4];
  11269. target.subtractToRef(bonePos, localTarget);
  11270. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11271. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11272. var newYaw = yaw;
  11273. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11274. if (xzlen == null) {
  11275. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11276. }
  11277. if (this._yawRange > Math.PI) {
  11278. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11279. localTarget.z = this._maxYawCos * xzlen;
  11280. localTarget.x = this._maxYawSin * xzlen;
  11281. newYaw = this._maxYaw;
  11282. }
  11283. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11284. localTarget.z = this._minYawCos * xzlen;
  11285. localTarget.x = this._minYawSin * xzlen;
  11286. newYaw = this._minYaw;
  11287. }
  11288. }
  11289. else {
  11290. if (yaw > this._maxYaw) {
  11291. localTarget.z = this._maxYawCos * xzlen;
  11292. localTarget.x = this._maxYawSin * xzlen;
  11293. newYaw = this._maxYaw;
  11294. }
  11295. else if (yaw < this._minYaw) {
  11296. localTarget.z = this._minYawCos * xzlen;
  11297. localTarget.x = this._minYawSin * xzlen;
  11298. newYaw = this._minYaw;
  11299. }
  11300. }
  11301. }
  11302. if (this._slerping && this._yawRange > Math.PI) {
  11303. //are we going to be crossing into the min/max region?
  11304. var boneFwd = BoneLookController._tmpVecs[8];
  11305. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11306. if (this._transformYawPitch) {
  11307. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11308. }
  11309. var boneRotMat = BoneLookController._tmpMats[4];
  11310. this._boneQuat.toRotationMatrix(boneRotMat);
  11311. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11312. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11313. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11314. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11315. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11316. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11317. if (angBtwTar > angBtwMidYaw) {
  11318. if (xzlen == null) {
  11319. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11320. }
  11321. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11322. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11323. if (angBtwMin < angBtwMax) {
  11324. newYaw = boneYaw + Math.PI * .75;
  11325. localTarget.z = Math.cos(newYaw) * xzlen;
  11326. localTarget.x = Math.sin(newYaw) * xzlen;
  11327. }
  11328. else {
  11329. newYaw = boneYaw - Math.PI * .75;
  11330. localTarget.z = Math.cos(newYaw) * xzlen;
  11331. localTarget.x = Math.sin(newYaw) * xzlen;
  11332. }
  11333. }
  11334. }
  11335. if (yaw != newYaw) {
  11336. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11337. localTarget.addInPlace(bonePos);
  11338. target = localTarget;
  11339. }
  11340. }
  11341. }
  11342. var zaxis = BoneLookController._tmpVecs[5];
  11343. var xaxis = BoneLookController._tmpVecs[6];
  11344. var yaxis = BoneLookController._tmpVecs[7];
  11345. var _tmpQuat = BoneLookController._tmpQuat;
  11346. target.subtractToRef(bonePos, zaxis);
  11347. zaxis.normalize();
  11348. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11349. xaxis.normalize();
  11350. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11351. yaxis.normalize();
  11352. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11353. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11354. return;
  11355. }
  11356. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11357. return;
  11358. }
  11359. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11360. return;
  11361. }
  11362. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11363. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11364. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11365. }
  11366. if (this.slerpAmount < 1) {
  11367. if (!this._slerping) {
  11368. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11369. }
  11370. if (this._transformYawPitch) {
  11371. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11372. }
  11373. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11374. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11375. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11376. this._slerping = true;
  11377. }
  11378. else {
  11379. if (this._transformYawPitch) {
  11380. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11381. }
  11382. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11383. this._slerping = false;
  11384. }
  11385. };
  11386. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11387. var angDiff = ang2 - ang1;
  11388. angDiff %= Math.PI * 2;
  11389. if (angDiff > Math.PI) {
  11390. angDiff -= Math.PI * 2;
  11391. }
  11392. else if (angDiff < -Math.PI) {
  11393. angDiff += Math.PI * 2;
  11394. }
  11395. return angDiff;
  11396. };
  11397. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11398. ang1 %= (2 * Math.PI);
  11399. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11400. ang2 %= (2 * Math.PI);
  11401. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11402. var ab = 0;
  11403. if (ang1 < ang2) {
  11404. ab = ang2 - ang1;
  11405. }
  11406. else {
  11407. ab = ang1 - ang2;
  11408. }
  11409. if (ab > Math.PI) {
  11410. ab = Math.PI * 2 - ab;
  11411. }
  11412. return ab;
  11413. };
  11414. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11415. ang %= (2 * Math.PI);
  11416. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11417. ang1 %= (2 * Math.PI);
  11418. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11419. ang2 %= (2 * Math.PI);
  11420. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11421. if (ang1 < ang2) {
  11422. if (ang > ang1 && ang < ang2) {
  11423. return true;
  11424. }
  11425. }
  11426. else {
  11427. if (ang > ang2 && ang < ang1) {
  11428. return true;
  11429. }
  11430. }
  11431. return false;
  11432. };
  11433. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11434. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11435. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11436. return BoneLookController;
  11437. }());
  11438. /***/ }),
  11439. /***/ "./Bones/index.ts":
  11440. /*!************************!*\
  11441. !*** ./Bones/index.ts ***!
  11442. \************************/
  11443. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11444. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11445. "use strict";
  11446. __webpack_require__.r(__webpack_exports__);
  11447. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11449. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11451. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11453. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11455. /***/ }),
  11456. /***/ "./Bones/skeleton.ts":
  11457. /*!***************************!*\
  11458. !*** ./Bones/skeleton.ts ***!
  11459. \***************************/
  11460. /*! exports provided: Skeleton */
  11461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11462. "use strict";
  11463. __webpack_require__.r(__webpack_exports__);
  11464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11465. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11466. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11467. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11468. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11469. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11470. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11471. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11472. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11473. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11474. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11475. /**
  11476. * Class used to handle skinning animations
  11477. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11478. */
  11479. var Skeleton = /** @class */ (function () {
  11480. /**
  11481. * Creates a new skeleton
  11482. * @param name defines the skeleton name
  11483. * @param id defines the skeleton Id
  11484. * @param scene defines the hosting scene
  11485. */
  11486. function Skeleton(
  11487. /** defines the skeleton name */
  11488. name,
  11489. /** defines the skeleton Id */
  11490. id, scene) {
  11491. this.name = name;
  11492. this.id = id;
  11493. /**
  11494. * Defines the list of child bones
  11495. */
  11496. this.bones = new Array();
  11497. /**
  11498. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11499. */
  11500. this.needInitialSkinMatrix = false;
  11501. /**
  11502. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11503. */
  11504. this.overrideMesh = null;
  11505. this._isDirty = true;
  11506. this._meshesWithPoseMatrix = new Array();
  11507. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11508. this._ranges = {};
  11509. this._lastAbsoluteTransformsUpdateId = -1;
  11510. this._canUseTextureForBones = false;
  11511. this._uniqueId = 0;
  11512. /** @hidden */
  11513. this._numBonesWithLinkedTransformNode = 0;
  11514. /**
  11515. * Specifies if the skeleton should be serialized
  11516. */
  11517. this.doNotSerialize = false;
  11518. this._useTextureToStoreBoneMatrices = true;
  11519. this._animationPropertiesOverride = null;
  11520. // Events
  11521. /**
  11522. * An observable triggered before computing the skeleton's matrices
  11523. */
  11524. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11525. this.bones = [];
  11526. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11527. this._uniqueId = this._scene.getUniqueId();
  11528. this._scene.addSkeleton(this);
  11529. //make sure it will recalculate the matrix next time prepare is called.
  11530. this._isDirty = true;
  11531. var engineCaps = this._scene.getEngine().getCaps();
  11532. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11533. }
  11534. Object.defineProperty(Skeleton.prototype, "useTextureToStoreBoneMatrices", {
  11535. /**
  11536. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11537. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11538. */
  11539. get: function () {
  11540. return this._useTextureToStoreBoneMatrices;
  11541. },
  11542. set: function (value) {
  11543. this._useTextureToStoreBoneMatrices = value;
  11544. this._markAsDirty();
  11545. },
  11546. enumerable: true,
  11547. configurable: true
  11548. });
  11549. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11550. /**
  11551. * Gets or sets the animation properties override
  11552. */
  11553. get: function () {
  11554. if (!this._animationPropertiesOverride) {
  11555. return this._scene.animationPropertiesOverride;
  11556. }
  11557. return this._animationPropertiesOverride;
  11558. },
  11559. set: function (value) {
  11560. this._animationPropertiesOverride = value;
  11561. },
  11562. enumerable: true,
  11563. configurable: true
  11564. });
  11565. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11566. /**
  11567. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11568. */
  11569. get: function () {
  11570. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11571. },
  11572. enumerable: true,
  11573. configurable: true
  11574. });
  11575. Object.defineProperty(Skeleton.prototype, "uniqueId", {
  11576. /**
  11577. * Gets the unique ID of this skeleton
  11578. */
  11579. get: function () {
  11580. return this._uniqueId;
  11581. },
  11582. enumerable: true,
  11583. configurable: true
  11584. });
  11585. /**
  11586. * Gets the current object class name.
  11587. * @return the class name
  11588. */
  11589. Skeleton.prototype.getClassName = function () {
  11590. return "Skeleton";
  11591. };
  11592. /**
  11593. * Returns an array containing the root bones
  11594. * @returns an array containing the root bones
  11595. */
  11596. Skeleton.prototype.getChildren = function () {
  11597. return this.bones.filter(function (b) { return !b.getParent(); });
  11598. };
  11599. // Members
  11600. /**
  11601. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11602. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11603. * @returns a Float32Array containing matrices data
  11604. */
  11605. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11606. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11607. return mesh._bonesTransformMatrices;
  11608. }
  11609. if (!this._transformMatrices) {
  11610. this.prepare();
  11611. }
  11612. return this._transformMatrices;
  11613. };
  11614. /**
  11615. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11616. * @returns a raw texture containing the data
  11617. */
  11618. Skeleton.prototype.getTransformMatrixTexture = function () {
  11619. return this._transformMatrixTexture;
  11620. };
  11621. /**
  11622. * Gets the current hosting scene
  11623. * @returns a scene object
  11624. */
  11625. Skeleton.prototype.getScene = function () {
  11626. return this._scene;
  11627. };
  11628. // Methods
  11629. /**
  11630. * Gets a string representing the current skeleton data
  11631. * @param fullDetails defines a boolean indicating if we want a verbose version
  11632. * @returns a string representing the current skeleton data
  11633. */
  11634. Skeleton.prototype.toString = function (fullDetails) {
  11635. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11636. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11637. if (fullDetails) {
  11638. ret += ", Ranges: {";
  11639. var first = true;
  11640. for (var name_1 in this._ranges) {
  11641. if (first) {
  11642. ret += ", ";
  11643. first = false;
  11644. }
  11645. ret += name_1;
  11646. }
  11647. ret += "}";
  11648. }
  11649. return ret;
  11650. };
  11651. /**
  11652. * Get bone's index searching by name
  11653. * @param name defines bone's name to search for
  11654. * @return the indice of the bone. Returns -1 if not found
  11655. */
  11656. Skeleton.prototype.getBoneIndexByName = function (name) {
  11657. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11658. if (this.bones[boneIndex].name === name) {
  11659. return boneIndex;
  11660. }
  11661. }
  11662. return -1;
  11663. };
  11664. /**
  11665. * Creater a new animation range
  11666. * @param name defines the name of the range
  11667. * @param from defines the start key
  11668. * @param to defines the end key
  11669. */
  11670. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11671. // check name not already in use
  11672. if (!this._ranges[name]) {
  11673. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11674. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11675. if (this.bones[i].animations[0]) {
  11676. this.bones[i].animations[0].createRange(name, from, to);
  11677. }
  11678. }
  11679. }
  11680. };
  11681. /**
  11682. * Delete a specific animation range
  11683. * @param name defines the name of the range
  11684. * @param deleteFrames defines if frames must be removed as well
  11685. */
  11686. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11687. if (deleteFrames === void 0) { deleteFrames = true; }
  11688. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11689. if (this.bones[i].animations[0]) {
  11690. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11691. }
  11692. }
  11693. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11694. };
  11695. /**
  11696. * Gets a specific animation range
  11697. * @param name defines the name of the range to look for
  11698. * @returns the requested animation range or null if not found
  11699. */
  11700. Skeleton.prototype.getAnimationRange = function (name) {
  11701. return this._ranges[name];
  11702. };
  11703. /**
  11704. * Gets the list of all animation ranges defined on this skeleton
  11705. * @returns an array
  11706. */
  11707. Skeleton.prototype.getAnimationRanges = function () {
  11708. var animationRanges = [];
  11709. var name;
  11710. for (name in this._ranges) {
  11711. animationRanges.push(this._ranges[name]);
  11712. }
  11713. return animationRanges;
  11714. };
  11715. /**
  11716. * Copy animation range from a source skeleton.
  11717. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11718. * @param source defines the source skeleton
  11719. * @param name defines the name of the range to copy
  11720. * @param rescaleAsRequired defines if rescaling must be applied if required
  11721. * @returns true if operation was successful
  11722. */
  11723. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11724. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11725. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11726. return false;
  11727. }
  11728. var ret = true;
  11729. var frameOffset = this._getHighestAnimationFrame() + 1;
  11730. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11731. var boneDict = {};
  11732. var sourceBones = source.bones;
  11733. var nBones;
  11734. var i;
  11735. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11736. boneDict[sourceBones[i].name] = sourceBones[i];
  11737. }
  11738. if (this.bones.length !== sourceBones.length) {
  11739. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11740. ret = false;
  11741. }
  11742. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11743. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11744. var boneName = this.bones[i].name;
  11745. var sourceBone = boneDict[boneName];
  11746. if (sourceBone) {
  11747. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11748. }
  11749. else {
  11750. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11751. ret = false;
  11752. }
  11753. }
  11754. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11755. var range = source.getAnimationRange(name);
  11756. if (range) {
  11757. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11758. }
  11759. return ret;
  11760. };
  11761. /**
  11762. * Forces the skeleton to go to rest pose
  11763. */
  11764. Skeleton.prototype.returnToRest = function () {
  11765. for (var index = 0; index < this.bones.length; index++) {
  11766. this.bones[index].returnToRest();
  11767. }
  11768. };
  11769. Skeleton.prototype._getHighestAnimationFrame = function () {
  11770. var ret = 0;
  11771. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11772. if (this.bones[i].animations[0]) {
  11773. var highest = this.bones[i].animations[0].getHighestFrame();
  11774. if (ret < highest) {
  11775. ret = highest;
  11776. }
  11777. }
  11778. }
  11779. return ret;
  11780. };
  11781. /**
  11782. * Begin a specific animation range
  11783. * @param name defines the name of the range to start
  11784. * @param loop defines if looping must be turned on (false by default)
  11785. * @param speedRatio defines the speed ratio to apply (1 by default)
  11786. * @param onAnimationEnd defines a callback which will be called when animation will end
  11787. * @returns a new animatable
  11788. */
  11789. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11790. var range = this.getAnimationRange(name);
  11791. if (!range) {
  11792. return null;
  11793. }
  11794. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11795. };
  11796. /** @hidden */
  11797. Skeleton.prototype._markAsDirty = function () {
  11798. this._isDirty = true;
  11799. };
  11800. /** @hidden */
  11801. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11802. this._meshesWithPoseMatrix.push(mesh);
  11803. };
  11804. /** @hidden */
  11805. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11806. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11807. if (index > -1) {
  11808. this._meshesWithPoseMatrix.splice(index, 1);
  11809. }
  11810. };
  11811. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11812. this.onBeforeComputeObservable.notifyObservers(this);
  11813. for (var index = 0; index < this.bones.length; index++) {
  11814. var bone = this.bones[index];
  11815. bone._childUpdateId++;
  11816. var parentBone = bone.getParent();
  11817. if (parentBone) {
  11818. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11819. }
  11820. else {
  11821. if (initialSkinMatrix) {
  11822. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11823. }
  11824. else {
  11825. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11826. }
  11827. }
  11828. if (bone._index !== -1) {
  11829. var mappedIndex = bone._index === null ? index : bone._index;
  11830. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11831. }
  11832. }
  11833. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11834. };
  11835. /**
  11836. * Build all resources required to render a skeleton
  11837. */
  11838. Skeleton.prototype.prepare = function () {
  11839. // Update the local matrix of bones with linked transform nodes.
  11840. if (this._numBonesWithLinkedTransformNode > 0) {
  11841. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11842. var bone_1 = _a[_i];
  11843. if (bone_1._linkedTransformNode) {
  11844. // Computing the world matrix also computes the local matrix.
  11845. bone_1._linkedTransformNode.computeWorldMatrix();
  11846. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11847. bone_1.markAsDirty();
  11848. }
  11849. }
  11850. }
  11851. if (!this._isDirty) {
  11852. return;
  11853. }
  11854. if (this.needInitialSkinMatrix) {
  11855. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11856. var mesh = this._meshesWithPoseMatrix[index];
  11857. var poseMatrix = mesh.getPoseMatrix();
  11858. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11859. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11860. }
  11861. if (this._synchronizedWithMesh !== mesh) {
  11862. this._synchronizedWithMesh = mesh;
  11863. // Prepare bones
  11864. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11865. var bone = this.bones[boneIndex];
  11866. if (!bone.getParent()) {
  11867. var matrix = bone.getBaseMatrix();
  11868. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11869. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11870. }
  11871. }
  11872. }
  11873. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11874. }
  11875. }
  11876. else {
  11877. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11878. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11879. if (this.isUsingTextureForMatrices) {
  11880. if (this._transformMatrixTexture) {
  11881. this._transformMatrixTexture.dispose();
  11882. }
  11883. 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);
  11884. }
  11885. }
  11886. this._computeTransformMatrices(this._transformMatrices, null);
  11887. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11888. this._transformMatrixTexture.update(this._transformMatrices);
  11889. }
  11890. }
  11891. this._isDirty = false;
  11892. this._scene._activeBones.addCount(this.bones.length, false);
  11893. };
  11894. /**
  11895. * Gets the list of animatables currently running for this skeleton
  11896. * @returns an array of animatables
  11897. */
  11898. Skeleton.prototype.getAnimatables = function () {
  11899. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11900. this._animatables = [];
  11901. for (var index = 0; index < this.bones.length; index++) {
  11902. this._animatables.push(this.bones[index]);
  11903. }
  11904. }
  11905. return this._animatables;
  11906. };
  11907. /**
  11908. * Clone the current skeleton
  11909. * @param name defines the name of the new skeleton
  11910. * @param id defines the id of the new skeleton
  11911. * @returns the new skeleton
  11912. */
  11913. Skeleton.prototype.clone = function (name, id) {
  11914. var result = new Skeleton(name, id || name, this._scene);
  11915. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11916. for (var index = 0; index < this.bones.length; index++) {
  11917. var source = this.bones[index];
  11918. var parentBone = null;
  11919. var parent_1 = source.getParent();
  11920. if (parent_1) {
  11921. var parentIndex = this.bones.indexOf(parent_1);
  11922. parentBone = result.bones[parentIndex];
  11923. }
  11924. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11925. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11926. }
  11927. if (this._ranges) {
  11928. result._ranges = {};
  11929. for (var rangeName in this._ranges) {
  11930. var range = this._ranges[rangeName];
  11931. if (range) {
  11932. result._ranges[rangeName] = range.clone();
  11933. }
  11934. }
  11935. }
  11936. this._isDirty = true;
  11937. return result;
  11938. };
  11939. /**
  11940. * Enable animation blending for this skeleton
  11941. * @param blendingSpeed defines the blending speed to apply
  11942. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11943. */
  11944. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11945. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11946. this.bones.forEach(function (bone) {
  11947. bone.animations.forEach(function (animation) {
  11948. animation.enableBlending = true;
  11949. animation.blendingSpeed = blendingSpeed;
  11950. });
  11951. });
  11952. };
  11953. /**
  11954. * Releases all resources associated with the current skeleton
  11955. */
  11956. Skeleton.prototype.dispose = function () {
  11957. this._meshesWithPoseMatrix = [];
  11958. // Animations
  11959. this.getScene().stopAnimation(this);
  11960. // Remove from scene
  11961. this.getScene().removeSkeleton(this);
  11962. if (this._transformMatrixTexture) {
  11963. this._transformMatrixTexture.dispose();
  11964. this._transformMatrixTexture = null;
  11965. }
  11966. };
  11967. /**
  11968. * Serialize the skeleton in a JSON object
  11969. * @returns a JSON object
  11970. */
  11971. Skeleton.prototype.serialize = function () {
  11972. var serializationObject = {};
  11973. serializationObject.name = this.name;
  11974. serializationObject.id = this.id;
  11975. if (this.dimensionsAtRest) {
  11976. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11977. }
  11978. serializationObject.bones = [];
  11979. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11980. for (var index = 0; index < this.bones.length; index++) {
  11981. var bone = this.bones[index];
  11982. var parent_2 = bone.getParent();
  11983. var serializedBone = {
  11984. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11985. name: bone.name,
  11986. matrix: bone.getBaseMatrix().toArray(),
  11987. rest: bone.getRestPose().toArray()
  11988. };
  11989. serializationObject.bones.push(serializedBone);
  11990. if (bone.length) {
  11991. serializedBone.length = bone.length;
  11992. }
  11993. if (bone.metadata) {
  11994. serializedBone.metadata = bone.metadata;
  11995. }
  11996. if (bone.animations && bone.animations.length > 0) {
  11997. serializedBone.animation = bone.animations[0].serialize();
  11998. }
  11999. serializationObject.ranges = [];
  12000. for (var name in this._ranges) {
  12001. var source = this._ranges[name];
  12002. if (!source) {
  12003. continue;
  12004. }
  12005. var range = {};
  12006. range.name = name;
  12007. range.from = source.from;
  12008. range.to = source.to;
  12009. serializationObject.ranges.push(range);
  12010. }
  12011. }
  12012. return serializationObject;
  12013. };
  12014. /**
  12015. * Creates a new skeleton from serialized data
  12016. * @param parsedSkeleton defines the serialized data
  12017. * @param scene defines the hosting scene
  12018. * @returns a new skeleton
  12019. */
  12020. Skeleton.Parse = function (parsedSkeleton, scene) {
  12021. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  12022. if (parsedSkeleton.dimensionsAtRest) {
  12023. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  12024. }
  12025. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  12026. var index;
  12027. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  12028. var parsedBone = parsedSkeleton.bones[index];
  12029. var parentBone = null;
  12030. if (parsedBone.parentBoneIndex > -1) {
  12031. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  12032. }
  12033. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  12034. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  12035. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  12036. bone.id = parsedBone.id;
  12037. }
  12038. if (parsedBone.length) {
  12039. bone.length = parsedBone.length;
  12040. }
  12041. if (parsedBone.metadata) {
  12042. bone.metadata = parsedBone.metadata;
  12043. }
  12044. if (parsedBone.animation) {
  12045. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  12046. }
  12047. }
  12048. // placed after bones, so createAnimationRange can cascade down
  12049. if (parsedSkeleton.ranges) {
  12050. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  12051. var data = parsedSkeleton.ranges[index];
  12052. skeleton.createAnimationRange(data.name, data.from, data.to);
  12053. }
  12054. }
  12055. return skeleton;
  12056. };
  12057. /**
  12058. * Compute all node absolute transforms
  12059. * @param forceUpdate defines if computation must be done even if cache is up to date
  12060. */
  12061. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  12062. if (forceUpdate === void 0) { forceUpdate = false; }
  12063. var renderId = this._scene.getRenderId();
  12064. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  12065. this.bones[0].computeAbsoluteTransforms();
  12066. this._lastAbsoluteTransformsUpdateId = renderId;
  12067. }
  12068. };
  12069. /**
  12070. * Gets the root pose matrix
  12071. * @returns a matrix
  12072. */
  12073. Skeleton.prototype.getPoseMatrix = function () {
  12074. var poseMatrix = null;
  12075. if (this._meshesWithPoseMatrix.length > 0) {
  12076. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  12077. }
  12078. return poseMatrix;
  12079. };
  12080. /**
  12081. * Sorts bones per internal index
  12082. */
  12083. Skeleton.prototype.sortBones = function () {
  12084. var bones = new Array();
  12085. var visited = new Array(this.bones.length);
  12086. for (var index = 0; index < this.bones.length; index++) {
  12087. this._sortBones(index, bones, visited);
  12088. }
  12089. this.bones = bones;
  12090. };
  12091. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12092. if (visited[index]) {
  12093. return;
  12094. }
  12095. visited[index] = true;
  12096. var bone = this.bones[index];
  12097. if (bone._index === undefined) {
  12098. bone._index = index;
  12099. }
  12100. var parentBone = bone.getParent();
  12101. if (parentBone) {
  12102. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12103. }
  12104. bones.push(bone);
  12105. };
  12106. return Skeleton;
  12107. }());
  12108. /***/ }),
  12109. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12110. /*!***************************************************!*\
  12111. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12112. \***************************************************/
  12113. /*! exports provided: BaseCameraPointersInput */
  12114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12115. "use strict";
  12116. __webpack_require__.r(__webpack_exports__);
  12117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12118. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12119. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12120. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12121. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12122. /**
  12123. * Base class for Camera Pointer Inputs.
  12124. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12125. * for example usage.
  12126. */
  12127. var BaseCameraPointersInput = /** @class */ (function () {
  12128. function BaseCameraPointersInput() {
  12129. /**
  12130. * Defines the buttons associated with the input to handle camera move.
  12131. */
  12132. this.buttons = [0, 1, 2];
  12133. }
  12134. /**
  12135. * Attach the input controls to a specific dom element to get the input from.
  12136. * @param element Defines the element the controls should be listened from
  12137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12138. */
  12139. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12140. var _this = this;
  12141. var engine = this.camera.getEngine();
  12142. var previousPinchSquaredDistance = 0;
  12143. var previousMultiTouchPanPosition = null;
  12144. this.pointA = null;
  12145. this.pointB = null;
  12146. this._altKey = false;
  12147. this._ctrlKey = false;
  12148. this._metaKey = false;
  12149. this._shiftKey = false;
  12150. this._buttonsPressed = 0;
  12151. this._pointerInput = function (p, s) {
  12152. var evt = p.event;
  12153. var isTouch = evt.pointerType === "touch";
  12154. if (engine.isInVRExclusivePointerMode) {
  12155. return;
  12156. }
  12157. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12158. _this.buttons.indexOf(evt.button) === -1) {
  12159. return;
  12160. }
  12161. var srcElement = (evt.srcElement || evt.target);
  12162. _this._altKey = evt.altKey;
  12163. _this._ctrlKey = evt.ctrlKey;
  12164. _this._metaKey = evt.metaKey;
  12165. _this._shiftKey = evt.shiftKey;
  12166. _this._buttonsPressed = evt.buttons;
  12167. if (engine.isPointerLock) {
  12168. var offsetX = evt.movementX ||
  12169. evt.mozMovementX ||
  12170. evt.webkitMovementX ||
  12171. evt.msMovementX ||
  12172. 0;
  12173. var offsetY = evt.movementY ||
  12174. evt.mozMovementY ||
  12175. evt.webkitMovementY ||
  12176. evt.msMovementY ||
  12177. 0;
  12178. _this.onTouch(null, offsetX, offsetY);
  12179. _this.pointA = null;
  12180. _this.pointB = null;
  12181. }
  12182. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12183. try {
  12184. srcElement.setPointerCapture(evt.pointerId);
  12185. }
  12186. catch (e) {
  12187. //Nothing to do with the error. Execution will continue.
  12188. }
  12189. if (_this.pointA === null) {
  12190. _this.pointA = { x: evt.clientX,
  12191. y: evt.clientY,
  12192. pointerId: evt.pointerId,
  12193. type: evt.pointerType };
  12194. }
  12195. else if (_this.pointB === null) {
  12196. _this.pointB = { x: evt.clientX,
  12197. y: evt.clientY,
  12198. pointerId: evt.pointerId,
  12199. type: evt.pointerType };
  12200. }
  12201. _this.onButtonDown(evt);
  12202. if (!noPreventDefault) {
  12203. evt.preventDefault();
  12204. element.focus();
  12205. }
  12206. }
  12207. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12208. _this.onDoubleTap(evt.pointerType);
  12209. }
  12210. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12211. try {
  12212. srcElement.releasePointerCapture(evt.pointerId);
  12213. }
  12214. catch (e) {
  12215. //Nothing to do with the error.
  12216. }
  12217. if (!isTouch) {
  12218. _this.pointB = null; // Mouse and pen are mono pointer
  12219. }
  12220. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12221. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12222. //when changing orientation while pinching camera,
  12223. //one pointer stay pressed forever if we don't release all pointers
  12224. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12225. if (engine._badOS) {
  12226. _this.pointA = _this.pointB = null;
  12227. }
  12228. else {
  12229. //only remove the impacted pointer in case of multitouch allowing on most
  12230. //platforms switching from rotate to zoom and pan seamlessly.
  12231. if (_this.pointB && _this.pointA && _this.pointA.pointerId == evt.pointerId) {
  12232. _this.pointA = _this.pointB;
  12233. _this.pointB = null;
  12234. }
  12235. else if (_this.pointA && _this.pointB &&
  12236. _this.pointB.pointerId == evt.pointerId) {
  12237. _this.pointB = null;
  12238. }
  12239. else {
  12240. _this.pointA = _this.pointB = null;
  12241. }
  12242. }
  12243. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12244. // Previous pinch data is populated but a button has been lifted
  12245. // so pinch has ended.
  12246. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12247. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12248. );
  12249. previousPinchSquaredDistance = 0;
  12250. previousMultiTouchPanPosition = null;
  12251. }
  12252. _this.onButtonUp(evt);
  12253. if (!noPreventDefault) {
  12254. evt.preventDefault();
  12255. }
  12256. }
  12257. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12258. if (!noPreventDefault) {
  12259. evt.preventDefault();
  12260. }
  12261. // One button down
  12262. if (_this.pointA && _this.pointB === null) {
  12263. var offsetX = evt.clientX - _this.pointA.x;
  12264. var offsetY = evt.clientY - _this.pointA.y;
  12265. _this.onTouch(_this.pointA, offsetX, offsetY);
  12266. _this.pointA.x = evt.clientX;
  12267. _this.pointA.y = evt.clientY;
  12268. }
  12269. // Two buttons down: pinch
  12270. else if (_this.pointA && _this.pointB) {
  12271. var ed = (_this.pointA.pointerId === evt.pointerId) ?
  12272. _this.pointA : _this.pointB;
  12273. ed.x = evt.clientX;
  12274. ed.y = evt.clientY;
  12275. var distX = _this.pointA.x - _this.pointB.x;
  12276. var distY = _this.pointA.y - _this.pointB.y;
  12277. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12278. var multiTouchPanPosition = { x: (_this.pointA.x + _this.pointB.x) / 2,
  12279. y: (_this.pointA.y + _this.pointB.y) / 2,
  12280. pointerId: evt.pointerId,
  12281. type: p.type };
  12282. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12283. previousMultiTouchPanPosition = multiTouchPanPosition;
  12284. previousPinchSquaredDistance = pinchSquaredDistance;
  12285. }
  12286. }
  12287. };
  12288. 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 |
  12289. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12290. this._onLostFocus = function () {
  12291. _this.pointA = _this.pointB = null;
  12292. previousPinchSquaredDistance = 0;
  12293. previousMultiTouchPanPosition = null;
  12294. _this.onLostFocus();
  12295. };
  12296. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12297. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12298. { name: "blur", handler: this._onLostFocus }
  12299. ]);
  12300. };
  12301. /**
  12302. * Detach the current controls from the specified dom element.
  12303. * @param element Defines the element to stop listening the inputs from
  12304. */
  12305. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12306. if (this._onLostFocus) {
  12307. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12308. { name: "blur", handler: this._onLostFocus }
  12309. ]);
  12310. }
  12311. if (element && this._observer) {
  12312. this.camera.getScene().onPointerObservable.remove(this._observer);
  12313. this._observer = null;
  12314. if (this.onContextMenu) {
  12315. element.removeEventListener("contextmenu", this.onContextMenu);
  12316. }
  12317. this._onLostFocus = null;
  12318. }
  12319. this._altKey = false;
  12320. this._ctrlKey = false;
  12321. this._metaKey = false;
  12322. this._shiftKey = false;
  12323. this._buttonsPressed = 0;
  12324. };
  12325. /**
  12326. * Gets the class name of the current input.
  12327. * @returns the class name
  12328. */
  12329. BaseCameraPointersInput.prototype.getClassName = function () {
  12330. return "BaseCameraPointersInput";
  12331. };
  12332. /**
  12333. * Get the friendly name associated with the input class.
  12334. * @returns the input friendly name
  12335. */
  12336. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12337. return "pointers";
  12338. };
  12339. /**
  12340. * Called on pointer POINTERDOUBLETAP event.
  12341. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12342. */
  12343. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12344. };
  12345. /**
  12346. * Called on pointer POINTERMOVE event if only a single touch is active.
  12347. * Override this method to provide functionality.
  12348. */
  12349. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12350. };
  12351. /**
  12352. * Called on pointer POINTERMOVE event if multiple touches are active.
  12353. * Override this method to provide functionality.
  12354. */
  12355. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12356. };
  12357. /**
  12358. * Called on JS contextmenu event.
  12359. * Override this method to provide functionality.
  12360. */
  12361. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12362. evt.preventDefault();
  12363. };
  12364. /**
  12365. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12366. * press.
  12367. * Override this method to provide functionality.
  12368. */
  12369. BaseCameraPointersInput.prototype.onButtonDown = function (evt) {
  12370. };
  12371. /**
  12372. * Called each time a new POINTERUP event occurs. Ie, for each button
  12373. * release.
  12374. * Override this method to provide functionality.
  12375. */
  12376. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12377. };
  12378. /**
  12379. * Called when window becomes inactive.
  12380. * Override this method to provide functionality.
  12381. */
  12382. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12383. };
  12384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12386. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12387. return BaseCameraPointersInput;
  12388. }());
  12389. /***/ }),
  12390. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12391. /*!*******************************************************!*\
  12392. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12393. \*******************************************************/
  12394. /*! exports provided: ArcRotateCameraGamepadInput */
  12395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12396. "use strict";
  12397. __webpack_require__.r(__webpack_exports__);
  12398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12399. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12400. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12401. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12402. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12403. /**
  12404. * Manage the gamepad inputs to control an arc rotate camera.
  12405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12406. */
  12407. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12408. function ArcRotateCameraGamepadInput() {
  12409. /**
  12410. * Defines the gamepad rotation sensiblity.
  12411. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12412. */
  12413. this.gamepadRotationSensibility = 80;
  12414. /**
  12415. * Defines the gamepad move sensiblity.
  12416. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12417. */
  12418. this.gamepadMoveSensibility = 40;
  12419. }
  12420. /**
  12421. * Attach the input controls to a specific dom element to get the input from.
  12422. * @param element Defines the element the controls should be listened from
  12423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12424. */
  12425. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12426. var _this = this;
  12427. var manager = this.camera.getScene().gamepadManager;
  12428. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12429. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12430. // prioritize XBOX gamepads.
  12431. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12432. _this.gamepad = gamepad;
  12433. }
  12434. }
  12435. });
  12436. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12437. if (_this.gamepad === gamepad) {
  12438. _this.gamepad = null;
  12439. }
  12440. });
  12441. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12442. };
  12443. /**
  12444. * Detach the current controls from the specified dom element.
  12445. * @param element Defines the element to stop listening the inputs from
  12446. */
  12447. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12448. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12449. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12450. this.gamepad = null;
  12451. };
  12452. /**
  12453. * Update the current camera state depending on the inputs that have been used this frame.
  12454. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12455. */
  12456. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12457. if (this.gamepad) {
  12458. var camera = this.camera;
  12459. var RSValues = this.gamepad.rightStick;
  12460. if (RSValues) {
  12461. if (RSValues.x != 0) {
  12462. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12463. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12464. camera.inertialAlphaOffset += normalizedRX;
  12465. }
  12466. }
  12467. if (RSValues.y != 0) {
  12468. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12469. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12470. camera.inertialBetaOffset += normalizedRY;
  12471. }
  12472. }
  12473. }
  12474. var LSValues = this.gamepad.leftStick;
  12475. if (LSValues && LSValues.y != 0) {
  12476. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12477. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12478. this.camera.inertialRadiusOffset -= normalizedLY;
  12479. }
  12480. }
  12481. }
  12482. };
  12483. /**
  12484. * Gets the class name of the current intput.
  12485. * @returns the class name
  12486. */
  12487. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12488. return "ArcRotateCameraGamepadInput";
  12489. };
  12490. /**
  12491. * Get the friendly name associated with the input class.
  12492. * @returns the input friendly name
  12493. */
  12494. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12495. return "gamepad";
  12496. };
  12497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12499. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12502. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12503. return ArcRotateCameraGamepadInput;
  12504. }());
  12505. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12506. /***/ }),
  12507. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12508. /*!************************************************************!*\
  12509. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12510. \************************************************************/
  12511. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12513. "use strict";
  12514. __webpack_require__.r(__webpack_exports__);
  12515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12516. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12517. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12518. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12519. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12520. /**
  12521. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12523. */
  12524. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12525. function ArcRotateCameraKeyboardMoveInput() {
  12526. /**
  12527. * Defines the list of key codes associated with the up action (increase alpha)
  12528. */
  12529. this.keysUp = [38];
  12530. /**
  12531. * Defines the list of key codes associated with the down action (decrease alpha)
  12532. */
  12533. this.keysDown = [40];
  12534. /**
  12535. * Defines the list of key codes associated with the left action (increase beta)
  12536. */
  12537. this.keysLeft = [37];
  12538. /**
  12539. * Defines the list of key codes associated with the right action (decrease beta)
  12540. */
  12541. this.keysRight = [39];
  12542. /**
  12543. * Defines the list of key codes associated with the reset action.
  12544. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12545. */
  12546. this.keysReset = [220];
  12547. /**
  12548. * Defines the panning sensibility of the inputs.
  12549. * (How fast is the camera paning)
  12550. */
  12551. this.panningSensibility = 50.0;
  12552. /**
  12553. * Defines the zooming sensibility of the inputs.
  12554. * (How fast is the camera zooming)
  12555. */
  12556. this.zoomingSensibility = 25.0;
  12557. /**
  12558. * Defines wether maintaining the alt key down switch the movement mode from
  12559. * orientation to zoom.
  12560. */
  12561. this.useAltToZoom = true;
  12562. /**
  12563. * Rotation speed of the camera
  12564. */
  12565. this.angularSpeed = 0.01;
  12566. this._keys = new Array();
  12567. }
  12568. /**
  12569. * Attach the input controls to a specific dom element to get the input from.
  12570. * @param element Defines the element the controls should be listened from
  12571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12572. */
  12573. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12574. var _this = this;
  12575. if (this._onCanvasBlurObserver) {
  12576. return;
  12577. }
  12578. this._scene = this.camera.getScene();
  12579. this._engine = this._scene.getEngine();
  12580. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12581. _this._keys = [];
  12582. });
  12583. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12584. var evt = info.event;
  12585. if (!evt.metaKey) {
  12586. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12587. _this._ctrlPressed = evt.ctrlKey;
  12588. _this._altPressed = evt.altKey;
  12589. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12590. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12591. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12592. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12593. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12594. var index = _this._keys.indexOf(evt.keyCode);
  12595. if (index === -1) {
  12596. _this._keys.push(evt.keyCode);
  12597. }
  12598. if (evt.preventDefault) {
  12599. if (!noPreventDefault) {
  12600. evt.preventDefault();
  12601. }
  12602. }
  12603. }
  12604. }
  12605. else {
  12606. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12607. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12608. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12609. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12610. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12611. var index = _this._keys.indexOf(evt.keyCode);
  12612. if (index >= 0) {
  12613. _this._keys.splice(index, 1);
  12614. }
  12615. if (evt.preventDefault) {
  12616. if (!noPreventDefault) {
  12617. evt.preventDefault();
  12618. }
  12619. }
  12620. }
  12621. }
  12622. }
  12623. });
  12624. };
  12625. /**
  12626. * Detach the current controls from the specified dom element.
  12627. * @param element Defines the element to stop listening the inputs from
  12628. */
  12629. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12630. if (this._scene) {
  12631. if (this._onKeyboardObserver) {
  12632. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12633. }
  12634. if (this._onCanvasBlurObserver) {
  12635. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12636. }
  12637. this._onKeyboardObserver = null;
  12638. this._onCanvasBlurObserver = null;
  12639. }
  12640. this._keys = [];
  12641. };
  12642. /**
  12643. * Update the current camera state depending on the inputs that have been used this frame.
  12644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12645. */
  12646. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12647. if (this._onKeyboardObserver) {
  12648. var camera = this.camera;
  12649. for (var index = 0; index < this._keys.length; index++) {
  12650. var keyCode = this._keys[index];
  12651. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12652. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12653. camera.inertialPanningX -= 1 / this.panningSensibility;
  12654. }
  12655. else {
  12656. camera.inertialAlphaOffset -= this.angularSpeed;
  12657. }
  12658. }
  12659. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12660. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12661. camera.inertialPanningY += 1 / this.panningSensibility;
  12662. }
  12663. else if (this._altPressed && this.useAltToZoom) {
  12664. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12665. }
  12666. else {
  12667. camera.inertialBetaOffset -= this.angularSpeed;
  12668. }
  12669. }
  12670. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12671. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12672. camera.inertialPanningX += 1 / this.panningSensibility;
  12673. }
  12674. else {
  12675. camera.inertialAlphaOffset += this.angularSpeed;
  12676. }
  12677. }
  12678. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12679. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12680. camera.inertialPanningY -= 1 / this.panningSensibility;
  12681. }
  12682. else if (this._altPressed && this.useAltToZoom) {
  12683. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12684. }
  12685. else {
  12686. camera.inertialBetaOffset += this.angularSpeed;
  12687. }
  12688. }
  12689. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12690. if (camera.useInputToRestoreState) {
  12691. camera.restoreState();
  12692. }
  12693. }
  12694. }
  12695. }
  12696. };
  12697. /**
  12698. * Gets the class name of the current intput.
  12699. * @returns the class name
  12700. */
  12701. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12702. return "ArcRotateCameraKeyboardMoveInput";
  12703. };
  12704. /**
  12705. * Get the friendly name associated with the input class.
  12706. * @returns the input friendly name
  12707. */
  12708. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12709. return "keyboard";
  12710. };
  12711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12713. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12716. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12719. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12720. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12722. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12725. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12728. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12729. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12730. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12731. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12733. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12734. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12735. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12736. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12737. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12738. return ArcRotateCameraKeyboardMoveInput;
  12739. }());
  12740. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12741. /***/ }),
  12742. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12743. /*!**********************************************************!*\
  12744. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12745. \**********************************************************/
  12746. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12748. "use strict";
  12749. __webpack_require__.r(__webpack_exports__);
  12750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12751. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12752. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12753. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12754. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12755. /**
  12756. * Manage the mouse wheel inputs to control an arc rotate camera.
  12757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12758. */
  12759. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12760. function ArcRotateCameraMouseWheelInput() {
  12761. /**
  12762. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12763. */
  12764. this.wheelPrecision = 3.0;
  12765. /**
  12766. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12767. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12768. */
  12769. this.wheelDeltaPercentage = 0;
  12770. }
  12771. /**
  12772. * Attach the input controls to a specific dom element to get the input from.
  12773. * @param element Defines the element the controls should be listened from
  12774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12775. */
  12776. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12777. var _this = this;
  12778. this._wheel = function (p, s) {
  12779. //sanity check - this should be a PointerWheel event.
  12780. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12781. return;
  12782. }
  12783. var event = p.event;
  12784. var delta = 0;
  12785. var mouseWheelLegacyEvent = event;
  12786. if (mouseWheelLegacyEvent.wheelDelta) {
  12787. if (_this.wheelDeltaPercentage) {
  12788. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12789. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12790. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12791. }
  12792. else {
  12793. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12794. }
  12795. }
  12796. else {
  12797. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12798. }
  12799. }
  12800. else {
  12801. var deltaValue = event.deltaY || event.detail;
  12802. delta = -deltaValue / _this.wheelPrecision;
  12803. }
  12804. if (delta) {
  12805. _this.camera.inertialRadiusOffset += delta;
  12806. }
  12807. if (event.preventDefault) {
  12808. if (!noPreventDefault) {
  12809. event.preventDefault();
  12810. }
  12811. }
  12812. };
  12813. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12814. };
  12815. /**
  12816. * Detach the current controls from the specified dom element.
  12817. * @param element Defines the element to stop listening the inputs from
  12818. */
  12819. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12820. if (this._observer && element) {
  12821. this.camera.getScene().onPointerObservable.remove(this._observer);
  12822. this._observer = null;
  12823. this._wheel = null;
  12824. }
  12825. };
  12826. /**
  12827. * Gets the class name of the current intput.
  12828. * @returns the class name
  12829. */
  12830. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12831. return "ArcRotateCameraMouseWheelInput";
  12832. };
  12833. /**
  12834. * Get the friendly name associated with the input class.
  12835. * @returns the input friendly name
  12836. */
  12837. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12838. return "mousewheel";
  12839. };
  12840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12842. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12845. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12846. return ArcRotateCameraMouseWheelInput;
  12847. }());
  12848. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12849. /***/ }),
  12850. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12851. /*!********************************************************!*\
  12852. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12853. \********************************************************/
  12854. /*! exports provided: ArcRotateCameraPointersInput */
  12855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12856. "use strict";
  12857. __webpack_require__.r(__webpack_exports__);
  12858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12859. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12860. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12861. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12862. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  12863. /**
  12864. * Manage the pointers inputs to control an arc rotate camera.
  12865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12866. */
  12867. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  12868. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  12869. function ArcRotateCameraPointersInput() {
  12870. var _this = _super !== null && _super.apply(this, arguments) || this;
  12871. /**
  12872. * Defines the buttons associated with the input to handle camera move.
  12873. */
  12874. _this.buttons = [0, 1, 2];
  12875. /**
  12876. * Defines the pointer angular sensibility along the X axis or how fast is
  12877. * the camera rotating.
  12878. */
  12879. _this.angularSensibilityX = 1000.0;
  12880. /**
  12881. * Defines the pointer angular sensibility along the Y axis or how fast is
  12882. * the camera rotating.
  12883. */
  12884. _this.angularSensibilityY = 1000.0;
  12885. /**
  12886. * Defines the pointer pinch precision or how fast is the camera zooming.
  12887. */
  12888. _this.pinchPrecision = 12.0;
  12889. /**
  12890. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  12891. * from 0.
  12892. * It defines the percentage of current camera.radius to use as delta when
  12893. * pinch zoom is used.
  12894. */
  12895. _this.pinchDeltaPercentage = 0;
  12896. /**
  12897. * Defines the pointer panning sensibility or how fast is the camera moving.
  12898. */
  12899. _this.panningSensibility = 1000.0;
  12900. /**
  12901. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12902. */
  12903. _this.multiTouchPanning = true;
  12904. /**
  12905. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  12906. * zoom (pinch) through multitouch.
  12907. */
  12908. _this.multiTouchPanAndZoom = true;
  12909. /**
  12910. * Revers pinch action direction.
  12911. */
  12912. _this.pinchInwards = true;
  12913. _this._isPanClick = false;
  12914. _this._twoFingerActivityCount = 0;
  12915. _this._isPinching = false;
  12916. return _this;
  12917. }
  12918. /**
  12919. * Gets the class name of the current input.
  12920. * @returns the class name
  12921. */
  12922. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12923. return "ArcRotateCameraPointersInput";
  12924. };
  12925. /**
  12926. * Called on pointer POINTERMOVE event if only a single touch is active.
  12927. */
  12928. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12929. if (this.panningSensibility !== 0 &&
  12930. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  12931. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  12932. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  12933. }
  12934. else {
  12935. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  12936. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  12937. }
  12938. };
  12939. /**
  12940. * Called on pointer POINTERDOUBLETAP event.
  12941. */
  12942. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  12943. if (this.camera.useInputToRestoreState) {
  12944. this.camera.restoreState();
  12945. }
  12946. };
  12947. /**
  12948. * Called on pointer POINTERMOVE event if multiple touches are active.
  12949. */
  12950. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12951. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  12952. // First time this method is called for new pinch.
  12953. // Next time this is called there will be a
  12954. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  12955. return;
  12956. }
  12957. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  12958. // Last time this method is called at the end of a pinch.
  12959. return;
  12960. }
  12961. var direction = this.pinchInwards ? 1 : -1;
  12962. if (this.multiTouchPanAndZoom) {
  12963. if (this.pinchDeltaPercentage) {
  12964. this.camera.inertialRadiusOffset +=
  12965. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12966. this.camera.radius * this.pinchDeltaPercentage;
  12967. }
  12968. else {
  12969. this.camera.inertialRadiusOffset +=
  12970. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12971. (this.pinchPrecision * direction *
  12972. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12973. }
  12974. if (this.panningSensibility !== 0 &&
  12975. previousMultiTouchPanPosition && multiTouchPanPosition) {
  12976. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12977. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12978. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12979. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12980. }
  12981. }
  12982. else {
  12983. this._twoFingerActivityCount++;
  12984. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  12985. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12986. if (this._isPinching ||
  12987. (this._twoFingerActivityCount < 20 &&
  12988. Math.abs(pinchDistance - previousPinchDistance) >
  12989. this.camera.pinchToPanMaxDistance)) {
  12990. // Since pinch has not been active long, assume we intend to zoom.
  12991. if (this.pinchDeltaPercentage) {
  12992. this.camera.inertialRadiusOffset +=
  12993. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12994. this.camera.radius * this.pinchDeltaPercentage;
  12995. }
  12996. else {
  12997. this.camera.inertialRadiusOffset +=
  12998. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12999. (this.pinchPrecision * direction *
  13000. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  13001. }
  13002. // Since we are pinching, remain pinching on next iteration.
  13003. this._isPinching = true;
  13004. }
  13005. else {
  13006. // Pause between pinch starting and moving implies not a zoom event.
  13007. // Pan instead.
  13008. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  13009. multiTouchPanPosition && previousMultiTouchPanPosition) {
  13010. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  13011. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  13012. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  13013. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  13014. }
  13015. }
  13016. }
  13017. };
  13018. /**
  13019. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  13020. * press.
  13021. */
  13022. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt) {
  13023. this._isPanClick = evt.button === this.camera._panningMouseButton;
  13024. };
  13025. /**
  13026. * Called each time a new POINTERUP event occurs. Ie, for each button
  13027. * release.
  13028. */
  13029. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  13030. this._twoFingerActivityCount = 0;
  13031. this._isPinching = false;
  13032. };
  13033. /**
  13034. * Called when window becomes inactive.
  13035. */
  13036. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  13037. this._isPanClick = false;
  13038. this._twoFingerActivityCount = 0;
  13039. this._isPinching = false;
  13040. };
  13041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13043. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  13044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13046. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  13047. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13049. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  13050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13052. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  13053. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13054. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13055. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  13056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13058. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  13059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13061. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  13062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13064. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  13065. return ArcRotateCameraPointersInput;
  13066. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  13067. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  13068. ArcRotateCameraPointersInput;
  13069. /***/ }),
  13070. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  13071. /*!*******************************************************************!*\
  13072. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  13073. \*******************************************************************/
  13074. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  13075. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13076. "use strict";
  13077. __webpack_require__.r(__webpack_exports__);
  13078. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  13079. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13080. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  13081. /**
  13082. * Add orientation input support to the input manager.
  13083. * @returns the current input manager
  13084. */
  13085. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13086. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13087. return this;
  13088. };
  13089. /**
  13090. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13092. */
  13093. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13094. /**
  13095. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13096. */
  13097. function ArcRotateCameraVRDeviceOrientationInput() {
  13098. /**
  13099. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13100. */
  13101. this.alphaCorrection = 1;
  13102. /**
  13103. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13104. */
  13105. this.gammaCorrection = 1;
  13106. this._alpha = 0;
  13107. this._gamma = 0;
  13108. this._dirty = false;
  13109. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13110. }
  13111. /**
  13112. * Attach the input controls to a specific dom element to get the input from.
  13113. * @param element Defines the element the controls should be listened from
  13114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13115. */
  13116. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13117. this.camera.attachControl(element, noPreventDefault);
  13118. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13119. };
  13120. /** @hidden */
  13121. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13122. if (evt.alpha !== null) {
  13123. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13124. }
  13125. if (evt.gamma !== null) {
  13126. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13127. }
  13128. this._dirty = true;
  13129. };
  13130. /**
  13131. * Update the current camera state depending on the inputs that have been used this frame.
  13132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13133. */
  13134. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13135. if (this._dirty) {
  13136. this._dirty = false;
  13137. if (this._gamma < 0) {
  13138. this._gamma = 180 + this._gamma;
  13139. }
  13140. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13141. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13142. }
  13143. };
  13144. /**
  13145. * Detach the current controls from the specified dom element.
  13146. * @param element Defines the element to stop listening the inputs from
  13147. */
  13148. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13149. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13150. };
  13151. /**
  13152. * Gets the class name of the current intput.
  13153. * @returns the class name
  13154. */
  13155. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13156. return "ArcRotateCameraVRDeviceOrientationInput";
  13157. };
  13158. /**
  13159. * Get the friendly name associated with the input class.
  13160. * @returns the input friendly name
  13161. */
  13162. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13163. return "VRDeviceOrientation";
  13164. };
  13165. return ArcRotateCameraVRDeviceOrientationInput;
  13166. }());
  13167. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13168. /***/ }),
  13169. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13170. /*!**************************************************!*\
  13171. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13172. \**************************************************/
  13173. /*! exports provided: FlyCameraKeyboardInput */
  13174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13175. "use strict";
  13176. __webpack_require__.r(__webpack_exports__);
  13177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13178. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13179. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13180. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13181. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13182. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13183. /**
  13184. * Listen to keyboard events to control the camera.
  13185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13186. */
  13187. var FlyCameraKeyboardInput = /** @class */ (function () {
  13188. function FlyCameraKeyboardInput() {
  13189. /**
  13190. * The list of keyboard keys used to control the forward move of the camera.
  13191. */
  13192. this.keysForward = [87];
  13193. /**
  13194. * The list of keyboard keys used to control the backward move of the camera.
  13195. */
  13196. this.keysBackward = [83];
  13197. /**
  13198. * The list of keyboard keys used to control the forward move of the camera.
  13199. */
  13200. this.keysUp = [69];
  13201. /**
  13202. * The list of keyboard keys used to control the backward move of the camera.
  13203. */
  13204. this.keysDown = [81];
  13205. /**
  13206. * The list of keyboard keys used to control the right strafe move of the camera.
  13207. */
  13208. this.keysRight = [68];
  13209. /**
  13210. * The list of keyboard keys used to control the left strafe move of the camera.
  13211. */
  13212. this.keysLeft = [65];
  13213. this._keys = new Array();
  13214. }
  13215. /**
  13216. * Attach the input controls to a specific dom element to get the input from.
  13217. * @param element Defines the element the controls should be listened from
  13218. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13219. */
  13220. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13221. var _this = this;
  13222. if (this._onCanvasBlurObserver) {
  13223. return;
  13224. }
  13225. this._scene = this.camera.getScene();
  13226. this._engine = this._scene.getEngine();
  13227. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13228. _this._keys = [];
  13229. });
  13230. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13231. var evt = info.event;
  13232. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13233. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13234. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13235. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13236. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13237. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13238. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13239. var index = _this._keys.indexOf(evt.keyCode);
  13240. if (index === -1) {
  13241. _this._keys.push(evt.keyCode);
  13242. }
  13243. if (!noPreventDefault) {
  13244. evt.preventDefault();
  13245. }
  13246. }
  13247. }
  13248. else {
  13249. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13250. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13251. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13252. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13253. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13254. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13255. var index = _this._keys.indexOf(evt.keyCode);
  13256. if (index >= 0) {
  13257. _this._keys.splice(index, 1);
  13258. }
  13259. if (!noPreventDefault) {
  13260. evt.preventDefault();
  13261. }
  13262. }
  13263. }
  13264. });
  13265. };
  13266. /**
  13267. * Detach the current controls from the specified dom element.
  13268. * @param element Defines the element to stop listening the inputs from
  13269. */
  13270. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13271. if (this._scene) {
  13272. if (this._onKeyboardObserver) {
  13273. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13274. }
  13275. if (this._onCanvasBlurObserver) {
  13276. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13277. }
  13278. this._onKeyboardObserver = null;
  13279. this._onCanvasBlurObserver = null;
  13280. }
  13281. this._keys = [];
  13282. };
  13283. /**
  13284. * Gets the class name of the current intput.
  13285. * @returns the class name
  13286. */
  13287. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13288. return "FlyCameraKeyboardInput";
  13289. };
  13290. /** @hidden */
  13291. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13292. this._keys = [];
  13293. };
  13294. /**
  13295. * Get the friendly name associated with the input class.
  13296. * @returns the input friendly name
  13297. */
  13298. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13299. return "keyboard";
  13300. };
  13301. /**
  13302. * Update the current camera state depending on the inputs that have been used this frame.
  13303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13304. */
  13305. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13306. if (this._onKeyboardObserver) {
  13307. var camera = this.camera;
  13308. // Keyboard
  13309. for (var index = 0; index < this._keys.length; index++) {
  13310. var keyCode = this._keys[index];
  13311. var speed = camera._computeLocalCameraSpeed();
  13312. if (this.keysForward.indexOf(keyCode) !== -1) {
  13313. camera._localDirection.copyFromFloats(0, 0, speed);
  13314. }
  13315. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13316. camera._localDirection.copyFromFloats(0, 0, -speed);
  13317. }
  13318. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13319. camera._localDirection.copyFromFloats(0, speed, 0);
  13320. }
  13321. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13322. camera._localDirection.copyFromFloats(0, -speed, 0);
  13323. }
  13324. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13325. camera._localDirection.copyFromFloats(speed, 0, 0);
  13326. }
  13327. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13328. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13329. }
  13330. if (camera.getScene().useRightHandedSystem) {
  13331. camera._localDirection.z *= -1;
  13332. }
  13333. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13334. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13335. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13336. }
  13337. }
  13338. };
  13339. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13340. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13341. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13342. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13343. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13344. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13345. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13347. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13350. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13351. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13352. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13353. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13356. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13357. return FlyCameraKeyboardInput;
  13358. }());
  13359. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13360. /***/ }),
  13361. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13362. /*!***********************************************!*\
  13363. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13364. \***********************************************/
  13365. /*! exports provided: FlyCameraMouseInput */
  13366. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13367. "use strict";
  13368. __webpack_require__.r(__webpack_exports__);
  13369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13370. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13371. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13372. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13373. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13374. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13375. /**
  13376. * Listen to mouse events to control the camera.
  13377. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13378. */
  13379. var FlyCameraMouseInput = /** @class */ (function () {
  13380. /**
  13381. * Listen to mouse events to control the camera.
  13382. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13384. */
  13385. function FlyCameraMouseInput(touchEnabled) {
  13386. if (touchEnabled === void 0) { touchEnabled = true; }
  13387. /**
  13388. * Defines the buttons associated with the input to handle camera rotation.
  13389. */
  13390. this.buttons = [0, 1, 2];
  13391. /**
  13392. * Assign buttons for Yaw control.
  13393. */
  13394. this.buttonsYaw = [-1, 0, 1];
  13395. /**
  13396. * Assign buttons for Pitch control.
  13397. */
  13398. this.buttonsPitch = [-1, 0, 1];
  13399. /**
  13400. * Assign buttons for Roll control.
  13401. */
  13402. this.buttonsRoll = [2];
  13403. /**
  13404. * Detect if any button is being pressed while mouse is moved.
  13405. * -1 = Mouse locked.
  13406. * 0 = Left button.
  13407. * 1 = Middle Button.
  13408. * 2 = Right Button.
  13409. */
  13410. this.activeButton = -1;
  13411. /**
  13412. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13413. * Higher values reduce its sensitivity.
  13414. */
  13415. this.angularSensibility = 1000.0;
  13416. this.previousPosition = null;
  13417. }
  13418. /**
  13419. * Attach the mouse control to the HTML DOM element.
  13420. * @param element Defines the element that listens to the input events.
  13421. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13422. */
  13423. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13424. var _this = this;
  13425. this.element = element;
  13426. this.noPreventDefault = noPreventDefault;
  13427. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13428. _this._pointerInput(p, s);
  13429. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13430. // Correct Roll by rate, if enabled.
  13431. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13432. if (_this.camera.rollCorrect) {
  13433. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13434. }
  13435. });
  13436. // Helper function to keep 'this'.
  13437. this._mousemoveCallback = function (e) {
  13438. _this._onMouseMove(e);
  13439. };
  13440. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13441. };
  13442. /**
  13443. * Detach the current controls from the specified dom element.
  13444. * @param element Defines the element to stop listening the inputs from
  13445. */
  13446. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13447. if (this._observer && element) {
  13448. this.camera.getScene().onPointerObservable.remove(this._observer);
  13449. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13450. if (this._mousemoveCallback) {
  13451. element.removeEventListener("mousemove", this._mousemoveCallback);
  13452. }
  13453. this._observer = null;
  13454. this._rollObserver = null;
  13455. this.previousPosition = null;
  13456. this.noPreventDefault = undefined;
  13457. }
  13458. };
  13459. /**
  13460. * Gets the class name of the current input.
  13461. * @returns the class name.
  13462. */
  13463. FlyCameraMouseInput.prototype.getClassName = function () {
  13464. return "FlyCameraMouseInput";
  13465. };
  13466. /**
  13467. * Get the friendly name associated with the input class.
  13468. * @returns the input's friendly name.
  13469. */
  13470. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13471. return "mouse";
  13472. };
  13473. // Track mouse movement, when the pointer is not locked.
  13474. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13475. var e = p.event;
  13476. var camera = this.camera;
  13477. var engine = camera.getEngine();
  13478. if (engine.isInVRExclusivePointerMode) {
  13479. return;
  13480. }
  13481. if (!this.touchEnabled && e.pointerType === "touch") {
  13482. return;
  13483. }
  13484. // Mouse is moved but an unknown mouse button is pressed.
  13485. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13486. return;
  13487. }
  13488. var srcElement = (e.srcElement || e.target);
  13489. // Mouse down.
  13490. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13491. try {
  13492. srcElement.setPointerCapture(e.pointerId);
  13493. }
  13494. catch (e) {
  13495. // Nothing to do with the error. Execution continues.
  13496. }
  13497. this.previousPosition = {
  13498. x: e.clientX,
  13499. y: e.clientY
  13500. };
  13501. this.activeButton = e.button;
  13502. if (!this.noPreventDefault) {
  13503. e.preventDefault();
  13504. this.element.focus();
  13505. }
  13506. }
  13507. else
  13508. // Mouse up.
  13509. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13510. try {
  13511. srcElement.releasePointerCapture(e.pointerId);
  13512. }
  13513. catch (e) {
  13514. // Nothing to do with the error. Execution continues.
  13515. }
  13516. this.activeButton = -1;
  13517. this.previousPosition = null;
  13518. if (!this.noPreventDefault) {
  13519. e.preventDefault();
  13520. }
  13521. }
  13522. else
  13523. // Mouse move.
  13524. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13525. if (!this.previousPosition || engine.isPointerLock) {
  13526. return;
  13527. }
  13528. var offsetX = e.clientX - this.previousPosition.x;
  13529. var offsetY = e.clientY - this.previousPosition.y;
  13530. this.rotateCamera(offsetX, offsetY);
  13531. this.previousPosition = {
  13532. x: e.clientX,
  13533. y: e.clientY
  13534. };
  13535. if (!this.noPreventDefault) {
  13536. e.preventDefault();
  13537. }
  13538. }
  13539. };
  13540. // Track mouse movement, when pointer is locked.
  13541. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13542. var camera = this.camera;
  13543. var engine = camera.getEngine();
  13544. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13545. return;
  13546. }
  13547. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13548. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13549. this.rotateCamera(offsetX, offsetY);
  13550. this.previousPosition = null;
  13551. if (!this.noPreventDefault) {
  13552. e.preventDefault();
  13553. }
  13554. };
  13555. /**
  13556. * Rotate camera by mouse offset.
  13557. */
  13558. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13559. var _this = this;
  13560. var camera = this.camera;
  13561. var scene = this.camera.getScene();
  13562. if (scene.useRightHandedSystem) {
  13563. offsetX *= -1;
  13564. }
  13565. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13566. offsetX *= -1;
  13567. }
  13568. var x = offsetX / this.angularSensibility;
  13569. var y = offsetY / this.angularSensibility;
  13570. // Initialize to current rotation.
  13571. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13572. var rotationChange;
  13573. // Pitch.
  13574. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13575. // Apply change in Radians to vector Angle.
  13576. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13577. // Apply Pitch to quaternion.
  13578. currentRotation.multiplyInPlace(rotationChange);
  13579. }
  13580. // Yaw.
  13581. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13582. // Apply change in Radians to vector Angle.
  13583. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13584. // Apply Yaw to quaternion.
  13585. currentRotation.multiplyInPlace(rotationChange);
  13586. // Add Roll, if banked turning is enabled, within Roll limit.
  13587. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13588. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13589. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13590. // Apply change in Radians to vector Angle.
  13591. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13592. // Apply Yaw to quaternion.
  13593. currentRotation.multiplyInPlace(rotationChange);
  13594. }
  13595. }
  13596. // Roll.
  13597. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13598. // Apply change in Radians to vector Angle.
  13599. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13600. // Track Rolling.
  13601. camera._trackRoll -= x;
  13602. // Apply Pitch to quaternion.
  13603. currentRotation.multiplyInPlace(rotationChange);
  13604. }
  13605. // Apply rotationQuaternion to Euler camera.rotation.
  13606. currentRotation.toEulerAnglesToRef(camera.rotation);
  13607. };
  13608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13610. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13613. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13614. return FlyCameraMouseInput;
  13615. }());
  13616. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13617. /***/ }),
  13618. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13619. /*!*********************************************************!*\
  13620. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13621. \*********************************************************/
  13622. /*! exports provided: FollowCameraKeyboardMoveInput */
  13623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13624. "use strict";
  13625. __webpack_require__.r(__webpack_exports__);
  13626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13627. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13628. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13629. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13630. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13631. /**
  13632. * Manage the keyboard inputs to control the movement of a follow camera.
  13633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13634. */
  13635. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13636. function FollowCameraKeyboardMoveInput() {
  13637. /**
  13638. * Defines the list of key codes associated with the up action (increase heightOffset)
  13639. */
  13640. this.keysHeightOffsetIncr = [38];
  13641. /**
  13642. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13643. */
  13644. this.keysHeightOffsetDecr = [40];
  13645. /**
  13646. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13647. */
  13648. this.keysHeightOffsetModifierAlt = false;
  13649. /**
  13650. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13651. */
  13652. this.keysHeightOffsetModifierCtrl = false;
  13653. /**
  13654. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13655. */
  13656. this.keysHeightOffsetModifierShift = false;
  13657. /**
  13658. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13659. */
  13660. this.keysRotationOffsetIncr = [37];
  13661. /**
  13662. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13663. */
  13664. this.keysRotationOffsetDecr = [39];
  13665. /**
  13666. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13667. */
  13668. this.keysRotationOffsetModifierAlt = false;
  13669. /**
  13670. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13671. */
  13672. this.keysRotationOffsetModifierCtrl = false;
  13673. /**
  13674. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13675. */
  13676. this.keysRotationOffsetModifierShift = false;
  13677. /**
  13678. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13679. */
  13680. this.keysRadiusIncr = [40];
  13681. /**
  13682. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13683. */
  13684. this.keysRadiusDecr = [38];
  13685. /**
  13686. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13687. */
  13688. this.keysRadiusModifierAlt = true;
  13689. /**
  13690. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13691. */
  13692. this.keysRadiusModifierCtrl = false;
  13693. /**
  13694. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13695. */
  13696. this.keysRadiusModifierShift = false;
  13697. /**
  13698. * Defines the rate of change of heightOffset.
  13699. */
  13700. this.heightSensibility = 1;
  13701. /**
  13702. * Defines the rate of change of rotationOffset.
  13703. */
  13704. this.rotationSensibility = 1;
  13705. /**
  13706. * Defines the rate of change of radius.
  13707. */
  13708. this.radiusSensibility = 1;
  13709. this._keys = new Array();
  13710. }
  13711. /**
  13712. * Attach the input controls to a specific dom element to get the input from.
  13713. * @param element Defines the element the controls should be listened from
  13714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13715. */
  13716. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13717. var _this = this;
  13718. if (this._onCanvasBlurObserver) {
  13719. return;
  13720. }
  13721. this._scene = this.camera.getScene();
  13722. this._engine = this._scene.getEngine();
  13723. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13724. _this._keys = [];
  13725. });
  13726. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13727. var evt = info.event;
  13728. if (!evt.metaKey) {
  13729. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13730. _this._ctrlPressed = evt.ctrlKey;
  13731. _this._altPressed = evt.altKey;
  13732. _this._shiftPressed = evt.shiftKey;
  13733. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13734. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13735. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13736. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13737. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13738. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13739. var index = _this._keys.indexOf(evt.keyCode);
  13740. if (index === -1) {
  13741. _this._keys.push(evt.keyCode);
  13742. }
  13743. if (evt.preventDefault) {
  13744. if (!noPreventDefault) {
  13745. evt.preventDefault();
  13746. }
  13747. }
  13748. }
  13749. }
  13750. else {
  13751. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13752. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13753. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13754. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13755. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13756. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13757. var index = _this._keys.indexOf(evt.keyCode);
  13758. if (index >= 0) {
  13759. _this._keys.splice(index, 1);
  13760. }
  13761. if (evt.preventDefault) {
  13762. if (!noPreventDefault) {
  13763. evt.preventDefault();
  13764. }
  13765. }
  13766. }
  13767. }
  13768. }
  13769. });
  13770. };
  13771. /**
  13772. * Detach the current controls from the specified dom element.
  13773. * @param element Defines the element to stop listening the inputs from
  13774. */
  13775. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13776. if (this._scene) {
  13777. if (this._onKeyboardObserver) {
  13778. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13779. }
  13780. if (this._onCanvasBlurObserver) {
  13781. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13782. }
  13783. this._onKeyboardObserver = null;
  13784. this._onCanvasBlurObserver = null;
  13785. }
  13786. this._keys = [];
  13787. };
  13788. /**
  13789. * Update the current camera state depending on the inputs that have been used this frame.
  13790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13791. */
  13792. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13793. var _this = this;
  13794. if (this._onKeyboardObserver) {
  13795. this._keys.forEach(function (keyCode) {
  13796. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13797. _this._modifierHeightOffset()) {
  13798. _this.camera.heightOffset += _this.heightSensibility;
  13799. }
  13800. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13801. _this._modifierHeightOffset()) {
  13802. _this.camera.heightOffset -= _this.heightSensibility;
  13803. }
  13804. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13805. _this._modifierRotationOffset()) {
  13806. _this.camera.rotationOffset += _this.rotationSensibility;
  13807. _this.camera.rotationOffset %= 360;
  13808. }
  13809. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13810. _this._modifierRotationOffset()) {
  13811. _this.camera.rotationOffset -= _this.rotationSensibility;
  13812. _this.camera.rotationOffset %= 360;
  13813. }
  13814. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13815. _this._modifierRadius()) {
  13816. _this.camera.radius += _this.radiusSensibility;
  13817. }
  13818. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13819. _this._modifierRadius()) {
  13820. _this.camera.radius -= _this.radiusSensibility;
  13821. }
  13822. });
  13823. }
  13824. };
  13825. /**
  13826. * Gets the class name of the current input.
  13827. * @returns the class name
  13828. */
  13829. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13830. return "FollowCameraKeyboardMoveInput";
  13831. };
  13832. /**
  13833. * Get the friendly name associated with the input class.
  13834. * @returns the input friendly name
  13835. */
  13836. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13837. return "keyboard";
  13838. };
  13839. /**
  13840. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13841. * allow modification of the heightOffset value.
  13842. */
  13843. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13844. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13845. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13846. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13847. };
  13848. /**
  13849. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13850. * allow modification of the rotationOffset value.
  13851. */
  13852. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13853. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13854. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13855. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13856. };
  13857. /**
  13858. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13859. * allow modification of the radius value.
  13860. */
  13861. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13862. return (this.keysRadiusModifierAlt === this._altPressed &&
  13863. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13864. this.keysRadiusModifierShift === this._shiftPressed);
  13865. };
  13866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13868. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13871. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13874. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13877. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13880. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13883. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13886. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13887. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13888. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13889. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13890. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13891. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13892. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13893. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13895. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13898. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13901. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13902. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13903. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13904. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13905. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13907. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13910. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13913. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13914. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13915. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13916. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13917. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13919. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13920. return FollowCameraKeyboardMoveInput;
  13921. }());
  13922. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13923. /***/ }),
  13924. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13925. /*!*******************************************************!*\
  13926. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13927. \*******************************************************/
  13928. /*! exports provided: FollowCameraMouseWheelInput */
  13929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13930. "use strict";
  13931. __webpack_require__.r(__webpack_exports__);
  13932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13933. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13934. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13935. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13936. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13937. /**
  13938. * Manage the mouse wheel inputs to control a follow camera.
  13939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13940. */
  13941. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13942. function FollowCameraMouseWheelInput() {
  13943. /**
  13944. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  13945. */
  13946. this.axisControlRadius = true;
  13947. /**
  13948. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  13949. */
  13950. this.axisControlHeight = false;
  13951. /**
  13952. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  13953. */
  13954. this.axisControlRotation = false;
  13955. /**
  13956. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13957. * relation to mouseWheel events.
  13958. */
  13959. this.wheelPrecision = 3.0;
  13960. /**
  13961. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13962. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13963. */
  13964. this.wheelDeltaPercentage = 0;
  13965. }
  13966. /**
  13967. * Attach the input controls to a specific dom element to get the input from.
  13968. * @param element Defines the element the controls should be listened from
  13969. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13970. */
  13971. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13972. var _this = this;
  13973. this._wheel = function (p, s) {
  13974. // sanity check - this should be a PointerWheel event.
  13975. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13976. return;
  13977. }
  13978. var event = p.event;
  13979. var delta = 0;
  13980. // Chrome, Safari: event.deltaY
  13981. // IE: event.wheelDelta
  13982. // Firefox: event.detail (inverted)
  13983. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13984. if (_this.wheelDeltaPercentage) {
  13985. console.assert((_this.axisControlRadius +
  13986. _this.axisControlHeight +
  13987. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13988. "controlls ONE axis. " +
  13989. "Currently enabled: " +
  13990. "axisControlRadius: " + _this.axisControlRadius +
  13991. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13992. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13993. if (_this.axisControlRadius) {
  13994. delta =
  13995. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13996. _this.camera.radius;
  13997. }
  13998. else if (_this.axisControlHeight) {
  13999. delta =
  14000. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  14001. _this.camera.heightOffset;
  14002. }
  14003. else if (_this.axisControlRotation) {
  14004. delta =
  14005. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  14006. _this.camera.rotationOffset;
  14007. }
  14008. }
  14009. else {
  14010. delta = wheelDelta * _this.wheelPrecision;
  14011. }
  14012. if (delta) {
  14013. if (_this.axisControlRadius) {
  14014. _this.camera.radius += delta;
  14015. }
  14016. else if (_this.axisControlHeight) {
  14017. _this.camera.heightOffset -= delta;
  14018. }
  14019. else if (_this.axisControlRotation) {
  14020. _this.camera.rotationOffset -= delta;
  14021. }
  14022. }
  14023. if (event.preventDefault) {
  14024. if (!noPreventDefault) {
  14025. event.preventDefault();
  14026. }
  14027. }
  14028. };
  14029. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  14030. };
  14031. /**
  14032. * Detach the current controls from the specified dom element.
  14033. * @param element Defines the element to stop listening the inputs from
  14034. */
  14035. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  14036. if (this._observer && element) {
  14037. this.camera.getScene().onPointerObservable.remove(this._observer);
  14038. this._observer = null;
  14039. this._wheel = null;
  14040. }
  14041. };
  14042. /**
  14043. * Gets the class name of the current intput.
  14044. * @returns the class name
  14045. */
  14046. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  14047. return "ArcRotateCameraMouseWheelInput";
  14048. };
  14049. /**
  14050. * Get the friendly name associated with the input class.
  14051. * @returns the input friendly name
  14052. */
  14053. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  14054. return "mousewheel";
  14055. };
  14056. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14057. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14058. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  14059. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14061. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  14062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14064. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  14065. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14066. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14067. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  14068. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14069. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14070. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  14071. return FollowCameraMouseWheelInput;
  14072. }());
  14073. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  14074. /***/ }),
  14075. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  14076. /*!*****************************************************!*\
  14077. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  14078. \*****************************************************/
  14079. /*! exports provided: FollowCameraPointersInput */
  14080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14081. "use strict";
  14082. __webpack_require__.r(__webpack_exports__);
  14083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14084. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14085. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14086. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14087. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14088. /**
  14089. * Manage the pointers inputs to control an follow camera.
  14090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14091. */
  14092. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14093. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14094. function FollowCameraPointersInput() {
  14095. var _this = _super !== null && _super.apply(this, arguments) || this;
  14096. /**
  14097. * Defines the pointer angular sensibility along the X axis or how fast is
  14098. * the camera rotating.
  14099. * A negative number will reverse the axis direction.
  14100. */
  14101. _this.angularSensibilityX = 1;
  14102. /**
  14103. * Defines the pointer angular sensibility along the Y axis or how fast is
  14104. * the camera rotating.
  14105. * A negative number will reverse the axis direction.
  14106. */
  14107. _this.angularSensibilityY = 1;
  14108. /**
  14109. * Defines the pointer pinch precision or how fast is the camera zooming.
  14110. * A negative number will reverse the axis direction.
  14111. */
  14112. _this.pinchPrecision = 10000.0;
  14113. /**
  14114. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14115. * from 0.
  14116. * It defines the percentage of current camera.radius to use as delta when
  14117. * pinch zoom is used.
  14118. */
  14119. _this.pinchDeltaPercentage = 0;
  14120. /**
  14121. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14122. */
  14123. _this.axisXControlRadius = false;
  14124. /**
  14125. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14126. */
  14127. _this.axisXControlHeight = false;
  14128. /**
  14129. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14130. */
  14131. _this.axisXControlRotation = true;
  14132. /**
  14133. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14134. */
  14135. _this.axisYControlRadius = false;
  14136. /**
  14137. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14138. */
  14139. _this.axisYControlHeight = true;
  14140. /**
  14141. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14142. */
  14143. _this.axisYControlRotation = false;
  14144. /**
  14145. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14146. */
  14147. _this.axisPinchControlRadius = true;
  14148. /**
  14149. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14150. */
  14151. _this.axisPinchControlHeight = false;
  14152. /**
  14153. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14154. */
  14155. _this.axisPinchControlRotation = false;
  14156. /**
  14157. * Log error messages if basic misconfiguration has occurred.
  14158. */
  14159. _this.warningEnable = true;
  14160. /* Check for obvious misconfiguration. */
  14161. _this._warningCounter = 0;
  14162. return _this;
  14163. }
  14164. /**
  14165. * Gets the class name of the current input.
  14166. * @returns the class name
  14167. */
  14168. FollowCameraPointersInput.prototype.getClassName = function () {
  14169. return "FollowCameraPointersInput";
  14170. };
  14171. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14172. this._warning();
  14173. if (this.axisXControlRotation) {
  14174. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14175. }
  14176. else if (this.axisYControlRotation) {
  14177. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14178. }
  14179. if (this.axisXControlHeight) {
  14180. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14181. }
  14182. else if (this.axisYControlHeight) {
  14183. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14184. }
  14185. if (this.axisXControlRadius) {
  14186. this.camera.radius -= offsetX / this.angularSensibilityY;
  14187. }
  14188. else if (this.axisYControlRadius) {
  14189. this.camera.radius -= offsetY / this.angularSensibilityY;
  14190. }
  14191. };
  14192. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14193. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14194. // First time this method is called for new pinch.
  14195. // Next time this is called there will be a
  14196. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14197. return;
  14198. }
  14199. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14200. // Last time this method is called at the end of a pinch.
  14201. return;
  14202. }
  14203. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14204. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14205. if (this.pinchDeltaPercentage) {
  14206. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14207. if (this.axisPinchControlRotation) {
  14208. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14209. }
  14210. if (this.axisPinchControlHeight) {
  14211. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14212. }
  14213. if (this.axisPinchControlRadius) {
  14214. this.camera.radius -= pinchDelta * this.camera.radius;
  14215. }
  14216. }
  14217. else {
  14218. if (this.axisPinchControlRotation) {
  14219. this.camera.rotationOffset += pinchDelta;
  14220. }
  14221. if (this.axisPinchControlHeight) {
  14222. this.camera.heightOffset += pinchDelta;
  14223. }
  14224. if (this.axisPinchControlRadius) {
  14225. this.camera.radius -= pinchDelta;
  14226. }
  14227. }
  14228. };
  14229. FollowCameraPointersInput.prototype._warning = function () {
  14230. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14231. return;
  14232. }
  14233. var warn = "It probably only makes sense to control ONE camera " +
  14234. "property with each pointer axis. Set 'warningEnable = false' " +
  14235. "if you are sure. Currently enabled: ";
  14236. console.assert((this.axisXControlRotation +
  14237. this.axisXControlHeight +
  14238. this.axisXControlRadius) <= 1, warn +
  14239. "axisXControlRotation: " + this.axisXControlRotation +
  14240. ", axisXControlHeight: " + this.axisXControlHeight +
  14241. ", axisXControlRadius: " + this.axisXControlRadius);
  14242. console.assert((this.axisYControlRotation +
  14243. this.axisYControlHeight +
  14244. this.axisYControlRadius) <= 1, warn +
  14245. "axisYControlRotation: " + this.axisYControlRotation +
  14246. ", axisYControlHeight: " + this.axisYControlHeight +
  14247. ", axisYControlRadius: " + this.axisYControlRadius);
  14248. console.assert((this.axisPinchControlRotation +
  14249. this.axisPinchControlHeight +
  14250. this.axisPinchControlRadius) <= 1, warn +
  14251. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14252. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14253. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14254. };
  14255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14257. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14260. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14263. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14266. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14269. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14272. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14275. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14276. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14278. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14279. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14281. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14284. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14287. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14288. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14289. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14290. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14291. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14292. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14293. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14294. return FollowCameraPointersInput;
  14295. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14296. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14297. /***/ }),
  14298. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14299. /*!************************************************************!*\
  14300. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14301. \************************************************************/
  14302. /*! exports provided: FreeCameraDeviceOrientationInput */
  14303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14304. "use strict";
  14305. __webpack_require__.r(__webpack_exports__);
  14306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14307. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14308. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14309. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14310. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14311. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14312. /**
  14313. * Add orientation input support to the input manager.
  14314. * @returns the current input manager
  14315. */
  14316. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14317. if (!this._deviceOrientationInput) {
  14318. this._deviceOrientationInput = new FreeCameraDeviceOrientationInput();
  14319. this.add(this._deviceOrientationInput);
  14320. }
  14321. return this;
  14322. };
  14323. /**
  14324. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14325. * Screen rotation is taken into account.
  14326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14327. */
  14328. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14329. /**
  14330. * Instantiates a new input
  14331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14332. */
  14333. function FreeCameraDeviceOrientationInput() {
  14334. var _this = this;
  14335. this._screenOrientationAngle = 0;
  14336. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14337. this._alpha = 0;
  14338. this._beta = 0;
  14339. this._gamma = 0;
  14340. /**
  14341. * @hidden
  14342. */
  14343. this._onDeviceOrientationChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  14344. this._orientationChanged = function () {
  14345. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14346. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14347. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14348. };
  14349. this._deviceOrientation = function (evt) {
  14350. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14351. _this._beta = evt.beta !== null ? evt.beta : 0;
  14352. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14353. if (evt.alpha !== null) {
  14354. _this._onDeviceOrientationChangedObservable.notifyObservers();
  14355. }
  14356. };
  14357. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14358. this._orientationChanged();
  14359. }
  14360. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14361. /**
  14362. * Define the camera controlled by the input.
  14363. */
  14364. get: function () {
  14365. return this._camera;
  14366. },
  14367. set: function (camera) {
  14368. var _this = this;
  14369. this._camera = camera;
  14370. if (this._camera != null && !this._camera.rotationQuaternion) {
  14371. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14372. }
  14373. if (this._camera) {
  14374. this._camera.onDisposeObservable.add(function () {
  14375. _this._onDeviceOrientationChangedObservable.clear();
  14376. });
  14377. }
  14378. },
  14379. enumerable: true,
  14380. configurable: true
  14381. });
  14382. /**
  14383. * Attach the input controls to a specific dom element to get the input from.
  14384. * @param element Defines the element the controls should be listened from
  14385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14386. */
  14387. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14388. window.addEventListener("orientationchange", this._orientationChanged);
  14389. window.addEventListener("deviceorientation", this._deviceOrientation);
  14390. //In certain cases, the attach control is called AFTER orientation was changed,
  14391. //So this is needed.
  14392. this._orientationChanged();
  14393. };
  14394. /**
  14395. * Detach the current controls from the specified dom element.
  14396. * @param element Defines the element to stop listening the inputs from
  14397. */
  14398. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14399. window.removeEventListener("orientationchange", this._orientationChanged);
  14400. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14401. this._alpha = 0;
  14402. };
  14403. /**
  14404. * Update the current camera state depending on the inputs that have been used this frame.
  14405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14406. */
  14407. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14408. //if no device orientation provided, don't update the rotation.
  14409. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14410. if (!this._alpha) {
  14411. return;
  14412. }
  14413. _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);
  14414. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14415. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14416. //Mirror on XY Plane
  14417. this._camera.rotationQuaternion.z *= -1;
  14418. this._camera.rotationQuaternion.w *= -1;
  14419. };
  14420. /**
  14421. * Gets the class name of the current intput.
  14422. * @returns the class name
  14423. */
  14424. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14425. return "FreeCameraDeviceOrientationInput";
  14426. };
  14427. /**
  14428. * Get the friendly name associated with the input class.
  14429. * @returns the input friendly name
  14430. */
  14431. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14432. return "deviceOrientation";
  14433. };
  14434. return FreeCameraDeviceOrientationInput;
  14435. }());
  14436. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14437. /***/ }),
  14438. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14439. /*!**************************************************!*\
  14440. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14441. \**************************************************/
  14442. /*! exports provided: FreeCameraGamepadInput */
  14443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14444. "use strict";
  14445. __webpack_require__.r(__webpack_exports__);
  14446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14447. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14448. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14449. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14450. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14451. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14452. /**
  14453. * Manage the gamepad inputs to control a free camera.
  14454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14455. */
  14456. var FreeCameraGamepadInput = /** @class */ (function () {
  14457. function FreeCameraGamepadInput() {
  14458. /**
  14459. * Defines the gamepad rotation sensiblity.
  14460. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14461. */
  14462. this.gamepadAngularSensibility = 200;
  14463. /**
  14464. * Defines the gamepad move sensiblity.
  14465. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14466. */
  14467. this.gamepadMoveSensibility = 40;
  14468. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14469. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14470. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14471. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14472. }
  14473. /**
  14474. * Attach the input controls to a specific dom element to get the input from.
  14475. * @param element Defines the element the controls should be listened from
  14476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14477. */
  14478. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14479. var _this = this;
  14480. var manager = this.camera.getScene().gamepadManager;
  14481. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14482. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14483. // prioritize XBOX gamepads.
  14484. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14485. _this.gamepad = gamepad;
  14486. }
  14487. }
  14488. });
  14489. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14490. if (_this.gamepad === gamepad) {
  14491. _this.gamepad = null;
  14492. }
  14493. });
  14494. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14495. };
  14496. /**
  14497. * Detach the current controls from the specified dom element.
  14498. * @param element Defines the element to stop listening the inputs from
  14499. */
  14500. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14501. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14502. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14503. this.gamepad = null;
  14504. };
  14505. /**
  14506. * Update the current camera state depending on the inputs that have been used this frame.
  14507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14508. */
  14509. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14510. if (this.gamepad && this.gamepad.leftStick) {
  14511. var camera = this.camera;
  14512. var LSValues = this.gamepad.leftStick;
  14513. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14514. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14515. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14516. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14517. var RSValues = this.gamepad.rightStick;
  14518. if (RSValues) {
  14519. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14520. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14521. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14522. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14523. }
  14524. else {
  14525. RSValues = { x: 0, y: 0 };
  14526. }
  14527. if (!camera.rotationQuaternion) {
  14528. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14529. }
  14530. else {
  14531. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14532. }
  14533. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14534. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14535. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14536. camera.cameraDirection.addInPlace(this._deltaTransform);
  14537. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14538. camera.cameraRotation.addInPlace(this._vector2);
  14539. }
  14540. };
  14541. /**
  14542. * Gets the class name of the current intput.
  14543. * @returns the class name
  14544. */
  14545. FreeCameraGamepadInput.prototype.getClassName = function () {
  14546. return "FreeCameraGamepadInput";
  14547. };
  14548. /**
  14549. * Get the friendly name associated with the input class.
  14550. * @returns the input friendly name
  14551. */
  14552. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14553. return "gamepad";
  14554. };
  14555. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14557. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14558. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14560. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14561. return FreeCameraGamepadInput;
  14562. }());
  14563. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14564. /***/ }),
  14565. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14566. /*!*******************************************************!*\
  14567. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14568. \*******************************************************/
  14569. /*! exports provided: FreeCameraKeyboardMoveInput */
  14570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14571. "use strict";
  14572. __webpack_require__.r(__webpack_exports__);
  14573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14574. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14575. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14576. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14577. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14578. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14579. /**
  14580. * Manage the keyboard inputs to control the movement of a free camera.
  14581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14582. */
  14583. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14584. function FreeCameraKeyboardMoveInput() {
  14585. /**
  14586. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14587. */
  14588. this.keysUp = [38];
  14589. /**
  14590. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14591. */
  14592. this.keysDown = [40];
  14593. /**
  14594. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14595. */
  14596. this.keysLeft = [37];
  14597. /**
  14598. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14599. */
  14600. this.keysRight = [39];
  14601. this._keys = new Array();
  14602. }
  14603. /**
  14604. * Attach the input controls to a specific dom element to get the input from.
  14605. * @param element Defines the element the controls should be listened from
  14606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14607. */
  14608. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14609. var _this = this;
  14610. if (this._onCanvasBlurObserver) {
  14611. return;
  14612. }
  14613. this._scene = this.camera.getScene();
  14614. this._engine = this._scene.getEngine();
  14615. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14616. _this._keys = [];
  14617. });
  14618. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14619. var evt = info.event;
  14620. if (!evt.metaKey) {
  14621. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14622. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14623. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14624. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14625. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14626. var index = _this._keys.indexOf(evt.keyCode);
  14627. if (index === -1) {
  14628. _this._keys.push(evt.keyCode);
  14629. }
  14630. if (!noPreventDefault) {
  14631. evt.preventDefault();
  14632. }
  14633. }
  14634. }
  14635. else {
  14636. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14637. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14638. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14639. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14640. var index = _this._keys.indexOf(evt.keyCode);
  14641. if (index >= 0) {
  14642. _this._keys.splice(index, 1);
  14643. }
  14644. if (!noPreventDefault) {
  14645. evt.preventDefault();
  14646. }
  14647. }
  14648. }
  14649. }
  14650. });
  14651. };
  14652. /**
  14653. * Detach the current controls from the specified dom element.
  14654. * @param element Defines the element to stop listening the inputs from
  14655. */
  14656. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14657. if (this._scene) {
  14658. if (this._onKeyboardObserver) {
  14659. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14660. }
  14661. if (this._onCanvasBlurObserver) {
  14662. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14663. }
  14664. this._onKeyboardObserver = null;
  14665. this._onCanvasBlurObserver = null;
  14666. }
  14667. this._keys = [];
  14668. };
  14669. /**
  14670. * Update the current camera state depending on the inputs that have been used this frame.
  14671. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14672. */
  14673. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14674. if (this._onKeyboardObserver) {
  14675. var camera = this.camera;
  14676. // Keyboard
  14677. for (var index = 0; index < this._keys.length; index++) {
  14678. var keyCode = this._keys[index];
  14679. var speed = camera._computeLocalCameraSpeed();
  14680. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14681. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14682. }
  14683. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14684. camera._localDirection.copyFromFloats(0, 0, speed);
  14685. }
  14686. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14687. camera._localDirection.copyFromFloats(speed, 0, 0);
  14688. }
  14689. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14690. camera._localDirection.copyFromFloats(0, 0, -speed);
  14691. }
  14692. if (camera.getScene().useRightHandedSystem) {
  14693. camera._localDirection.z *= -1;
  14694. }
  14695. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14696. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14697. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14698. }
  14699. }
  14700. };
  14701. /**
  14702. * Gets the class name of the current intput.
  14703. * @returns the class name
  14704. */
  14705. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14706. return "FreeCameraKeyboardMoveInput";
  14707. };
  14708. /** @hidden */
  14709. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14710. this._keys = [];
  14711. };
  14712. /**
  14713. * Get the friendly name associated with the input class.
  14714. * @returns the input friendly name
  14715. */
  14716. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14717. return "keyboard";
  14718. };
  14719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14721. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14724. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14727. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14728. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14729. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14730. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14731. return FreeCameraKeyboardMoveInput;
  14732. }());
  14733. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14734. /***/ }),
  14735. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14736. /*!************************************************!*\
  14737. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14738. \************************************************/
  14739. /*! exports provided: FreeCameraMouseInput */
  14740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14741. "use strict";
  14742. __webpack_require__.r(__webpack_exports__);
  14743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14744. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14745. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14746. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14747. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14748. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14749. /**
  14750. * Manage the mouse inputs to control the movement of a free camera.
  14751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14752. */
  14753. var FreeCameraMouseInput = /** @class */ (function () {
  14754. /**
  14755. * Manage the mouse inputs to control the movement of a free camera.
  14756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14757. * @param touchEnabled Defines if touch is enabled or not
  14758. */
  14759. function FreeCameraMouseInput(
  14760. /**
  14761. * Define if touch is enabled in the mouse input
  14762. */
  14763. touchEnabled) {
  14764. if (touchEnabled === void 0) { touchEnabled = true; }
  14765. this.touchEnabled = touchEnabled;
  14766. /**
  14767. * Defines the buttons associated with the input to handle camera move.
  14768. */
  14769. this.buttons = [0, 1, 2];
  14770. /**
  14771. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14772. */
  14773. this.angularSensibility = 2000.0;
  14774. this.previousPosition = null;
  14775. /**
  14776. * Observable for when a pointer move event occurs containing the move offset
  14777. */
  14778. this.onPointerMovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  14779. /**
  14780. * @hidden
  14781. * If the camera should be rotated automatically based on pointer movement
  14782. */
  14783. this._allowCameraRotation = true;
  14784. }
  14785. /**
  14786. * Attach the input controls to a specific dom element to get the input from.
  14787. * @param element Defines the element the controls should be listened from
  14788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14789. */
  14790. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14791. var _this = this;
  14792. var engine = this.camera.getEngine();
  14793. if (!this._pointerInput) {
  14794. this._pointerInput = function (p) {
  14795. var evt = p.event;
  14796. if (engine.isInVRExclusivePointerMode) {
  14797. return;
  14798. }
  14799. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14800. return;
  14801. }
  14802. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14803. return;
  14804. }
  14805. var srcElement = (evt.srcElement || evt.target);
  14806. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14807. try {
  14808. srcElement.setPointerCapture(evt.pointerId);
  14809. }
  14810. catch (e) {
  14811. //Nothing to do with the error. Execution will continue.
  14812. }
  14813. _this.previousPosition = {
  14814. x: evt.clientX,
  14815. y: evt.clientY
  14816. };
  14817. if (!noPreventDefault) {
  14818. evt.preventDefault();
  14819. element.focus();
  14820. }
  14821. }
  14822. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  14823. try {
  14824. srcElement.releasePointerCapture(evt.pointerId);
  14825. }
  14826. catch (e) {
  14827. //Nothing to do with the error.
  14828. }
  14829. _this.previousPosition = null;
  14830. if (!noPreventDefault) {
  14831. evt.preventDefault();
  14832. }
  14833. }
  14834. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  14835. if (!_this.previousPosition || engine.isPointerLock) {
  14836. return;
  14837. }
  14838. var offsetX = evt.clientX - _this.previousPosition.x;
  14839. var offsetY = evt.clientY - _this.previousPosition.y;
  14840. if (_this.camera.getScene().useRightHandedSystem) {
  14841. offsetX *= -1;
  14842. }
  14843. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14844. offsetX *= -1;
  14845. }
  14846. if (_this._allowCameraRotation) {
  14847. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14848. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14849. }
  14850. _this.onPointerMovedObservable.notifyObservers({ offsetX: offsetX, offsetY: offsetY });
  14851. _this.previousPosition = {
  14852. x: evt.clientX,
  14853. y: evt.clientY
  14854. };
  14855. if (!noPreventDefault) {
  14856. evt.preventDefault();
  14857. }
  14858. }
  14859. };
  14860. }
  14861. this._onMouseMove = function (evt) {
  14862. if (!engine.isPointerLock) {
  14863. return;
  14864. }
  14865. if (engine.isInVRExclusivePointerMode) {
  14866. return;
  14867. }
  14868. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14869. if (_this.camera.getScene().useRightHandedSystem) {
  14870. offsetX *= -1;
  14871. }
  14872. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14873. offsetX *= -1;
  14874. }
  14875. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14876. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14877. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14878. _this.previousPosition = null;
  14879. if (!noPreventDefault) {
  14880. evt.preventDefault();
  14881. }
  14882. };
  14883. 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);
  14884. element.addEventListener("mousemove", this._onMouseMove, false);
  14885. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  14886. };
  14887. /**
  14888. * Called on JS contextmenu event.
  14889. * Override this method to provide functionality.
  14890. */
  14891. FreeCameraMouseInput.prototype.onContextMenu = function (evt) {
  14892. evt.preventDefault();
  14893. };
  14894. /**
  14895. * Detach the current controls from the specified dom element.
  14896. * @param element Defines the element to stop listening the inputs from
  14897. */
  14898. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14899. if (this._observer && element) {
  14900. this.camera.getScene().onPointerObservable.remove(this._observer);
  14901. if (this._onMouseMove) {
  14902. element.removeEventListener("mousemove", this._onMouseMove);
  14903. }
  14904. if (this.onContextMenu) {
  14905. element.removeEventListener("contextmenu", this.onContextMenu);
  14906. }
  14907. if (this.onPointerMovedObservable) {
  14908. this.onPointerMovedObservable.clear();
  14909. }
  14910. this._observer = null;
  14911. this._onMouseMove = null;
  14912. this.previousPosition = null;
  14913. }
  14914. };
  14915. /**
  14916. * Gets the class name of the current intput.
  14917. * @returns the class name
  14918. */
  14919. FreeCameraMouseInput.prototype.getClassName = function () {
  14920. return "FreeCameraMouseInput";
  14921. };
  14922. /**
  14923. * Get the friendly name associated with the input class.
  14924. * @returns the input friendly name
  14925. */
  14926. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14927. return "mouse";
  14928. };
  14929. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14931. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14932. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14933. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14934. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14935. return FreeCameraMouseInput;
  14936. }());
  14937. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14938. /***/ }),
  14939. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14940. /*!************************************************!*\
  14941. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14942. \************************************************/
  14943. /*! exports provided: FreeCameraTouchInput */
  14944. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14945. "use strict";
  14946. __webpack_require__.r(__webpack_exports__);
  14947. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14948. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14949. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14950. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14951. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14952. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14953. /**
  14954. * Manage the touch inputs to control the movement of a free camera.
  14955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14956. */
  14957. var FreeCameraTouchInput = /** @class */ (function () {
  14958. function FreeCameraTouchInput() {
  14959. /**
  14960. * Defines the touch sensibility for rotation.
  14961. * The higher the faster.
  14962. */
  14963. this.touchAngularSensibility = 200000.0;
  14964. /**
  14965. * Defines the touch sensibility for move.
  14966. * The higher the faster.
  14967. */
  14968. this.touchMoveSensibility = 250.0;
  14969. this._offsetX = null;
  14970. this._offsetY = null;
  14971. this._pointerPressed = new Array();
  14972. }
  14973. /**
  14974. * Attach the input controls to a specific dom element to get the input from.
  14975. * @param element Defines the element the controls should be listened from
  14976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14977. */
  14978. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14979. var _this = this;
  14980. var previousPosition = null;
  14981. if (this._pointerInput === undefined) {
  14982. this._onLostFocus = function () {
  14983. _this._offsetX = null;
  14984. _this._offsetY = null;
  14985. };
  14986. this._pointerInput = function (p) {
  14987. var evt = p.event;
  14988. if (evt.pointerType === "mouse") {
  14989. return;
  14990. }
  14991. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14992. if (!noPreventDefault) {
  14993. evt.preventDefault();
  14994. }
  14995. _this._pointerPressed.push(evt.pointerId);
  14996. if (_this._pointerPressed.length !== 1) {
  14997. return;
  14998. }
  14999. previousPosition = {
  15000. x: evt.clientX,
  15001. y: evt.clientY
  15002. };
  15003. }
  15004. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  15005. if (!noPreventDefault) {
  15006. evt.preventDefault();
  15007. }
  15008. var index = _this._pointerPressed.indexOf(evt.pointerId);
  15009. if (index === -1) {
  15010. return;
  15011. }
  15012. _this._pointerPressed.splice(index, 1);
  15013. if (index != 0) {
  15014. return;
  15015. }
  15016. previousPosition = null;
  15017. _this._offsetX = null;
  15018. _this._offsetY = null;
  15019. }
  15020. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  15021. if (!noPreventDefault) {
  15022. evt.preventDefault();
  15023. }
  15024. if (!previousPosition) {
  15025. return;
  15026. }
  15027. var index = _this._pointerPressed.indexOf(evt.pointerId);
  15028. if (index != 0) {
  15029. return;
  15030. }
  15031. _this._offsetX = evt.clientX - previousPosition.x;
  15032. _this._offsetY = -(evt.clientY - previousPosition.y);
  15033. }
  15034. };
  15035. }
  15036. 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);
  15037. if (this._onLostFocus) {
  15038. element.addEventListener("blur", this._onLostFocus);
  15039. }
  15040. };
  15041. /**
  15042. * Detach the current controls from the specified dom element.
  15043. * @param element Defines the element to stop listening the inputs from
  15044. */
  15045. FreeCameraTouchInput.prototype.detachControl = function (element) {
  15046. if (this._pointerInput && element) {
  15047. if (this._observer) {
  15048. this.camera.getScene().onPointerObservable.remove(this._observer);
  15049. this._observer = null;
  15050. }
  15051. if (this._onLostFocus) {
  15052. element.removeEventListener("blur", this._onLostFocus);
  15053. this._onLostFocus = null;
  15054. }
  15055. this._pointerPressed = [];
  15056. this._offsetX = null;
  15057. this._offsetY = null;
  15058. }
  15059. };
  15060. /**
  15061. * Update the current camera state depending on the inputs that have been used this frame.
  15062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15063. */
  15064. FreeCameraTouchInput.prototype.checkInputs = function () {
  15065. if (this._offsetX && this._offsetY) {
  15066. var camera = this.camera;
  15067. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  15068. if (this._pointerPressed.length > 1) {
  15069. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  15070. }
  15071. else {
  15072. var speed = camera._computeLocalCameraSpeed();
  15073. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  15074. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  15075. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  15076. }
  15077. }
  15078. };
  15079. /**
  15080. * Gets the class name of the current intput.
  15081. * @returns the class name
  15082. */
  15083. FreeCameraTouchInput.prototype.getClassName = function () {
  15084. return "FreeCameraTouchInput";
  15085. };
  15086. /**
  15087. * Get the friendly name associated with the input class.
  15088. * @returns the input friendly name
  15089. */
  15090. FreeCameraTouchInput.prototype.getSimpleName = function () {
  15091. return "touch";
  15092. };
  15093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15095. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  15096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15098. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  15099. return FreeCameraTouchInput;
  15100. }());
  15101. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  15102. /***/ }),
  15103. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  15104. /*!**********************************************************!*\
  15105. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  15106. \**********************************************************/
  15107. /*! exports provided: FreeCameraVirtualJoystickInput */
  15108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15109. "use strict";
  15110. __webpack_require__.r(__webpack_exports__);
  15111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  15112. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  15113. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15114. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15115. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  15116. /**
  15117. * Add virtual joystick input support to the input manager.
  15118. * @returns the current input manager
  15119. */
  15120. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  15121. this.add(new FreeCameraVirtualJoystickInput());
  15122. return this;
  15123. };
  15124. /**
  15125. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  15126. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15127. */
  15128. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15129. function FreeCameraVirtualJoystickInput() {
  15130. }
  15131. /**
  15132. * Gets the left stick of the virtual joystick.
  15133. * @returns The virtual Joystick
  15134. */
  15135. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15136. return this._leftjoystick;
  15137. };
  15138. /**
  15139. * Gets the right stick of the virtual joystick.
  15140. * @returns The virtual Joystick
  15141. */
  15142. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15143. return this._rightjoystick;
  15144. };
  15145. /**
  15146. * Update the current camera state depending on the inputs that have been used this frame.
  15147. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15148. */
  15149. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15150. if (this._leftjoystick) {
  15151. var camera = this.camera;
  15152. var speed = camera._computeLocalCameraSpeed() * 50;
  15153. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15154. 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);
  15155. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15156. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15157. if (!this._leftjoystick.pressed) {
  15158. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15159. }
  15160. if (!this._rightjoystick.pressed) {
  15161. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15162. }
  15163. }
  15164. };
  15165. /**
  15166. * Attach the input controls to a specific dom element to get the input from.
  15167. * @param element Defines the element the controls should be listened from
  15168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15169. */
  15170. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15171. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15172. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15173. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15174. this._leftjoystick.setJoystickSensibility(0.15);
  15175. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15176. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15177. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15178. this._rightjoystick.reverseUpDown = true;
  15179. this._rightjoystick.setJoystickSensibility(0.05);
  15180. this._rightjoystick.setJoystickColor("yellow");
  15181. };
  15182. /**
  15183. * Detach the current controls from the specified dom element.
  15184. * @param element Defines the element to stop listening the inputs from
  15185. */
  15186. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15187. this._leftjoystick.releaseCanvas();
  15188. this._rightjoystick.releaseCanvas();
  15189. };
  15190. /**
  15191. * Gets the class name of the current intput.
  15192. * @returns the class name
  15193. */
  15194. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15195. return "FreeCameraVirtualJoystickInput";
  15196. };
  15197. /**
  15198. * Get the friendly name associated with the input class.
  15199. * @returns the input friendly name
  15200. */
  15201. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15202. return "virtualJoystick";
  15203. };
  15204. return FreeCameraVirtualJoystickInput;
  15205. }());
  15206. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15207. /***/ }),
  15208. /***/ "./Cameras/Inputs/index.ts":
  15209. /*!*********************************!*\
  15210. !*** ./Cameras/Inputs/index.ts ***!
  15211. \*********************************/
  15212. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15214. "use strict";
  15215. __webpack_require__.r(__webpack_exports__);
  15216. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15218. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15220. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15222. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15224. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15226. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15228. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15230. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15232. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15234. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15236. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15238. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15240. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15242. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15244. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15246. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15248. /***/ }),
  15249. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15250. /*!*********************************************************!*\
  15251. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15252. \*********************************************************/
  15253. /*! no exports provided */
  15254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15255. "use strict";
  15256. __webpack_require__.r(__webpack_exports__);
  15257. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15258. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15259. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15260. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15261. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15262. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15263. };
  15264. /***/ }),
  15265. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15266. /*!*************************************************!*\
  15267. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  15268. \*************************************************/
  15269. /*! no exports provided */
  15270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15271. "use strict";
  15272. __webpack_require__.r(__webpack_exports__);
  15273. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15274. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15275. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15276. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15277. 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;
  15278. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15279. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15280. };
  15281. /***/ }),
  15282. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15283. /*!***************************************!*\
  15284. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15285. \***************************************/
  15286. /*! no exports provided */
  15287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15288. "use strict";
  15289. __webpack_require__.r(__webpack_exports__);
  15290. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15291. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15292. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15293. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  15294. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15295. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15296. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15297. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__["VRCameraMetrics"].GetDefault();
  15298. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15299. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15300. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15301. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15302. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15303. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15304. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15305. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15306. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15307. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15308. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15309. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15310. // For multiview on a webVR camera
  15311. // First multiview will be rendered to camera._multiviewTexture
  15312. // Then this postprocess will run on each eye to copy the right texture to each eye
  15313. if (metrics.multiviewEnabled) {
  15314. if (!camera.getScene().getEngine().getCaps().multiview) {
  15315. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  15316. metrics.multiviewEnabled = false;
  15317. }
  15318. else {
  15319. camera._useMultiviewToSingleView = true;
  15320. camera._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", camera, metrics.postProcessScaleFactor);
  15321. }
  15322. }
  15323. if (metrics.compensateDistortion) {
  15324. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15325. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15326. }
  15327. };
  15328. /***/ }),
  15329. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15330. /*!******************************************!*\
  15331. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15332. \******************************************/
  15333. /*! no exports provided */
  15334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15335. "use strict";
  15336. __webpack_require__.r(__webpack_exports__);
  15337. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15338. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15339. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15340. if (rigParams.vrDisplay) {
  15341. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15342. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15343. //Left eye
  15344. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15345. camera._rigCameras[0].setCameraRigParameter("left", true);
  15346. //leaving this for future reference
  15347. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15348. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15349. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15350. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15351. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15352. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15353. camera._rigCameras[0].parent = camera;
  15354. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15355. //Right eye
  15356. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15357. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15358. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15359. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15360. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15361. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15362. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15363. camera._rigCameras[1].parent = camera;
  15364. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15365. }
  15366. };
  15367. /***/ }),
  15368. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15369. /*!*********************************************************!*\
  15370. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15371. \*********************************************************/
  15372. /*! exports provided: AnaglyphArcRotateCamera */
  15373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15374. "use strict";
  15375. __webpack_require__.r(__webpack_exports__);
  15376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15377. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15378. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15379. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15380. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15381. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15382. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15383. // Side effect import to define the stereoscopic mode.
  15384. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15385. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15386. });
  15387. /**
  15388. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15389. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15390. */
  15391. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15392. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15393. /**
  15394. * Creates a new AnaglyphArcRotateCamera
  15395. * @param name defines camera name
  15396. * @param alpha defines alpha angle (in radians)
  15397. * @param beta defines beta angle (in radians)
  15398. * @param radius defines radius
  15399. * @param target defines camera target
  15400. * @param interaxialDistance defines distance between each color axis
  15401. * @param scene defines the hosting scene
  15402. */
  15403. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15404. var _this = _super.call(this, name, alpha, beta, radius, target, 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 AnaglyphArcRotateCamera
  15412. */
  15413. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15414. return "AnaglyphArcRotateCamera";
  15415. };
  15416. return AnaglyphArcRotateCamera;
  15417. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15418. /***/ }),
  15419. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15420. /*!****************************************************!*\
  15421. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15422. \****************************************************/
  15423. /*! exports provided: AnaglyphFreeCamera */
  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__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  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_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.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("AnaglyphFreeCamera", function (name, scene, options) {
  15436. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15437. });
  15438. /**
  15439. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15440. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15441. */
  15442. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15443. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15444. /**
  15445. * Creates a new AnaglyphFreeCamera
  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 AnaglyphFreeCamera(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 AnaglyphFreeCamera
  15460. */
  15461. AnaglyphFreeCamera.prototype.getClassName = function () {
  15462. return "AnaglyphFreeCamera";
  15463. };
  15464. return AnaglyphFreeCamera;
  15465. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15466. /***/ }),
  15467. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15468. /*!*******************************************************!*\
  15469. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15470. \*******************************************************/
  15471. /*! exports provided: AnaglyphGamepadCamera */
  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__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  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_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.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("AnaglyphGamepadCamera", function (name, scene, options) {
  15484. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15485. });
  15486. /**
  15487. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15488. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15489. */
  15490. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15491. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15492. /**
  15493. * Creates a new AnaglyphGamepadCamera
  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 AnaglyphGamepadCamera(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 AnaglyphGamepadCamera
  15508. */
  15509. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15510. return "AnaglyphGamepadCamera";
  15511. };
  15512. return AnaglyphGamepadCamera;
  15513. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15514. /***/ }),
  15515. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15516. /*!*********************************************************!*\
  15517. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15518. \*********************************************************/
  15519. /*! exports provided: AnaglyphUniversalCamera */
  15520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15521. "use strict";
  15522. __webpack_require__.r(__webpack_exports__);
  15523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15524. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15525. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15526. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15527. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15528. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15529. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15530. // Side effect import to define the stereoscopic mode.
  15531. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15532. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15533. });
  15534. /**
  15535. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15536. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15537. */
  15538. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15539. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15540. /**
  15541. * Creates a new AnaglyphUniversalCamera
  15542. * @param name defines camera name
  15543. * @param position defines initial position
  15544. * @param interaxialDistance defines distance between each color axis
  15545. * @param scene defines the hosting scene
  15546. */
  15547. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15548. var _this = _super.call(this, name, position, scene) || this;
  15549. _this.interaxialDistance = interaxialDistance;
  15550. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15551. return _this;
  15552. }
  15553. /**
  15554. * Gets camera class name
  15555. * @returns AnaglyphUniversalCamera
  15556. */
  15557. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15558. return "AnaglyphUniversalCamera";
  15559. };
  15560. return AnaglyphUniversalCamera;
  15561. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15562. /***/ }),
  15563. /***/ "./Cameras/Stereoscopic/index.ts":
  15564. /*!***************************************!*\
  15565. !*** ./Cameras/Stereoscopic/index.ts ***!
  15566. \***************************************/
  15567. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15569. "use strict";
  15570. __webpack_require__.r(__webpack_exports__);
  15571. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15573. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15575. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15577. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15579. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15581. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15583. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15585. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15587. /***/ }),
  15588. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15589. /*!*************************************************************!*\
  15590. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15591. \*************************************************************/
  15592. /*! exports provided: StereoscopicArcRotateCamera */
  15593. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15594. "use strict";
  15595. __webpack_require__.r(__webpack_exports__);
  15596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15597. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15598. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15599. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15600. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15601. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15602. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15603. // Side effect import to define the stereoscopic mode.
  15604. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15605. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15606. });
  15607. /**
  15608. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15609. * @see http://doc.babylonjs.com/features/cameras
  15610. */
  15611. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15612. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15613. /**
  15614. * Creates a new StereoscopicArcRotateCamera
  15615. * @param name defines camera name
  15616. * @param alpha defines alpha angle (in radians)
  15617. * @param beta defines beta angle (in radians)
  15618. * @param radius defines radius
  15619. * @param target defines camera target
  15620. * @param interaxialDistance defines distance between each color axis
  15621. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15622. * @param scene defines the hosting scene
  15623. */
  15624. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15625. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15626. _this.interaxialDistance = interaxialDistance;
  15627. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15628. _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 });
  15629. return _this;
  15630. }
  15631. /**
  15632. * Gets camera class name
  15633. * @returns StereoscopicArcRotateCamera
  15634. */
  15635. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15636. return "StereoscopicArcRotateCamera";
  15637. };
  15638. return StereoscopicArcRotateCamera;
  15639. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15640. /***/ }),
  15641. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15642. /*!********************************************************!*\
  15643. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15644. \********************************************************/
  15645. /*! exports provided: StereoscopicFreeCamera */
  15646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15647. "use strict";
  15648. __webpack_require__.r(__webpack_exports__);
  15649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15650. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15651. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15652. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15654. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15655. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15656. // Side effect import to define the stereoscopic mode.
  15657. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15658. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15659. });
  15660. /**
  15661. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15662. * @see http://doc.babylonjs.com/features/cameras
  15663. */
  15664. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15665. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15666. /**
  15667. * Creates a new StereoscopicFreeCamera
  15668. * @param name defines camera name
  15669. * @param position defines initial position
  15670. * @param interaxialDistance defines distance between each color axis
  15671. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15672. * @param scene defines the hosting scene
  15673. */
  15674. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15675. var _this = _super.call(this, name, position, scene) || this;
  15676. _this.interaxialDistance = interaxialDistance;
  15677. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15678. _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 });
  15679. return _this;
  15680. }
  15681. /**
  15682. * Gets camera class name
  15683. * @returns StereoscopicFreeCamera
  15684. */
  15685. StereoscopicFreeCamera.prototype.getClassName = function () {
  15686. return "StereoscopicFreeCamera";
  15687. };
  15688. return StereoscopicFreeCamera;
  15689. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15690. /***/ }),
  15691. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15692. /*!***********************************************************!*\
  15693. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15694. \***********************************************************/
  15695. /*! exports provided: StereoscopicGamepadCamera */
  15696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15697. "use strict";
  15698. __webpack_require__.r(__webpack_exports__);
  15699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15700. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15701. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15702. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15703. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15704. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15705. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15706. // Side effect import to define the stereoscopic mode.
  15707. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15708. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15709. });
  15710. /**
  15711. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15712. * @see http://doc.babylonjs.com/features/cameras
  15713. */
  15714. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15715. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15716. /**
  15717. * Creates a new StereoscopicGamepadCamera
  15718. * @param name defines camera name
  15719. * @param position defines initial position
  15720. * @param interaxialDistance defines distance between each color axis
  15721. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15722. * @param scene defines the hosting scene
  15723. */
  15724. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15725. var _this = _super.call(this, name, position, scene) || this;
  15726. _this.interaxialDistance = interaxialDistance;
  15727. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15728. _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 });
  15729. return _this;
  15730. }
  15731. /**
  15732. * Gets camera class name
  15733. * @returns StereoscopicGamepadCamera
  15734. */
  15735. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15736. return "StereoscopicGamepadCamera";
  15737. };
  15738. return StereoscopicGamepadCamera;
  15739. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15740. /***/ }),
  15741. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15742. /*!*************************************************************!*\
  15743. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15744. \*************************************************************/
  15745. /*! exports provided: StereoscopicUniversalCamera */
  15746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15747. "use strict";
  15748. __webpack_require__.r(__webpack_exports__);
  15749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15751. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15752. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15753. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15754. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15755. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15756. // Side effect import to define the stereoscopic mode.
  15757. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15758. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15759. });
  15760. /**
  15761. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15762. * @see http://doc.babylonjs.com/features/cameras
  15763. */
  15764. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15765. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15766. /**
  15767. * Creates a new StereoscopicUniversalCamera
  15768. * @param name defines camera name
  15769. * @param position defines initial position
  15770. * @param interaxialDistance defines distance between each color axis
  15771. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15772. * @param scene defines the hosting scene
  15773. */
  15774. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15775. var _this = _super.call(this, name, position, scene) || this;
  15776. _this.interaxialDistance = interaxialDistance;
  15777. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15778. _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 });
  15779. return _this;
  15780. }
  15781. /**
  15782. * Gets camera class name
  15783. * @returns StereoscopicUniversalCamera
  15784. */
  15785. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15786. return "StereoscopicUniversalCamera";
  15787. };
  15788. return StereoscopicUniversalCamera;
  15789. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15790. /***/ }),
  15791. /***/ "./Cameras/VR/index.ts":
  15792. /*!*****************************!*\
  15793. !*** ./Cameras/VR/index.ts ***!
  15794. \*****************************/
  15795. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15797. "use strict";
  15798. __webpack_require__.r(__webpack_exports__);
  15799. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15801. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15803. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15805. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15807. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  15809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15810. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15812. /***/ }),
  15813. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15814. /*!***************************************!*\
  15815. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15816. \***************************************/
  15817. /*! exports provided: VRCameraMetrics */
  15818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15819. "use strict";
  15820. __webpack_require__.r(__webpack_exports__);
  15821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15822. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15823. /**
  15824. * This represents all the required metrics to create a VR camera.
  15825. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15826. */
  15827. var VRCameraMetrics = /** @class */ (function () {
  15828. function VRCameraMetrics() {
  15829. /**
  15830. * Define if the current vr camera should compensate the distortion of the lense or not.
  15831. */
  15832. this.compensateDistortion = true;
  15833. /**
  15834. * Defines if multiview should be enabled when rendering (Default: false)
  15835. */
  15836. this.multiviewEnabled = false;
  15837. }
  15838. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15839. /**
  15840. * Gets the rendering aspect ratio based on the provided resolutions.
  15841. */
  15842. get: function () {
  15843. return this.hResolution / (2 * this.vResolution);
  15844. },
  15845. enumerable: true,
  15846. configurable: true
  15847. });
  15848. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15849. /**
  15850. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15851. */
  15852. get: function () {
  15853. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15854. },
  15855. enumerable: true,
  15856. configurable: true
  15857. });
  15858. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15859. /**
  15860. * @hidden
  15861. */
  15862. get: function () {
  15863. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15864. var h = (4 * meters) / this.hScreenSize;
  15865. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15866. },
  15867. enumerable: true,
  15868. configurable: true
  15869. });
  15870. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15871. /**
  15872. * @hidden
  15873. */
  15874. get: function () {
  15875. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15876. var h = (4 * meters) / this.hScreenSize;
  15877. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15878. },
  15879. enumerable: true,
  15880. configurable: true
  15881. });
  15882. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15883. /**
  15884. * @hidden
  15885. */
  15886. get: function () {
  15887. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15888. },
  15889. enumerable: true,
  15890. configurable: true
  15891. });
  15892. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15893. /**
  15894. * @hidden
  15895. */
  15896. get: function () {
  15897. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15898. },
  15899. enumerable: true,
  15900. configurable: true
  15901. });
  15902. /**
  15903. * Get the default VRMetrics based on the most generic setup.
  15904. * @returns the default vr metrics
  15905. */
  15906. VRCameraMetrics.GetDefault = function () {
  15907. var result = new VRCameraMetrics();
  15908. result.hResolution = 1280;
  15909. result.vResolution = 800;
  15910. result.hScreenSize = 0.149759993;
  15911. result.vScreenSize = 0.0935999975;
  15912. result.vScreenCenter = 0.0467999987;
  15913. result.eyeToScreenDistance = 0.0410000011;
  15914. result.lensSeparationDistance = 0.0635000020;
  15915. result.interpupillaryDistance = 0.0640000030;
  15916. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15917. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15918. result.postProcessScaleFactor = 1.714605507808412;
  15919. result.lensCenterOffset = 0.151976421;
  15920. return result;
  15921. };
  15922. return VRCameraMetrics;
  15923. }());
  15924. /***/ }),
  15925. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15926. /*!**********************************************************!*\
  15927. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15928. \**********************************************************/
  15929. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15931. "use strict";
  15932. __webpack_require__.r(__webpack_exports__);
  15933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15935. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15936. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15937. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15938. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15939. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15940. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15941. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15942. // Side effect import to define the stereoscopic mode.
  15943. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15944. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15945. });
  15946. /**
  15947. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15948. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15949. */
  15950. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15951. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15952. /**
  15953. * Creates a new VRDeviceOrientationArcRotateCamera
  15954. * @param name defines camera name
  15955. * @param alpha defines the camera rotation along the logitudinal axis
  15956. * @param beta defines the camera rotation along the latitudinal axis
  15957. * @param radius defines the camera distance from its target
  15958. * @param target defines the camera target
  15959. * @param scene defines the scene the camera belongs to
  15960. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15961. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15962. */
  15963. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15964. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15965. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15966. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15967. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15968. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15969. _this.inputs.addVRDeviceOrientation();
  15970. return _this;
  15971. }
  15972. /**
  15973. * Gets camera class name
  15974. * @returns VRDeviceOrientationArcRotateCamera
  15975. */
  15976. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15977. return "VRDeviceOrientationArcRotateCamera";
  15978. };
  15979. return VRDeviceOrientationArcRotateCamera;
  15980. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15981. /***/ }),
  15982. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15983. /*!*****************************************************!*\
  15984. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15985. \*****************************************************/
  15986. /*! exports provided: VRDeviceOrientationFreeCamera */
  15987. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15988. "use strict";
  15989. __webpack_require__.r(__webpack_exports__);
  15990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15991. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15992. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15993. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15994. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15995. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15996. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15997. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15998. // Side effect import to define the stereoscopic mode.
  15999. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  16000. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  16001. });
  16002. /**
  16003. * Camera used to simulate VR rendering (based on FreeCamera)
  16004. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16005. */
  16006. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  16007. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  16008. /**
  16009. * Creates a new VRDeviceOrientationFreeCamera
  16010. * @param name defines camera name
  16011. * @param position defines the start position of the camera
  16012. * @param scene defines the scene the camera belongs to
  16013. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16014. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16015. */
  16016. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16017. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16018. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  16019. var _this = _super.call(this, name, position, scene) || this;
  16020. vrCameraMetrics.compensateDistortion = compensateDistortion;
  16021. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  16022. return _this;
  16023. }
  16024. /**
  16025. * Gets camera class name
  16026. * @returns VRDeviceOrientationFreeCamera
  16027. */
  16028. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  16029. return "VRDeviceOrientationFreeCamera";
  16030. };
  16031. return VRDeviceOrientationFreeCamera;
  16032. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  16033. /***/ }),
  16034. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  16035. /*!********************************************************!*\
  16036. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  16037. \********************************************************/
  16038. /*! exports provided: VRDeviceOrientationGamepadCamera */
  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__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  16043. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16044. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16045. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16046. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16047. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16048. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  16049. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  16050. });
  16051. /**
  16052. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  16053. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16054. */
  16055. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  16056. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  16057. /**
  16058. * Creates a new VRDeviceOrientationGamepadCamera
  16059. * @param name defines camera name
  16060. * @param position defines the start position of the camera
  16061. * @param scene defines the scene the camera belongs to
  16062. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16063. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16064. */
  16065. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16066. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16067. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  16068. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  16069. _this.inputs.addGamepad();
  16070. return _this;
  16071. }
  16072. /**
  16073. * Gets camera class name
  16074. * @returns VRDeviceOrientationGamepadCamera
  16075. */
  16076. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  16077. return "VRDeviceOrientationGamepadCamera";
  16078. };
  16079. return VRDeviceOrientationGamepadCamera;
  16080. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  16081. /***/ }),
  16082. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  16083. /*!******************************************!*\
  16084. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  16085. \******************************************/
  16086. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  16087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16088. "use strict";
  16089. __webpack_require__.r(__webpack_exports__);
  16090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  16091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  16092. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16093. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  16094. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16095. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16096. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  16097. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  16098. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16099. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  16100. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  16101. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16102. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16103. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16104. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  16105. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  16106. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  16107. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  16108. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  16109. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  16110. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  16111. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  16112. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  16113. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  16114. /* harmony import */ var _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Cameras/VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16115. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  16116. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  16117. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  16118. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16119. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  16120. var VRExperienceHelperGazer = /** @class */ (function () {
  16121. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  16122. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  16123. this.scene = scene;
  16124. /** @hidden */
  16125. this._pointerDownOnMeshAsked = false;
  16126. /** @hidden */
  16127. this._isActionableMesh = false;
  16128. /** @hidden */
  16129. this._teleportationRequestInitiated = false;
  16130. /** @hidden */
  16131. this._teleportationBackRequestInitiated = false;
  16132. /** @hidden */
  16133. this._rotationRightAsked = false;
  16134. /** @hidden */
  16135. this._rotationLeftAsked = false;
  16136. /** @hidden */
  16137. this._dpadPressed = true;
  16138. /** @hidden */
  16139. this._activePointer = false;
  16140. this._id = VRExperienceHelperGazer._idCounter++;
  16141. // Gaze tracker
  16142. if (!gazeTrackerToClone) {
  16143. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16144. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16145. this._gazeTracker.isPickable = false;
  16146. this._gazeTracker.isVisible = false;
  16147. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  16148. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  16149. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16150. targetMat.backFaceCulling = false;
  16151. this._gazeTracker.material = targetMat;
  16152. }
  16153. else {
  16154. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16155. }
  16156. }
  16157. /** @hidden */
  16158. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16159. 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));
  16160. };
  16161. /** @hidden */
  16162. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16163. this._pointerDownOnMeshAsked = true;
  16164. if (this._currentHit) {
  16165. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16166. }
  16167. };
  16168. /** @hidden */
  16169. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16170. if (this._currentHit) {
  16171. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16172. }
  16173. this._pointerDownOnMeshAsked = false;
  16174. };
  16175. /** @hidden */
  16176. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16177. this._activePointer = true;
  16178. };
  16179. /** @hidden */
  16180. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16181. this._activePointer = false;
  16182. };
  16183. /** @hidden */
  16184. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16185. if (distance === void 0) { distance = 100; }
  16186. };
  16187. VRExperienceHelperGazer.prototype.dispose = function () {
  16188. this._interactionsEnabled = false;
  16189. this._teleportationEnabled = false;
  16190. if (this._gazeTracker) {
  16191. this._gazeTracker.dispose();
  16192. }
  16193. };
  16194. VRExperienceHelperGazer._idCounter = 0;
  16195. return VRExperienceHelperGazer;
  16196. }());
  16197. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16198. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16199. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16200. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16201. _this.webVRController = webVRController;
  16202. // Laser pointer
  16203. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16204. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  16205. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16206. laserPointerMaterial.alpha = 0.6;
  16207. _this._laserPointer.material = laserPointerMaterial;
  16208. _this._laserPointer.rotation.x = Math.PI / 2;
  16209. _this._laserPointer.position.z = -0.5;
  16210. _this._laserPointer.isVisible = false;
  16211. _this._laserPointer.isPickable = false;
  16212. if (!webVRController.mesh) {
  16213. // Create an empty mesh that is used prior to loading the high quality model
  16214. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  16215. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  16216. preloadPointerPose.rotation.x = -0.7;
  16217. preloadMesh.addChild(preloadPointerPose);
  16218. webVRController.attachToMesh(preloadMesh);
  16219. }
  16220. _this._setLaserPointerParent(webVRController.mesh);
  16221. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16222. _this._setLaserPointerParent(mesh);
  16223. });
  16224. return _this;
  16225. }
  16226. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16227. return this.webVRController.getForwardRay(length);
  16228. };
  16229. /** @hidden */
  16230. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16231. _super.prototype._activatePointer.call(this);
  16232. this._laserPointer.isVisible = true;
  16233. };
  16234. /** @hidden */
  16235. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16236. _super.prototype._deactivatePointer.call(this);
  16237. this._laserPointer.isVisible = false;
  16238. };
  16239. /** @hidden */
  16240. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16241. this._laserPointer.material.emissiveColor = color;
  16242. };
  16243. /** @hidden */
  16244. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16245. var makeNotPick = function (root) {
  16246. root.isPickable = false;
  16247. root.getChildMeshes().forEach(function (c) {
  16248. makeNotPick(c);
  16249. });
  16250. };
  16251. makeNotPick(mesh);
  16252. var meshChildren = mesh.getChildren(undefined, false);
  16253. var laserParent = mesh;
  16254. this.webVRController._pointingPoseNode = null;
  16255. for (var i = 0; i < meshChildren.length; i++) {
  16256. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16257. laserParent = meshChildren[i];
  16258. this.webVRController._pointingPoseNode = laserParent;
  16259. break;
  16260. }
  16261. }
  16262. this._laserPointer.parent = laserParent;
  16263. };
  16264. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16265. if (distance === void 0) { distance = 100; }
  16266. this._laserPointer.scaling.y = distance;
  16267. this._laserPointer.position.z = -distance / 2;
  16268. };
  16269. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16270. _super.prototype.dispose.call(this);
  16271. this._laserPointer.dispose();
  16272. if (this._meshAttachedObserver) {
  16273. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16274. }
  16275. };
  16276. return VRExperienceHelperControllerGazer;
  16277. }(VRExperienceHelperGazer));
  16278. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16279. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16280. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16281. var _this = _super.call(this, scene) || this;
  16282. _this.getCamera = getCamera;
  16283. return _this;
  16284. }
  16285. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16286. var camera = this.getCamera();
  16287. if (camera) {
  16288. return camera.getForwardRay(length);
  16289. }
  16290. else {
  16291. 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());
  16292. }
  16293. };
  16294. return VRExperienceHelperCameraGazer;
  16295. }(VRExperienceHelperGazer));
  16296. /**
  16297. * Event containing information after VR has been entered
  16298. */
  16299. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16300. function OnAfterEnteringVRObservableEvent() {
  16301. }
  16302. return OnAfterEnteringVRObservableEvent;
  16303. }());
  16304. /**
  16305. * Helps to quickly add VR support to an existing scene.
  16306. * See http://doc.babylonjs.com/how_to/webvr_helper
  16307. */
  16308. var VRExperienceHelper = /** @class */ (function () {
  16309. /**
  16310. * Instantiates a VRExperienceHelper.
  16311. * Helps to quickly add VR support to an existing scene.
  16312. * @param scene The scene the VRExperienceHelper belongs to.
  16313. * @param webVROptions Options to modify the vr experience helper's behavior.
  16314. */
  16315. function VRExperienceHelper(scene,
  16316. /** Options to modify the vr experience helper's behavior. */
  16317. webVROptions) {
  16318. if (webVROptions === void 0) { webVROptions = {}; }
  16319. var _this = this;
  16320. this.webVROptions = webVROptions;
  16321. // Can the system support WebVR, even if a headset isn't plugged in?
  16322. this._webVRsupported = false;
  16323. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16324. this._webVRready = false;
  16325. // Are we waiting for the requestPresent callback to complete?
  16326. this._webVRrequesting = false;
  16327. // Are we presenting to the headset right now? (this is the vrDevice state)
  16328. this._webVRpresenting = false;
  16329. // Are we presenting in the fullscreen fallback?
  16330. this._fullscreenVRpresenting = false;
  16331. /**
  16332. * Observable raised right before entering VR.
  16333. */
  16334. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16335. /**
  16336. * Observable raised when entering VR has completed.
  16337. */
  16338. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16339. /**
  16340. * Observable raised when exiting VR.
  16341. */
  16342. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16343. /**
  16344. * Observable raised when controller mesh is loaded.
  16345. */
  16346. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16347. this._useCustomVRButton = false;
  16348. this._teleportationRequested = false;
  16349. this._teleportActive = false;
  16350. this._floorMeshesCollection = [];
  16351. this._rotationAllowed = true;
  16352. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16353. this._isDefaultTeleportationTarget = true;
  16354. this._teleportationFillColor = "#444444";
  16355. this._teleportationBorderColor = "#FFFFFF";
  16356. this._rotationAngle = 0;
  16357. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16358. this._padSensibilityUp = 0.65;
  16359. this._padSensibilityDown = 0.35;
  16360. this._leftController = null;
  16361. this._rightController = null;
  16362. /**
  16363. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16364. */
  16365. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16366. /**
  16367. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16368. */
  16369. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16370. /**
  16371. * Observable raised before camera teleportation
  16372. */
  16373. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16374. /**
  16375. * Observable raised after camera teleportation
  16376. */
  16377. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16378. /**
  16379. * Observable raised when current selected mesh gets unselected
  16380. */
  16381. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16382. /**
  16383. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16384. */
  16385. this.teleportationEnabled = true;
  16386. this._teleportationInitialized = false;
  16387. this._interactionsEnabled = false;
  16388. this._interactionsRequested = false;
  16389. this._displayGaze = true;
  16390. this._displayLaserPointer = true;
  16391. /**
  16392. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16393. */
  16394. this.updateGazeTrackerScale = true;
  16395. /**
  16396. * If the gaze trackers color should be updated when selecting meshes
  16397. */
  16398. this.updateGazeTrackerColor = true;
  16399. /**
  16400. * Defines wether or not Pointer lock should be requested when switching to
  16401. * full screen.
  16402. */
  16403. this.requestPointerLockOnFullScreen = true;
  16404. this._onResize = function () {
  16405. _this.moveButtonToBottomRight();
  16406. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16407. _this.exitVR();
  16408. }
  16409. };
  16410. this._onFullscreenChange = function () {
  16411. var anyDoc = document;
  16412. if (anyDoc.fullscreen !== undefined) {
  16413. _this._fullscreenVRpresenting = document.fullscreen;
  16414. }
  16415. else if (anyDoc.mozFullScreen !== undefined) {
  16416. _this._fullscreenVRpresenting = anyDoc.mozFullScreen;
  16417. }
  16418. else if (anyDoc.webkitIsFullScreen !== undefined) {
  16419. _this._fullscreenVRpresenting = anyDoc.webkitIsFullScreen;
  16420. }
  16421. else if (anyDoc.msIsFullScreen !== undefined) {
  16422. _this._fullscreenVRpresenting = anyDoc.msIsFullScreen;
  16423. }
  16424. else if (document.msFullscreenElement !== undefined) {
  16425. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16426. }
  16427. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16428. _this.exitVR();
  16429. if (!_this._useCustomVRButton) {
  16430. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16431. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16432. }
  16433. }
  16434. };
  16435. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16436. this.beforeRender = function () {
  16437. if (_this._leftController && _this._leftController._activePointer) {
  16438. _this._castRayAndSelectObject(_this._leftController);
  16439. }
  16440. if (_this._rightController && _this._rightController._activePointer) {
  16441. _this._castRayAndSelectObject(_this._rightController);
  16442. }
  16443. if (_this._noControllerIsActive) {
  16444. _this._castRayAndSelectObject(_this._cameraGazer);
  16445. }
  16446. else {
  16447. _this._cameraGazer._gazeTracker.isVisible = false;
  16448. }
  16449. };
  16450. this._onNewGamepadConnected = function (gamepad) {
  16451. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  16452. if (gamepad.leftStick) {
  16453. gamepad.onleftstickchanged(function (stickValues) {
  16454. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16455. // Listening to classic/xbox gamepad only if no VR controller is active
  16456. if ((!_this._leftController && !_this._rightController) ||
  16457. ((_this._leftController && !_this._leftController._activePointer) &&
  16458. (_this._rightController && !_this._rightController._activePointer))) {
  16459. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16460. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16461. }
  16462. }
  16463. });
  16464. }
  16465. if (gamepad.rightStick) {
  16466. gamepad.onrightstickchanged(function (stickValues) {
  16467. if (_this._teleportationInitialized) {
  16468. _this._checkRotate(stickValues, _this._cameraGazer);
  16469. }
  16470. });
  16471. }
  16472. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  16473. gamepad.onbuttondown(function (buttonPressed) {
  16474. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16475. _this._cameraGazer._selectionPointerDown();
  16476. }
  16477. });
  16478. gamepad.onbuttonup(function (buttonPressed) {
  16479. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16480. _this._cameraGazer._selectionPointerUp();
  16481. }
  16482. });
  16483. }
  16484. }
  16485. else {
  16486. var webVRController = gamepad;
  16487. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16488. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16489. _this._rightController = controller;
  16490. }
  16491. else {
  16492. _this._leftController = controller;
  16493. }
  16494. _this._tryEnableInteractionOnController(controller);
  16495. }
  16496. };
  16497. // 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
  16498. this._tryEnableInteractionOnController = function (controller) {
  16499. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16500. _this._enableInteractionOnController(controller);
  16501. }
  16502. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16503. _this._enableTeleportationOnController(controller);
  16504. }
  16505. };
  16506. this._onNewGamepadDisconnected = function (gamepad) {
  16507. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  16508. if (gamepad.hand === "left" && _this._leftController != null) {
  16509. _this._leftController.dispose();
  16510. _this._leftController = null;
  16511. }
  16512. if (gamepad.hand === "right" && _this._rightController != null) {
  16513. _this._rightController.dispose();
  16514. _this._rightController = null;
  16515. }
  16516. }
  16517. };
  16518. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16519. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16520. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16521. this._scene = scene;
  16522. this._canvas = scene.getEngine().getRenderingCanvas();
  16523. // Parse options
  16524. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16525. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16526. }
  16527. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16528. webVROptions.createDeviceOrientationCamera = true;
  16529. }
  16530. if (webVROptions.laserToggle === undefined) {
  16531. webVROptions.laserToggle = true;
  16532. }
  16533. if (webVROptions.defaultHeight === undefined) {
  16534. webVROptions.defaultHeight = 1.7;
  16535. }
  16536. if (webVROptions.useCustomVRButton) {
  16537. this._useCustomVRButton = true;
  16538. if (webVROptions.customVRButton) {
  16539. this._btnVR = webVROptions.customVRButton;
  16540. }
  16541. }
  16542. if (webVROptions.rayLength) {
  16543. this._rayLength = webVROptions.rayLength;
  16544. }
  16545. this._defaultHeight = webVROptions.defaultHeight;
  16546. if (webVROptions.positionScale) {
  16547. this._rayLength *= webVROptions.positionScale;
  16548. this._defaultHeight *= webVROptions.positionScale;
  16549. }
  16550. this._hasEnteredVR = false;
  16551. // Set position
  16552. if (this._scene.activeCamera) {
  16553. this._position = this._scene.activeCamera.position.clone();
  16554. }
  16555. else {
  16556. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16557. }
  16558. // Set non-vr camera
  16559. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16560. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16561. // Copy data from existing camera
  16562. if (this._scene.activeCamera) {
  16563. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16564. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16565. // Set rotation from previous camera
  16566. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16567. var targetCamera = this._scene.activeCamera;
  16568. if (targetCamera.rotationQuaternion) {
  16569. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16570. }
  16571. else {
  16572. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16573. }
  16574. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16575. }
  16576. }
  16577. this._scene.activeCamera = this._deviceOrientationCamera;
  16578. if (this._canvas) {
  16579. this._scene.activeCamera.attachControl(this._canvas);
  16580. }
  16581. }
  16582. else {
  16583. this._existingCamera = this._scene.activeCamera;
  16584. }
  16585. // Create VR cameras
  16586. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16587. if (webVROptions.useMultiview) {
  16588. if (!webVROptions.vrDeviceOrientationCameraMetrics) {
  16589. webVROptions.vrDeviceOrientationCameraMetrics = _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__["VRCameraMetrics"].GetDefault();
  16590. }
  16591. webVROptions.vrDeviceOrientationCameraMetrics.multiviewEnabled = true;
  16592. }
  16593. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16594. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16595. }
  16596. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16597. this._webVRCamera.useStandingMatrix();
  16598. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16599. // Create default button
  16600. if (!this._useCustomVRButton) {
  16601. this._btnVR = document.createElement("BUTTON");
  16602. this._btnVR.className = "babylonVRicon";
  16603. this._btnVR.id = "babylonVRiconbtn";
  16604. this._btnVR.title = "Click to switch to VR";
  16605. 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) }";
  16606. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16607. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16608. // css += ".babylonVRicon.vrdisplaysupported { }";
  16609. // css += ".babylonVRicon.vrdisplayready { }";
  16610. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16611. var style = document.createElement('style');
  16612. style.appendChild(document.createTextNode(css));
  16613. document.getElementsByTagName('head')[0].appendChild(style);
  16614. this.moveButtonToBottomRight();
  16615. }
  16616. // VR button click event
  16617. if (this._btnVR) {
  16618. this._btnVR.addEventListener("click", function () {
  16619. if (!_this.isInVRMode) {
  16620. _this.enterVR();
  16621. }
  16622. else {
  16623. _this.exitVR();
  16624. }
  16625. });
  16626. }
  16627. // Window events
  16628. window.addEventListener("resize", this._onResize);
  16629. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16630. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16631. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16632. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16633. document.onmsfullscreenchange = this._onFullscreenChange;
  16634. // Display vr button when headset is connected
  16635. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16636. this.displayVRButton();
  16637. }
  16638. else {
  16639. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16640. if (e.vrDisplay) {
  16641. _this.displayVRButton();
  16642. }
  16643. });
  16644. }
  16645. // Exiting VR mode using 'ESC' key on desktop
  16646. this._onKeyDown = function (event) {
  16647. if (event.keyCode === 27 && _this.isInVRMode) {
  16648. _this.exitVR();
  16649. }
  16650. };
  16651. document.addEventListener("keydown", this._onKeyDown);
  16652. // Exiting VR mode double tapping the touch screen
  16653. this._scene.onPrePointerObservable.add(function () {
  16654. if (_this.isInVRMode) {
  16655. _this.exitVR();
  16656. if (_this._fullscreenVRpresenting) {
  16657. _this._scene.getEngine().exitFullscreen();
  16658. }
  16659. }
  16660. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16661. // Listen for WebVR display changes
  16662. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16663. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16664. this._onVRRequestPresentStart = function () {
  16665. _this._webVRrequesting = true;
  16666. _this.updateButtonVisibility();
  16667. };
  16668. this._onVRRequestPresentComplete = function () {
  16669. _this._webVRrequesting = false;
  16670. _this.updateButtonVisibility();
  16671. };
  16672. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16673. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16674. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16675. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16676. scene.onDisposeObservable.add(function () {
  16677. _this.dispose();
  16678. });
  16679. // Gamepad connection events
  16680. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16681. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16682. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16683. this.updateButtonVisibility();
  16684. //create easing functions
  16685. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16686. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16687. if (this.webVROptions.floorMeshes) {
  16688. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16689. }
  16690. }
  16691. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16692. /** Return this.onEnteringVRObservable
  16693. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16694. */
  16695. get: function () {
  16696. return this.onEnteringVRObservable;
  16697. },
  16698. enumerable: true,
  16699. configurable: true
  16700. });
  16701. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16702. /** Return this.onExitingVRObservable
  16703. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16704. */
  16705. get: function () {
  16706. return this.onExitingVRObservable;
  16707. },
  16708. enumerable: true,
  16709. configurable: true
  16710. });
  16711. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16712. /** Return this.onControllerMeshLoadedObservable
  16713. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16714. */
  16715. get: function () {
  16716. return this.onControllerMeshLoadedObservable;
  16717. },
  16718. enumerable: true,
  16719. configurable: true
  16720. });
  16721. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16722. /**
  16723. * The mesh used to display where the user is going to teleport.
  16724. */
  16725. get: function () {
  16726. return this._teleportationTarget;
  16727. },
  16728. /**
  16729. * Sets the mesh to be used to display where the user is going to teleport.
  16730. */
  16731. set: function (value) {
  16732. if (value) {
  16733. value.name = "teleportationTarget";
  16734. this._isDefaultTeleportationTarget = false;
  16735. this._teleportationTarget = value;
  16736. }
  16737. },
  16738. enumerable: true,
  16739. configurable: true
  16740. });
  16741. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16742. /**
  16743. * 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
  16744. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16745. * See http://doc.babylonjs.com/resources/baking_transformations
  16746. */
  16747. get: function () {
  16748. return this._cameraGazer._gazeTracker;
  16749. },
  16750. set: function (value) {
  16751. if (value) {
  16752. // Dispose of existing meshes
  16753. if (this._cameraGazer._gazeTracker) {
  16754. this._cameraGazer._gazeTracker.dispose();
  16755. }
  16756. if (this._leftController && this._leftController._gazeTracker) {
  16757. this._leftController._gazeTracker.dispose();
  16758. }
  16759. if (this._rightController && this._rightController._gazeTracker) {
  16760. this._rightController._gazeTracker.dispose();
  16761. }
  16762. // Set and create gaze trackers on head and controllers
  16763. this._cameraGazer._gazeTracker = value;
  16764. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16765. this._cameraGazer._gazeTracker.isPickable = false;
  16766. this._cameraGazer._gazeTracker.isVisible = false;
  16767. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16768. if (this._leftController) {
  16769. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16770. }
  16771. if (this._rightController) {
  16772. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16773. }
  16774. }
  16775. },
  16776. enumerable: true,
  16777. configurable: true
  16778. });
  16779. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16780. /**
  16781. * The gaze tracking mesh corresponding to the left controller
  16782. */
  16783. get: function () {
  16784. if (this._leftController) {
  16785. return this._leftController._gazeTracker;
  16786. }
  16787. return null;
  16788. },
  16789. enumerable: true,
  16790. configurable: true
  16791. });
  16792. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16793. /**
  16794. * The gaze tracking mesh corresponding to the right controller
  16795. */
  16796. get: function () {
  16797. if (this._rightController) {
  16798. return this._rightController._gazeTracker;
  16799. }
  16800. return null;
  16801. },
  16802. enumerable: true,
  16803. configurable: true
  16804. });
  16805. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16806. /**
  16807. * If the ray of the gaze should be displayed.
  16808. */
  16809. get: function () {
  16810. return this._displayGaze;
  16811. },
  16812. /**
  16813. * Sets if the ray of the gaze should be displayed.
  16814. */
  16815. set: function (value) {
  16816. this._displayGaze = value;
  16817. if (!value) {
  16818. this._cameraGazer._gazeTracker.isVisible = false;
  16819. if (this._leftController) {
  16820. this._leftController._gazeTracker.isVisible = false;
  16821. }
  16822. if (this._rightController) {
  16823. this._rightController._gazeTracker.isVisible = false;
  16824. }
  16825. }
  16826. },
  16827. enumerable: true,
  16828. configurable: true
  16829. });
  16830. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16831. /**
  16832. * If the ray of the LaserPointer should be displayed.
  16833. */
  16834. get: function () {
  16835. return this._displayLaserPointer;
  16836. },
  16837. /**
  16838. * Sets if the ray of the LaserPointer should be displayed.
  16839. */
  16840. set: function (value) {
  16841. this._displayLaserPointer = value;
  16842. if (!value) {
  16843. if (this._rightController) {
  16844. this._rightController._deactivatePointer();
  16845. this._rightController._gazeTracker.isVisible = false;
  16846. }
  16847. if (this._leftController) {
  16848. this._leftController._deactivatePointer();
  16849. this._leftController._gazeTracker.isVisible = false;
  16850. }
  16851. }
  16852. else {
  16853. if (this._rightController) {
  16854. this._rightController._activatePointer();
  16855. }
  16856. if (this._leftController) {
  16857. this._leftController._activatePointer();
  16858. }
  16859. }
  16860. },
  16861. enumerable: true,
  16862. configurable: true
  16863. });
  16864. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16865. /**
  16866. * The deviceOrientationCamera used as the camera when not in VR.
  16867. */
  16868. get: function () {
  16869. return this._deviceOrientationCamera;
  16870. },
  16871. enumerable: true,
  16872. configurable: true
  16873. });
  16874. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16875. /**
  16876. * Based on the current WebVR support, returns the current VR camera used.
  16877. */
  16878. get: function () {
  16879. if (this._webVRready) {
  16880. return this._webVRCamera;
  16881. }
  16882. else {
  16883. return this._scene.activeCamera;
  16884. }
  16885. },
  16886. enumerable: true,
  16887. configurable: true
  16888. });
  16889. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16890. /**
  16891. * The webVRCamera which is used when in VR.
  16892. */
  16893. get: function () {
  16894. return this._webVRCamera;
  16895. },
  16896. enumerable: true,
  16897. configurable: true
  16898. });
  16899. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16900. /**
  16901. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16902. */
  16903. get: function () {
  16904. return this._vrDeviceOrientationCamera;
  16905. },
  16906. enumerable: true,
  16907. configurable: true
  16908. });
  16909. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16910. get: function () {
  16911. var result = this._cameraGazer._teleportationRequestInitiated
  16912. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16913. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16914. return result;
  16915. },
  16916. enumerable: true,
  16917. configurable: true
  16918. });
  16919. // Raised when one of the controller has loaded successfully its associated default mesh
  16920. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16921. if (this._leftController && this._leftController.webVRController == webVRController) {
  16922. if (webVRController.mesh) {
  16923. this._leftController._setLaserPointerParent(webVRController.mesh);
  16924. }
  16925. }
  16926. if (this._rightController && this._rightController.webVRController == webVRController) {
  16927. if (webVRController.mesh) {
  16928. this._rightController._setLaserPointerParent(webVRController.mesh);
  16929. }
  16930. }
  16931. try {
  16932. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16933. }
  16934. catch (err) {
  16935. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16936. }
  16937. };
  16938. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16939. /**
  16940. * Gets a value indicating if we are currently in VR mode.
  16941. */
  16942. get: function () {
  16943. return this._webVRpresenting || this._fullscreenVRpresenting;
  16944. },
  16945. enumerable: true,
  16946. configurable: true
  16947. });
  16948. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16949. var vrDisplay = this._scene.getEngine().getVRDevice();
  16950. if (vrDisplay) {
  16951. var wasPresenting = this._webVRpresenting;
  16952. this._webVRpresenting = vrDisplay.isPresenting;
  16953. if (wasPresenting && !this._webVRpresenting) {
  16954. this.exitVR();
  16955. }
  16956. }
  16957. else {
  16958. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16959. }
  16960. this.updateButtonVisibility();
  16961. };
  16962. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16963. this._webVRsupported = eventArgs.vrSupported;
  16964. this._webVRready = !!eventArgs.vrDisplay;
  16965. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16966. this.updateButtonVisibility();
  16967. };
  16968. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16969. if (this._canvas && !this._useCustomVRButton) {
  16970. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16971. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16972. }
  16973. };
  16974. VRExperienceHelper.prototype.displayVRButton = function () {
  16975. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16976. document.body.appendChild(this._btnVR);
  16977. this._btnVRDisplayed = true;
  16978. }
  16979. };
  16980. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16981. if (!this._btnVR || this._useCustomVRButton) {
  16982. return;
  16983. }
  16984. this._btnVR.className = "babylonVRicon";
  16985. if (this.isInVRMode) {
  16986. this._btnVR.className += " vrdisplaypresenting";
  16987. }
  16988. else {
  16989. if (this._webVRready) {
  16990. this._btnVR.className += " vrdisplayready";
  16991. }
  16992. if (this._webVRsupported) {
  16993. this._btnVR.className += " vrdisplaysupported";
  16994. }
  16995. if (this._webVRrequesting) {
  16996. this._btnVR.className += " vrdisplayrequesting";
  16997. }
  16998. }
  16999. };
  17000. /**
  17001. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  17002. * Otherwise, will use the fullscreen API.
  17003. */
  17004. VRExperienceHelper.prototype.enterVR = function () {
  17005. var _this = this;
  17006. if (this.onEnteringVRObservable) {
  17007. try {
  17008. this.onEnteringVRObservable.notifyObservers(this);
  17009. }
  17010. catch (err) {
  17011. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  17012. }
  17013. }
  17014. if (this._scene.activeCamera) {
  17015. this._position = this._scene.activeCamera.position.clone();
  17016. if (this.vrDeviceOrientationCamera) {
  17017. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  17018. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  17019. }
  17020. if (this.webVRCamera) {
  17021. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  17022. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  17023. var delta = desiredYRotation - currentYRotation;
  17024. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  17025. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  17026. }
  17027. // make sure that we return to the last active camera
  17028. this._existingCamera = this._scene.activeCamera;
  17029. // Remove and cache angular sensability to avoid camera rotation when in VR
  17030. if (this._existingCamera.angularSensibilityX) {
  17031. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  17032. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  17033. }
  17034. if (this._existingCamera.angularSensibilityY) {
  17035. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  17036. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  17037. }
  17038. if (this._existingCamera.angularSensibility) {
  17039. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  17040. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  17041. }
  17042. }
  17043. if (this._webVRrequesting) {
  17044. return;
  17045. }
  17046. // If WebVR is supported and a headset is connected
  17047. if (this._webVRready) {
  17048. if (!this._webVRpresenting) {
  17049. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  17050. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  17051. });
  17052. this._webVRCamera.position = this._position;
  17053. this._scene.activeCamera = this._webVRCamera;
  17054. }
  17055. }
  17056. else if (this._vrDeviceOrientationCamera) {
  17057. this._vrDeviceOrientationCamera.position = this._position;
  17058. if (this._scene.activeCamera) {
  17059. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  17060. }
  17061. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  17062. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  17063. this.updateButtonVisibility();
  17064. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  17065. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  17066. });
  17067. }
  17068. if (this._scene.activeCamera && this._canvas) {
  17069. this._scene.activeCamera.attachControl(this._canvas);
  17070. }
  17071. if (this._interactionsEnabled) {
  17072. this._scene.registerBeforeRender(this.beforeRender);
  17073. }
  17074. if (this._displayLaserPointer) {
  17075. [this._leftController, this._rightController].forEach(function (controller) {
  17076. if (controller) {
  17077. controller._activatePointer();
  17078. }
  17079. });
  17080. }
  17081. this._hasEnteredVR = true;
  17082. };
  17083. /**
  17084. * Attempt to exit VR, or fullscreen.
  17085. */
  17086. VRExperienceHelper.prototype.exitVR = function () {
  17087. if (this._hasEnteredVR) {
  17088. if (this.onExitingVRObservable) {
  17089. try {
  17090. this.onExitingVRObservable.notifyObservers(this);
  17091. }
  17092. catch (err) {
  17093. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  17094. }
  17095. }
  17096. if (this._webVRpresenting) {
  17097. this._scene.getEngine().disableVR();
  17098. }
  17099. if (this._scene.activeCamera) {
  17100. this._position = this._scene.activeCamera.position.clone();
  17101. }
  17102. if (this.vrDeviceOrientationCamera) {
  17103. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  17104. }
  17105. if (this._deviceOrientationCamera) {
  17106. this._deviceOrientationCamera.position = this._position;
  17107. this._scene.activeCamera = this._deviceOrientationCamera;
  17108. if (this._canvas) {
  17109. this._scene.activeCamera.attachControl(this._canvas);
  17110. }
  17111. // Restore angular sensibility
  17112. if (this._cachedAngularSensibility.angularSensibilityX) {
  17113. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17114. this._cachedAngularSensibility.angularSensibilityX = null;
  17115. }
  17116. if (this._cachedAngularSensibility.angularSensibilityY) {
  17117. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17118. this._cachedAngularSensibility.angularSensibilityY = null;
  17119. }
  17120. if (this._cachedAngularSensibility.angularSensibility) {
  17121. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17122. this._cachedAngularSensibility.angularSensibility = null;
  17123. }
  17124. }
  17125. else if (this._existingCamera) {
  17126. this._existingCamera.position = this._position;
  17127. this._scene.activeCamera = this._existingCamera;
  17128. // Restore angular sensibility
  17129. if (this._cachedAngularSensibility.angularSensibilityX) {
  17130. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17131. this._cachedAngularSensibility.angularSensibilityX = null;
  17132. }
  17133. if (this._cachedAngularSensibility.angularSensibilityY) {
  17134. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17135. this._cachedAngularSensibility.angularSensibilityY = null;
  17136. }
  17137. if (this._cachedAngularSensibility.angularSensibility) {
  17138. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17139. this._cachedAngularSensibility.angularSensibility = null;
  17140. }
  17141. }
  17142. this.updateButtonVisibility();
  17143. if (this._interactionsEnabled) {
  17144. this._scene.unregisterBeforeRender(this.beforeRender);
  17145. this._cameraGazer._gazeTracker.isVisible = false;
  17146. if (this._leftController) {
  17147. this._leftController._gazeTracker.isVisible = false;
  17148. }
  17149. if (this._rightController) {
  17150. this._rightController._gazeTracker.isVisible = false;
  17151. }
  17152. }
  17153. // resize to update width and height when exiting vr exits fullscreen
  17154. this._scene.getEngine().resize();
  17155. [this._leftController, this._rightController].forEach(function (controller) {
  17156. if (controller) {
  17157. controller._deactivatePointer();
  17158. }
  17159. });
  17160. this._hasEnteredVR = false;
  17161. }
  17162. };
  17163. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17164. /**
  17165. * The position of the vr experience helper.
  17166. */
  17167. get: function () {
  17168. return this._position;
  17169. },
  17170. /**
  17171. * Sets the position of the vr experience helper.
  17172. */
  17173. set: function (value) {
  17174. this._position = value;
  17175. if (this._scene.activeCamera) {
  17176. this._scene.activeCamera.position = value;
  17177. }
  17178. },
  17179. enumerable: true,
  17180. configurable: true
  17181. });
  17182. /**
  17183. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17184. */
  17185. VRExperienceHelper.prototype.enableInteractions = function () {
  17186. var _this = this;
  17187. if (!this._interactionsEnabled) {
  17188. this._interactionsRequested = true;
  17189. if (this._leftController) {
  17190. this._enableInteractionOnController(this._leftController);
  17191. }
  17192. if (this._rightController) {
  17193. this._enableInteractionOnController(this._rightController);
  17194. }
  17195. this.raySelectionPredicate = function (mesh) {
  17196. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17197. };
  17198. this.meshSelectionPredicate = function () {
  17199. return true;
  17200. };
  17201. this._raySelectionPredicate = function (mesh) {
  17202. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17203. && mesh.name.indexOf("teleportationTarget") === -1
  17204. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17205. return _this.raySelectionPredicate(mesh);
  17206. }
  17207. return false;
  17208. };
  17209. this._interactionsEnabled = true;
  17210. }
  17211. };
  17212. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17213. get: function () {
  17214. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17215. },
  17216. enumerable: true,
  17217. configurable: true
  17218. });
  17219. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17220. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17221. if (this._floorMeshesCollection[i].id === mesh.id) {
  17222. return true;
  17223. }
  17224. }
  17225. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17226. return true;
  17227. }
  17228. return false;
  17229. };
  17230. /**
  17231. * Adds a floor mesh to be used for teleportation.
  17232. * @param floorMesh the mesh to be used for teleportation.
  17233. */
  17234. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17235. if (!this._floorMeshesCollection) {
  17236. return;
  17237. }
  17238. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17239. return;
  17240. }
  17241. this._floorMeshesCollection.push(floorMesh);
  17242. };
  17243. /**
  17244. * Removes a floor mesh from being used for teleportation.
  17245. * @param floorMesh the mesh to be removed.
  17246. */
  17247. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17248. if (!this._floorMeshesCollection) {
  17249. return;
  17250. }
  17251. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17252. if (meshIndex !== -1) {
  17253. this._floorMeshesCollection.splice(meshIndex, 1);
  17254. }
  17255. };
  17256. /**
  17257. * Enables interactions and teleportation using the VR controllers and gaze.
  17258. * @param vrTeleportationOptions options to modify teleportation behavior.
  17259. */
  17260. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17261. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17262. if (!this._teleportationInitialized) {
  17263. this._teleportationRequested = true;
  17264. this.enableInteractions();
  17265. if (vrTeleportationOptions.floorMeshName) {
  17266. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17267. }
  17268. if (vrTeleportationOptions.floorMeshes) {
  17269. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17270. }
  17271. if (this._leftController != null) {
  17272. this._enableTeleportationOnController(this._leftController);
  17273. }
  17274. if (this._rightController != null) {
  17275. this._enableTeleportationOnController(this._rightController);
  17276. }
  17277. // Creates an image processing post process for the vignette not relying
  17278. // on the main scene configuration for image processing to reduce setup and spaces
  17279. // (gamma/linear) conflicts.
  17280. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  17281. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  17282. imageProcessingConfiguration.vignetteEnabled = true;
  17283. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17284. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17285. this._teleportationInitialized = true;
  17286. if (this._isDefaultTeleportationTarget) {
  17287. this._createTeleportationCircles();
  17288. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17289. }
  17290. }
  17291. };
  17292. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17293. var _this = this;
  17294. var controllerMesh = controller.webVRController.mesh;
  17295. if (controllerMesh) {
  17296. controller._interactionsEnabled = true;
  17297. if (this.isInVRMode && this._displayLaserPointer) {
  17298. controller._activatePointer();
  17299. }
  17300. if (this.webVROptions.laserToggle) {
  17301. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17302. // Enabling / disabling laserPointer
  17303. if (_this._displayLaserPointer && stateObject.value === 1) {
  17304. if (controller._activePointer) {
  17305. controller._deactivatePointer();
  17306. }
  17307. else {
  17308. controller._activatePointer();
  17309. }
  17310. if (_this.displayGaze) {
  17311. controller._gazeTracker.isVisible = controller._activePointer;
  17312. }
  17313. }
  17314. });
  17315. }
  17316. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17317. var gazer = controller;
  17318. if (_this._noControllerIsActive) {
  17319. gazer = _this._cameraGazer;
  17320. }
  17321. if (!gazer._pointerDownOnMeshAsked) {
  17322. if (stateObject.value > _this._padSensibilityUp) {
  17323. gazer._selectionPointerDown();
  17324. }
  17325. }
  17326. else if (stateObject.value < _this._padSensibilityDown) {
  17327. gazer._selectionPointerUp();
  17328. }
  17329. });
  17330. }
  17331. };
  17332. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17333. // Dont teleport if another gaze already requested teleportation
  17334. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17335. return;
  17336. }
  17337. if (!gazer._teleportationRequestInitiated) {
  17338. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17339. gazer._activatePointer();
  17340. gazer._teleportationRequestInitiated = true;
  17341. }
  17342. }
  17343. else {
  17344. // Listening to the proper controller values changes to confirm teleportation
  17345. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17346. if (this._teleportActive) {
  17347. this.teleportCamera(this._haloCenter);
  17348. }
  17349. gazer._teleportationRequestInitiated = false;
  17350. }
  17351. }
  17352. };
  17353. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17354. // Only rotate when user is not currently selecting a teleportation location
  17355. if (gazer._teleportationRequestInitiated) {
  17356. return;
  17357. }
  17358. if (!gazer._rotationLeftAsked) {
  17359. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17360. gazer._rotationLeftAsked = true;
  17361. if (this._rotationAllowed) {
  17362. this._rotateCamera(false);
  17363. }
  17364. }
  17365. }
  17366. else {
  17367. if (stateObject.x > -this._padSensibilityDown) {
  17368. gazer._rotationLeftAsked = false;
  17369. }
  17370. }
  17371. if (!gazer._rotationRightAsked) {
  17372. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17373. gazer._rotationRightAsked = true;
  17374. if (this._rotationAllowed) {
  17375. this._rotateCamera(true);
  17376. }
  17377. }
  17378. }
  17379. else {
  17380. if (stateObject.x < this._padSensibilityDown) {
  17381. gazer._rotationRightAsked = false;
  17382. }
  17383. }
  17384. };
  17385. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17386. // Only teleport backwards when user is not currently selecting a teleportation location
  17387. if (gazer._teleportationRequestInitiated) {
  17388. return;
  17389. }
  17390. // Teleport backwards
  17391. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17392. if (!gazer._teleportationBackRequestInitiated) {
  17393. if (!this.currentVRCamera) {
  17394. return;
  17395. }
  17396. // Get rotation and position of the current camera
  17397. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17398. var position = this.currentVRCamera.position;
  17399. // If the camera has device position, use that instead
  17400. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17401. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17402. position = this.currentVRCamera.devicePosition;
  17403. }
  17404. // Get matrix with only the y rotation of the device rotation
  17405. rotation.toEulerAnglesToRef(this._workingVector);
  17406. this._workingVector.z = 0;
  17407. this._workingVector.x = 0;
  17408. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17409. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17410. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17411. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17412. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17413. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  17414. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17415. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17416. this.teleportCamera(hit.pickedPoint);
  17417. }
  17418. gazer._teleportationBackRequestInitiated = true;
  17419. }
  17420. }
  17421. else {
  17422. gazer._teleportationBackRequestInitiated = false;
  17423. }
  17424. };
  17425. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17426. var _this = this;
  17427. var controllerMesh = controller.webVRController.mesh;
  17428. if (controllerMesh) {
  17429. if (!controller._interactionsEnabled) {
  17430. this._enableInteractionOnController(controller);
  17431. }
  17432. controller._interactionsEnabled = true;
  17433. controller._teleportationEnabled = true;
  17434. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  17435. controller._dpadPressed = false;
  17436. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17437. controller._dpadPressed = stateObject.pressed;
  17438. if (!controller._dpadPressed) {
  17439. controller._rotationLeftAsked = false;
  17440. controller._rotationRightAsked = false;
  17441. controller._teleportationBackRequestInitiated = false;
  17442. }
  17443. });
  17444. }
  17445. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17446. if (_this.teleportationEnabled) {
  17447. _this._checkTeleportBackwards(stateObject, controller);
  17448. _this._checkTeleportWithRay(stateObject, controller);
  17449. }
  17450. _this._checkRotate(stateObject, controller);
  17451. });
  17452. }
  17453. };
  17454. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17455. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17456. this._teleportationTarget.isPickable = false;
  17457. var length = 512;
  17458. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17459. dynamicTexture.hasAlpha = true;
  17460. var context = dynamicTexture.getContext();
  17461. var centerX = length / 2;
  17462. var centerY = length / 2;
  17463. var radius = 200;
  17464. context.beginPath();
  17465. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17466. context.fillStyle = this._teleportationFillColor;
  17467. context.fill();
  17468. context.lineWidth = 10;
  17469. context.strokeStyle = this._teleportationBorderColor;
  17470. context.stroke();
  17471. context.closePath();
  17472. dynamicTexture.update();
  17473. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17474. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17475. this._teleportationTarget.material = teleportationCircleMaterial;
  17476. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17477. torus.isPickable = false;
  17478. torus.parent = this._teleportationTarget;
  17479. 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);
  17480. var keys = [];
  17481. keys.push({
  17482. frame: 0,
  17483. value: 0
  17484. });
  17485. keys.push({
  17486. frame: 30,
  17487. value: 0.4
  17488. });
  17489. keys.push({
  17490. frame: 60,
  17491. value: 0
  17492. });
  17493. animationInnerCircle.setKeys(keys);
  17494. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  17495. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  17496. animationInnerCircle.setEasingFunction(easingFunction);
  17497. torus.animations = [];
  17498. torus.animations.push(animationInnerCircle);
  17499. this._scene.beginAnimation(torus, 0, 60, true);
  17500. this._hideTeleportationTarget();
  17501. };
  17502. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17503. this._teleportActive = true;
  17504. if (this._teleportationInitialized) {
  17505. this._teleportationTarget.isVisible = true;
  17506. if (this._isDefaultTeleportationTarget) {
  17507. this._teleportationTarget.getChildren()[0].isVisible = true;
  17508. }
  17509. }
  17510. };
  17511. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17512. this._teleportActive = false;
  17513. if (this._teleportationInitialized) {
  17514. this._teleportationTarget.isVisible = false;
  17515. if (this._isDefaultTeleportationTarget) {
  17516. this._teleportationTarget.getChildren()[0].isVisible = false;
  17517. }
  17518. }
  17519. };
  17520. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17521. var _this = this;
  17522. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17523. return;
  17524. }
  17525. if (right) {
  17526. this._rotationAngle++;
  17527. }
  17528. else {
  17529. this._rotationAngle--;
  17530. }
  17531. this.currentVRCamera.animations = [];
  17532. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17533. 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);
  17534. var animationRotationKeys = [];
  17535. animationRotationKeys.push({
  17536. frame: 0,
  17537. value: this.currentVRCamera.rotationQuaternion
  17538. });
  17539. animationRotationKeys.push({
  17540. frame: 6,
  17541. value: target
  17542. });
  17543. animationRotation.setKeys(animationRotationKeys);
  17544. animationRotation.setEasingFunction(this._circleEase);
  17545. this.currentVRCamera.animations.push(animationRotation);
  17546. this._postProcessMove.animations = [];
  17547. 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);
  17548. var vignetteWeightKeys = [];
  17549. vignetteWeightKeys.push({
  17550. frame: 0,
  17551. value: 0
  17552. });
  17553. vignetteWeightKeys.push({
  17554. frame: 3,
  17555. value: 4
  17556. });
  17557. vignetteWeightKeys.push({
  17558. frame: 6,
  17559. value: 0
  17560. });
  17561. animationPP.setKeys(vignetteWeightKeys);
  17562. animationPP.setEasingFunction(this._circleEase);
  17563. this._postProcessMove.animations.push(animationPP);
  17564. 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);
  17565. var vignetteStretchKeys = [];
  17566. vignetteStretchKeys.push({
  17567. frame: 0,
  17568. value: 0
  17569. });
  17570. vignetteStretchKeys.push({
  17571. frame: 3,
  17572. value: 10
  17573. });
  17574. vignetteStretchKeys.push({
  17575. frame: 6,
  17576. value: 0
  17577. });
  17578. animationPP2.setKeys(vignetteStretchKeys);
  17579. animationPP2.setEasingFunction(this._circleEase);
  17580. this._postProcessMove.animations.push(animationPP2);
  17581. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17582. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17583. this._postProcessMove.samples = 4;
  17584. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17585. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17586. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17587. });
  17588. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17589. };
  17590. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17591. if (hit.pickedPoint) {
  17592. if (gazer._teleportationRequestInitiated) {
  17593. this._displayTeleportationTarget();
  17594. this._haloCenter.copyFrom(hit.pickedPoint);
  17595. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17596. }
  17597. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17598. if (pickNormal) {
  17599. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17600. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17601. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17602. }
  17603. this._teleportationTarget.position.y += 0.1;
  17604. }
  17605. };
  17606. /**
  17607. * Teleports the users feet to the desired location
  17608. * @param location The location where the user's feet should be placed
  17609. */
  17610. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17611. var _this = this;
  17612. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17613. return;
  17614. }
  17615. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17616. // offset of the headset from the anchor.
  17617. if (this.webVRCamera.leftCamera) {
  17618. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17619. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17620. location.subtractToRef(this._workingVector, this._workingVector);
  17621. }
  17622. else {
  17623. this._workingVector.copyFrom(location);
  17624. }
  17625. // Add height to account for user's height offset
  17626. if (this.isInVRMode) {
  17627. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17628. }
  17629. else {
  17630. this._workingVector.y += this._defaultHeight;
  17631. }
  17632. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17633. // Create animation from the camera's position to the new location
  17634. this.currentVRCamera.animations = [];
  17635. 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);
  17636. var animationCameraTeleportationKeys = [{
  17637. frame: 0,
  17638. value: this.currentVRCamera.position
  17639. },
  17640. {
  17641. frame: 11,
  17642. value: this._workingVector
  17643. }
  17644. ];
  17645. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17646. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17647. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17648. this._postProcessMove.animations = [];
  17649. 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);
  17650. var vignetteWeightKeys = [];
  17651. vignetteWeightKeys.push({
  17652. frame: 0,
  17653. value: 0
  17654. });
  17655. vignetteWeightKeys.push({
  17656. frame: 5,
  17657. value: 8
  17658. });
  17659. vignetteWeightKeys.push({
  17660. frame: 11,
  17661. value: 0
  17662. });
  17663. animationPP.setKeys(vignetteWeightKeys);
  17664. this._postProcessMove.animations.push(animationPP);
  17665. 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);
  17666. var vignetteStretchKeys = [];
  17667. vignetteStretchKeys.push({
  17668. frame: 0,
  17669. value: 0
  17670. });
  17671. vignetteStretchKeys.push({
  17672. frame: 5,
  17673. value: 10
  17674. });
  17675. vignetteStretchKeys.push({
  17676. frame: 11,
  17677. value: 0
  17678. });
  17679. animationPP2.setKeys(vignetteStretchKeys);
  17680. this._postProcessMove.animations.push(animationPP2);
  17681. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17682. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17683. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17684. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17685. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17686. });
  17687. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17688. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17689. });
  17690. this._hideTeleportationTarget();
  17691. };
  17692. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17693. if (normal) {
  17694. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17695. if (angle < Math.PI / 2) {
  17696. normal.scaleInPlace(-1);
  17697. }
  17698. }
  17699. return normal;
  17700. };
  17701. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17702. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17703. return;
  17704. }
  17705. var ray = gazer._getForwardRay(this._rayLength);
  17706. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17707. if (hit) {
  17708. // Populate the contrllers mesh that can be used for drag/drop
  17709. if (gazer._laserPointer) {
  17710. hit.originMesh = gazer._laserPointer.parent;
  17711. }
  17712. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17713. }
  17714. gazer._currentHit = hit;
  17715. // Moving the gazeTracker on the mesh face targetted
  17716. if (hit && hit.pickedPoint) {
  17717. if (this._displayGaze) {
  17718. var multiplier = 1;
  17719. gazer._gazeTracker.isVisible = true;
  17720. if (gazer._isActionableMesh) {
  17721. multiplier = 3;
  17722. }
  17723. if (this.updateGazeTrackerScale) {
  17724. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17725. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17726. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17727. }
  17728. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17729. // To avoid z-fighting
  17730. var deltaFighting = 0.002;
  17731. if (pickNormal) {
  17732. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17733. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17734. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17735. }
  17736. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17737. if (gazer._gazeTracker.position.x < 0) {
  17738. gazer._gazeTracker.position.x += deltaFighting;
  17739. }
  17740. else {
  17741. gazer._gazeTracker.position.x -= deltaFighting;
  17742. }
  17743. if (gazer._gazeTracker.position.y < 0) {
  17744. gazer._gazeTracker.position.y += deltaFighting;
  17745. }
  17746. else {
  17747. gazer._gazeTracker.position.y -= deltaFighting;
  17748. }
  17749. if (gazer._gazeTracker.position.z < 0) {
  17750. gazer._gazeTracker.position.z += deltaFighting;
  17751. }
  17752. else {
  17753. gazer._gazeTracker.position.z -= deltaFighting;
  17754. }
  17755. }
  17756. // Changing the size of the laser pointer based on the distance from the targetted point
  17757. gazer._updatePointerDistance(hit.distance);
  17758. }
  17759. else {
  17760. gazer._updatePointerDistance();
  17761. gazer._gazeTracker.isVisible = false;
  17762. }
  17763. if (hit && hit.pickedMesh) {
  17764. // The object selected is the floor, we're in a teleportation scenario
  17765. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17766. // Moving the teleportation area to this targetted point
  17767. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17768. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17769. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17770. }
  17771. gazer._currentMeshSelected = null;
  17772. if (gazer._teleportationRequestInitiated) {
  17773. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17774. }
  17775. return;
  17776. }
  17777. // If not, we're in a selection scenario
  17778. //this._teleportationAllowed = false;
  17779. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17780. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17781. this.onNewMeshPicked.notifyObservers(hit);
  17782. gazer._currentMeshSelected = hit.pickedMesh;
  17783. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17784. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17785. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17786. gazer._isActionableMesh = true;
  17787. }
  17788. else {
  17789. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17790. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17791. gazer._isActionableMesh = false;
  17792. }
  17793. try {
  17794. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17795. }
  17796. catch (err) {
  17797. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17798. }
  17799. }
  17800. else {
  17801. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17802. gazer._currentMeshSelected = null;
  17803. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17804. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17805. }
  17806. }
  17807. }
  17808. else {
  17809. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17810. gazer._currentMeshSelected = null;
  17811. //this._teleportationAllowed = false;
  17812. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17813. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17814. }
  17815. };
  17816. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17817. if (mesh) {
  17818. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17819. }
  17820. };
  17821. /**
  17822. * Sets the color of the laser ray from the vr controllers.
  17823. * @param color new color for the ray.
  17824. */
  17825. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17826. if (this._leftController) {
  17827. this._leftController._setLaserPointerColor(color);
  17828. }
  17829. if (this._rightController) {
  17830. this._rightController._setLaserPointerColor(color);
  17831. }
  17832. };
  17833. /**
  17834. * Sets the color of the ray from the vr headsets gaze.
  17835. * @param color new color for the ray.
  17836. */
  17837. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17838. if (!this.updateGazeTrackerColor) {
  17839. return;
  17840. }
  17841. if (!this._cameraGazer._gazeTracker.material) {
  17842. return;
  17843. }
  17844. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17845. if (this._leftController) {
  17846. this._leftController._gazeTracker.material.emissiveColor = color;
  17847. }
  17848. if (this._rightController) {
  17849. this._rightController._gazeTracker.material.emissiveColor = color;
  17850. }
  17851. };
  17852. /**
  17853. * Exits VR and disposes of the vr experience helper
  17854. */
  17855. VRExperienceHelper.prototype.dispose = function () {
  17856. if (this.isInVRMode) {
  17857. this.exitVR();
  17858. }
  17859. if (this._postProcessMove) {
  17860. this._postProcessMove.dispose();
  17861. }
  17862. if (this._webVRCamera) {
  17863. this._webVRCamera.dispose();
  17864. }
  17865. if (this._vrDeviceOrientationCamera) {
  17866. this._vrDeviceOrientationCamera.dispose();
  17867. }
  17868. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17869. document.body.removeChild(this._btnVR);
  17870. }
  17871. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17872. this._deviceOrientationCamera.dispose();
  17873. }
  17874. if (this._cameraGazer) {
  17875. this._cameraGazer.dispose();
  17876. }
  17877. if (this._leftController) {
  17878. this._leftController.dispose();
  17879. }
  17880. if (this._rightController) {
  17881. this._rightController.dispose();
  17882. }
  17883. if (this._teleportationTarget) {
  17884. this._teleportationTarget.dispose();
  17885. }
  17886. this._floorMeshesCollection = [];
  17887. document.removeEventListener("keydown", this._onKeyDown);
  17888. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17889. window.removeEventListener("resize", this._onResize);
  17890. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17891. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17892. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17893. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17894. document.onmsfullscreenchange = null;
  17895. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17896. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17897. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17898. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17899. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17900. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17901. this._scene.unregisterBeforeRender(this.beforeRender);
  17902. };
  17903. /**
  17904. * Gets the name of the VRExperienceHelper class
  17905. * @returns "VRExperienceHelper"
  17906. */
  17907. VRExperienceHelper.prototype.getClassName = function () {
  17908. return "VRExperienceHelper";
  17909. };
  17910. return VRExperienceHelper;
  17911. }());
  17912. /***/ }),
  17913. /***/ "./Cameras/VR/webVRCamera.ts":
  17914. /*!***********************************!*\
  17915. !*** ./Cameras/VR/webVRCamera.ts ***!
  17916. \***********************************/
  17917. /*! exports provided: WebVRFreeCamera */
  17918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17919. "use strict";
  17920. __webpack_require__.r(__webpack_exports__);
  17921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17923. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17924. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17925. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17926. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17927. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17928. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17929. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17930. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17931. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  17932. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  17933. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17934. // Side effect import to define the stereoscopic mode.
  17935. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17936. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17937. });
  17938. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17939. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17940. });
  17941. /**
  17942. * This represents a WebVR camera.
  17943. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17944. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17945. */
  17946. var WebVRFreeCamera = /** @class */ (function (_super) {
  17947. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17948. /**
  17949. * Instantiates a WebVRFreeCamera.
  17950. * @param name The name of the WebVRFreeCamera
  17951. * @param position The starting anchor position for the camera
  17952. * @param scene The scene the camera belongs to
  17953. * @param webVROptions a set of customizable options for the webVRCamera
  17954. */
  17955. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17956. if (webVROptions === void 0) { webVROptions = {}; }
  17957. var _this = _super.call(this, name, position, scene) || this;
  17958. _this.webVROptions = webVROptions;
  17959. /**
  17960. * @hidden
  17961. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17962. */
  17963. _this._vrDevice = null;
  17964. /**
  17965. * The rawPose of the vrDevice.
  17966. */
  17967. _this.rawPose = null;
  17968. _this._specsVersion = "1.1";
  17969. _this._attached = false;
  17970. _this._descendants = [];
  17971. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17972. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17973. /** @hidden */
  17974. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17975. _this._standingMatrix = null;
  17976. /**
  17977. * Represents device position in babylon space.
  17978. */
  17979. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17980. /**
  17981. * Represents device rotation in babylon space.
  17982. */
  17983. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17984. /**
  17985. * The scale of the device to be used when translating from device space to babylon space.
  17986. */
  17987. _this.deviceScaleFactor = 1;
  17988. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17989. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17990. /**
  17991. * References to the webVR controllers for the vrDevice.
  17992. */
  17993. _this.controllers = [];
  17994. /**
  17995. * Emits an event when a controller is attached.
  17996. */
  17997. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17998. /**
  17999. * Emits an event when a controller's mesh has been loaded;
  18000. */
  18001. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18002. /**
  18003. * Emits an event when the HMD's pose has been updated.
  18004. */
  18005. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18006. _this._poseSet = false;
  18007. /**
  18008. * If the rig cameras be used as parent instead of this camera.
  18009. */
  18010. _this.rigParenting = true;
  18011. _this._defaultHeight = undefined;
  18012. _this._htmlElementAttached = null;
  18013. _this._detachIfAttached = function () {
  18014. var vrDisplay = _this.getEngine().getVRDevice();
  18015. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  18016. _this.detachControl(_this._htmlElementAttached);
  18017. }
  18018. };
  18019. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18020. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  18021. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18022. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18023. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18024. if (webVROptions.defaultHeight) {
  18025. _this._defaultHeight = webVROptions.defaultHeight;
  18026. _this.position.y = _this._defaultHeight;
  18027. }
  18028. _this.minZ = 0.1;
  18029. //legacy support - the compensation boolean was removed.
  18030. if (arguments.length === 5) {
  18031. _this.webVROptions = arguments[4];
  18032. }
  18033. // default webVR options
  18034. if (_this.webVROptions.trackPosition == undefined) {
  18035. _this.webVROptions.trackPosition = true;
  18036. }
  18037. if (_this.webVROptions.controllerMeshes == undefined) {
  18038. _this.webVROptions.controllerMeshes = true;
  18039. }
  18040. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  18041. _this.webVROptions.defaultLightingOnControllers = true;
  18042. }
  18043. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  18044. if (_this.webVROptions && _this.webVROptions.positionScale) {
  18045. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  18046. }
  18047. //enable VR
  18048. var engine = _this.getEngine();
  18049. _this._onVREnabled = function (success) { if (success) {
  18050. _this.initControllers();
  18051. } };
  18052. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  18053. engine.initWebVR().add(function (event) {
  18054. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  18055. return;
  18056. }
  18057. _this._vrDevice = event.vrDisplay;
  18058. //reset the rig parameters.
  18059. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  18060. if (_this._attached) {
  18061. _this.getEngine().enableVR();
  18062. }
  18063. });
  18064. if (typeof (VRFrameData) !== "undefined") {
  18065. _this._frameData = new VRFrameData();
  18066. }
  18067. if (webVROptions.useMultiview) {
  18068. if (!_this.getScene().getEngine().getCaps().multiview) {
  18069. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  18070. _this._useMultiviewToSingleView = false;
  18071. }
  18072. else {
  18073. _this._useMultiviewToSingleView = true;
  18074. _this._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", _this, 1.0);
  18075. }
  18076. }
  18077. /**
  18078. * The idea behind the following lines:
  18079. * objects that have the camera as parent should actually have the rig cameras as a parent.
  18080. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  18081. * the second will not show it correctly.
  18082. *
  18083. * To solve this - each object that has the camera as parent will be added to a protected array.
  18084. * When the rig camera renders, it will take this array and set all of those to be its children.
  18085. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  18086. * Amazing!
  18087. */
  18088. scene.onBeforeCameraRenderObservable.add(function (camera) {
  18089. if (camera.parent === _this && _this.rigParenting) {
  18090. _this._descendants = _this.getDescendants(true, function (n) {
  18091. // don't take the cameras or the controllers!
  18092. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  18093. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  18094. return !isController && !isRigCamera;
  18095. });
  18096. _this._descendants.forEach(function (node) {
  18097. node.parent = camera;
  18098. });
  18099. }
  18100. });
  18101. scene.onAfterCameraRenderObservable.add(function (camera) {
  18102. if (camera.parent === _this && _this.rigParenting) {
  18103. _this._descendants.forEach(function (node) {
  18104. node.parent = _this;
  18105. });
  18106. }
  18107. });
  18108. return _this;
  18109. }
  18110. /**
  18111. * Gets the device distance from the ground in meters.
  18112. * @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.
  18113. */
  18114. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  18115. if (this._standingMatrix) {
  18116. // Add standing matrix offset to get real offset from ground in room
  18117. this._standingMatrix.getTranslationToRef(this._workingVector);
  18118. return this._deviceRoomPosition.y + this._workingVector.y;
  18119. }
  18120. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  18121. return this._defaultHeight || 0;
  18122. };
  18123. /**
  18124. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18125. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18126. */
  18127. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  18128. var _this = this;
  18129. if (callback === void 0) { callback = function (bool) { }; }
  18130. // Use standing matrix if available
  18131. this.getEngine().initWebVRAsync().then(function (result) {
  18132. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  18133. callback(false);
  18134. }
  18135. else {
  18136. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18137. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  18138. if (!_this.getScene().useRightHandedSystem) {
  18139. if (_this._standingMatrix) {
  18140. _this._standingMatrix.toggleModelMatrixHandInPlace();
  18141. }
  18142. }
  18143. callback(true);
  18144. }
  18145. });
  18146. };
  18147. /**
  18148. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18149. * @returns A promise with a boolean set to if the standing matrix is supported.
  18150. */
  18151. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  18152. var _this = this;
  18153. return new Promise(function (res) {
  18154. _this.useStandingMatrix(function (supported) {
  18155. res(supported);
  18156. });
  18157. });
  18158. };
  18159. /**
  18160. * Disposes the camera
  18161. */
  18162. WebVRFreeCamera.prototype.dispose = function () {
  18163. this._detachIfAttached();
  18164. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18165. if (this._updateCacheWhenTrackingDisabledObserver) {
  18166. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18167. }
  18168. _super.prototype.dispose.call(this);
  18169. };
  18170. /**
  18171. * Gets a vrController by name.
  18172. * @param name The name of the controller to retreive
  18173. * @returns the controller matching the name specified or null if not found
  18174. */
  18175. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18176. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18177. var gp = _a[_i];
  18178. if (gp.hand === name) {
  18179. return gp;
  18180. }
  18181. }
  18182. return null;
  18183. };
  18184. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18185. /**
  18186. * The controller corrisponding to the users left hand.
  18187. */
  18188. get: function () {
  18189. if (!this._leftController) {
  18190. this._leftController = this.getControllerByName("left");
  18191. }
  18192. return this._leftController;
  18193. },
  18194. enumerable: true,
  18195. configurable: true
  18196. });
  18197. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18198. /**
  18199. * The controller corrisponding to the users right hand.
  18200. */
  18201. get: function () {
  18202. if (!this._rightController) {
  18203. this._rightController = this.getControllerByName("right");
  18204. }
  18205. return this._rightController;
  18206. },
  18207. enumerable: true,
  18208. configurable: true
  18209. });
  18210. /**
  18211. * Casts a ray forward from the vrCamera's gaze.
  18212. * @param length Length of the ray (default: 100)
  18213. * @returns the ray corrisponding to the gaze
  18214. */
  18215. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18216. if (length === void 0) { length = 100; }
  18217. if (this.leftCamera) {
  18218. // Use left eye to avoid computation to compute center on every call
  18219. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18220. }
  18221. else {
  18222. return _super.prototype.getForwardRay.call(this, length);
  18223. }
  18224. };
  18225. /**
  18226. * @hidden
  18227. * Updates the camera based on device's frame data
  18228. */
  18229. WebVRFreeCamera.prototype._checkInputs = function () {
  18230. if (this._vrDevice && this._vrDevice.isPresenting) {
  18231. this._vrDevice.getFrameData(this._frameData);
  18232. this.updateFromDevice(this._frameData.pose);
  18233. }
  18234. _super.prototype._checkInputs.call(this);
  18235. };
  18236. /**
  18237. * Updates the poseControlled values based on the input device pose.
  18238. * @param poseData Pose coming from the device
  18239. */
  18240. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18241. if (poseData && poseData.orientation) {
  18242. this.rawPose = poseData;
  18243. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18244. if (this.getScene().useRightHandedSystem) {
  18245. this._deviceRoomRotationQuaternion.z *= -1;
  18246. this._deviceRoomRotationQuaternion.w *= -1;
  18247. }
  18248. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18249. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18250. if (this.getScene().useRightHandedSystem) {
  18251. this._deviceRoomPosition.z *= -1;
  18252. }
  18253. }
  18254. this._poseSet = true;
  18255. }
  18256. };
  18257. /**
  18258. * WebVR's attach control will start broadcasting frames to the device.
  18259. * Note that in certain browsers (chrome for example) this function must be called
  18260. * within a user-interaction callback. Example:
  18261. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18262. *
  18263. * @param element html element to attach the vrDevice to
  18264. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18265. */
  18266. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18267. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18268. this._attached = true;
  18269. this._htmlElementAttached = element;
  18270. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18271. if (this._vrDevice) {
  18272. this.getEngine().enableVR();
  18273. }
  18274. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18275. };
  18276. /**
  18277. * Detaches the camera from the html element and disables VR
  18278. *
  18279. * @param element html element to detach from
  18280. */
  18281. WebVRFreeCamera.prototype.detachControl = function (element) {
  18282. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18283. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18284. _super.prototype.detachControl.call(this, element);
  18285. this._attached = false;
  18286. this.getEngine().disableVR();
  18287. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18288. };
  18289. /**
  18290. * @returns the name of this class
  18291. */
  18292. WebVRFreeCamera.prototype.getClassName = function () {
  18293. return "WebVRFreeCamera";
  18294. };
  18295. /**
  18296. * Calls resetPose on the vrDisplay
  18297. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18298. */
  18299. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18300. //uses the vrDisplay's "resetPose()".
  18301. //pitch and roll won't be affected.
  18302. this._vrDevice.resetPose();
  18303. };
  18304. /**
  18305. * @hidden
  18306. * Updates the rig cameras (left and right eye)
  18307. */
  18308. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18309. var camLeft = this._rigCameras[0];
  18310. var camRight = this._rigCameras[1];
  18311. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18312. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18313. camLeft.position.copyFrom(this._deviceRoomPosition);
  18314. camRight.position.copyFrom(this._deviceRoomPosition);
  18315. };
  18316. // Remove translation from 6dof headset if trackposition is set to false
  18317. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18318. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18319. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18320. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18321. if (!isViewMatrix) {
  18322. this._tmpMatrix.invert();
  18323. }
  18324. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18325. }
  18326. };
  18327. /**
  18328. * @hidden
  18329. * Updates the cached values of the camera
  18330. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18331. */
  18332. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18333. var _this = this;
  18334. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18335. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18336. if (!this.updateCacheCalled) {
  18337. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18338. this.updateCacheCalled = true;
  18339. this.update();
  18340. }
  18341. // Set working vector to the device position in room space rotated by the new rotation
  18342. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18343. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18344. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18345. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18346. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18347. // Add translation from anchor position
  18348. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18349. this._workingVector.addInPlace(this.position);
  18350. this._workingVector.subtractInPlace(this._cache.position);
  18351. this._deviceToWorld.setTranslation(this._workingVector);
  18352. // Set an inverted matrix to be used when updating the camera
  18353. this._deviceToWorld.invertToRef(this._worldToDevice);
  18354. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18355. this.controllers.forEach(function (controller) {
  18356. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18357. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18358. controller.update();
  18359. });
  18360. }
  18361. if (!ignoreParentClass) {
  18362. _super.prototype._updateCache.call(this);
  18363. }
  18364. this.updateCacheCalled = false;
  18365. };
  18366. /**
  18367. * @hidden
  18368. * Get current device position in babylon world
  18369. */
  18370. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18371. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18372. };
  18373. /**
  18374. * Updates the current device position and rotation in the babylon world
  18375. */
  18376. WebVRFreeCamera.prototype.update = function () {
  18377. this._computeDevicePosition();
  18378. // Get current device rotation in babylon world
  18379. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18380. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18381. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18382. if (this._poseSet) {
  18383. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18384. }
  18385. _super.prototype.update.call(this);
  18386. };
  18387. /**
  18388. * @hidden
  18389. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18390. * @returns an identity matrix
  18391. */
  18392. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18393. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18394. };
  18395. /**
  18396. * This function is called by the two RIG cameras.
  18397. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18398. * @hidden
  18399. */
  18400. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18401. // Update the parent camera prior to using a child camera to avoid desynchronization
  18402. var parentCamera = this._cameraRigParams["parentCamera"];
  18403. parentCamera._updateCache();
  18404. //WebVR 1.1
  18405. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18406. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18407. if (!this.getScene().useRightHandedSystem) {
  18408. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18409. }
  18410. // update the camera rotation matrix
  18411. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18412. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18413. // Computing target and final matrix
  18414. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18415. // should the view matrix be updated with scale and position offset?
  18416. if (parentCamera.deviceScaleFactor !== 1) {
  18417. this._webvrViewMatrix.invert();
  18418. // scale the position, if set
  18419. if (parentCamera.deviceScaleFactor) {
  18420. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18421. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18422. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18423. }
  18424. this._webvrViewMatrix.invert();
  18425. }
  18426. // Remove translation from 6dof headset if trackposition is set to false
  18427. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18428. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18429. // Compute global position
  18430. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18431. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18432. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18433. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18434. this._markSyncedWithParent();
  18435. return this._webvrViewMatrix;
  18436. };
  18437. /** @hidden */
  18438. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18439. var parentCamera = this.parent;
  18440. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18441. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18442. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18443. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18444. //babylon compatible matrix
  18445. if (!this.getScene().useRightHandedSystem) {
  18446. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18447. }
  18448. return this._projectionMatrix;
  18449. };
  18450. /**
  18451. * Initializes the controllers and their meshes
  18452. */
  18453. WebVRFreeCamera.prototype.initControllers = function () {
  18454. var _this = this;
  18455. this.controllers = [];
  18456. var manager = this.getScene().gamepadManager;
  18457. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18458. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18459. var webVrController = gamepad;
  18460. if (webVrController.defaultModel) {
  18461. webVrController.defaultModel.setEnabled(false);
  18462. }
  18463. if (webVrController.hand === "right") {
  18464. _this._rightController = null;
  18465. }
  18466. if (webVrController.hand === "left") {
  18467. _this._leftController = null;
  18468. }
  18469. var controllerIndex = _this.controllers.indexOf(webVrController);
  18470. if (controllerIndex !== -1) {
  18471. _this.controllers.splice(controllerIndex, 1);
  18472. }
  18473. }
  18474. });
  18475. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18476. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18477. var webVrController_1 = gamepad;
  18478. if (!_this.webVROptions.trackPosition) {
  18479. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18480. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18481. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18482. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18483. _this._updateCache();
  18484. });
  18485. }
  18486. }
  18487. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18488. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18489. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18490. if (_this.webVROptions.controllerMeshes) {
  18491. if (webVrController_1.defaultModel) {
  18492. webVrController_1.defaultModel.setEnabled(true);
  18493. }
  18494. else {
  18495. // Load the meshes
  18496. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18497. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18498. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18499. if (_this.webVROptions.defaultLightingOnControllers) {
  18500. if (!_this._lightOnControllers) {
  18501. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18502. }
  18503. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18504. var children = mesh.getChildren();
  18505. if (children && children.length !== 0) {
  18506. children.forEach(function (mesh) {
  18507. light.includedOnlyMeshes.push(mesh);
  18508. activateLightOnSubMeshes_1(mesh, light);
  18509. });
  18510. }
  18511. };
  18512. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18513. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18514. }
  18515. });
  18516. }
  18517. }
  18518. webVrController_1.attachToPoseControlledCamera(_this);
  18519. // since this is async - sanity check. Is the controller already stored?
  18520. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18521. //add to the controllers array
  18522. _this.controllers.push(webVrController_1);
  18523. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18524. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18525. // So we're overriding setting left & right manually to be sure
  18526. var firstViveWandDetected = false;
  18527. for (var i = 0; i < _this.controllers.length; i++) {
  18528. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18529. if (!firstViveWandDetected) {
  18530. firstViveWandDetected = true;
  18531. _this.controllers[i].hand = "left";
  18532. }
  18533. else {
  18534. _this.controllers[i].hand = "right";
  18535. }
  18536. }
  18537. }
  18538. //did we find enough controllers? Great! let the developer know.
  18539. if (_this.controllers.length >= 2) {
  18540. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18541. }
  18542. }
  18543. }
  18544. });
  18545. };
  18546. return WebVRFreeCamera;
  18547. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18548. /***/ }),
  18549. /***/ "./Cameras/XR/index.ts":
  18550. /*!*****************************!*\
  18551. !*** ./Cameras/XR/index.ts ***!
  18552. \*****************************/
  18553. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18555. "use strict";
  18556. __webpack_require__.r(__webpack_exports__);
  18557. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18559. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18563. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18566. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18569. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18571. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18573. /***/ }),
  18574. /***/ "./Cameras/XR/webXRCamera.ts":
  18575. /*!***********************************!*\
  18576. !*** ./Cameras/XR/webXRCamera.ts ***!
  18577. \***********************************/
  18578. /*! exports provided: WebXRCamera */
  18579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18580. "use strict";
  18581. __webpack_require__.r(__webpack_exports__);
  18582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18583. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18584. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18585. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18586. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18587. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18588. /**
  18589. * WebXR Camera which holds the views for the xrSession
  18590. * @see https://doc.babylonjs.com/how_to/webxr
  18591. */
  18592. var WebXRCamera = /** @class */ (function (_super) {
  18593. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18594. /**
  18595. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18596. * @param name the name of the camera
  18597. * @param scene the scene to add the camera to
  18598. */
  18599. function WebXRCamera(name, scene) {
  18600. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18601. // Initial camera configuration
  18602. _this.minZ = 0;
  18603. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18604. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18605. _this.updateUpVectorFromRotation = true;
  18606. _this._updateNumberOfRigCameras(1);
  18607. return _this;
  18608. }
  18609. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18610. if (viewCount === void 0) { viewCount = 1; }
  18611. while (this.rigCameras.length < viewCount) {
  18612. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18613. newCamera.minZ = 0;
  18614. newCamera.parent = this;
  18615. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18616. newCamera.updateUpVectorFromRotation = true;
  18617. this.rigCameras.push(newCamera);
  18618. }
  18619. while (this.rigCameras.length > viewCount) {
  18620. var removedCamera = this.rigCameras.pop();
  18621. if (removedCamera) {
  18622. removedCamera.dispose();
  18623. }
  18624. }
  18625. };
  18626. /** @hidden */
  18627. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18628. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18629. // Create initial camera rigs
  18630. this._updateNumberOfRigCameras(2);
  18631. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18632. this.rigCameras[0].position.x = -pupilDistance / 2;
  18633. this.rigCameras[0].outputRenderTarget = null;
  18634. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18635. this.rigCameras[1].position.x = pupilDistance / 2;
  18636. this.rigCameras[1].outputRenderTarget = null;
  18637. };
  18638. /**
  18639. * Updates the cameras position from the current pose information of the XR session
  18640. * @param xrSessionManager the session containing pose information
  18641. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18642. */
  18643. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18644. var _this = this;
  18645. // Ensure all frame data is available
  18646. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18647. return false;
  18648. }
  18649. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18650. if (!pose || !pose.poseModelMatrix) {
  18651. return false;
  18652. }
  18653. // Update the parent cameras matrix
  18654. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18655. if (!this._scene.useRightHandedSystem) {
  18656. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18657. }
  18658. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18659. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18660. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18661. this.computeWorldMatrix();
  18662. // Update camera rigs
  18663. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18664. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18665. // Update view/projection matrix
  18666. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18667. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18668. if (!_this._scene.useRightHandedSystem) {
  18669. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18670. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18671. }
  18672. // Update viewport
  18673. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18674. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18675. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18676. _this.rigCameras[i].viewport.width = viewport.width / width;
  18677. _this.rigCameras[i].viewport.height = viewport.height / height;
  18678. _this.rigCameras[i].viewport.x = viewport.x / width;
  18679. _this.rigCameras[i].viewport.y = viewport.y / height;
  18680. // Set cameras to render to the session's render target
  18681. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18682. });
  18683. return true;
  18684. };
  18685. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18686. return WebXRCamera;
  18687. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18688. /***/ }),
  18689. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18690. /*!****************************************!*\
  18691. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18692. \****************************************/
  18693. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18695. "use strict";
  18696. __webpack_require__.r(__webpack_exports__);
  18697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18698. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18700. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18701. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18702. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18703. /**
  18704. * Button which can be used to enter a different mode of XR
  18705. */
  18706. var WebXREnterExitUIButton = /** @class */ (function () {
  18707. /**
  18708. * Creates a WebXREnterExitUIButton
  18709. * @param element button element
  18710. * @param initializationOptions XR initialization options for the button
  18711. */
  18712. function WebXREnterExitUIButton(
  18713. /** button element */
  18714. element,
  18715. /** XR initialization options for the button */
  18716. initializationOptions) {
  18717. this.element = element;
  18718. this.initializationOptions = initializationOptions;
  18719. }
  18720. /**
  18721. * Overwritable function which can be used to update the button's visuals when the state changes
  18722. * @param activeButton the current active button in the UI
  18723. */
  18724. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18725. };
  18726. return WebXREnterExitUIButton;
  18727. }());
  18728. /**
  18729. * Options to create the webXR UI
  18730. */
  18731. var WebXREnterExitUIOptions = /** @class */ (function () {
  18732. function WebXREnterExitUIOptions() {
  18733. }
  18734. return WebXREnterExitUIOptions;
  18735. }());
  18736. /**
  18737. * UI to allow the user to enter/exit XR mode
  18738. */
  18739. var WebXREnterExitUI = /** @class */ (function () {
  18740. function WebXREnterExitUI(scene, options) {
  18741. var _this = this;
  18742. this.scene = scene;
  18743. this._buttons = [];
  18744. this._activeButton = null;
  18745. /**
  18746. * Fired every time the active button is changed.
  18747. *
  18748. * When xr is entered via a button that launches xr that button will be the callback parameter
  18749. *
  18750. * When exiting xr the callback parameter will be null)
  18751. */
  18752. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18753. this._overlay = document.createElement("div");
  18754. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18755. if (options.customButtons) {
  18756. this._buttons = options.customButtons;
  18757. }
  18758. else {
  18759. var hmdBtn = document.createElement("button");
  18760. 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;";
  18761. hmdBtn.innerText = "HMD";
  18762. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18763. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18764. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18765. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18766. };
  18767. var windowBtn = document.createElement("button");
  18768. windowBtn.style.cssText = hmdBtn.style.cssText;
  18769. windowBtn.innerText = "Window";
  18770. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18771. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18772. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18773. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18774. };
  18775. this._updateButtons(null);
  18776. }
  18777. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18778. if (renderCanvas && renderCanvas.parentNode) {
  18779. renderCanvas.parentNode.appendChild(this._overlay);
  18780. scene.onDisposeObservable.addOnce(function () {
  18781. _this.dispose();
  18782. });
  18783. }
  18784. }
  18785. /**
  18786. * Creates UI to allow the user to enter/exit XR mode
  18787. * @param scene the scene to add the ui to
  18788. * @param helper the xr experience helper to enter/exit xr with
  18789. * @param options options to configure the UI
  18790. * @returns the created ui
  18791. */
  18792. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18793. var _this = this;
  18794. var ui = new WebXREnterExitUI(scene, options);
  18795. var supportedPromises = ui._buttons.map(function (btn) {
  18796. return helper.supportsSessionAsync(btn.initializationOptions);
  18797. });
  18798. helper.onStateChangedObservable.add(function (state) {
  18799. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18800. ui._updateButtons(null);
  18801. }
  18802. });
  18803. return Promise.all(supportedPromises).then(function (results) {
  18804. results.forEach(function (supported, i) {
  18805. if (supported) {
  18806. ui._overlay.appendChild(ui._buttons[i].element);
  18807. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18808. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18809. switch (_a.label) {
  18810. case 0:
  18811. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18812. ui._updateButtons(null);
  18813. return [4 /*yield*/, helper.exitXRAsync()];
  18814. case 1:
  18815. _a.sent();
  18816. return [2 /*return*/];
  18817. case 2:
  18818. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18819. ui._updateButtons(ui._buttons[i]);
  18820. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18821. case 3:
  18822. _a.sent();
  18823. _a.label = 4;
  18824. case 4: return [2 /*return*/];
  18825. }
  18826. });
  18827. }); };
  18828. }
  18829. });
  18830. return ui;
  18831. });
  18832. };
  18833. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18834. var _this = this;
  18835. this._activeButton = activeButton;
  18836. this._buttons.forEach(function (b) {
  18837. b.update(_this._activeButton);
  18838. });
  18839. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18840. };
  18841. /**
  18842. * Disposes of the object
  18843. */
  18844. WebXREnterExitUI.prototype.dispose = function () {
  18845. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18846. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18847. renderCanvas.parentNode.removeChild(this._overlay);
  18848. }
  18849. this.activeButtonChangedObservable.clear();
  18850. };
  18851. return WebXREnterExitUI;
  18852. }());
  18853. /***/ }),
  18854. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18855. /*!*********************************************!*\
  18856. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18857. \*********************************************/
  18858. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18860. "use strict";
  18861. __webpack_require__.r(__webpack_exports__);
  18862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18864. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18865. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18866. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18867. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18868. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18869. /**
  18870. * States of the webXR experience
  18871. */
  18872. var WebXRState;
  18873. (function (WebXRState) {
  18874. /**
  18875. * Transitioning to being in XR mode
  18876. */
  18877. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18878. /**
  18879. * Transitioning to non XR mode
  18880. */
  18881. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18882. /**
  18883. * In XR mode and presenting
  18884. */
  18885. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18886. /**
  18887. * Not entered XR mode
  18888. */
  18889. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18890. })(WebXRState || (WebXRState = {}));
  18891. /**
  18892. * Helper class used to enable XR
  18893. * @see https://doc.babylonjs.com/how_to/webxr
  18894. */
  18895. var WebXRExperienceHelper = /** @class */ (function () {
  18896. /**
  18897. * Creates a WebXRExperienceHelper
  18898. * @param scene The scene the helper should be created in
  18899. */
  18900. function WebXRExperienceHelper(scene) {
  18901. this.scene = scene;
  18902. /**
  18903. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18904. */
  18905. this.state = WebXRState.NOT_IN_XR;
  18906. /**
  18907. * Fires when the state of the experience helper has changed
  18908. */
  18909. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18910. this._nonVRCamera = null;
  18911. this._originalSceneAutoClear = true;
  18912. this._supported = false;
  18913. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18914. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18915. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18916. this.camera.parent = this.container;
  18917. }
  18918. WebXRExperienceHelper.prototype._setState = function (val) {
  18919. this.state = val;
  18920. this.onStateChangedObservable.notifyObservers(this.state);
  18921. };
  18922. /**
  18923. * Creates the experience helper
  18924. * @param scene the scene to attach the experience helper to
  18925. * @returns a promise for the experience helper
  18926. */
  18927. WebXRExperienceHelper.CreateAsync = function (scene) {
  18928. var helper = new WebXRExperienceHelper(scene);
  18929. return helper._sessionManager.initializeAsync().then(function () {
  18930. helper._supported = true;
  18931. return helper;
  18932. }).catch(function () {
  18933. return helper;
  18934. });
  18935. };
  18936. /**
  18937. * Exits XR mode and returns the scene to its original state
  18938. * @returns promise that resolves after xr mode has exited
  18939. */
  18940. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18941. this._setState(WebXRState.EXITING_XR);
  18942. return this._sessionManager.exitXRAsync();
  18943. };
  18944. /**
  18945. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18946. * @param sessionCreationOptions options for the XR session
  18947. * @param frameOfReference frame of reference of the XR session
  18948. * @returns promise that resolves after xr mode has entered
  18949. */
  18950. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18951. var _this = this;
  18952. if (!this._supported) {
  18953. throw "XR session not supported by this browser";
  18954. }
  18955. this._setState(WebXRState.ENTERING_XR);
  18956. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18957. // Cache pre xr scene settings
  18958. _this._originalSceneAutoClear = _this.scene.autoClear;
  18959. _this._nonVRCamera = _this.scene.activeCamera;
  18960. // Overwrite current scene settings
  18961. _this.scene.autoClear = false;
  18962. _this.scene.activeCamera = _this.camera;
  18963. _this._sessionManager.onXRFrameObservable.add(function () {
  18964. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18965. });
  18966. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18967. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18968. _this.camera.rigCameras.forEach(function (c) {
  18969. c.outputRenderTarget = null;
  18970. });
  18971. // Restore scene settings
  18972. _this.scene.autoClear = _this._originalSceneAutoClear;
  18973. _this.scene.activeCamera = _this._nonVRCamera;
  18974. _this._sessionManager.onXRFrameObservable.clear();
  18975. _this._setState(WebXRState.NOT_IN_XR);
  18976. });
  18977. _this._setState(WebXRState.IN_XR);
  18978. });
  18979. };
  18980. /**
  18981. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18982. * @param ray ray to cast into the environment
  18983. * @returns Promise which resolves with a collision point in the environment if it exists
  18984. */
  18985. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18986. return this._sessionManager.environmentPointHitTestAsync(ray);
  18987. };
  18988. /**
  18989. * Updates the global position of the camera by moving the camera's container
  18990. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18991. * @param position The desired global position of the camera
  18992. */
  18993. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18994. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18995. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18996. };
  18997. /**
  18998. * Rotates the xr camera by rotating the camera's container around the camera's position
  18999. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  19000. * @param rotation the desired quaternion rotation to apply to the camera
  19001. */
  19002. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  19003. if (!this.container.rotationQuaternion) {
  19004. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  19005. }
  19006. this.container.rotationQuaternion.multiplyInPlace(rotation);
  19007. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  19008. };
  19009. /**
  19010. * Checks if the creation options are supported by the xr session
  19011. * @param options creation options
  19012. * @returns true if supported
  19013. */
  19014. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  19015. if (!this._supported) {
  19016. return Promise.resolve(false);
  19017. }
  19018. return this._sessionManager.supportsSessionAsync(options);
  19019. };
  19020. /**
  19021. * Disposes of the experience helper
  19022. */
  19023. WebXRExperienceHelper.prototype.dispose = function () {
  19024. this.camera.dispose();
  19025. this.container.dispose();
  19026. this.onStateChangedObservable.clear();
  19027. this._sessionManager.dispose();
  19028. };
  19029. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  19030. return WebXRExperienceHelper;
  19031. }());
  19032. /***/ }),
  19033. /***/ "./Cameras/XR/webXRInput.ts":
  19034. /*!**********************************!*\
  19035. !*** ./Cameras/XR/webXRInput.ts ***!
  19036. \**********************************/
  19037. /*! exports provided: WebXRController, WebXRInput */
  19038. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19039. "use strict";
  19040. __webpack_require__.r(__webpack_exports__);
  19041. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  19042. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  19043. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19044. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  19045. /**
  19046. * Represents an XR input
  19047. */
  19048. var WebXRController = /** @class */ (function () {
  19049. /**
  19050. * Creates the controller
  19051. * @see https://doc.babylonjs.com/how_to/webxr
  19052. * @param scene the scene which the controller should be associated to
  19053. */
  19054. function WebXRController(scene) {
  19055. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  19056. }
  19057. /**
  19058. * Disposes of the object
  19059. */
  19060. WebXRController.prototype.dispose = function () {
  19061. if (this.grip) {
  19062. this.grip.dispose();
  19063. }
  19064. this.pointer.dispose();
  19065. };
  19066. return WebXRController;
  19067. }());
  19068. /**
  19069. * XR input used to track XR inputs such as controllers/rays
  19070. */
  19071. var WebXRInput = /** @class */ (function () {
  19072. /**
  19073. * Initializes the WebXRInput
  19074. * @param helper experience helper which the input should be created for
  19075. */
  19076. function WebXRInput(helper) {
  19077. var _this = this;
  19078. this.helper = helper;
  19079. /**
  19080. * XR controllers being tracked
  19081. */
  19082. this.controllers = [];
  19083. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  19084. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  19085. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  19086. return;
  19087. }
  19088. var xrFrame = helper._sessionManager._currentXRFrame;
  19089. var inputSources = helper._sessionManager._xrSession.getInputSources();
  19090. inputSources.forEach(function (input, i) {
  19091. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  19092. if (inputPose) {
  19093. if (_this.controllers.length <= i) {
  19094. _this.controllers.push(new WebXRController(helper.container.getScene()));
  19095. }
  19096. var controller = _this.controllers[i];
  19097. // Manage the grip if it exists
  19098. if (inputPose.gripMatrix) {
  19099. if (!controller.grip) {
  19100. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  19101. }
  19102. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  19103. if (!controller.grip.getScene().useRightHandedSystem) {
  19104. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19105. }
  19106. if (!controller.grip.rotationQuaternion) {
  19107. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19108. }
  19109. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  19110. }
  19111. // Manager pointer of controller
  19112. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  19113. if (!controller.pointer.getScene().useRightHandedSystem) {
  19114. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19115. }
  19116. if (!controller.pointer.rotationQuaternion) {
  19117. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19118. }
  19119. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  19120. }
  19121. });
  19122. });
  19123. }
  19124. /**
  19125. * Disposes of the object
  19126. */
  19127. WebXRInput.prototype.dispose = function () {
  19128. this.controllers.forEach(function (c) {
  19129. c.dispose();
  19130. });
  19131. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  19132. };
  19133. return WebXRInput;
  19134. }());
  19135. /***/ }),
  19136. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  19137. /*!************************************************!*\
  19138. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  19139. \************************************************/
  19140. /*! exports provided: WebXRManagedOutputCanvas */
  19141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19142. "use strict";
  19143. __webpack_require__.r(__webpack_exports__);
  19144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  19145. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19146. /**
  19147. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  19148. */
  19149. var WebXRManagedOutputCanvas = /** @class */ (function () {
  19150. /**
  19151. * Initializes the canvas to be added/removed upon entering/exiting xr
  19152. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  19153. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  19154. */
  19155. function WebXRManagedOutputCanvas(helper, canvas) {
  19156. var _this = this;
  19157. this._canvas = null;
  19158. /**
  19159. * xrpresent context of the canvas which can be used to display/mirror xr content
  19160. */
  19161. this.canvasContext = null;
  19162. if (!canvas) {
  19163. canvas = document.createElement('canvas');
  19164. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  19165. }
  19166. this._setManagedOutputCanvas(canvas);
  19167. helper.onStateChangedObservable.add(function (stateInfo) {
  19168. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19169. // 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
  19170. _this._addCanvas();
  19171. }
  19172. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19173. _this._removeCanvas();
  19174. }
  19175. });
  19176. }
  19177. /**
  19178. * Disposes of the object
  19179. */
  19180. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19181. this._removeCanvas();
  19182. this._setManagedOutputCanvas(null);
  19183. };
  19184. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19185. this._removeCanvas();
  19186. if (!canvas) {
  19187. this._canvas = null;
  19188. this.canvasContext = null;
  19189. }
  19190. else {
  19191. this._canvas = canvas;
  19192. this.canvasContext = this._canvas.getContext('xrpresent');
  19193. }
  19194. };
  19195. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  19196. if (this._canvas) {
  19197. document.body.appendChild(this._canvas);
  19198. }
  19199. };
  19200. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  19201. if (this._canvas && document.body.contains(this._canvas)) {
  19202. document.body.removeChild(this._canvas);
  19203. }
  19204. };
  19205. return WebXRManagedOutputCanvas;
  19206. }());
  19207. /***/ }),
  19208. /***/ "./Cameras/XR/webXRSessionManager.ts":
  19209. /*!*******************************************!*\
  19210. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  19211. \*******************************************/
  19212. /*! exports provided: WebXRSessionManager */
  19213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19214. "use strict";
  19215. __webpack_require__.r(__webpack_exports__);
  19216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  19217. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  19218. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19219. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19220. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  19221. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  19222. /**
  19223. * Manages an XRSession
  19224. * @see https://doc.babylonjs.com/how_to/webxr
  19225. */
  19226. var WebXRSessionManager = /** @class */ (function () {
  19227. /**
  19228. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  19229. * @param scene The scene which the session should be created for
  19230. */
  19231. function WebXRSessionManager(scene) {
  19232. this.scene = scene;
  19233. /**
  19234. * Fires every time a new xrFrame arrives which can be used to update the camera
  19235. */
  19236. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19237. /**
  19238. * Fires when the xr session is ended either by the device or manually done
  19239. */
  19240. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19241. /** @hidden */
  19242. this._sessionRenderTargetTexture = null;
  19243. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  19244. }
  19245. /**
  19246. * Initializes the manager
  19247. * After initialization enterXR can be called to start an XR session
  19248. * @returns Promise which resolves after it is initialized
  19249. */
  19250. WebXRSessionManager.prototype.initializeAsync = function () {
  19251. var _this = this;
  19252. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  19253. // Check if the browser supports webXR
  19254. this._xrNavigator = navigator;
  19255. if (!this._xrNavigator.xr) {
  19256. return Promise.reject("webXR not supported by this browser");
  19257. }
  19258. // Request the webXR device
  19259. return this._xrNavigator.xr.requestDevice().then(function (device) {
  19260. _this._xrDevice = device;
  19261. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  19262. });
  19263. };
  19264. /**
  19265. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  19266. * @param sessionCreationOptions xr options to create the session with
  19267. * @param frameOfReferenceType option to configure how the xr pose is expressed
  19268. * @returns Promise which resolves after it enters XR
  19269. */
  19270. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  19271. var _this = this;
  19272. // initialize session
  19273. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  19274. _this._xrSession = session;
  19275. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  19276. _this._xrSession.addEventListener("end", function () {
  19277. // Remove render target texture and notify frame obervers
  19278. _this._sessionRenderTargetTexture = null;
  19279. // Restore frame buffer to avoid clear on xr framebuffer after session end
  19280. _this.scene.getEngine().restoreDefaultFramebuffer();
  19281. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  19282. _this.scene.getEngine().customAnimationFrameRequester = null;
  19283. _this.onXRSessionEnded.notifyObservers(null);
  19284. _this.scene.getEngine()._renderLoop();
  19285. }, { once: true });
  19286. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  19287. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  19288. }).then(function (frameOfRef) {
  19289. _this._frameOfReference = frameOfRef;
  19290. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  19291. _this.scene.getEngine().customAnimationFrameRequester = {
  19292. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  19293. renderFunction: function (timestamp, xrFrame) {
  19294. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  19295. _this._currentXRFrame = xrFrame;
  19296. _this.onXRFrameObservable.notifyObservers(null);
  19297. _this.scene.getEngine()._renderLoop();
  19298. }
  19299. };
  19300. // Create render target texture from xr's webgl render target
  19301. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  19302. // Stop window's animation frame and trigger sessions animation frame
  19303. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  19304. _this.scene.getEngine()._renderLoop();
  19305. });
  19306. };
  19307. /**
  19308. * Stops the xrSession and restores the renderloop
  19309. * @returns Promise which resolves after it exits XR
  19310. */
  19311. WebXRSessionManager.prototype.exitXRAsync = function () {
  19312. return this._xrSession.end();
  19313. };
  19314. /**
  19315. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19316. * @param ray ray to cast into the environment
  19317. * @returns Promise which resolves with a collision point in the environment if it exists
  19318. */
  19319. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  19320. var _this = this;
  19321. return new Promise(function (res) {
  19322. // Compute left handed inputs to request hit test
  19323. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  19324. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  19325. if (!_this.scene.useRightHandedSystem) {
  19326. origin[2] *= -1;
  19327. direction[2] *= -1;
  19328. }
  19329. // Fire hittest
  19330. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  19331. .then(function (hits) {
  19332. if (hits.length > 0) {
  19333. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  19334. var hitPoint = _this._tmpMatrix.getTranslation();
  19335. if (!_this.scene.useRightHandedSystem) {
  19336. hitPoint.z *= -1;
  19337. }
  19338. res(hitPoint);
  19339. }
  19340. else {
  19341. res(null);
  19342. }
  19343. }).catch(function () {
  19344. res(null);
  19345. });
  19346. });
  19347. };
  19348. /**
  19349. * Checks if a session would be supported for the creation options specified
  19350. * @param options creation options to check if they are supported
  19351. * @returns true if supported
  19352. */
  19353. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  19354. return this._xrDevice.supportsSession(options).then(function () {
  19355. return true;
  19356. }).catch(function () {
  19357. return false;
  19358. });
  19359. };
  19360. /**
  19361. * @hidden
  19362. * Converts the render layer of xrSession to a render target
  19363. * @param session session to create render target for
  19364. * @param scene scene the new render target should be created for
  19365. */
  19366. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  19367. // Create internal texture
  19368. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  19369. internalTexture.width = session.baseLayer.framebufferWidth;
  19370. internalTexture.height = session.baseLayer.framebufferHeight;
  19371. internalTexture._framebuffer = session.baseLayer.framebuffer;
  19372. // Create render target texture from the internal texture
  19373. 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);
  19374. renderTargetTexture._texture = internalTexture;
  19375. return renderTargetTexture;
  19376. };
  19377. /**
  19378. * Disposes of the session manager
  19379. */
  19380. WebXRSessionManager.prototype.dispose = function () {
  19381. this.onXRFrameObservable.clear();
  19382. this.onXRSessionEnded.clear();
  19383. };
  19384. return WebXRSessionManager;
  19385. }());
  19386. /***/ }),
  19387. /***/ "./Cameras/arcRotateCamera.ts":
  19388. /*!************************************!*\
  19389. !*** ./Cameras/arcRotateCamera.ts ***!
  19390. \************************************/
  19391. /*! exports provided: ArcRotateCamera */
  19392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19393. "use strict";
  19394. __webpack_require__.r(__webpack_exports__);
  19395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  19396. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19397. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19398. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19399. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19400. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  19401. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  19402. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  19403. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  19404. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  19405. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  19406. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  19407. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  19408. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  19409. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  19410. });
  19411. /**
  19412. * This represents an orbital type of camera.
  19413. *
  19414. * 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.
  19415. * 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.
  19416. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  19417. */
  19418. var ArcRotateCamera = /** @class */ (function (_super) {
  19419. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  19420. /**
  19421. * Instantiates a new ArcRotateCamera in a given scene
  19422. * @param name Defines the name of the camera
  19423. * @param alpha Defines the camera rotation along the logitudinal axis
  19424. * @param beta Defines the camera rotation along the latitudinal axis
  19425. * @param radius Defines the camera distance from its target
  19426. * @param target Defines the camera target
  19427. * @param scene Defines the scene the camera belongs to
  19428. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19429. */
  19430. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  19431. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19432. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  19433. _this._upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  19434. /**
  19435. * Current inertia value on the longitudinal axis.
  19436. * The bigger this number the longer it will take for the camera to stop.
  19437. */
  19438. _this.inertialAlphaOffset = 0;
  19439. /**
  19440. * Current inertia value on the latitudinal axis.
  19441. * The bigger this number the longer it will take for the camera to stop.
  19442. */
  19443. _this.inertialBetaOffset = 0;
  19444. /**
  19445. * Current inertia value on the radius axis.
  19446. * The bigger this number the longer it will take for the camera to stop.
  19447. */
  19448. _this.inertialRadiusOffset = 0;
  19449. /**
  19450. * Minimum allowed angle on the longitudinal axis.
  19451. * This can help limiting how the Camera is able to move in the scene.
  19452. */
  19453. _this.lowerAlphaLimit = null;
  19454. /**
  19455. * Maximum allowed angle on the longitudinal axis.
  19456. * This can help limiting how the Camera is able to move in the scene.
  19457. */
  19458. _this.upperAlphaLimit = null;
  19459. /**
  19460. * Minimum allowed angle on the latitudinal axis.
  19461. * This can help limiting how the Camera is able to move in the scene.
  19462. */
  19463. _this.lowerBetaLimit = 0.01;
  19464. /**
  19465. * Maximum allowed angle on the latitudinal axis.
  19466. * This can help limiting how the Camera is able to move in the scene.
  19467. */
  19468. _this.upperBetaLimit = Math.PI - 0.01;
  19469. /**
  19470. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  19471. * This can help limiting how the Camera is able to move in the scene.
  19472. */
  19473. _this.lowerRadiusLimit = null;
  19474. /**
  19475. * Maximum allowed distance of the camera to the target (The camera can not get further).
  19476. * This can help limiting how the Camera is able to move in the scene.
  19477. */
  19478. _this.upperRadiusLimit = null;
  19479. /**
  19480. * Defines the current inertia value used during panning of the camera along the X axis.
  19481. */
  19482. _this.inertialPanningX = 0;
  19483. /**
  19484. * Defines the current inertia value used during panning of the camera along the Y axis.
  19485. */
  19486. _this.inertialPanningY = 0;
  19487. /**
  19488. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  19489. * Basically if your fingers moves away from more than this distance you will be considered
  19490. * in pinch mode.
  19491. */
  19492. _this.pinchToPanMaxDistance = 20;
  19493. /**
  19494. * Defines the maximum distance the camera can pan.
  19495. * This could help keeping the cammera always in your scene.
  19496. */
  19497. _this.panningDistanceLimit = null;
  19498. /**
  19499. * Defines the target of the camera before paning.
  19500. */
  19501. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19502. /**
  19503. * Defines the value of the inertia used during panning.
  19504. * 0 would mean stop inertia and one would mean no decelleration at all.
  19505. */
  19506. _this.panningInertia = 0.9;
  19507. //-- end properties for backward compatibility for inputs
  19508. /**
  19509. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  19510. */
  19511. _this.zoomOnFactor = 1;
  19512. /**
  19513. * Defines a screen offset for the camera position.
  19514. */
  19515. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19516. /**
  19517. * Allows the camera to be completely reversed.
  19518. * If false the camera can not arrive upside down.
  19519. */
  19520. _this.allowUpsideDown = true;
  19521. /**
  19522. * Define if double tap/click is used to restore the previously saved state of the camera.
  19523. */
  19524. _this.useInputToRestoreState = true;
  19525. /** @hidden */
  19526. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19527. /**
  19528. * Defines the allowed panning axis.
  19529. */
  19530. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  19531. /**
  19532. * Observable triggered when the mesh target has been changed on the camera.
  19533. */
  19534. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  19535. /**
  19536. * Defines whether the camera should check collision with the objects oh the scene.
  19537. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  19538. */
  19539. _this.checkCollisions = false;
  19540. /**
  19541. * Defines the collision radius of the camera.
  19542. * This simulates a sphere around the camera.
  19543. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19544. */
  19545. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  19546. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19547. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19548. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19549. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19550. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  19551. if (collidedMesh === void 0) { collidedMesh = null; }
  19552. if (!collidedMesh) {
  19553. _this._previousPosition.copyFrom(_this._position);
  19554. }
  19555. else {
  19556. _this.setPosition(newPosition);
  19557. if (_this.onCollide) {
  19558. _this.onCollide(collidedMesh);
  19559. }
  19560. }
  19561. // Recompute because of constraints
  19562. var cosa = Math.cos(_this.alpha);
  19563. var sina = Math.sin(_this.alpha);
  19564. var cosb = Math.cos(_this.beta);
  19565. var sinb = Math.sin(_this.beta);
  19566. if (sinb === 0) {
  19567. sinb = 0.0001;
  19568. }
  19569. var target = _this._getTargetPosition();
  19570. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19571. target.addToRef(_this._computationVector, _this._newPosition);
  19572. _this._position.copyFrom(_this._newPosition);
  19573. var up = _this.upVector;
  19574. if (_this.allowUpsideDown && _this.beta < 0) {
  19575. up = up.clone();
  19576. up = up.negate();
  19577. }
  19578. _this._computeViewMatrix(_this._position, target, up);
  19579. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19580. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19581. _this._collisionTriggered = false;
  19582. };
  19583. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19584. if (target) {
  19585. _this.setTarget(target);
  19586. }
  19587. _this.alpha = alpha;
  19588. _this.beta = beta;
  19589. _this.radius = radius;
  19590. _this.getViewMatrix();
  19591. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19592. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19593. return _this;
  19594. }
  19595. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19596. /**
  19597. * Defines the target point of the camera.
  19598. * The camera looks towards it form the radius distance.
  19599. */
  19600. get: function () {
  19601. return this._target;
  19602. },
  19603. set: function (value) {
  19604. this.setTarget(value);
  19605. },
  19606. enumerable: true,
  19607. configurable: true
  19608. });
  19609. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  19610. /**
  19611. * Define the current local position of the camera in the scene
  19612. */
  19613. get: function () {
  19614. return this._position;
  19615. },
  19616. set: function (newPosition) {
  19617. this.setPosition(newPosition);
  19618. },
  19619. enumerable: true,
  19620. configurable: true
  19621. });
  19622. Object.defineProperty(ArcRotateCamera.prototype, "upVector", {
  19623. get: function () {
  19624. return this._upVector;
  19625. },
  19626. /**
  19627. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  19628. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  19629. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  19630. */
  19631. set: function (vec) {
  19632. if (!this._upToYMatrix) {
  19633. this._YToUpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19634. this._upToYMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19635. this._upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19636. }
  19637. vec.normalize();
  19638. this._upVector.copyFrom(vec);
  19639. this.setMatUp();
  19640. },
  19641. enumerable: true,
  19642. configurable: true
  19643. });
  19644. /**
  19645. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  19646. */
  19647. ArcRotateCamera.prototype.setMatUp = function () {
  19648. // from y-up to custom-up (used in _getViewMatrix)
  19649. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upVector, this._YToUpMatrix);
  19650. // from custom-up to y-up (used in rebuildAnglesAndRadius)
  19651. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(this._upVector, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upToYMatrix);
  19652. };
  19653. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19654. //-- begin properties for backward compatibility for inputs
  19655. /**
  19656. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19657. */
  19658. get: function () {
  19659. var pointers = this.inputs.attached["pointers"];
  19660. if (pointers) {
  19661. return pointers.angularSensibilityX;
  19662. }
  19663. return 0;
  19664. },
  19665. set: function (value) {
  19666. var pointers = this.inputs.attached["pointers"];
  19667. if (pointers) {
  19668. pointers.angularSensibilityX = value;
  19669. }
  19670. },
  19671. enumerable: true,
  19672. configurable: true
  19673. });
  19674. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19675. /**
  19676. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19677. */
  19678. get: function () {
  19679. var pointers = this.inputs.attached["pointers"];
  19680. if (pointers) {
  19681. return pointers.angularSensibilityY;
  19682. }
  19683. return 0;
  19684. },
  19685. set: function (value) {
  19686. var pointers = this.inputs.attached["pointers"];
  19687. if (pointers) {
  19688. pointers.angularSensibilityY = value;
  19689. }
  19690. },
  19691. enumerable: true,
  19692. configurable: true
  19693. });
  19694. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19695. /**
  19696. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19697. */
  19698. get: function () {
  19699. var pointers = this.inputs.attached["pointers"];
  19700. if (pointers) {
  19701. return pointers.pinchPrecision;
  19702. }
  19703. return 0;
  19704. },
  19705. set: function (value) {
  19706. var pointers = this.inputs.attached["pointers"];
  19707. if (pointers) {
  19708. pointers.pinchPrecision = value;
  19709. }
  19710. },
  19711. enumerable: true,
  19712. configurable: true
  19713. });
  19714. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19715. /**
  19716. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19717. * It will be used instead of pinchDeltaPrecision if different from 0.
  19718. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19719. */
  19720. get: function () {
  19721. var pointers = this.inputs.attached["pointers"];
  19722. if (pointers) {
  19723. return pointers.pinchDeltaPercentage;
  19724. }
  19725. return 0;
  19726. },
  19727. set: function (value) {
  19728. var pointers = this.inputs.attached["pointers"];
  19729. if (pointers) {
  19730. pointers.pinchDeltaPercentage = value;
  19731. }
  19732. },
  19733. enumerable: true,
  19734. configurable: true
  19735. });
  19736. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19737. /**
  19738. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19739. */
  19740. get: function () {
  19741. var pointers = this.inputs.attached["pointers"];
  19742. if (pointers) {
  19743. return pointers.panningSensibility;
  19744. }
  19745. return 0;
  19746. },
  19747. set: function (value) {
  19748. var pointers = this.inputs.attached["pointers"];
  19749. if (pointers) {
  19750. pointers.panningSensibility = value;
  19751. }
  19752. },
  19753. enumerable: true,
  19754. configurable: true
  19755. });
  19756. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19757. /**
  19758. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19759. */
  19760. get: function () {
  19761. var keyboard = this.inputs.attached["keyboard"];
  19762. if (keyboard) {
  19763. return keyboard.keysUp;
  19764. }
  19765. return [];
  19766. },
  19767. set: function (value) {
  19768. var keyboard = this.inputs.attached["keyboard"];
  19769. if (keyboard) {
  19770. keyboard.keysUp = value;
  19771. }
  19772. },
  19773. enumerable: true,
  19774. configurable: true
  19775. });
  19776. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19777. /**
  19778. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19779. */
  19780. get: function () {
  19781. var keyboard = this.inputs.attached["keyboard"];
  19782. if (keyboard) {
  19783. return keyboard.keysDown;
  19784. }
  19785. return [];
  19786. },
  19787. set: function (value) {
  19788. var keyboard = this.inputs.attached["keyboard"];
  19789. if (keyboard) {
  19790. keyboard.keysDown = value;
  19791. }
  19792. },
  19793. enumerable: true,
  19794. configurable: true
  19795. });
  19796. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19797. /**
  19798. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19799. */
  19800. get: function () {
  19801. var keyboard = this.inputs.attached["keyboard"];
  19802. if (keyboard) {
  19803. return keyboard.keysLeft;
  19804. }
  19805. return [];
  19806. },
  19807. set: function (value) {
  19808. var keyboard = this.inputs.attached["keyboard"];
  19809. if (keyboard) {
  19810. keyboard.keysLeft = value;
  19811. }
  19812. },
  19813. enumerable: true,
  19814. configurable: true
  19815. });
  19816. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19817. /**
  19818. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19819. */
  19820. get: function () {
  19821. var keyboard = this.inputs.attached["keyboard"];
  19822. if (keyboard) {
  19823. return keyboard.keysRight;
  19824. }
  19825. return [];
  19826. },
  19827. set: function (value) {
  19828. var keyboard = this.inputs.attached["keyboard"];
  19829. if (keyboard) {
  19830. keyboard.keysRight = value;
  19831. }
  19832. },
  19833. enumerable: true,
  19834. configurable: true
  19835. });
  19836. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19837. /**
  19838. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19839. */
  19840. get: function () {
  19841. var mousewheel = this.inputs.attached["mousewheel"];
  19842. if (mousewheel) {
  19843. return mousewheel.wheelPrecision;
  19844. }
  19845. return 0;
  19846. },
  19847. set: function (value) {
  19848. var mousewheel = this.inputs.attached["mousewheel"];
  19849. if (mousewheel) {
  19850. mousewheel.wheelPrecision = value;
  19851. }
  19852. },
  19853. enumerable: true,
  19854. configurable: true
  19855. });
  19856. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19857. /**
  19858. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19859. * It will be used instead of pinchDeltaPrecision if different from 0.
  19860. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19861. */
  19862. get: function () {
  19863. var mousewheel = this.inputs.attached["mousewheel"];
  19864. if (mousewheel) {
  19865. return mousewheel.wheelDeltaPercentage;
  19866. }
  19867. return 0;
  19868. },
  19869. set: function (value) {
  19870. var mousewheel = this.inputs.attached["mousewheel"];
  19871. if (mousewheel) {
  19872. mousewheel.wheelDeltaPercentage = value;
  19873. }
  19874. },
  19875. enumerable: true,
  19876. configurable: true
  19877. });
  19878. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19879. /**
  19880. * Gets the bouncing behavior of the camera if it has been enabled.
  19881. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19882. */
  19883. get: function () {
  19884. return this._bouncingBehavior;
  19885. },
  19886. enumerable: true,
  19887. configurable: true
  19888. });
  19889. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19890. /**
  19891. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19892. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19893. */
  19894. get: function () {
  19895. return this._bouncingBehavior != null;
  19896. },
  19897. set: function (value) {
  19898. if (value === this.useBouncingBehavior) {
  19899. return;
  19900. }
  19901. if (value) {
  19902. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19903. this.addBehavior(this._bouncingBehavior);
  19904. }
  19905. else if (this._bouncingBehavior) {
  19906. this.removeBehavior(this._bouncingBehavior);
  19907. this._bouncingBehavior = null;
  19908. }
  19909. },
  19910. enumerable: true,
  19911. configurable: true
  19912. });
  19913. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19914. /**
  19915. * Gets the framing behavior of the camera if it has been enabled.
  19916. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19917. */
  19918. get: function () {
  19919. return this._framingBehavior;
  19920. },
  19921. enumerable: true,
  19922. configurable: true
  19923. });
  19924. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19925. /**
  19926. * Defines if the framing behavior of the camera is enabled on the camera.
  19927. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19928. */
  19929. get: function () {
  19930. return this._framingBehavior != null;
  19931. },
  19932. set: function (value) {
  19933. if (value === this.useFramingBehavior) {
  19934. return;
  19935. }
  19936. if (value) {
  19937. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19938. this.addBehavior(this._framingBehavior);
  19939. }
  19940. else if (this._framingBehavior) {
  19941. this.removeBehavior(this._framingBehavior);
  19942. this._framingBehavior = null;
  19943. }
  19944. },
  19945. enumerable: true,
  19946. configurable: true
  19947. });
  19948. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19949. /**
  19950. * Gets the auto rotation behavior of the camera if it has been enabled.
  19951. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19952. */
  19953. get: function () {
  19954. return this._autoRotationBehavior;
  19955. },
  19956. enumerable: true,
  19957. configurable: true
  19958. });
  19959. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19960. /**
  19961. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19962. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19963. */
  19964. get: function () {
  19965. return this._autoRotationBehavior != null;
  19966. },
  19967. set: function (value) {
  19968. if (value === this.useAutoRotationBehavior) {
  19969. return;
  19970. }
  19971. if (value) {
  19972. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19973. this.addBehavior(this._autoRotationBehavior);
  19974. }
  19975. else if (this._autoRotationBehavior) {
  19976. this.removeBehavior(this._autoRotationBehavior);
  19977. this._autoRotationBehavior = null;
  19978. }
  19979. },
  19980. enumerable: true,
  19981. configurable: true
  19982. });
  19983. // Cache
  19984. /** @hidden */
  19985. ArcRotateCamera.prototype._initCache = function () {
  19986. _super.prototype._initCache.call(this);
  19987. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19988. this._cache.alpha = undefined;
  19989. this._cache.beta = undefined;
  19990. this._cache.radius = undefined;
  19991. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19992. };
  19993. /** @hidden */
  19994. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19995. if (!ignoreParentClass) {
  19996. _super.prototype._updateCache.call(this);
  19997. }
  19998. this._cache._target.copyFrom(this._getTargetPosition());
  19999. this._cache.alpha = this.alpha;
  20000. this._cache.beta = this.beta;
  20001. this._cache.radius = this.radius;
  20002. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  20003. };
  20004. ArcRotateCamera.prototype._getTargetPosition = function () {
  20005. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  20006. var pos = this._targetHost.absolutePosition;
  20007. if (this._targetBoundingCenter) {
  20008. pos.addToRef(this._targetBoundingCenter, this._target);
  20009. }
  20010. else {
  20011. this._target.copyFrom(pos);
  20012. }
  20013. }
  20014. var lockedTargetPosition = this._getLockedTargetPosition();
  20015. if (lockedTargetPosition) {
  20016. return lockedTargetPosition;
  20017. }
  20018. return this._target;
  20019. };
  20020. /**
  20021. * Stores the current state of the camera (alpha, beta, radius and target)
  20022. * @returns the camera itself
  20023. */
  20024. ArcRotateCamera.prototype.storeState = function () {
  20025. this._storedAlpha = this.alpha;
  20026. this._storedBeta = this.beta;
  20027. this._storedRadius = this.radius;
  20028. this._storedTarget = this._getTargetPosition().clone();
  20029. return _super.prototype.storeState.call(this);
  20030. };
  20031. /**
  20032. * @hidden
  20033. * Restored camera state. You must call storeState() first
  20034. */
  20035. ArcRotateCamera.prototype._restoreStateValues = function () {
  20036. if (!_super.prototype._restoreStateValues.call(this)) {
  20037. return false;
  20038. }
  20039. this.alpha = this._storedAlpha;
  20040. this.beta = this._storedBeta;
  20041. this.radius = this._storedRadius;
  20042. this.setTarget(this._storedTarget.clone());
  20043. this.inertialAlphaOffset = 0;
  20044. this.inertialBetaOffset = 0;
  20045. this.inertialRadiusOffset = 0;
  20046. this.inertialPanningX = 0;
  20047. this.inertialPanningY = 0;
  20048. return true;
  20049. };
  20050. // Synchronized
  20051. /** @hidden */
  20052. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  20053. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  20054. return false;
  20055. }
  20056. return this._cache._target.equals(this._getTargetPosition())
  20057. && this._cache.alpha === this.alpha
  20058. && this._cache.beta === this.beta
  20059. && this._cache.radius === this.radius
  20060. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  20061. };
  20062. /**
  20063. * Attached controls to the current camera.
  20064. * @param element Defines the element the controls should be listened from
  20065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20066. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  20067. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  20068. */
  20069. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  20070. var _this = this;
  20071. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  20072. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  20073. this._useCtrlForPanning = useCtrlForPanning;
  20074. this._panningMouseButton = panningMouseButton;
  20075. this.inputs.attachElement(element, noPreventDefault);
  20076. this._reset = function () {
  20077. _this.inertialAlphaOffset = 0;
  20078. _this.inertialBetaOffset = 0;
  20079. _this.inertialRadiusOffset = 0;
  20080. _this.inertialPanningX = 0;
  20081. _this.inertialPanningY = 0;
  20082. };
  20083. };
  20084. /**
  20085. * Detach the current controls from the camera.
  20086. * The camera will stop reacting to inputs.
  20087. * @param element Defines the element to stop listening the inputs from
  20088. */
  20089. ArcRotateCamera.prototype.detachControl = function (element) {
  20090. this.inputs.detachElement(element);
  20091. if (this._reset) {
  20092. this._reset();
  20093. }
  20094. };
  20095. /** @hidden */
  20096. ArcRotateCamera.prototype._checkInputs = function () {
  20097. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  20098. if (this._collisionTriggered) {
  20099. return;
  20100. }
  20101. this.inputs.checkInputs();
  20102. // Inertia
  20103. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  20104. var inertialAlphaOffset = this.inertialAlphaOffset;
  20105. if (this.beta <= 0) {
  20106. inertialAlphaOffset *= -1;
  20107. }
  20108. if (this.getScene().useRightHandedSystem) {
  20109. inertialAlphaOffset *= -1;
  20110. }
  20111. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  20112. inertialAlphaOffset *= -1;
  20113. }
  20114. this.alpha += inertialAlphaOffset;
  20115. this.beta += this.inertialBetaOffset;
  20116. this.radius -= this.inertialRadiusOffset;
  20117. this.inertialAlphaOffset *= this.inertia;
  20118. this.inertialBetaOffset *= this.inertia;
  20119. this.inertialRadiusOffset *= this.inertia;
  20120. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20121. this.inertialAlphaOffset = 0;
  20122. }
  20123. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20124. this.inertialBetaOffset = 0;
  20125. }
  20126. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20127. this.inertialRadiusOffset = 0;
  20128. }
  20129. }
  20130. // Panning inertia
  20131. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  20132. if (!this._localDirection) {
  20133. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20134. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20135. }
  20136. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  20137. this._localDirection.multiplyInPlace(this.panningAxis);
  20138. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  20139. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  20140. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  20141. if (!this.panningAxis.y) {
  20142. this._transformedDirection.y = 0;
  20143. }
  20144. if (!this._targetHost) {
  20145. if (this.panningDistanceLimit) {
  20146. this._transformedDirection.addInPlace(this._target);
  20147. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  20148. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  20149. this._target.copyFrom(this._transformedDirection);
  20150. }
  20151. }
  20152. else {
  20153. this._target.addInPlace(this._transformedDirection);
  20154. }
  20155. }
  20156. this.inertialPanningX *= this.panningInertia;
  20157. this.inertialPanningY *= this.panningInertia;
  20158. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20159. this.inertialPanningX = 0;
  20160. }
  20161. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20162. this.inertialPanningY = 0;
  20163. }
  20164. }
  20165. // Limits
  20166. this._checkLimits();
  20167. _super.prototype._checkInputs.call(this);
  20168. };
  20169. ArcRotateCamera.prototype._checkLimits = function () {
  20170. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  20171. if (this.allowUpsideDown && this.beta > Math.PI) {
  20172. this.beta = this.beta - (2 * Math.PI);
  20173. }
  20174. }
  20175. else {
  20176. if (this.beta < this.lowerBetaLimit) {
  20177. this.beta = this.lowerBetaLimit;
  20178. }
  20179. }
  20180. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  20181. if (this.allowUpsideDown && this.beta < -Math.PI) {
  20182. this.beta = this.beta + (2 * Math.PI);
  20183. }
  20184. }
  20185. else {
  20186. if (this.beta > this.upperBetaLimit) {
  20187. this.beta = this.upperBetaLimit;
  20188. }
  20189. }
  20190. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  20191. this.alpha = this.lowerAlphaLimit;
  20192. }
  20193. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  20194. this.alpha = this.upperAlphaLimit;
  20195. }
  20196. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  20197. this.radius = this.lowerRadiusLimit;
  20198. this.inertialRadiusOffset = 0;
  20199. }
  20200. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  20201. this.radius = this.upperRadiusLimit;
  20202. this.inertialRadiusOffset = 0;
  20203. }
  20204. };
  20205. /**
  20206. * Rebuilds angles (alpha, beta) and radius from the give position and target
  20207. */
  20208. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  20209. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  20210. // need to rotate to Y up equivalent if up vector not Axis.Y
  20211. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  20212. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector);
  20213. }
  20214. this.radius = this._computationVector.length();
  20215. if (this.radius === 0) {
  20216. this.radius = 0.0001; // Just to avoid division by zero
  20217. }
  20218. // Alpha
  20219. if (this._computationVector.x === 0 && this._computationVector.z === 0) {
  20220. this.alpha = Math.PI / 2; // avoid division by zero when looking along up axis, and set to acos(0)
  20221. }
  20222. else {
  20223. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  20224. }
  20225. if (this._computationVector.z < 0) {
  20226. this.alpha = 2 * Math.PI - this.alpha;
  20227. }
  20228. // Beta
  20229. this.beta = Math.acos(this._computationVector.y / this.radius);
  20230. this._checkLimits();
  20231. };
  20232. /**
  20233. * Use a position to define the current camera related information like aplha, beta and radius
  20234. * @param position Defines the position to set the camera at
  20235. */
  20236. ArcRotateCamera.prototype.setPosition = function (position) {
  20237. if (this._position.equals(position)) {
  20238. return;
  20239. }
  20240. this._position.copyFrom(position);
  20241. this.rebuildAnglesAndRadius();
  20242. };
  20243. /**
  20244. * Defines the target the camera should look at.
  20245. * This will automatically adapt alpha beta and radius to fit within the new target.
  20246. * @param target Defines the new target as a Vector or a mesh
  20247. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  20248. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  20249. */
  20250. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  20251. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  20252. if (allowSamePosition === void 0) { allowSamePosition = false; }
  20253. if (target.getBoundingInfo) {
  20254. if (toBoundingCenter) {
  20255. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  20256. }
  20257. else {
  20258. this._targetBoundingCenter = null;
  20259. }
  20260. target.computeWorldMatrix();
  20261. this._targetHost = target;
  20262. this._target = this._getTargetPosition();
  20263. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  20264. }
  20265. else {
  20266. var newTarget = target;
  20267. var currentTarget = this._getTargetPosition();
  20268. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  20269. return;
  20270. }
  20271. this._targetHost = null;
  20272. this._target = newTarget;
  20273. this._targetBoundingCenter = null;
  20274. this.onMeshTargetChangedObservable.notifyObservers(null);
  20275. }
  20276. this.rebuildAnglesAndRadius();
  20277. };
  20278. /** @hidden */
  20279. ArcRotateCamera.prototype._getViewMatrix = function () {
  20280. // Compute
  20281. var cosa = Math.cos(this.alpha);
  20282. var sina = Math.sin(this.alpha);
  20283. var cosb = Math.cos(this.beta);
  20284. var sinb = Math.sin(this.beta);
  20285. if (sinb === 0) {
  20286. sinb = 0.0001;
  20287. }
  20288. var target = this._getTargetPosition();
  20289. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  20290. // Rotate according to up vector
  20291. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  20292. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector);
  20293. }
  20294. target.addToRef(this._computationVector, this._newPosition);
  20295. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  20296. var coordinator = this.getScene().collisionCoordinator;
  20297. if (!this._collider) {
  20298. this._collider = coordinator.createCollider();
  20299. }
  20300. this._collider._radius = this.collisionRadius;
  20301. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  20302. this._collisionTriggered = true;
  20303. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20304. }
  20305. else {
  20306. this._position.copyFrom(this._newPosition);
  20307. var up = this.upVector;
  20308. if (this.allowUpsideDown && sinb < 0) {
  20309. up = up.clone();
  20310. up = up.negate();
  20311. }
  20312. this._computeViewMatrix(this._position, target, up);
  20313. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  20314. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  20315. }
  20316. this._currentTarget = target;
  20317. return this._viewMatrix;
  20318. };
  20319. /**
  20320. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  20321. * @param meshes Defines the mesh to zoom on
  20322. * @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)
  20323. */
  20324. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  20325. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20326. meshes = meshes || this.getScene().meshes;
  20327. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20328. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  20329. this.radius = distance * this.zoomOnFactor;
  20330. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  20331. };
  20332. /**
  20333. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  20334. * The target will be changed but the radius
  20335. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  20336. * @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)
  20337. */
  20338. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  20339. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20340. var meshesOrMinMaxVector;
  20341. var distance;
  20342. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  20343. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  20344. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20345. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  20346. }
  20347. else { //minMaxVector and distance
  20348. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  20349. meshesOrMinMaxVector = minMaxVectorAndDistance;
  20350. distance = minMaxVectorAndDistance.distance;
  20351. }
  20352. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  20353. if (!doNotUpdateMaxZ) {
  20354. this.maxZ = distance * 2;
  20355. }
  20356. };
  20357. /**
  20358. * @override
  20359. * Override Camera.createRigCamera
  20360. */
  20361. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  20362. var alphaShift = 0;
  20363. switch (this.cameraRigMode) {
  20364. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20365. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20366. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20367. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20368. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  20369. break;
  20370. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20371. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  20372. break;
  20373. }
  20374. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  20375. rigCam._cameraRigParams = {};
  20376. return rigCam;
  20377. };
  20378. /**
  20379. * @hidden
  20380. * @override
  20381. * Override Camera._updateRigCameras
  20382. */
  20383. ArcRotateCamera.prototype._updateRigCameras = function () {
  20384. var camLeft = this._rigCameras[0];
  20385. var camRight = this._rigCameras[1];
  20386. camLeft.beta = camRight.beta = this.beta;
  20387. switch (this.cameraRigMode) {
  20388. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20389. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20390. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20391. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20392. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20393. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20394. break;
  20395. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20396. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20397. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20398. break;
  20399. }
  20400. _super.prototype._updateRigCameras.call(this);
  20401. };
  20402. /**
  20403. * Destroy the camera and release the current resources hold by it.
  20404. */
  20405. ArcRotateCamera.prototype.dispose = function () {
  20406. this.inputs.clear();
  20407. _super.prototype.dispose.call(this);
  20408. };
  20409. /**
  20410. * Gets the current object class name.
  20411. * @return the class name
  20412. */
  20413. ArcRotateCamera.prototype.getClassName = function () {
  20414. return "ArcRotateCamera";
  20415. };
  20416. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20417. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20418. ], ArcRotateCamera.prototype, "alpha", void 0);
  20419. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20421. ], ArcRotateCamera.prototype, "beta", void 0);
  20422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20424. ], ArcRotateCamera.prototype, "radius", void 0);
  20425. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20426. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  20427. ], ArcRotateCamera.prototype, "_target", void 0);
  20428. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20429. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("upVector")
  20430. ], ArcRotateCamera.prototype, "_upVector", void 0);
  20431. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20432. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20433. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  20434. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20436. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  20437. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20438. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20439. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  20440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20442. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  20443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20445. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  20446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20448. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  20449. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20450. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20451. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  20452. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20453. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20454. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  20455. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20457. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  20458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20460. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  20461. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20462. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20463. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  20464. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20465. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20466. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  20467. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20468. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20469. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  20470. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20471. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20472. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  20473. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20474. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20475. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  20476. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20477. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20478. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  20479. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20480. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20481. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  20482. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20483. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20484. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  20485. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20486. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20487. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  20488. return ArcRotateCamera;
  20489. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  20490. /***/ }),
  20491. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  20492. /*!*************************************************!*\
  20493. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  20494. \*************************************************/
  20495. /*! exports provided: ArcRotateCameraInputsManager */
  20496. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20497. "use strict";
  20498. __webpack_require__.r(__webpack_exports__);
  20499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  20500. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20501. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  20502. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  20503. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  20504. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  20505. /**
  20506. * Default Inputs manager for the ArcRotateCamera.
  20507. * It groups all the default supported inputs for ease of use.
  20508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20509. */
  20510. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  20511. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  20512. /**
  20513. * Instantiates a new ArcRotateCameraInputsManager.
  20514. * @param camera Defines the camera the inputs belong to
  20515. */
  20516. function ArcRotateCameraInputsManager(camera) {
  20517. return _super.call(this, camera) || this;
  20518. }
  20519. /**
  20520. * Add mouse wheel input support to the input manager.
  20521. * @returns the current input manager
  20522. */
  20523. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  20524. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  20525. return this;
  20526. };
  20527. /**
  20528. * Add pointers input support to the input manager.
  20529. * @returns the current input manager
  20530. */
  20531. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  20532. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  20533. return this;
  20534. };
  20535. /**
  20536. * Add keyboard input support to the input manager.
  20537. * @returns the current input manager
  20538. */
  20539. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  20540. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  20541. return this;
  20542. };
  20543. return ArcRotateCameraInputsManager;
  20544. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  20545. /***/ }),
  20546. /***/ "./Cameras/camera.ts":
  20547. /*!***************************!*\
  20548. !*** ./Cameras/camera.ts ***!
  20549. \***************************/
  20550. /*! exports provided: Camera */
  20551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20552. "use strict";
  20553. __webpack_require__.r(__webpack_exports__);
  20554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  20555. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20556. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20557. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  20558. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  20559. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20560. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20561. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  20562. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20563. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  20564. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  20565. /**
  20566. * This is the base class of all the camera used in the application.
  20567. * @see http://doc.babylonjs.com/features/cameras
  20568. */
  20569. var Camera = /** @class */ (function (_super) {
  20570. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  20571. /**
  20572. * Instantiates a new camera object.
  20573. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  20574. * @see http://doc.babylonjs.com/features/cameras
  20575. * @param name Defines the name of the camera in the scene
  20576. * @param position Defines the position of the camera
  20577. * @param scene Defines the scene the camera belongs too
  20578. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  20579. */
  20580. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20581. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20582. var _this = _super.call(this, name, scene) || this;
  20583. /** @hidden */
  20584. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20585. /**
  20586. * The vector the camera should consider as up.
  20587. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  20588. */
  20589. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  20590. /**
  20591. * Define the current limit on the left side for an orthographic camera
  20592. * In scene unit
  20593. */
  20594. _this.orthoLeft = null;
  20595. /**
  20596. * Define the current limit on the right side for an orthographic camera
  20597. * In scene unit
  20598. */
  20599. _this.orthoRight = null;
  20600. /**
  20601. * Define the current limit on the bottom side for an orthographic camera
  20602. * In scene unit
  20603. */
  20604. _this.orthoBottom = null;
  20605. /**
  20606. * Define the current limit on the top side for an orthographic camera
  20607. * In scene unit
  20608. */
  20609. _this.orthoTop = null;
  20610. /**
  20611. * Field Of View is set in Radians. (default is 0.8)
  20612. */
  20613. _this.fov = 0.8;
  20614. /**
  20615. * Define the minimum distance the camera can see from.
  20616. * This is important to note that the depth buffer are not infinite and the closer it starts
  20617. * the more your scene might encounter depth fighting issue.
  20618. */
  20619. _this.minZ = 1;
  20620. /**
  20621. * Define the maximum distance the camera can see to.
  20622. * This is important to note that the depth buffer are not infinite and the further it end
  20623. * the more your scene might encounter depth fighting issue.
  20624. */
  20625. _this.maxZ = 10000.0;
  20626. /**
  20627. * Define the default inertia of the camera.
  20628. * This helps giving a smooth feeling to the camera movement.
  20629. */
  20630. _this.inertia = 0.9;
  20631. /**
  20632. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20633. */
  20634. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20635. /**
  20636. * Define wether the camera is intermediate.
  20637. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20638. */
  20639. _this.isIntermediate = false;
  20640. /**
  20641. * Define the viewport of the camera.
  20642. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20643. */
  20644. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20645. /**
  20646. * Restricts the camera to viewing objects with the same layerMask.
  20647. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20648. */
  20649. _this.layerMask = 0x0FFFFFFF;
  20650. /**
  20651. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20652. */
  20653. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20654. /**
  20655. * Rig mode of the camera.
  20656. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20657. * This is normally controlled byt the camera themselves as internal use.
  20658. */
  20659. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20660. /**
  20661. * 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
  20662. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20663. * else in the scene.
  20664. */
  20665. _this.customRenderTargets = new Array();
  20666. /**
  20667. * When set, the camera will render to this render target instead of the default canvas
  20668. */
  20669. _this.outputRenderTarget = null;
  20670. /**
  20671. * Observable triggered when the camera view matrix has changed.
  20672. */
  20673. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20674. /**
  20675. * Observable triggered when the camera Projection matrix has changed.
  20676. */
  20677. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20678. /**
  20679. * Observable triggered when the inputs have been processed.
  20680. */
  20681. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20682. /**
  20683. * Observable triggered when reset has been called and applied to the camera.
  20684. */
  20685. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20686. /** @hidden */
  20687. _this._rigCameras = new Array();
  20688. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20689. /** @hidden */
  20690. _this._skipRendering = false;
  20691. /** @hidden */
  20692. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20693. /** @hidden */
  20694. _this._postProcesses = new Array();
  20695. /** @hidden */
  20696. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20697. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20698. /** hidden */
  20699. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20700. _this._doNotComputeProjectionMatrix = false;
  20701. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20702. _this._refreshFrustumPlanes = true;
  20703. /** @hidden */
  20704. _this._isCamera = true;
  20705. /** @hidden */
  20706. _this._isLeftCamera = false;
  20707. /** @hidden */
  20708. _this._isRightCamera = true;
  20709. _this.getScene().addCamera(_this);
  20710. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20711. _this.getScene().activeCamera = _this;
  20712. }
  20713. _this.position = position;
  20714. return _this;
  20715. }
  20716. Object.defineProperty(Camera.prototype, "position", {
  20717. /**
  20718. * Define the current local position of the camera in the scene
  20719. */
  20720. get: function () {
  20721. return this._position;
  20722. },
  20723. set: function (newPosition) {
  20724. this._position = newPosition;
  20725. },
  20726. enumerable: true,
  20727. configurable: true
  20728. });
  20729. /**
  20730. * Store current camera state (fov, position, etc..)
  20731. * @returns the camera
  20732. */
  20733. Camera.prototype.storeState = function () {
  20734. this._stateStored = true;
  20735. this._storedFov = this.fov;
  20736. return this;
  20737. };
  20738. /**
  20739. * Restores the camera state values if it has been stored. You must call storeState() first
  20740. */
  20741. Camera.prototype._restoreStateValues = function () {
  20742. if (!this._stateStored) {
  20743. return false;
  20744. }
  20745. this.fov = this._storedFov;
  20746. return true;
  20747. };
  20748. /**
  20749. * Restored camera state. You must call storeState() first.
  20750. * @returns true if restored and false otherwise
  20751. */
  20752. Camera.prototype.restoreState = function () {
  20753. if (this._restoreStateValues()) {
  20754. this.onRestoreStateObservable.notifyObservers(this);
  20755. return true;
  20756. }
  20757. return false;
  20758. };
  20759. /**
  20760. * Gets the class name of the camera.
  20761. * @returns the class name
  20762. */
  20763. Camera.prototype.getClassName = function () {
  20764. return "Camera";
  20765. };
  20766. /**
  20767. * Gets a string representation of the camera useful for debug purpose.
  20768. * @param fullDetails Defines that a more verboe level of logging is required
  20769. * @returns the string representation
  20770. */
  20771. Camera.prototype.toString = function (fullDetails) {
  20772. var ret = "Name: " + this.name;
  20773. ret += ", type: " + this.getClassName();
  20774. if (this.animations) {
  20775. for (var i = 0; i < this.animations.length; i++) {
  20776. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20777. }
  20778. }
  20779. if (fullDetails) {
  20780. }
  20781. return ret;
  20782. };
  20783. Object.defineProperty(Camera.prototype, "globalPosition", {
  20784. /**
  20785. * Gets the current world space position of the camera.
  20786. */
  20787. get: function () {
  20788. return this._globalPosition;
  20789. },
  20790. enumerable: true,
  20791. configurable: true
  20792. });
  20793. /**
  20794. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20795. * @returns the active meshe list
  20796. */
  20797. Camera.prototype.getActiveMeshes = function () {
  20798. return this._activeMeshes;
  20799. };
  20800. /**
  20801. * Check wether a mesh is part of the current active mesh list of the camera
  20802. * @param mesh Defines the mesh to check
  20803. * @returns true if active, false otherwise
  20804. */
  20805. Camera.prototype.isActiveMesh = function (mesh) {
  20806. return (this._activeMeshes.indexOf(mesh) !== -1);
  20807. };
  20808. /**
  20809. * Is this camera ready to be used/rendered
  20810. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20811. * @return true if the camera is ready
  20812. */
  20813. Camera.prototype.isReady = function (completeCheck) {
  20814. if (completeCheck === void 0) { completeCheck = false; }
  20815. if (completeCheck) {
  20816. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20817. var pp = _a[_i];
  20818. if (pp && !pp.isReady()) {
  20819. return false;
  20820. }
  20821. }
  20822. }
  20823. return _super.prototype.isReady.call(this, completeCheck);
  20824. };
  20825. /** @hidden */
  20826. Camera.prototype._initCache = function () {
  20827. _super.prototype._initCache.call(this);
  20828. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20829. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20830. this._cache.mode = undefined;
  20831. this._cache.minZ = undefined;
  20832. this._cache.maxZ = undefined;
  20833. this._cache.fov = undefined;
  20834. this._cache.fovMode = undefined;
  20835. this._cache.aspectRatio = undefined;
  20836. this._cache.orthoLeft = undefined;
  20837. this._cache.orthoRight = undefined;
  20838. this._cache.orthoBottom = undefined;
  20839. this._cache.orthoTop = undefined;
  20840. this._cache.renderWidth = undefined;
  20841. this._cache.renderHeight = undefined;
  20842. };
  20843. /** @hidden */
  20844. Camera.prototype._updateCache = function (ignoreParentClass) {
  20845. if (!ignoreParentClass) {
  20846. _super.prototype._updateCache.call(this);
  20847. }
  20848. this._cache.position.copyFrom(this.position);
  20849. this._cache.upVector.copyFrom(this.upVector);
  20850. };
  20851. /** @hidden */
  20852. Camera.prototype._isSynchronized = function () {
  20853. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20854. };
  20855. /** @hidden */
  20856. Camera.prototype._isSynchronizedViewMatrix = function () {
  20857. if (!_super.prototype._isSynchronized.call(this)) {
  20858. return false;
  20859. }
  20860. return this._cache.position.equals(this.position)
  20861. && this._cache.upVector.equals(this.upVector)
  20862. && this.isSynchronizedWithParent();
  20863. };
  20864. /** @hidden */
  20865. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20866. var check = this._cache.mode === this.mode
  20867. && this._cache.minZ === this.minZ
  20868. && this._cache.maxZ === this.maxZ;
  20869. if (!check) {
  20870. return false;
  20871. }
  20872. var engine = this.getEngine();
  20873. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20874. check = this._cache.fov === this.fov
  20875. && this._cache.fovMode === this.fovMode
  20876. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20877. }
  20878. else {
  20879. check = this._cache.orthoLeft === this.orthoLeft
  20880. && this._cache.orthoRight === this.orthoRight
  20881. && this._cache.orthoBottom === this.orthoBottom
  20882. && this._cache.orthoTop === this.orthoTop
  20883. && this._cache.renderWidth === engine.getRenderWidth()
  20884. && this._cache.renderHeight === engine.getRenderHeight();
  20885. }
  20886. return check;
  20887. };
  20888. /**
  20889. * Attach the input controls to a specific dom element to get the input from.
  20890. * @param element Defines the element the controls should be listened from
  20891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20892. */
  20893. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20894. };
  20895. /**
  20896. * Detach the current controls from the specified dom element.
  20897. * @param element Defines the element to stop listening the inputs from
  20898. */
  20899. Camera.prototype.detachControl = function (element) {
  20900. };
  20901. /**
  20902. * Update the camera state according to the different inputs gathered during the frame.
  20903. */
  20904. Camera.prototype.update = function () {
  20905. this._checkInputs();
  20906. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20907. this._updateRigCameras();
  20908. }
  20909. };
  20910. /** @hidden */
  20911. Camera.prototype._checkInputs = function () {
  20912. this.onAfterCheckInputsObservable.notifyObservers(this);
  20913. };
  20914. Object.defineProperty(Camera.prototype, "rigCameras", {
  20915. /** @hidden */
  20916. get: function () {
  20917. return this._rigCameras;
  20918. },
  20919. enumerable: true,
  20920. configurable: true
  20921. });
  20922. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20923. /**
  20924. * Gets the post process used by the rig cameras
  20925. */
  20926. get: function () {
  20927. return this._rigPostProcess;
  20928. },
  20929. enumerable: true,
  20930. configurable: true
  20931. });
  20932. /**
  20933. * Internal, gets the first post proces.
  20934. * @returns the first post process to be run on this camera.
  20935. */
  20936. Camera.prototype._getFirstPostProcess = function () {
  20937. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20938. if (this._postProcesses[ppIndex] !== null) {
  20939. return this._postProcesses[ppIndex];
  20940. }
  20941. }
  20942. return null;
  20943. };
  20944. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20945. // invalidate framebuffer
  20946. var firstPostProcess = this._getFirstPostProcess();
  20947. if (firstPostProcess) {
  20948. firstPostProcess.markTextureDirty();
  20949. }
  20950. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20951. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20952. var cam = this._rigCameras[i];
  20953. var rigPostProcess = cam._rigPostProcess;
  20954. // for VR rig, there does not have to be a post process
  20955. if (rigPostProcess) {
  20956. var isPass = rigPostProcess.getEffectName() === "pass";
  20957. if (isPass) {
  20958. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20959. cam.isIntermediate = this._postProcesses.length === 0;
  20960. }
  20961. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20962. rigPostProcess.markTextureDirty();
  20963. }
  20964. else {
  20965. cam._postProcesses = this._postProcesses.slice(0);
  20966. }
  20967. }
  20968. };
  20969. /**
  20970. * Attach a post process to the camera.
  20971. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20972. * @param postProcess The post process to attach to the camera
  20973. * @param insertAt The position of the post process in case several of them are in use in the scene
  20974. * @returns the position the post process has been inserted at
  20975. */
  20976. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20977. if (insertAt === void 0) { insertAt = null; }
  20978. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20979. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20980. return 0;
  20981. }
  20982. if (insertAt == null || insertAt < 0) {
  20983. this._postProcesses.push(postProcess);
  20984. }
  20985. else if (this._postProcesses[insertAt] === null) {
  20986. this._postProcesses[insertAt] = postProcess;
  20987. }
  20988. else {
  20989. this._postProcesses.splice(insertAt, 0, postProcess);
  20990. }
  20991. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20992. return this._postProcesses.indexOf(postProcess);
  20993. };
  20994. /**
  20995. * Detach a post process to the camera.
  20996. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20997. * @param postProcess The post process to detach from the camera
  20998. */
  20999. Camera.prototype.detachPostProcess = function (postProcess) {
  21000. var idx = this._postProcesses.indexOf(postProcess);
  21001. if (idx !== -1) {
  21002. this._postProcesses[idx] = null;
  21003. }
  21004. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  21005. };
  21006. /**
  21007. * Gets the current world matrix of the camera
  21008. */
  21009. Camera.prototype.getWorldMatrix = function () {
  21010. if (this._isSynchronizedViewMatrix()) {
  21011. return this._worldMatrix;
  21012. }
  21013. // Getting the the view matrix will also compute the world matrix.
  21014. this.getViewMatrix();
  21015. return this._worldMatrix;
  21016. };
  21017. /** @hidden */
  21018. Camera.prototype._getViewMatrix = function () {
  21019. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21020. };
  21021. /**
  21022. * Gets the current view matrix of the camera.
  21023. * @param force forces the camera to recompute the matrix without looking at the cached state
  21024. * @returns the view matrix
  21025. */
  21026. Camera.prototype.getViewMatrix = function (force) {
  21027. if (!force && this._isSynchronizedViewMatrix()) {
  21028. return this._computedViewMatrix;
  21029. }
  21030. this.updateCache();
  21031. this._computedViewMatrix = this._getViewMatrix();
  21032. this._currentRenderId = this.getScene().getRenderId();
  21033. this._childUpdateId++;
  21034. this._refreshFrustumPlanes = true;
  21035. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  21036. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  21037. }
  21038. this.onViewMatrixChangedObservable.notifyObservers(this);
  21039. this._computedViewMatrix.invertToRef(this._worldMatrix);
  21040. return this._computedViewMatrix;
  21041. };
  21042. /**
  21043. * Freeze the projection matrix.
  21044. * It will prevent the cache check of the camera projection compute and can speed up perf
  21045. * if no parameter of the camera are meant to change
  21046. * @param projection Defines manually a projection if necessary
  21047. */
  21048. Camera.prototype.freezeProjectionMatrix = function (projection) {
  21049. this._doNotComputeProjectionMatrix = true;
  21050. if (projection !== undefined) {
  21051. this._projectionMatrix = projection;
  21052. }
  21053. };
  21054. /**
  21055. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  21056. */
  21057. Camera.prototype.unfreezeProjectionMatrix = function () {
  21058. this._doNotComputeProjectionMatrix = false;
  21059. };
  21060. /**
  21061. * Gets the current projection matrix of the camera.
  21062. * @param force forces the camera to recompute the matrix without looking at the cached state
  21063. * @returns the projection matrix
  21064. */
  21065. Camera.prototype.getProjectionMatrix = function (force) {
  21066. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  21067. return this._projectionMatrix;
  21068. }
  21069. // Cache
  21070. this._cache.mode = this.mode;
  21071. this._cache.minZ = this.minZ;
  21072. this._cache.maxZ = this.maxZ;
  21073. // Matrix
  21074. this._refreshFrustumPlanes = true;
  21075. var engine = this.getEngine();
  21076. var scene = this.getScene();
  21077. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  21078. this._cache.fov = this.fov;
  21079. this._cache.fovMode = this.fovMode;
  21080. this._cache.aspectRatio = engine.getAspectRatio(this);
  21081. if (this.minZ <= 0) {
  21082. this.minZ = 0.1;
  21083. }
  21084. if (scene.useRightHandedSystem) {
  21085. _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);
  21086. }
  21087. else {
  21088. _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);
  21089. }
  21090. }
  21091. else {
  21092. var halfWidth = engine.getRenderWidth() / 2.0;
  21093. var halfHeight = engine.getRenderHeight() / 2.0;
  21094. if (scene.useRightHandedSystem) {
  21095. _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);
  21096. }
  21097. else {
  21098. _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);
  21099. }
  21100. this._cache.orthoLeft = this.orthoLeft;
  21101. this._cache.orthoRight = this.orthoRight;
  21102. this._cache.orthoBottom = this.orthoBottom;
  21103. this._cache.orthoTop = this.orthoTop;
  21104. this._cache.renderWidth = engine.getRenderWidth();
  21105. this._cache.renderHeight = engine.getRenderHeight();
  21106. }
  21107. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  21108. return this._projectionMatrix;
  21109. };
  21110. /**
  21111. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  21112. * @returns a Matrix
  21113. */
  21114. Camera.prototype.getTransformationMatrix = function () {
  21115. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  21116. return this._transformMatrix;
  21117. };
  21118. Camera.prototype._updateFrustumPlanes = function () {
  21119. if (!this._refreshFrustumPlanes) {
  21120. return;
  21121. }
  21122. this.getTransformationMatrix();
  21123. if (!this._frustumPlanes) {
  21124. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  21125. }
  21126. else {
  21127. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  21128. }
  21129. this._refreshFrustumPlanes = false;
  21130. };
  21131. /**
  21132. * Checks if a cullable object (mesh...) is in the camera frustum
  21133. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  21134. * @param target The object to check
  21135. * @returns true if the object is in frustum otherwise false
  21136. */
  21137. Camera.prototype.isInFrustum = function (target) {
  21138. this._updateFrustumPlanes();
  21139. return target.isInFrustum(this._frustumPlanes);
  21140. };
  21141. /**
  21142. * Checks if a cullable object (mesh...) is in the camera frustum
  21143. * Unlike isInFrustum this cheks the full bounding box
  21144. * @param target The object to check
  21145. * @returns true if the object is in frustum otherwise false
  21146. */
  21147. Camera.prototype.isCompletelyInFrustum = function (target) {
  21148. this._updateFrustumPlanes();
  21149. return target.isCompletelyInFrustum(this._frustumPlanes);
  21150. };
  21151. /**
  21152. * Gets a ray in the forward direction from the camera.
  21153. * @param length Defines the length of the ray to create
  21154. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  21155. * @param origin Defines the start point of the ray which defaults to the camera position
  21156. * @returns the forward ray
  21157. */
  21158. Camera.prototype.getForwardRay = function (length, transform, origin) {
  21159. if (length === void 0) { length = 100; }
  21160. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  21161. };
  21162. /**
  21163. * Releases resources associated with this node.
  21164. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21165. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21166. */
  21167. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  21168. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  21169. // Observables
  21170. this.onViewMatrixChangedObservable.clear();
  21171. this.onProjectionMatrixChangedObservable.clear();
  21172. this.onAfterCheckInputsObservable.clear();
  21173. this.onRestoreStateObservable.clear();
  21174. // Inputs
  21175. if (this.inputs) {
  21176. this.inputs.clear();
  21177. }
  21178. // Animations
  21179. this.getScene().stopAnimation(this);
  21180. // Remove from scene
  21181. this.getScene().removeCamera(this);
  21182. while (this._rigCameras.length > 0) {
  21183. var camera = this._rigCameras.pop();
  21184. if (camera) {
  21185. camera.dispose();
  21186. }
  21187. }
  21188. // Postprocesses
  21189. if (this._rigPostProcess) {
  21190. this._rigPostProcess.dispose(this);
  21191. this._rigPostProcess = null;
  21192. this._postProcesses = [];
  21193. }
  21194. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21195. this._rigPostProcess = null;
  21196. this._postProcesses = [];
  21197. }
  21198. else {
  21199. var i = this._postProcesses.length;
  21200. while (--i >= 0) {
  21201. var postProcess = this._postProcesses[i];
  21202. if (postProcess) {
  21203. postProcess.dispose(this);
  21204. }
  21205. }
  21206. }
  21207. // Render targets
  21208. var i = this.customRenderTargets.length;
  21209. while (--i >= 0) {
  21210. this.customRenderTargets[i].dispose();
  21211. }
  21212. this.customRenderTargets = [];
  21213. // Active Meshes
  21214. this._activeMeshes.dispose();
  21215. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  21216. };
  21217. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  21218. /**
  21219. * Gets the left camera of a rig setup in case of Rigged Camera
  21220. */
  21221. get: function () {
  21222. return this._isLeftCamera;
  21223. },
  21224. enumerable: true,
  21225. configurable: true
  21226. });
  21227. Object.defineProperty(Camera.prototype, "isRightCamera", {
  21228. /**
  21229. * Gets the right camera of a rig setup in case of Rigged Camera
  21230. */
  21231. get: function () {
  21232. return this._isRightCamera;
  21233. },
  21234. enumerable: true,
  21235. configurable: true
  21236. });
  21237. Object.defineProperty(Camera.prototype, "leftCamera", {
  21238. /**
  21239. * Gets the left camera of a rig setup in case of Rigged Camera
  21240. */
  21241. get: function () {
  21242. if (this._rigCameras.length < 1) {
  21243. return null;
  21244. }
  21245. return this._rigCameras[0];
  21246. },
  21247. enumerable: true,
  21248. configurable: true
  21249. });
  21250. Object.defineProperty(Camera.prototype, "rightCamera", {
  21251. /**
  21252. * Gets the right camera of a rig setup in case of Rigged Camera
  21253. */
  21254. get: function () {
  21255. if (this._rigCameras.length < 2) {
  21256. return null;
  21257. }
  21258. return this._rigCameras[1];
  21259. },
  21260. enumerable: true,
  21261. configurable: true
  21262. });
  21263. /**
  21264. * Gets the left camera target of a rig setup in case of Rigged Camera
  21265. * @returns the target position
  21266. */
  21267. Camera.prototype.getLeftTarget = function () {
  21268. if (this._rigCameras.length < 1) {
  21269. return null;
  21270. }
  21271. return this._rigCameras[0].getTarget();
  21272. };
  21273. /**
  21274. * Gets the right camera target of a rig setup in case of Rigged Camera
  21275. * @returns the target position
  21276. */
  21277. Camera.prototype.getRightTarget = function () {
  21278. if (this._rigCameras.length < 2) {
  21279. return null;
  21280. }
  21281. return this._rigCameras[1].getTarget();
  21282. };
  21283. /**
  21284. * @hidden
  21285. */
  21286. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  21287. if (this.cameraRigMode === mode) {
  21288. return;
  21289. }
  21290. while (this._rigCameras.length > 0) {
  21291. var camera = this._rigCameras.pop();
  21292. if (camera) {
  21293. camera.dispose();
  21294. }
  21295. }
  21296. this.cameraRigMode = mode;
  21297. this._cameraRigParams = {};
  21298. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  21299. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  21300. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  21301. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  21302. // create the rig cameras, unless none
  21303. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21304. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  21305. if (leftCamera) {
  21306. leftCamera._isLeftCamera = true;
  21307. }
  21308. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  21309. if (rightCamera) {
  21310. rightCamera._isRightCamera = true;
  21311. }
  21312. if (leftCamera && rightCamera) {
  21313. this._rigCameras.push(leftCamera);
  21314. this._rigCameras.push(rightCamera);
  21315. }
  21316. }
  21317. switch (this.cameraRigMode) {
  21318. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21319. Camera._setStereoscopicAnaglyphRigMode(this);
  21320. break;
  21321. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21322. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21323. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21324. Camera._setStereoscopicRigMode(this);
  21325. break;
  21326. case Camera.RIG_MODE_VR:
  21327. Camera._setVRRigMode(this, rigParams);
  21328. break;
  21329. case Camera.RIG_MODE_WEBVR:
  21330. Camera._setWebVRRigMode(this, rigParams);
  21331. break;
  21332. }
  21333. this._cascadePostProcessesToRigCams();
  21334. this.update();
  21335. };
  21336. /** @hidden */
  21337. Camera._setStereoscopicRigMode = function (camera) {
  21338. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  21339. };
  21340. /** @hidden */
  21341. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  21342. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  21343. };
  21344. /** @hidden */
  21345. Camera._setVRRigMode = function (camera, rigParams) {
  21346. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  21347. };
  21348. /** @hidden */
  21349. Camera._setWebVRRigMode = function (camera, rigParams) {
  21350. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  21351. };
  21352. /** @hidden */
  21353. Camera.prototype._getVRProjectionMatrix = function () {
  21354. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  21355. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  21356. return this._projectionMatrix;
  21357. };
  21358. Camera.prototype._updateCameraRotationMatrix = function () {
  21359. //Here for WebVR
  21360. };
  21361. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  21362. //Here for WebVR
  21363. };
  21364. /**
  21365. * This function MUST be overwritten by the different WebVR cameras available.
  21366. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21367. * @hidden
  21368. */
  21369. Camera.prototype._getWebVRProjectionMatrix = function () {
  21370. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21371. };
  21372. /**
  21373. * This function MUST be overwritten by the different WebVR cameras available.
  21374. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21375. * @hidden
  21376. */
  21377. Camera.prototype._getWebVRViewMatrix = function () {
  21378. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21379. };
  21380. /** @hidden */
  21381. Camera.prototype.setCameraRigParameter = function (name, value) {
  21382. if (!this._cameraRigParams) {
  21383. this._cameraRigParams = {};
  21384. }
  21385. this._cameraRigParams[name] = value;
  21386. //provisionnally:
  21387. if (name === "interaxialDistance") {
  21388. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  21389. }
  21390. };
  21391. /**
  21392. * needs to be overridden by children so sub has required properties to be copied
  21393. * @hidden
  21394. */
  21395. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  21396. return null;
  21397. };
  21398. /**
  21399. * May need to be overridden by children
  21400. * @hidden
  21401. */
  21402. Camera.prototype._updateRigCameras = function () {
  21403. for (var i = 0; i < this._rigCameras.length; i++) {
  21404. this._rigCameras[i].minZ = this.minZ;
  21405. this._rigCameras[i].maxZ = this.maxZ;
  21406. this._rigCameras[i].fov = this.fov;
  21407. this._rigCameras[i].upVector.copyFrom(this.upVector);
  21408. }
  21409. // only update viewport when ANAGLYPH
  21410. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  21411. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  21412. }
  21413. };
  21414. /** @hidden */
  21415. Camera.prototype._setupInputs = function () {
  21416. };
  21417. /**
  21418. * Serialiaze the camera setup to a json represention
  21419. * @returns the JSON representation
  21420. */
  21421. Camera.prototype.serialize = function () {
  21422. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  21423. // Type
  21424. serializationObject.type = this.getClassName();
  21425. // Parent
  21426. if (this.parent) {
  21427. serializationObject.parentId = this.parent.id;
  21428. }
  21429. if (this.inputs) {
  21430. this.inputs.serialize(serializationObject);
  21431. }
  21432. // Animations
  21433. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  21434. serializationObject.ranges = this.serializeAnimationRanges();
  21435. return serializationObject;
  21436. };
  21437. /**
  21438. * Clones the current camera.
  21439. * @param name The cloned camera name
  21440. * @returns the cloned camera
  21441. */
  21442. Camera.prototype.clone = function (name) {
  21443. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  21444. };
  21445. /**
  21446. * Gets the direction of the camera relative to a given local axis.
  21447. * @param localAxis Defines the reference axis to provide a relative direction.
  21448. * @return the direction
  21449. */
  21450. Camera.prototype.getDirection = function (localAxis) {
  21451. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21452. this.getDirectionToRef(localAxis, result);
  21453. return result;
  21454. };
  21455. /**
  21456. * Gets the direction of the camera relative to a given local axis into a passed vector.
  21457. * @param localAxis Defines the reference axis to provide a relative direction.
  21458. * @param result Defines the vector to store the result in
  21459. */
  21460. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  21461. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  21462. };
  21463. /**
  21464. * Gets a camera constructor for a given camera type
  21465. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  21466. * @param name The name of the camera the result will be able to instantiate
  21467. * @param scene The scene the result will construct the camera in
  21468. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  21469. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  21470. * @returns a factory method to construc the camera
  21471. */
  21472. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  21473. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  21474. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  21475. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  21476. interaxial_distance: interaxial_distance,
  21477. isStereoscopicSideBySide: isStereoscopicSideBySide
  21478. });
  21479. if (constructorFunc) {
  21480. return constructorFunc;
  21481. }
  21482. // Default to universal camera
  21483. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  21484. };
  21485. /**
  21486. * Compute the world matrix of the camera.
  21487. * @returns the camera workd matrix
  21488. */
  21489. Camera.prototype.computeWorldMatrix = function () {
  21490. return this.getWorldMatrix();
  21491. };
  21492. /**
  21493. * Parse a JSON and creates the camera from the parsed information
  21494. * @param parsedCamera The JSON to parse
  21495. * @param scene The scene to instantiate the camera in
  21496. * @returns the newly constructed camera
  21497. */
  21498. Camera.Parse = function (parsedCamera, scene) {
  21499. var type = parsedCamera.type;
  21500. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  21501. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  21502. // Parent
  21503. if (parsedCamera.parentId) {
  21504. camera._waitingParentId = parsedCamera.parentId;
  21505. }
  21506. //If camera has an input manager, let it parse inputs settings
  21507. if (camera.inputs) {
  21508. camera.inputs.parse(parsedCamera);
  21509. camera._setupInputs();
  21510. }
  21511. if (camera.setPosition) { // need to force position
  21512. camera.position.copyFromFloats(0, 0, 0);
  21513. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  21514. }
  21515. // Target
  21516. if (parsedCamera.target) {
  21517. if (camera.setTarget) {
  21518. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  21519. }
  21520. }
  21521. // Apply 3d rig, when found
  21522. if (parsedCamera.cameraRigMode) {
  21523. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  21524. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  21525. }
  21526. // Animations
  21527. if (parsedCamera.animations) {
  21528. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  21529. var parsedAnimation = parsedCamera.animations[animationIndex];
  21530. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  21531. if (internalClass) {
  21532. camera.animations.push(internalClass.Parse(parsedAnimation));
  21533. }
  21534. }
  21535. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  21536. }
  21537. if (parsedCamera.autoAnimate) {
  21538. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  21539. }
  21540. return camera;
  21541. };
  21542. /** @hidden */
  21543. Camera._createDefaultParsedCamera = function (name, scene) {
  21544. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  21545. };
  21546. /**
  21547. * This is the default projection mode used by the cameras.
  21548. * It helps recreating a feeling of perspective and better appreciate depth.
  21549. * This is the best way to simulate real life cameras.
  21550. */
  21551. Camera.PERSPECTIVE_CAMERA = 0;
  21552. /**
  21553. * This helps creating camera with an orthographic mode.
  21554. * 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.
  21555. */
  21556. Camera.ORTHOGRAPHIC_CAMERA = 1;
  21557. /**
  21558. * This is the default FOV mode for perspective cameras.
  21559. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  21560. */
  21561. Camera.FOVMODE_VERTICAL_FIXED = 0;
  21562. /**
  21563. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  21564. */
  21565. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  21566. /**
  21567. * This specifies ther is no need for a camera rig.
  21568. * Basically only one eye is rendered corresponding to the camera.
  21569. */
  21570. Camera.RIG_MODE_NONE = 0;
  21571. /**
  21572. * Simulates a camera Rig with one blue eye and one red eye.
  21573. * This can be use with 3d blue and red glasses.
  21574. */
  21575. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  21576. /**
  21577. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  21578. */
  21579. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  21580. /**
  21581. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  21582. */
  21583. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  21584. /**
  21585. * Defines that both eyes of the camera will be rendered over under each other.
  21586. */
  21587. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  21588. /**
  21589. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  21590. */
  21591. Camera.RIG_MODE_VR = 20;
  21592. /**
  21593. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  21594. */
  21595. Camera.RIG_MODE_WEBVR = 21;
  21596. /**
  21597. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  21598. */
  21599. Camera.RIG_MODE_CUSTOM = 22;
  21600. /**
  21601. * Defines if by default attaching controls should prevent the default javascript event to continue.
  21602. */
  21603. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  21604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  21606. ], Camera.prototype, "_position", void 0);
  21607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21609. ], Camera.prototype, "upVector", void 0);
  21610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21612. ], Camera.prototype, "orthoLeft", void 0);
  21613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21615. ], Camera.prototype, "orthoRight", void 0);
  21616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21618. ], Camera.prototype, "orthoBottom", void 0);
  21619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21621. ], Camera.prototype, "orthoTop", void 0);
  21622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21624. ], Camera.prototype, "fov", void 0);
  21625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21627. ], Camera.prototype, "minZ", void 0);
  21628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21630. ], Camera.prototype, "maxZ", void 0);
  21631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21633. ], Camera.prototype, "inertia", void 0);
  21634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21636. ], Camera.prototype, "mode", void 0);
  21637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21639. ], Camera.prototype, "layerMask", void 0);
  21640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21642. ], Camera.prototype, "fovMode", void 0);
  21643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21645. ], Camera.prototype, "cameraRigMode", void 0);
  21646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21648. ], Camera.prototype, "interaxialDistance", void 0);
  21649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21651. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21652. return Camera;
  21653. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21654. /***/ }),
  21655. /***/ "./Cameras/cameraInputsManager.ts":
  21656. /*!****************************************!*\
  21657. !*** ./Cameras/cameraInputsManager.ts ***!
  21658. \****************************************/
  21659. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21660. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21661. "use strict";
  21662. __webpack_require__.r(__webpack_exports__);
  21663. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21665. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21666. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21667. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21668. /**
  21669. * @ignore
  21670. * This is a list of all the different input types that are available in the application.
  21671. * Fo instance: ArcRotateCameraGamepadInput...
  21672. */
  21673. var CameraInputTypes = {};
  21674. /**
  21675. * This represents the input manager used within a camera.
  21676. * It helps dealing with all the different kind of input attached to a camera.
  21677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21678. */
  21679. var CameraInputsManager = /** @class */ (function () {
  21680. /**
  21681. * Instantiate a new Camera Input Manager.
  21682. * @param camera Defines the camera the input manager blongs to
  21683. */
  21684. function CameraInputsManager(camera) {
  21685. this.attached = {};
  21686. this.camera = camera;
  21687. this.checkInputs = function () { };
  21688. }
  21689. /**
  21690. * Add an input method to a camera
  21691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21692. * @param input camera input method
  21693. */
  21694. CameraInputsManager.prototype.add = function (input) {
  21695. var type = input.getSimpleName();
  21696. if (this.attached[type]) {
  21697. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21698. return;
  21699. }
  21700. this.attached[type] = input;
  21701. input.camera = this.camera;
  21702. //for checkInputs, we are dynamically creating a function
  21703. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21704. if (input.checkInputs) {
  21705. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21706. }
  21707. if (this.attachedElement) {
  21708. input.attachControl(this.attachedElement);
  21709. }
  21710. };
  21711. /**
  21712. * Remove a specific input method from a camera
  21713. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21714. * @param inputToRemove camera input method
  21715. */
  21716. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21717. for (var cam in this.attached) {
  21718. var input = this.attached[cam];
  21719. if (input === inputToRemove) {
  21720. input.detachControl(this.attachedElement);
  21721. input.camera = null;
  21722. delete this.attached[cam];
  21723. this.rebuildInputCheck();
  21724. }
  21725. }
  21726. };
  21727. /**
  21728. * Remove a specific input type from a camera
  21729. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21730. * @param inputType the type of the input to remove
  21731. */
  21732. CameraInputsManager.prototype.removeByType = function (inputType) {
  21733. for (var cam in this.attached) {
  21734. var input = this.attached[cam];
  21735. if (input.getClassName() === inputType) {
  21736. input.detachControl(this.attachedElement);
  21737. input.camera = null;
  21738. delete this.attached[cam];
  21739. this.rebuildInputCheck();
  21740. }
  21741. }
  21742. };
  21743. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21744. var current = this.checkInputs;
  21745. return function () {
  21746. current();
  21747. fn();
  21748. };
  21749. };
  21750. /**
  21751. * Attach the input controls to the currently attached dom element to listen the events from.
  21752. * @param input Defines the input to attach
  21753. */
  21754. CameraInputsManager.prototype.attachInput = function (input) {
  21755. if (this.attachedElement) {
  21756. input.attachControl(this.attachedElement, this.noPreventDefault);
  21757. }
  21758. };
  21759. /**
  21760. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21761. * @param element Defines the dom element to collect the events from
  21762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21763. */
  21764. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21765. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21766. if (this.attachedElement) {
  21767. return;
  21768. }
  21769. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21770. this.attachedElement = element;
  21771. this.noPreventDefault = noPreventDefault;
  21772. for (var cam in this.attached) {
  21773. this.attached[cam].attachControl(element, noPreventDefault);
  21774. }
  21775. };
  21776. /**
  21777. * Detach the current manager inputs controls from a specific dom element.
  21778. * @param element Defines the dom element to collect the events from
  21779. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21780. */
  21781. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21782. if (disconnect === void 0) { disconnect = false; }
  21783. if (this.attachedElement !== element) {
  21784. return;
  21785. }
  21786. for (var cam in this.attached) {
  21787. this.attached[cam].detachControl(element);
  21788. if (disconnect) {
  21789. this.attached[cam].camera = null;
  21790. }
  21791. }
  21792. this.attachedElement = null;
  21793. };
  21794. /**
  21795. * Rebuild the dynamic inputCheck function from the current list of
  21796. * defined inputs in the manager.
  21797. */
  21798. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21799. this.checkInputs = function () { };
  21800. for (var cam in this.attached) {
  21801. var input = this.attached[cam];
  21802. if (input.checkInputs) {
  21803. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21804. }
  21805. }
  21806. };
  21807. /**
  21808. * Remove all attached input methods from a camera
  21809. */
  21810. CameraInputsManager.prototype.clear = function () {
  21811. if (this.attachedElement) {
  21812. this.detachElement(this.attachedElement, true);
  21813. }
  21814. this.attached = {};
  21815. this.attachedElement = null;
  21816. this.checkInputs = function () { };
  21817. };
  21818. /**
  21819. * Serialize the current input manager attached to a camera.
  21820. * This ensures than once parsed,
  21821. * the input associated to the camera will be identical to the current ones
  21822. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21823. */
  21824. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21825. var inputs = {};
  21826. for (var cam in this.attached) {
  21827. var input = this.attached[cam];
  21828. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21829. inputs[input.getClassName()] = res;
  21830. }
  21831. serializedCamera.inputsmgr = inputs;
  21832. };
  21833. /**
  21834. * Parses an input manager serialized JSON to restore the previous list of inputs
  21835. * and states associated to a camera.
  21836. * @param parsedCamera Defines the JSON to parse
  21837. */
  21838. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21839. var parsedInputs = parsedCamera.inputsmgr;
  21840. if (parsedInputs) {
  21841. this.clear();
  21842. for (var n in parsedInputs) {
  21843. var construct = CameraInputTypes[n];
  21844. if (construct) {
  21845. var parsedinput = parsedInputs[n];
  21846. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21847. this.add(input);
  21848. }
  21849. }
  21850. }
  21851. else {
  21852. //2016-03-08 this part is for managing backward compatibility
  21853. for (var n in this.attached) {
  21854. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21855. if (construct) {
  21856. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21857. this.remove(this.attached[n]);
  21858. this.add(input);
  21859. }
  21860. }
  21861. }
  21862. };
  21863. return CameraInputsManager;
  21864. }());
  21865. /***/ }),
  21866. /***/ "./Cameras/deviceOrientationCamera.ts":
  21867. /*!********************************************!*\
  21868. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21869. \********************************************/
  21870. /*! exports provided: DeviceOrientationCamera */
  21871. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21872. "use strict";
  21873. __webpack_require__.r(__webpack_exports__);
  21874. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21875. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21876. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21877. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21878. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21879. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21880. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21881. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21882. });
  21883. // We're mainly based on the logic defined into the FreeCamera code
  21884. /**
  21885. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21886. * being tilted forward or back and left or right.
  21887. */
  21888. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21889. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21890. /**
  21891. * Creates a new device orientation camera
  21892. * @param name The name of the camera
  21893. * @param position The start position camera
  21894. * @param scene The scene the camera belongs to
  21895. */
  21896. function DeviceOrientationCamera(name, position, scene) {
  21897. var _this = _super.call(this, name, position, scene) || this;
  21898. _this._tmpDragQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21899. /**
  21900. * Disabled pointer input on first orientation sensor update (Default: true)
  21901. */
  21902. _this.disablePointerInputWhenUsingDeviceOrientation = true;
  21903. _this._dragFactor = 0;
  21904. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21905. _this.inputs.addDeviceOrientation();
  21906. // When the orientation sensor fires it's first event, disable mouse input
  21907. if (_this.inputs._deviceOrientationInput) {
  21908. _this.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function () {
  21909. if (_this.disablePointerInputWhenUsingDeviceOrientation) {
  21910. if (_this.inputs._mouseInput) {
  21911. _this.inputs._mouseInput._allowCameraRotation = false;
  21912. _this.inputs._mouseInput.onPointerMovedObservable.add(function (e) {
  21913. if (_this._dragFactor != 0) {
  21914. if (!_this._initialQuaternion) {
  21915. _this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21916. }
  21917. // Rotate the initial space around the y axis to allow users to "turn around" via touch/mouse
  21918. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromEulerAnglesToRef(0, e.offsetX * _this._dragFactor, 0, _this._tmpDragQuaternion);
  21919. _this._initialQuaternion.multiplyToRef(_this._tmpDragQuaternion, _this._initialQuaternion);
  21920. }
  21921. });
  21922. }
  21923. }
  21924. });
  21925. }
  21926. return _this;
  21927. }
  21928. /**
  21929. * Enabled turning on the y axis when the orientation sensor is active
  21930. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  21931. */
  21932. DeviceOrientationCamera.prototype.enableHorizontalDragging = function (dragFactor) {
  21933. if (dragFactor === void 0) { dragFactor = 1 / 300; }
  21934. this._dragFactor = dragFactor;
  21935. };
  21936. /**
  21937. * Gets the current instance class name ("DeviceOrientationCamera").
  21938. * This helps avoiding instanceof at run time.
  21939. * @returns the class name
  21940. */
  21941. DeviceOrientationCamera.prototype.getClassName = function () {
  21942. return "DeviceOrientationCamera";
  21943. };
  21944. /**
  21945. * @hidden
  21946. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21947. */
  21948. DeviceOrientationCamera.prototype._checkInputs = function () {
  21949. _super.prototype._checkInputs.call(this);
  21950. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21951. if (this._initialQuaternion) {
  21952. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21953. }
  21954. };
  21955. /**
  21956. * Reset the camera to its default orientation on the specified axis only.
  21957. * @param axis The axis to reset
  21958. */
  21959. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21960. var _this = this;
  21961. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21962. //can only work if this camera has a rotation quaternion already.
  21963. if (!this.rotationQuaternion) {
  21964. return;
  21965. }
  21966. if (!this._initialQuaternion) {
  21967. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21968. }
  21969. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21970. ['x', 'y', 'z'].forEach(function (axisName) {
  21971. if (!axis[axisName]) {
  21972. _this._initialQuaternion[axisName] = 0;
  21973. }
  21974. else {
  21975. _this._initialQuaternion[axisName] *= -1;
  21976. }
  21977. });
  21978. this._initialQuaternion.normalize();
  21979. //force rotation update
  21980. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21981. };
  21982. return DeviceOrientationCamera;
  21983. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21984. /***/ }),
  21985. /***/ "./Cameras/flyCamera.ts":
  21986. /*!******************************!*\
  21987. !*** ./Cameras/flyCamera.ts ***!
  21988. \******************************/
  21989. /*! exports provided: FlyCamera */
  21990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21991. "use strict";
  21992. __webpack_require__.r(__webpack_exports__);
  21993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21994. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21995. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21996. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21997. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21998. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21999. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22000. /**
  22001. * This is a flying camera, designed for 3D movement and rotation in all directions,
  22002. * such as in a 3D Space Shooter or a Flight Simulator.
  22003. */
  22004. var FlyCamera = /** @class */ (function (_super) {
  22005. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  22006. /**
  22007. * Instantiates a FlyCamera.
  22008. * This is a flying camera, designed for 3D movement and rotation in all directions,
  22009. * such as in a 3D Space Shooter or a Flight Simulator.
  22010. * @param name Define the name of the camera in the scene.
  22011. * @param position Define the starting position of the camera in the scene.
  22012. * @param scene Define the scene the camera belongs to.
  22013. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  22014. */
  22015. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22016. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22017. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22018. /**
  22019. * Define the collision ellipsoid of the camera.
  22020. * This is helpful for simulating a camera body, like a player's body.
  22021. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22022. */
  22023. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  22024. /**
  22025. * Define an offset for the position of the ellipsoid around the camera.
  22026. * This can be helpful if the camera is attached away from the player's body center,
  22027. * such as at its head.
  22028. */
  22029. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22030. /**
  22031. * Enable or disable collisions of the camera with the rest of the scene objects.
  22032. */
  22033. _this.checkCollisions = false;
  22034. /**
  22035. * Enable or disable gravity on the camera.
  22036. */
  22037. _this.applyGravity = false;
  22038. /**
  22039. * Define the current direction the camera is moving to.
  22040. */
  22041. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22042. /**
  22043. * Track Roll to maintain the wanted Rolling when looking around.
  22044. */
  22045. _this._trackRoll = 0;
  22046. /**
  22047. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  22048. */
  22049. _this.rollCorrect = 100;
  22050. /**
  22051. * Mimic a banked turn, Rolling the camera when Yawing.
  22052. * It's recommended to use rollCorrect = 10 for faster banking correction.
  22053. */
  22054. _this.bankedTurn = false;
  22055. /**
  22056. * Limit in radians for how much Roll banking will add. (Default: 90°)
  22057. */
  22058. _this.bankedTurnLimit = Math.PI / 2;
  22059. /**
  22060. * Value of 0 disables the banked Roll.
  22061. * Value of 1 is equal to the Yaw angle in radians.
  22062. */
  22063. _this.bankedTurnMultiplier = 1;
  22064. _this._needMoveForGravity = false;
  22065. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22066. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22067. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22068. // Collisions.
  22069. _this._collisionMask = -1;
  22070. /** @hidden */
  22071. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22072. if (collidedMesh === void 0) { collidedMesh = null; }
  22073. var updatePosition = function (newPos) {
  22074. _this._newPosition.copyFrom(newPos);
  22075. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22076. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22077. _this.position.addInPlace(_this._diffPosition);
  22078. if (_this.onCollide && collidedMesh) {
  22079. _this.onCollide(collidedMesh);
  22080. }
  22081. }
  22082. };
  22083. updatePosition(newPosition);
  22084. };
  22085. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  22086. _this.inputs.addKeyboard().addMouse();
  22087. return _this;
  22088. }
  22089. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  22090. /**
  22091. * Gets the input sensibility for mouse input.
  22092. * Higher values reduce sensitivity.
  22093. */
  22094. get: function () {
  22095. var mouse = this.inputs.attached["mouse"];
  22096. if (mouse) {
  22097. return mouse.angularSensibility;
  22098. }
  22099. return 0;
  22100. },
  22101. /**
  22102. * Sets the input sensibility for a mouse input.
  22103. * Higher values reduce sensitivity.
  22104. */
  22105. set: function (value) {
  22106. var mouse = this.inputs.attached["mouse"];
  22107. if (mouse) {
  22108. mouse.angularSensibility = value;
  22109. }
  22110. },
  22111. enumerable: true,
  22112. configurable: true
  22113. });
  22114. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  22115. /**
  22116. * Get the keys for camera movement forward.
  22117. */
  22118. get: function () {
  22119. var keyboard = this.inputs.attached["keyboard"];
  22120. if (keyboard) {
  22121. return keyboard.keysForward;
  22122. }
  22123. return [];
  22124. },
  22125. /**
  22126. * Set the keys for camera movement forward.
  22127. */
  22128. set: function (value) {
  22129. var keyboard = this.inputs.attached["keyboard"];
  22130. if (keyboard) {
  22131. keyboard.keysForward = value;
  22132. }
  22133. },
  22134. enumerable: true,
  22135. configurable: true
  22136. });
  22137. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  22138. /**
  22139. * Get the keys for camera movement backward.
  22140. */
  22141. get: function () {
  22142. var keyboard = this.inputs.attached["keyboard"];
  22143. if (keyboard) {
  22144. return keyboard.keysBackward;
  22145. }
  22146. return [];
  22147. },
  22148. set: function (value) {
  22149. var keyboard = this.inputs.attached["keyboard"];
  22150. if (keyboard) {
  22151. keyboard.keysBackward = value;
  22152. }
  22153. },
  22154. enumerable: true,
  22155. configurable: true
  22156. });
  22157. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  22158. /**
  22159. * Get the keys for camera movement up.
  22160. */
  22161. get: function () {
  22162. var keyboard = this.inputs.attached["keyboard"];
  22163. if (keyboard) {
  22164. return keyboard.keysUp;
  22165. }
  22166. return [];
  22167. },
  22168. /**
  22169. * Set the keys for camera movement up.
  22170. */
  22171. set: function (value) {
  22172. var keyboard = this.inputs.attached["keyboard"];
  22173. if (keyboard) {
  22174. keyboard.keysUp = value;
  22175. }
  22176. },
  22177. enumerable: true,
  22178. configurable: true
  22179. });
  22180. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  22181. /**
  22182. * Get the keys for camera movement down.
  22183. */
  22184. get: function () {
  22185. var keyboard = this.inputs.attached["keyboard"];
  22186. if (keyboard) {
  22187. return keyboard.keysDown;
  22188. }
  22189. return [];
  22190. },
  22191. /**
  22192. * Set the keys for camera movement down.
  22193. */
  22194. set: function (value) {
  22195. var keyboard = this.inputs.attached["keyboard"];
  22196. if (keyboard) {
  22197. keyboard.keysDown = value;
  22198. }
  22199. },
  22200. enumerable: true,
  22201. configurable: true
  22202. });
  22203. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  22204. /**
  22205. * Get the keys for camera movement left.
  22206. */
  22207. get: function () {
  22208. var keyboard = this.inputs.attached["keyboard"];
  22209. if (keyboard) {
  22210. return keyboard.keysLeft;
  22211. }
  22212. return [];
  22213. },
  22214. /**
  22215. * Set the keys for camera movement left.
  22216. */
  22217. set: function (value) {
  22218. var keyboard = this.inputs.attached["keyboard"];
  22219. if (keyboard) {
  22220. keyboard.keysLeft = value;
  22221. }
  22222. },
  22223. enumerable: true,
  22224. configurable: true
  22225. });
  22226. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  22227. /**
  22228. * Set the keys for camera movement right.
  22229. */
  22230. get: function () {
  22231. var keyboard = this.inputs.attached["keyboard"];
  22232. if (keyboard) {
  22233. return keyboard.keysRight;
  22234. }
  22235. return [];
  22236. },
  22237. /**
  22238. * Set the keys for camera movement right.
  22239. */
  22240. set: function (value) {
  22241. var keyboard = this.inputs.attached["keyboard"];
  22242. if (keyboard) {
  22243. keyboard.keysRight = value;
  22244. }
  22245. },
  22246. enumerable: true,
  22247. configurable: true
  22248. });
  22249. /**
  22250. * Attach a control to the HTML DOM element.
  22251. * @param element Defines the element that listens to the input events.
  22252. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  22253. */
  22254. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  22255. this.inputs.attachElement(element, noPreventDefault);
  22256. };
  22257. /**
  22258. * Detach a control from the HTML DOM element.
  22259. * The camera will stop reacting to that input.
  22260. * @param element Defines the element that listens to the input events.
  22261. */
  22262. FlyCamera.prototype.detachControl = function (element) {
  22263. this.inputs.detachElement(element);
  22264. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22265. };
  22266. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  22267. /**
  22268. * Get the mask that the camera ignores in collision events.
  22269. */
  22270. get: function () {
  22271. return this._collisionMask;
  22272. },
  22273. /**
  22274. * Set the mask that the camera ignores in collision events.
  22275. */
  22276. set: function (mask) {
  22277. this._collisionMask = !isNaN(mask) ? mask : -1;
  22278. },
  22279. enumerable: true,
  22280. configurable: true
  22281. });
  22282. /** @hidden */
  22283. FlyCamera.prototype._collideWithWorld = function (displacement) {
  22284. var globalPosition;
  22285. if (this.parent) {
  22286. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22287. }
  22288. else {
  22289. globalPosition = this.position;
  22290. }
  22291. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22292. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22293. var coordinator = this.getScene().collisionCoordinator;
  22294. if (!this._collider) {
  22295. this._collider = coordinator.createCollider();
  22296. }
  22297. this._collider._radius = this.ellipsoid;
  22298. this._collider.collisionMask = this._collisionMask;
  22299. // No need for clone, as long as gravity is not on.
  22300. var actualDisplacement = displacement;
  22301. // Add gravity to direction to prevent dual-collision checking.
  22302. if (this.applyGravity) {
  22303. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  22304. actualDisplacement = displacement.add(this.getScene().gravity);
  22305. }
  22306. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22307. };
  22308. /** @hidden */
  22309. FlyCamera.prototype._checkInputs = function () {
  22310. if (!this._localDirection) {
  22311. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22312. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22313. }
  22314. this.inputs.checkInputs();
  22315. _super.prototype._checkInputs.call(this);
  22316. };
  22317. /** @hidden */
  22318. FlyCamera.prototype._decideIfNeedsToMove = function () {
  22319. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22320. };
  22321. /** @hidden */
  22322. FlyCamera.prototype._updatePosition = function () {
  22323. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22324. this._collideWithWorld(this.cameraDirection);
  22325. }
  22326. else {
  22327. _super.prototype._updatePosition.call(this);
  22328. }
  22329. };
  22330. /**
  22331. * Restore the Roll to its target value at the rate specified.
  22332. * @param rate - Higher means slower restoring.
  22333. * @hidden
  22334. */
  22335. FlyCamera.prototype.restoreRoll = function (rate) {
  22336. var limit = this._trackRoll; // Target Roll.
  22337. var z = this.rotation.z; // Current Roll.
  22338. var delta = limit - z; // Difference in Roll.
  22339. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  22340. // If the difference is noticable, restore the Roll.
  22341. if (Math.abs(delta) >= minRad) {
  22342. // Change Z rotation towards the target Roll.
  22343. this.rotation.z += delta / rate;
  22344. // Match when near enough.
  22345. if (Math.abs(limit - this.rotation.z) <= minRad) {
  22346. this.rotation.z = limit;
  22347. }
  22348. }
  22349. };
  22350. /**
  22351. * Destroy the camera and release the current resources held by it.
  22352. */
  22353. FlyCamera.prototype.dispose = function () {
  22354. this.inputs.clear();
  22355. _super.prototype.dispose.call(this);
  22356. };
  22357. /**
  22358. * Get the current object class name.
  22359. * @returns the class name.
  22360. */
  22361. FlyCamera.prototype.getClassName = function () {
  22362. return "FlyCamera";
  22363. };
  22364. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22365. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22366. ], FlyCamera.prototype, "ellipsoid", void 0);
  22367. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22368. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22369. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  22370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22372. ], FlyCamera.prototype, "checkCollisions", void 0);
  22373. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22375. ], FlyCamera.prototype, "applyGravity", void 0);
  22376. return FlyCamera;
  22377. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22378. /***/ }),
  22379. /***/ "./Cameras/flyCameraInputsManager.ts":
  22380. /*!*******************************************!*\
  22381. !*** ./Cameras/flyCameraInputsManager.ts ***!
  22382. \*******************************************/
  22383. /*! exports provided: FlyCameraInputsManager */
  22384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22385. "use strict";
  22386. __webpack_require__.r(__webpack_exports__);
  22387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  22388. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22389. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22390. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  22391. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  22392. /**
  22393. * Default Inputs manager for the FlyCamera.
  22394. * It groups all the default supported inputs for ease of use.
  22395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22396. */
  22397. var FlyCameraInputsManager = /** @class */ (function (_super) {
  22398. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  22399. /**
  22400. * Instantiates a new FlyCameraInputsManager.
  22401. * @param camera Defines the camera the inputs belong to.
  22402. */
  22403. function FlyCameraInputsManager(camera) {
  22404. return _super.call(this, camera) || this;
  22405. }
  22406. /**
  22407. * Add keyboard input support to the input manager.
  22408. * @returns the new FlyCameraKeyboardMoveInput().
  22409. */
  22410. FlyCameraInputsManager.prototype.addKeyboard = function () {
  22411. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  22412. return this;
  22413. };
  22414. /**
  22415. * Add mouse input support to the input manager.
  22416. * @param touchEnabled Enable touch screen support.
  22417. * @returns the new FlyCameraMouseInput().
  22418. */
  22419. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22420. if (touchEnabled === void 0) { touchEnabled = true; }
  22421. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  22422. return this;
  22423. };
  22424. return FlyCameraInputsManager;
  22425. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22426. /***/ }),
  22427. /***/ "./Cameras/followCamera.ts":
  22428. /*!*********************************!*\
  22429. !*** ./Cameras/followCamera.ts ***!
  22430. \*********************************/
  22431. /*! exports provided: FollowCamera, ArcFollowCamera */
  22432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22433. "use strict";
  22434. __webpack_require__.r(__webpack_exports__);
  22435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  22436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  22437. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22438. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22439. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  22440. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22441. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22442. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  22443. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  22444. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  22445. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  22446. });
  22447. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  22448. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  22449. });
  22450. /**
  22451. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  22452. * an arc rotate version arcFollowCamera are available.
  22453. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22454. */
  22455. var FollowCamera = /** @class */ (function (_super) {
  22456. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  22457. /**
  22458. * Instantiates the follow camera.
  22459. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22460. * @param name Define the name of the camera in the scene
  22461. * @param position Define the position of the camera
  22462. * @param scene Define the scene the camera belong to
  22463. * @param lockedTarget Define the target of the camera
  22464. */
  22465. function FollowCamera(name, position, scene, lockedTarget) {
  22466. if (lockedTarget === void 0) { lockedTarget = null; }
  22467. var _this = _super.call(this, name, position, scene) || this;
  22468. /**
  22469. * Distance the follow camera should follow an object at
  22470. */
  22471. _this.radius = 12;
  22472. /**
  22473. * Minimum allowed distance of the camera to the axis of rotation
  22474. * (The camera can not get closer).
  22475. * This can help limiting how the Camera is able to move in the scene.
  22476. */
  22477. _this.lowerRadiusLimit = null;
  22478. /**
  22479. * Maximum allowed distance of the camera to the axis of rotation
  22480. * (The camera can not get further).
  22481. * This can help limiting how the Camera is able to move in the scene.
  22482. */
  22483. _this.upperRadiusLimit = null;
  22484. /**
  22485. * Define a rotation offset between the camera and the object it follows
  22486. */
  22487. _this.rotationOffset = 0;
  22488. /**
  22489. * Minimum allowed angle to camera position relative to target object.
  22490. * This can help limiting how the Camera is able to move in the scene.
  22491. */
  22492. _this.lowerRotationOffsetLimit = null;
  22493. /**
  22494. * Maximum allowed angle to camera position relative to target object.
  22495. * This can help limiting how the Camera is able to move in the scene.
  22496. */
  22497. _this.upperRotationOffsetLimit = null;
  22498. /**
  22499. * Define a height offset between the camera and the object it follows.
  22500. * It can help following an object from the top (like a car chaing a plane)
  22501. */
  22502. _this.heightOffset = 4;
  22503. /**
  22504. * Minimum allowed height of camera position relative to target object.
  22505. * This can help limiting how the Camera is able to move in the scene.
  22506. */
  22507. _this.lowerHeightOffsetLimit = null;
  22508. /**
  22509. * Maximum allowed height of camera position relative to target object.
  22510. * This can help limiting how the Camera is able to move in the scene.
  22511. */
  22512. _this.upperHeightOffsetLimit = null;
  22513. /**
  22514. * Define how fast the camera can accelerate to follow it s target.
  22515. */
  22516. _this.cameraAcceleration = 0.05;
  22517. /**
  22518. * Define the speed limit of the camera following an object.
  22519. */
  22520. _this.maxCameraSpeed = 20;
  22521. _this.lockedTarget = lockedTarget;
  22522. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  22523. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  22524. return _this;
  22525. // Uncomment the following line when the relevant handlers have been implemented.
  22526. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  22527. }
  22528. FollowCamera.prototype._follow = function (cameraTarget) {
  22529. if (!cameraTarget) {
  22530. return;
  22531. }
  22532. var yRotation;
  22533. if (cameraTarget.rotationQuaternion) {
  22534. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  22535. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  22536. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  22537. }
  22538. else {
  22539. yRotation = cameraTarget.rotation.y;
  22540. }
  22541. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  22542. var targetPosition = cameraTarget.getAbsolutePosition();
  22543. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  22544. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  22545. var dx = targetX - this.position.x;
  22546. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  22547. var dz = (targetZ) - this.position.z;
  22548. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  22549. var vy = dy * this.cameraAcceleration;
  22550. var vz = dz * this.cameraAcceleration * 2;
  22551. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  22552. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22553. }
  22554. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  22555. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22556. }
  22557. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  22558. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22559. }
  22560. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  22561. this.setTarget(targetPosition);
  22562. };
  22563. /**
  22564. * Attached controls to the current camera.
  22565. * @param element Defines the element the controls should be listened from
  22566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22567. */
  22568. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  22569. this.inputs.attachElement(element, noPreventDefault);
  22570. this._reset = function () {
  22571. };
  22572. };
  22573. /**
  22574. * Detach the current controls from the camera.
  22575. * The camera will stop reacting to inputs.
  22576. * @param element Defines the element to stop listening the inputs from
  22577. */
  22578. FollowCamera.prototype.detachControl = function (element) {
  22579. this.inputs.detachElement(element);
  22580. if (this._reset) {
  22581. this._reset();
  22582. }
  22583. };
  22584. /** @hidden */
  22585. FollowCamera.prototype._checkInputs = function () {
  22586. this.inputs.checkInputs();
  22587. this._checkLimits();
  22588. _super.prototype._checkInputs.call(this);
  22589. if (this.lockedTarget) {
  22590. this._follow(this.lockedTarget);
  22591. }
  22592. };
  22593. FollowCamera.prototype._checkLimits = function () {
  22594. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  22595. this.radius = this.lowerRadiusLimit;
  22596. }
  22597. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  22598. this.radius = this.upperRadiusLimit;
  22599. }
  22600. if (this.lowerHeightOffsetLimit !== null &&
  22601. this.heightOffset < this.lowerHeightOffsetLimit) {
  22602. this.heightOffset = this.lowerHeightOffsetLimit;
  22603. }
  22604. if (this.upperHeightOffsetLimit !== null &&
  22605. this.heightOffset > this.upperHeightOffsetLimit) {
  22606. this.heightOffset = this.upperHeightOffsetLimit;
  22607. }
  22608. if (this.lowerRotationOffsetLimit !== null &&
  22609. this.rotationOffset < this.lowerRotationOffsetLimit) {
  22610. this.rotationOffset = this.lowerRotationOffsetLimit;
  22611. }
  22612. if (this.upperRotationOffsetLimit !== null &&
  22613. this.rotationOffset > this.upperRotationOffsetLimit) {
  22614. this.rotationOffset = this.upperRotationOffsetLimit;
  22615. }
  22616. };
  22617. /**
  22618. * Gets the camera class name.
  22619. * @returns the class name
  22620. */
  22621. FollowCamera.prototype.getClassName = function () {
  22622. return "FollowCamera";
  22623. };
  22624. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22625. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22626. ], FollowCamera.prototype, "radius", void 0);
  22627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22629. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  22630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22632. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  22633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22635. ], FollowCamera.prototype, "rotationOffset", void 0);
  22636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22638. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  22639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22641. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  22642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22644. ], FollowCamera.prototype, "heightOffset", void 0);
  22645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22647. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  22648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22650. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  22651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22653. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  22654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22656. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  22657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22659. ], FollowCamera.prototype, "lockedTarget", void 0);
  22660. return FollowCamera;
  22661. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22662. /**
  22663. * Arc Rotate version of the follow camera.
  22664. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  22665. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22666. */
  22667. var ArcFollowCamera = /** @class */ (function (_super) {
  22668. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  22669. /**
  22670. * Instantiates a new ArcFollowCamera
  22671. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22672. * @param name Define the name of the camera
  22673. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  22674. * @param beta Define the rotation angle of the camera around the elevation axis
  22675. * @param radius Define the radius of the camera from its target point
  22676. * @param target Define the target of the camera
  22677. * @param scene Define the scene the camera belongs to
  22678. */
  22679. function ArcFollowCamera(name,
  22680. /** The longitudinal angle of the camera */
  22681. alpha,
  22682. /** The latitudinal angle of the camera */
  22683. beta,
  22684. /** The radius of the camera from its target */
  22685. radius,
  22686. /** Define the camera target (the messh it should follow) */
  22687. target, scene) {
  22688. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22689. _this.alpha = alpha;
  22690. _this.beta = beta;
  22691. _this.radius = radius;
  22692. _this.target = target;
  22693. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22694. _this._follow();
  22695. return _this;
  22696. }
  22697. ArcFollowCamera.prototype._follow = function () {
  22698. if (!this.target) {
  22699. return;
  22700. }
  22701. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22702. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22703. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22704. var targetPosition = this.target.getAbsolutePosition();
  22705. this.position = targetPosition.add(this._cartesianCoordinates);
  22706. this.setTarget(targetPosition);
  22707. };
  22708. /** @hidden */
  22709. ArcFollowCamera.prototype._checkInputs = function () {
  22710. _super.prototype._checkInputs.call(this);
  22711. this._follow();
  22712. };
  22713. /**
  22714. * Returns the class name of the object.
  22715. * It is mostly used internally for serialization purposes.
  22716. */
  22717. ArcFollowCamera.prototype.getClassName = function () {
  22718. return "ArcFollowCamera";
  22719. };
  22720. return ArcFollowCamera;
  22721. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22722. /***/ }),
  22723. /***/ "./Cameras/followCameraInputsManager.ts":
  22724. /*!**********************************************!*\
  22725. !*** ./Cameras/followCameraInputsManager.ts ***!
  22726. \**********************************************/
  22727. /*! exports provided: FollowCameraInputsManager */
  22728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22729. "use strict";
  22730. __webpack_require__.r(__webpack_exports__);
  22731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22732. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22733. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22734. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22735. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22736. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  22737. /**
  22738. * Default Inputs manager for the FollowCamera.
  22739. * It groups all the default supported inputs for ease of use.
  22740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22741. */
  22742. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22743. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22744. /**
  22745. * Instantiates a new FollowCameraInputsManager.
  22746. * @param camera Defines the camera the inputs belong to
  22747. */
  22748. function FollowCameraInputsManager(camera) {
  22749. return _super.call(this, camera) || this;
  22750. }
  22751. /**
  22752. * Add keyboard input support to the input manager.
  22753. * @returns the current input manager
  22754. */
  22755. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22756. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22757. return this;
  22758. };
  22759. /**
  22760. * Add mouse wheel input support to the input manager.
  22761. * @returns the current input manager
  22762. */
  22763. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22764. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22765. return this;
  22766. };
  22767. /**
  22768. * Add pointers input support to the input manager.
  22769. * @returns the current input manager
  22770. */
  22771. FollowCameraInputsManager.prototype.addPointers = function () {
  22772. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  22773. return this;
  22774. };
  22775. /**
  22776. * Add orientation input support to the input manager.
  22777. * @returns the current input manager
  22778. */
  22779. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22780. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22781. return this;
  22782. };
  22783. return FollowCameraInputsManager;
  22784. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22785. /***/ }),
  22786. /***/ "./Cameras/freeCamera.ts":
  22787. /*!*******************************!*\
  22788. !*** ./Cameras/freeCamera.ts ***!
  22789. \*******************************/
  22790. /*! exports provided: FreeCamera */
  22791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22792. "use strict";
  22793. __webpack_require__.r(__webpack_exports__);
  22794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22795. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22796. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22797. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22798. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22799. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22800. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22801. /**
  22802. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22803. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22804. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22805. */
  22806. var FreeCamera = /** @class */ (function (_super) {
  22807. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22808. /**
  22809. * Instantiates a Free Camera.
  22810. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22811. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22812. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22813. * @param name Define the name of the camera in the scene
  22814. * @param position Define the start position of the camera in the scene
  22815. * @param scene Define the scene the camera belongs to
  22816. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22817. */
  22818. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22819. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22820. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22821. /**
  22822. * Define the collision ellipsoid of the camera.
  22823. * This is helpful to simulate a camera body like the player body around the camera
  22824. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22825. */
  22826. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22827. /**
  22828. * Define an offset for the position of the ellipsoid around the camera.
  22829. * This can be helpful to determine the center of the body near the gravity center of the body
  22830. * instead of its head.
  22831. */
  22832. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22833. /**
  22834. * Enable or disable collisions of the camera with the rest of the scene objects.
  22835. */
  22836. _this.checkCollisions = false;
  22837. /**
  22838. * Enable or disable gravity on the camera.
  22839. */
  22840. _this.applyGravity = false;
  22841. _this._needMoveForGravity = false;
  22842. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22843. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22844. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22845. // Collisions
  22846. _this._collisionMask = -1;
  22847. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22848. if (collidedMesh === void 0) { collidedMesh = null; }
  22849. var updatePosition = function (newPos) {
  22850. _this._newPosition.copyFrom(newPos);
  22851. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22852. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22853. _this.position.addInPlace(_this._diffPosition);
  22854. if (_this.onCollide && collidedMesh) {
  22855. _this.onCollide(collidedMesh);
  22856. }
  22857. }
  22858. };
  22859. updatePosition(newPosition);
  22860. };
  22861. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22862. _this.inputs.addKeyboard().addMouse();
  22863. return _this;
  22864. }
  22865. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22866. /**
  22867. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22868. * Higher values reduce sensitivity.
  22869. */
  22870. get: function () {
  22871. var mouse = this.inputs.attached["mouse"];
  22872. if (mouse) {
  22873. return mouse.angularSensibility;
  22874. }
  22875. return 0;
  22876. },
  22877. /**
  22878. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22879. * Higher values reduce sensitivity.
  22880. */
  22881. set: function (value) {
  22882. var mouse = this.inputs.attached["mouse"];
  22883. if (mouse) {
  22884. mouse.angularSensibility = value;
  22885. }
  22886. },
  22887. enumerable: true,
  22888. configurable: true
  22889. });
  22890. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22891. /**
  22892. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22893. */
  22894. get: function () {
  22895. var keyboard = this.inputs.attached["keyboard"];
  22896. if (keyboard) {
  22897. return keyboard.keysUp;
  22898. }
  22899. return [];
  22900. },
  22901. set: function (value) {
  22902. var keyboard = this.inputs.attached["keyboard"];
  22903. if (keyboard) {
  22904. keyboard.keysUp = value;
  22905. }
  22906. },
  22907. enumerable: true,
  22908. configurable: true
  22909. });
  22910. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22911. /**
  22912. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22913. */
  22914. get: function () {
  22915. var keyboard = this.inputs.attached["keyboard"];
  22916. if (keyboard) {
  22917. return keyboard.keysDown;
  22918. }
  22919. return [];
  22920. },
  22921. set: function (value) {
  22922. var keyboard = this.inputs.attached["keyboard"];
  22923. if (keyboard) {
  22924. keyboard.keysDown = value;
  22925. }
  22926. },
  22927. enumerable: true,
  22928. configurable: true
  22929. });
  22930. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22931. /**
  22932. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22933. */
  22934. get: function () {
  22935. var keyboard = this.inputs.attached["keyboard"];
  22936. if (keyboard) {
  22937. return keyboard.keysLeft;
  22938. }
  22939. return [];
  22940. },
  22941. set: function (value) {
  22942. var keyboard = this.inputs.attached["keyboard"];
  22943. if (keyboard) {
  22944. keyboard.keysLeft = value;
  22945. }
  22946. },
  22947. enumerable: true,
  22948. configurable: true
  22949. });
  22950. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22951. /**
  22952. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22953. */
  22954. get: function () {
  22955. var keyboard = this.inputs.attached["keyboard"];
  22956. if (keyboard) {
  22957. return keyboard.keysRight;
  22958. }
  22959. return [];
  22960. },
  22961. set: function (value) {
  22962. var keyboard = this.inputs.attached["keyboard"];
  22963. if (keyboard) {
  22964. keyboard.keysRight = value;
  22965. }
  22966. },
  22967. enumerable: true,
  22968. configurable: true
  22969. });
  22970. /**
  22971. * Attached controls to the current camera.
  22972. * @param element Defines the element the controls should be listened from
  22973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22974. */
  22975. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22976. this.inputs.attachElement(element, noPreventDefault);
  22977. };
  22978. /**
  22979. * Detach the current controls from the camera.
  22980. * The camera will stop reacting to inputs.
  22981. * @param element Defines the element to stop listening the inputs from
  22982. */
  22983. FreeCamera.prototype.detachControl = function (element) {
  22984. this.inputs.detachElement(element);
  22985. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22986. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22987. };
  22988. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22989. /**
  22990. * Define a collision mask to limit the list of object the camera can collide with
  22991. */
  22992. get: function () {
  22993. return this._collisionMask;
  22994. },
  22995. set: function (mask) {
  22996. this._collisionMask = !isNaN(mask) ? mask : -1;
  22997. },
  22998. enumerable: true,
  22999. configurable: true
  23000. });
  23001. /** @hidden */
  23002. FreeCamera.prototype._collideWithWorld = function (displacement) {
  23003. var globalPosition;
  23004. if (this.parent) {
  23005. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  23006. }
  23007. else {
  23008. globalPosition = this.position;
  23009. }
  23010. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  23011. this._oldPosition.addInPlace(this.ellipsoidOffset);
  23012. var coordinator = this.getScene().collisionCoordinator;
  23013. if (!this._collider) {
  23014. this._collider = coordinator.createCollider();
  23015. }
  23016. this._collider._radius = this.ellipsoid;
  23017. this._collider.collisionMask = this._collisionMask;
  23018. //no need for clone, as long as gravity is not on.
  23019. var actualDisplacement = displacement;
  23020. //add gravity to the direction to prevent the dual-collision checking
  23021. if (this.applyGravity) {
  23022. //this prevents mending with cameraDirection, a global variable of the free camera class.
  23023. actualDisplacement = displacement.add(this.getScene().gravity);
  23024. }
  23025. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  23026. };
  23027. /** @hidden */
  23028. FreeCamera.prototype._checkInputs = function () {
  23029. if (!this._localDirection) {
  23030. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23031. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23032. }
  23033. this.inputs.checkInputs();
  23034. _super.prototype._checkInputs.call(this);
  23035. };
  23036. /** @hidden */
  23037. FreeCamera.prototype._decideIfNeedsToMove = function () {
  23038. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23039. };
  23040. /** @hidden */
  23041. FreeCamera.prototype._updatePosition = function () {
  23042. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  23043. this._collideWithWorld(this.cameraDirection);
  23044. }
  23045. else {
  23046. _super.prototype._updatePosition.call(this);
  23047. }
  23048. };
  23049. /**
  23050. * Destroy the camera and release the current resources hold by it.
  23051. */
  23052. FreeCamera.prototype.dispose = function () {
  23053. this.inputs.clear();
  23054. _super.prototype.dispose.call(this);
  23055. };
  23056. /**
  23057. * Gets the current object class name.
  23058. * @return the class name
  23059. */
  23060. FreeCamera.prototype.getClassName = function () {
  23061. return "FreeCamera";
  23062. };
  23063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23065. ], FreeCamera.prototype, "ellipsoid", void 0);
  23066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23068. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  23069. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23071. ], FreeCamera.prototype, "checkCollisions", void 0);
  23072. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23074. ], FreeCamera.prototype, "applyGravity", void 0);
  23075. return FreeCamera;
  23076. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  23077. /***/ }),
  23078. /***/ "./Cameras/freeCameraInputsManager.ts":
  23079. /*!********************************************!*\
  23080. !*** ./Cameras/freeCameraInputsManager.ts ***!
  23081. \********************************************/
  23082. /*! exports provided: FreeCameraInputsManager */
  23083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23084. "use strict";
  23085. __webpack_require__.r(__webpack_exports__);
  23086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  23087. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23088. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23089. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  23090. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  23091. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  23092. /**
  23093. * Default Inputs manager for the FreeCamera.
  23094. * It groups all the default supported inputs for ease of use.
  23095. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  23096. */
  23097. var FreeCameraInputsManager = /** @class */ (function (_super) {
  23098. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  23099. /**
  23100. * Instantiates a new FreeCameraInputsManager.
  23101. * @param camera Defines the camera the inputs belong to
  23102. */
  23103. function FreeCameraInputsManager(camera) {
  23104. var _this = _super.call(this, camera) || this;
  23105. /**
  23106. * @hidden
  23107. */
  23108. _this._keyboardInput = null;
  23109. /**
  23110. * @hidden
  23111. */
  23112. _this._mouseInput = null;
  23113. return _this;
  23114. }
  23115. /**
  23116. * Add keyboard input support to the input manager.
  23117. * @returns the current input manager
  23118. */
  23119. FreeCameraInputsManager.prototype.addKeyboard = function () {
  23120. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  23121. return this;
  23122. };
  23123. /**
  23124. * Add mouse input support to the input manager.
  23125. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  23126. * @returns the current input manager
  23127. */
  23128. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  23129. if (touchEnabled === void 0) { touchEnabled = true; }
  23130. if (!this._mouseInput) {
  23131. this._mouseInput = new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled);
  23132. this.add(this._mouseInput);
  23133. }
  23134. return this;
  23135. };
  23136. /**
  23137. * Removes the mouse input support from the manager
  23138. * @returns the current input manager
  23139. */
  23140. FreeCameraInputsManager.prototype.removeMouse = function () {
  23141. if (this._mouseInput) {
  23142. this.remove(this._mouseInput);
  23143. }
  23144. return this;
  23145. };
  23146. /**
  23147. * Add touch input support to the input manager.
  23148. * @returns the current input manager
  23149. */
  23150. FreeCameraInputsManager.prototype.addTouch = function () {
  23151. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  23152. return this;
  23153. };
  23154. return FreeCameraInputsManager;
  23155. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  23156. /***/ }),
  23157. /***/ "./Cameras/gamepadCamera.ts":
  23158. /*!**********************************!*\
  23159. !*** ./Cameras/gamepadCamera.ts ***!
  23160. \**********************************/
  23161. /*! exports provided: GamepadCamera */
  23162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23163. "use strict";
  23164. __webpack_require__.r(__webpack_exports__);
  23165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  23166. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23167. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23168. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23169. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23170. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  23171. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23172. });
  23173. /**
  23174. * This represents a FPS type of camera. This is only here for back compat purpose.
  23175. * Please use the UniversalCamera instead as both are identical.
  23176. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23177. */
  23178. var GamepadCamera = /** @class */ (function (_super) {
  23179. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  23180. /**
  23181. * Instantiates a new Gamepad Camera
  23182. * This represents a FPS type of camera. This is only here for back compat purpose.
  23183. * Please use the UniversalCamera instead as both are identical.
  23184. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23185. * @param name Define the name of the camera in the scene
  23186. * @param position Define the start position of the camera in the scene
  23187. * @param scene Define the scene the camera belongs to
  23188. */
  23189. function GamepadCamera(name, position, scene) {
  23190. return _super.call(this, name, position, scene) || this;
  23191. }
  23192. /**
  23193. * Gets the current object class name.
  23194. * @return the class name
  23195. */
  23196. GamepadCamera.prototype.getClassName = function () {
  23197. return "GamepadCamera";
  23198. };
  23199. return GamepadCamera;
  23200. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  23201. /***/ }),
  23202. /***/ "./Cameras/index.ts":
  23203. /*!**************************!*\
  23204. !*** ./Cameras/index.ts ***!
  23205. \**************************/
  23206. /*! 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 */
  23207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23208. "use strict";
  23209. __webpack_require__.r(__webpack_exports__);
  23210. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  23211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  23212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  23213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  23214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  23215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  23216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  23217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  23218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  23219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  23220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  23221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  23222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  23223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  23224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  23225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  23226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  23227. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  23229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  23230. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  23232. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  23234. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  23236. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  23237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  23238. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  23240. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  23241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  23242. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  23243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  23244. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  23245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  23246. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  23247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  23248. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  23249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  23250. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  23251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  23252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  23253. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  23254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  23255. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  23256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  23257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  23258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  23259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  23260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  23261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  23262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  23263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  23264. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  23266. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  23267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  23268. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  23269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  23270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  23271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  23272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  23273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  23274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  23275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  23276. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  23277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  23278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  23279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  23280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  23281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  23282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  23283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  23284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  23285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  23286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  23287. /***/ }),
  23288. /***/ "./Cameras/targetCamera.ts":
  23289. /*!*********************************!*\
  23290. !*** ./Cameras/targetCamera.ts ***!
  23291. \*********************************/
  23292. /*! exports provided: TargetCamera */
  23293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23294. "use strict";
  23295. __webpack_require__.r(__webpack_exports__);
  23296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  23297. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23298. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23299. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23300. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23301. /**
  23302. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  23303. * This is the base of the follow, arc rotate cameras and Free camera
  23304. * @see http://doc.babylonjs.com/features/cameras
  23305. */
  23306. var TargetCamera = /** @class */ (function (_super) {
  23307. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  23308. /**
  23309. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  23310. * This is the base of the follow, arc rotate cameras and Free camera
  23311. * @see http://doc.babylonjs.com/features/cameras
  23312. * @param name Defines the name of the camera in the scene
  23313. * @param position Defines the start position of the camera in the scene
  23314. * @param scene Defines the scene the camera belongs to
  23315. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23316. */
  23317. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23318. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23319. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23320. /**
  23321. * Define the current direction the camera is moving to
  23322. */
  23323. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23324. /**
  23325. * Define the current rotation the camera is rotating to
  23326. */
  23327. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  23328. /**
  23329. * When set, the up vector of the camera will be updated by the rotation of the camera
  23330. */
  23331. _this.updateUpVectorFromRotation = false;
  23332. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23333. /**
  23334. * Define the current rotation of the camera
  23335. */
  23336. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23337. /**
  23338. * Define the current speed of the camera
  23339. */
  23340. _this.speed = 2.0;
  23341. /**
  23342. * Add cconstraint to the camera to prevent it to move freely in all directions and
  23343. * around all axis.
  23344. */
  23345. _this.noRotationConstraint = false;
  23346. /**
  23347. * Define the current target of the camera as an object or a position.
  23348. */
  23349. _this.lockedTarget = null;
  23350. /** @hidden */
  23351. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23352. /** @hidden */
  23353. _this._initialFocalDistance = 1;
  23354. /** @hidden */
  23355. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23356. /** @hidden */
  23357. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23358. /** @hidden */
  23359. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23360. /** @hidden */
  23361. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23362. /** @hidden */
  23363. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  23364. /** @hidden */
  23365. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23366. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23367. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23368. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  23369. _this._cachedRotationZ = 0;
  23370. _this._cachedQuaternionRotationZ = 0;
  23371. return _this;
  23372. }
  23373. /**
  23374. * Gets the position in front of the camera at a given distance.
  23375. * @param distance The distance from the camera we want the position to be
  23376. * @returns the position
  23377. */
  23378. TargetCamera.prototype.getFrontPosition = function (distance) {
  23379. this.getWorldMatrix();
  23380. var direction = this.getTarget().subtract(this.position);
  23381. direction.normalize();
  23382. direction.scaleInPlace(distance);
  23383. return this.globalPosition.add(direction);
  23384. };
  23385. /** @hidden */
  23386. TargetCamera.prototype._getLockedTargetPosition = function () {
  23387. if (!this.lockedTarget) {
  23388. return null;
  23389. }
  23390. if (this.lockedTarget.absolutePosition) {
  23391. this.lockedTarget.computeWorldMatrix();
  23392. }
  23393. return this.lockedTarget.absolutePosition || this.lockedTarget;
  23394. };
  23395. /**
  23396. * Store current camera state of the camera (fov, position, rotation, etc..)
  23397. * @returns the camera
  23398. */
  23399. TargetCamera.prototype.storeState = function () {
  23400. this._storedPosition = this.position.clone();
  23401. this._storedRotation = this.rotation.clone();
  23402. if (this.rotationQuaternion) {
  23403. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  23404. }
  23405. return _super.prototype.storeState.call(this);
  23406. };
  23407. /**
  23408. * Restored camera state. You must call storeState() first
  23409. * @returns whether it was successful or not
  23410. * @hidden
  23411. */
  23412. TargetCamera.prototype._restoreStateValues = function () {
  23413. if (!_super.prototype._restoreStateValues.call(this)) {
  23414. return false;
  23415. }
  23416. this.position = this._storedPosition.clone();
  23417. this.rotation = this._storedRotation.clone();
  23418. if (this.rotationQuaternion) {
  23419. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  23420. }
  23421. this.cameraDirection.copyFromFloats(0, 0, 0);
  23422. this.cameraRotation.copyFromFloats(0, 0);
  23423. return true;
  23424. };
  23425. /** @hidden */
  23426. TargetCamera.prototype._initCache = function () {
  23427. _super.prototype._initCache.call(this);
  23428. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23429. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23430. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23431. };
  23432. /** @hidden */
  23433. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  23434. if (!ignoreParentClass) {
  23435. _super.prototype._updateCache.call(this);
  23436. }
  23437. var lockedTargetPosition = this._getLockedTargetPosition();
  23438. if (!lockedTargetPosition) {
  23439. this._cache.lockedTarget = null;
  23440. }
  23441. else {
  23442. if (!this._cache.lockedTarget) {
  23443. this._cache.lockedTarget = lockedTargetPosition.clone();
  23444. }
  23445. else {
  23446. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  23447. }
  23448. }
  23449. this._cache.rotation.copyFrom(this.rotation);
  23450. if (this.rotationQuaternion) {
  23451. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23452. }
  23453. };
  23454. // Synchronized
  23455. /** @hidden */
  23456. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  23457. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  23458. return false;
  23459. }
  23460. var lockedTargetPosition = this._getLockedTargetPosition();
  23461. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  23462. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  23463. };
  23464. // Methods
  23465. /** @hidden */
  23466. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  23467. var engine = this.getEngine();
  23468. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  23469. };
  23470. // Target
  23471. /**
  23472. * Defines the target the camera should look at.
  23473. * This will automatically adapt alpha beta and radius to fit within the new target.
  23474. * @param target Defines the new target as a Vector or a mesh
  23475. */
  23476. TargetCamera.prototype.setTarget = function (target) {
  23477. this.upVector.normalize();
  23478. this._initialFocalDistance = target.subtract(this.position).length();
  23479. if (this.position.z === target.z) {
  23480. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  23481. }
  23482. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  23483. this._camMatrix.invert();
  23484. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  23485. var vDir = target.subtract(this.position);
  23486. if (vDir.x >= 0.0) {
  23487. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  23488. }
  23489. else {
  23490. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  23491. }
  23492. this.rotation.z = 0;
  23493. if (isNaN(this.rotation.x)) {
  23494. this.rotation.x = 0;
  23495. }
  23496. if (isNaN(this.rotation.y)) {
  23497. this.rotation.y = 0;
  23498. }
  23499. if (isNaN(this.rotation.z)) {
  23500. this.rotation.z = 0;
  23501. }
  23502. if (this.rotationQuaternion) {
  23503. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23504. }
  23505. };
  23506. /**
  23507. * Return the current target position of the camera. This value is expressed in local space.
  23508. * @returns the target position
  23509. */
  23510. TargetCamera.prototype.getTarget = function () {
  23511. return this._currentTarget;
  23512. };
  23513. /** @hidden */
  23514. TargetCamera.prototype._decideIfNeedsToMove = function () {
  23515. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23516. };
  23517. /** @hidden */
  23518. TargetCamera.prototype._updatePosition = function () {
  23519. if (this.parent) {
  23520. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  23521. _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]);
  23522. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23523. return;
  23524. }
  23525. this.position.addInPlace(this.cameraDirection);
  23526. };
  23527. /** @hidden */
  23528. TargetCamera.prototype._checkInputs = function () {
  23529. var needToMove = this._decideIfNeedsToMove();
  23530. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  23531. // Move
  23532. if (needToMove) {
  23533. this._updatePosition();
  23534. }
  23535. // Rotate
  23536. if (needToRotate) {
  23537. this.rotation.x += this.cameraRotation.x;
  23538. this.rotation.y += this.cameraRotation.y;
  23539. //rotate, if quaternion is set and rotation was used
  23540. if (this.rotationQuaternion) {
  23541. var len = this.rotation.lengthSquared();
  23542. if (len) {
  23543. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23544. }
  23545. }
  23546. if (!this.noRotationConstraint) {
  23547. var limit = (Math.PI / 2) * 0.95;
  23548. if (this.rotation.x > limit) {
  23549. this.rotation.x = limit;
  23550. }
  23551. if (this.rotation.x < -limit) {
  23552. this.rotation.x = -limit;
  23553. }
  23554. }
  23555. }
  23556. // Inertia
  23557. if (needToMove) {
  23558. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23559. this.cameraDirection.x = 0;
  23560. }
  23561. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23562. this.cameraDirection.y = 0;
  23563. }
  23564. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23565. this.cameraDirection.z = 0;
  23566. }
  23567. this.cameraDirection.scaleInPlace(this.inertia);
  23568. }
  23569. if (needToRotate) {
  23570. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23571. this.cameraRotation.x = 0;
  23572. }
  23573. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23574. this.cameraRotation.y = 0;
  23575. }
  23576. this.cameraRotation.scaleInPlace(this.inertia);
  23577. }
  23578. _super.prototype._checkInputs.call(this);
  23579. };
  23580. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  23581. if (this.rotationQuaternion) {
  23582. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  23583. }
  23584. else {
  23585. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  23586. }
  23587. };
  23588. /**
  23589. * 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)
  23590. * @returns the current camera
  23591. */
  23592. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  23593. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  23594. return this;
  23595. };
  23596. /** @hidden */
  23597. TargetCamera.prototype._getViewMatrix = function () {
  23598. if (this.lockedTarget) {
  23599. this.setTarget(this._getLockedTargetPosition());
  23600. }
  23601. // Compute
  23602. this._updateCameraRotationMatrix();
  23603. // Apply the changed rotation to the upVector
  23604. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  23605. this._rotateUpVectorWithCameraRotationMatrix();
  23606. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  23607. }
  23608. else if (this._cachedRotationZ != this.rotation.z) {
  23609. this._rotateUpVectorWithCameraRotationMatrix();
  23610. this._cachedRotationZ = this.rotation.z;
  23611. }
  23612. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  23613. // Computing target and final matrix
  23614. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  23615. if (this.updateUpVectorFromRotation) {
  23616. if (this.rotationQuaternion) {
  23617. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  23618. }
  23619. else {
  23620. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  23621. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  23622. }
  23623. }
  23624. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  23625. return this._viewMatrix;
  23626. };
  23627. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  23628. if (this.parent) {
  23629. var parentWorldMatrix = this.parent.getWorldMatrix();
  23630. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  23631. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  23632. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  23633. this._markSyncedWithParent();
  23634. }
  23635. else {
  23636. this._globalPosition.copyFrom(position);
  23637. this._globalCurrentTarget.copyFrom(target);
  23638. this._globalCurrentUpVector.copyFrom(up);
  23639. }
  23640. if (this.getScene().useRightHandedSystem) {
  23641. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23642. }
  23643. else {
  23644. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23645. }
  23646. };
  23647. /**
  23648. * @hidden
  23649. */
  23650. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  23651. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  23652. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  23653. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  23654. if (!this.rotationQuaternion) {
  23655. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23656. }
  23657. rigCamera._cameraRigParams = {};
  23658. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23659. }
  23660. return rigCamera;
  23661. }
  23662. return null;
  23663. };
  23664. /**
  23665. * @hidden
  23666. */
  23667. TargetCamera.prototype._updateRigCameras = function () {
  23668. var camLeft = this._rigCameras[0];
  23669. var camRight = this._rigCameras[1];
  23670. this.computeWorldMatrix();
  23671. switch (this.cameraRigMode) {
  23672. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  23673. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  23674. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  23675. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  23676. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  23677. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  23678. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  23679. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  23680. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  23681. break;
  23682. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  23683. if (camLeft.rotationQuaternion) {
  23684. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23685. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23686. }
  23687. else {
  23688. camLeft.rotation.copyFrom(this.rotation);
  23689. camRight.rotation.copyFrom(this.rotation);
  23690. }
  23691. camLeft.position.copyFrom(this.position);
  23692. camRight.position.copyFrom(this.position);
  23693. break;
  23694. }
  23695. _super.prototype._updateRigCameras.call(this);
  23696. };
  23697. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  23698. var target = this.getTarget();
  23699. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  23700. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  23701. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  23702. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23703. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  23704. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23705. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23706. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23707. rigCamera.setTarget(newFocalTarget);
  23708. };
  23709. /**
  23710. * Gets the current object class name.
  23711. * @return the class name
  23712. */
  23713. TargetCamera.prototype.getClassName = function () {
  23714. return "TargetCamera";
  23715. };
  23716. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23717. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23718. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23719. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23720. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23721. ], TargetCamera.prototype, "rotation", void 0);
  23722. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23723. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23724. ], TargetCamera.prototype, "speed", void 0);
  23725. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23726. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23727. ], TargetCamera.prototype, "lockedTarget", void 0);
  23728. return TargetCamera;
  23729. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23730. /***/ }),
  23731. /***/ "./Cameras/touchCamera.ts":
  23732. /*!********************************!*\
  23733. !*** ./Cameras/touchCamera.ts ***!
  23734. \********************************/
  23735. /*! exports provided: TouchCamera */
  23736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23737. "use strict";
  23738. __webpack_require__.r(__webpack_exports__);
  23739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23740. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23741. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23742. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23743. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23744. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23745. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23746. });
  23747. /**
  23748. * This represents a FPS type of camera controlled by touch.
  23749. * This is like a universal camera minus the Gamepad controls.
  23750. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23751. */
  23752. var TouchCamera = /** @class */ (function (_super) {
  23753. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23754. /**
  23755. * Instantiates a new touch camera.
  23756. * This represents a FPS type of camera controlled by touch.
  23757. * This is like a universal camera minus the Gamepad controls.
  23758. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23759. * @param name Define the name of the camera in the scene
  23760. * @param position Define the start position of the camera in the scene
  23761. * @param scene Define the scene the camera belongs to
  23762. */
  23763. function TouchCamera(name, position, scene) {
  23764. var _this = _super.call(this, name, position, scene) || this;
  23765. _this.inputs.addTouch();
  23766. _this._setupInputs();
  23767. return _this;
  23768. }
  23769. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23770. /**
  23771. * Defines the touch sensibility for rotation.
  23772. * The higher the faster.
  23773. */
  23774. get: function () {
  23775. var touch = this.inputs.attached["touch"];
  23776. if (touch) {
  23777. return touch.touchAngularSensibility;
  23778. }
  23779. return 0;
  23780. },
  23781. set: function (value) {
  23782. var touch = this.inputs.attached["touch"];
  23783. if (touch) {
  23784. touch.touchAngularSensibility = value;
  23785. }
  23786. },
  23787. enumerable: true,
  23788. configurable: true
  23789. });
  23790. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23791. /**
  23792. * Defines the touch sensibility for move.
  23793. * The higher the faster.
  23794. */
  23795. get: function () {
  23796. var touch = this.inputs.attached["touch"];
  23797. if (touch) {
  23798. return touch.touchMoveSensibility;
  23799. }
  23800. return 0;
  23801. },
  23802. set: function (value) {
  23803. var touch = this.inputs.attached["touch"];
  23804. if (touch) {
  23805. touch.touchMoveSensibility = value;
  23806. }
  23807. },
  23808. enumerable: true,
  23809. configurable: true
  23810. });
  23811. /**
  23812. * Gets the current object class name.
  23813. * @return the class name
  23814. */
  23815. TouchCamera.prototype.getClassName = function () {
  23816. return "TouchCamera";
  23817. };
  23818. /** @hidden */
  23819. TouchCamera.prototype._setupInputs = function () {
  23820. var mouse = this.inputs.attached["mouse"];
  23821. if (mouse) {
  23822. mouse.touchEnabled = false;
  23823. }
  23824. };
  23825. return TouchCamera;
  23826. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23827. /***/ }),
  23828. /***/ "./Cameras/universalCamera.ts":
  23829. /*!************************************!*\
  23830. !*** ./Cameras/universalCamera.ts ***!
  23831. \************************************/
  23832. /*! exports provided: UniversalCamera */
  23833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23834. "use strict";
  23835. __webpack_require__.r(__webpack_exports__);
  23836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23837. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23838. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23839. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23840. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23841. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23842. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23843. // Forcing to use the Universal camera
  23844. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23845. });
  23846. /**
  23847. * 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,
  23848. * which still works and will still be found in many Playgrounds.
  23849. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23850. */
  23851. var UniversalCamera = /** @class */ (function (_super) {
  23852. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23853. /**
  23854. * 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,
  23855. * which still works and will still be found in many Playgrounds.
  23856. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23857. * @param name Define the name of the camera in the scene
  23858. * @param position Define the start position of the camera in the scene
  23859. * @param scene Define the scene the camera belongs to
  23860. */
  23861. function UniversalCamera(name, position, scene) {
  23862. var _this = _super.call(this, name, position, scene) || this;
  23863. _this.inputs.addGamepad();
  23864. return _this;
  23865. }
  23866. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23867. /**
  23868. * Defines the gamepad rotation sensiblity.
  23869. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23870. */
  23871. get: function () {
  23872. var gamepad = this.inputs.attached["gamepad"];
  23873. if (gamepad) {
  23874. return gamepad.gamepadAngularSensibility;
  23875. }
  23876. return 0;
  23877. },
  23878. set: function (value) {
  23879. var gamepad = this.inputs.attached["gamepad"];
  23880. if (gamepad) {
  23881. gamepad.gamepadAngularSensibility = value;
  23882. }
  23883. },
  23884. enumerable: true,
  23885. configurable: true
  23886. });
  23887. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23888. /**
  23889. * Defines the gamepad move sensiblity.
  23890. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23891. */
  23892. get: function () {
  23893. var gamepad = this.inputs.attached["gamepad"];
  23894. if (gamepad) {
  23895. return gamepad.gamepadMoveSensibility;
  23896. }
  23897. return 0;
  23898. },
  23899. set: function (value) {
  23900. var gamepad = this.inputs.attached["gamepad"];
  23901. if (gamepad) {
  23902. gamepad.gamepadMoveSensibility = value;
  23903. }
  23904. },
  23905. enumerable: true,
  23906. configurable: true
  23907. });
  23908. /**
  23909. * Gets the current object class name.
  23910. * @return the class name
  23911. */
  23912. UniversalCamera.prototype.getClassName = function () {
  23913. return "UniversalCamera";
  23914. };
  23915. return UniversalCamera;
  23916. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23917. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23918. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23919. };
  23920. /***/ }),
  23921. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23922. /*!*******************************************!*\
  23923. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23924. \*******************************************/
  23925. /*! exports provided: VirtualJoysticksCamera */
  23926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23927. "use strict";
  23928. __webpack_require__.r(__webpack_exports__);
  23929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23930. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23931. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23932. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23933. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23934. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23935. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23936. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23937. });
  23938. /**
  23939. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23940. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23941. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23942. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23943. */
  23944. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23945. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23946. /**
  23947. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23948. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23949. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23950. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23951. * @param name Define the name of the camera in the scene
  23952. * @param position Define the start position of the camera in the scene
  23953. * @param scene Define the scene the camera belongs to
  23954. */
  23955. function VirtualJoysticksCamera(name, position, scene) {
  23956. var _this = _super.call(this, name, position, scene) || this;
  23957. _this.inputs.addVirtualJoystick();
  23958. return _this;
  23959. }
  23960. /**
  23961. * Gets the current object class name.
  23962. * @return the class name
  23963. */
  23964. VirtualJoysticksCamera.prototype.getClassName = function () {
  23965. return "VirtualJoysticksCamera";
  23966. };
  23967. return VirtualJoysticksCamera;
  23968. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23969. /***/ }),
  23970. /***/ "./Collisions/collider.ts":
  23971. /*!********************************!*\
  23972. !*** ./Collisions/collider.ts ***!
  23973. \********************************/
  23974. /*! exports provided: Collider */
  23975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23976. "use strict";
  23977. __webpack_require__.r(__webpack_exports__);
  23978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23980. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23981. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23982. return false;
  23983. }
  23984. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23985. return false;
  23986. }
  23987. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23988. return false;
  23989. }
  23990. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23991. return false;
  23992. }
  23993. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23994. return false;
  23995. }
  23996. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23997. return false;
  23998. }
  23999. return true;
  24000. };
  24001. var getLowestRoot = (function () {
  24002. var result = { root: 0, found: false };
  24003. return function (a, b, c, maxR) {
  24004. result.root = 0;
  24005. result.found = false;
  24006. var determinant = b * b - 4.0 * a * c;
  24007. if (determinant < 0) {
  24008. return result;
  24009. }
  24010. var sqrtD = Math.sqrt(determinant);
  24011. var r1 = (-b - sqrtD) / (2.0 * a);
  24012. var r2 = (-b + sqrtD) / (2.0 * a);
  24013. if (r1 > r2) {
  24014. var temp = r2;
  24015. r2 = r1;
  24016. r1 = temp;
  24017. }
  24018. if (r1 > 0 && r1 < maxR) {
  24019. result.root = r1;
  24020. result.found = true;
  24021. return result;
  24022. }
  24023. if (r2 > 0 && r2 < maxR) {
  24024. result.root = r2;
  24025. result.found = true;
  24026. return result;
  24027. }
  24028. return result;
  24029. };
  24030. })();
  24031. /** @hidden */
  24032. var Collider = /** @class */ (function () {
  24033. function Collider() {
  24034. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24035. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24036. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24037. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24038. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24039. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24040. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24041. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24042. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24043. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24044. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24045. /** @hidden */
  24046. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  24047. /** @hidden */
  24048. this._retry = 0;
  24049. /** @hidden */
  24050. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24051. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24052. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24053. this._collisionMask = -1;
  24054. }
  24055. Object.defineProperty(Collider.prototype, "collisionMask", {
  24056. get: function () {
  24057. return this._collisionMask;
  24058. },
  24059. set: function (mask) {
  24060. this._collisionMask = !isNaN(mask) ? mask : -1;
  24061. },
  24062. enumerable: true,
  24063. configurable: true
  24064. });
  24065. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  24066. /**
  24067. * Gets the plane normal used to compute the sliding response (in local space)
  24068. */
  24069. get: function () {
  24070. return this._slidePlaneNormal;
  24071. },
  24072. enumerable: true,
  24073. configurable: true
  24074. });
  24075. // Methods
  24076. /** @hidden */
  24077. Collider.prototype._initialize = function (source, dir, e) {
  24078. this._velocity = dir;
  24079. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  24080. this._basePoint = source;
  24081. source.multiplyToRef(this._radius, this._basePointWorld);
  24082. dir.multiplyToRef(this._radius, this._velocityWorld);
  24083. this._velocityWorldLength = this._velocityWorld.length();
  24084. this._epsilon = e;
  24085. this.collisionFound = false;
  24086. };
  24087. /** @hidden */
  24088. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  24089. pa.subtractToRef(point, this._tempVector);
  24090. pb.subtractToRef(point, this._tempVector2);
  24091. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  24092. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24093. if (d < 0) {
  24094. return false;
  24095. }
  24096. pc.subtractToRef(point, this._tempVector3);
  24097. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  24098. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24099. if (d < 0) {
  24100. return false;
  24101. }
  24102. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  24103. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24104. return d >= 0;
  24105. };
  24106. /** @hidden */
  24107. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  24108. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  24109. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  24110. if (distance > this._velocityWorldLength + max + sphereRadius) {
  24111. return false;
  24112. }
  24113. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  24114. return false;
  24115. }
  24116. return true;
  24117. };
  24118. /** @hidden */
  24119. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  24120. var t0;
  24121. var embeddedInPlane = false;
  24122. //defensive programming, actually not needed.
  24123. if (!trianglePlaneArray) {
  24124. trianglePlaneArray = [];
  24125. }
  24126. if (!trianglePlaneArray[faceIndex]) {
  24127. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  24128. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  24129. }
  24130. var trianglePlane = trianglePlaneArray[faceIndex];
  24131. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  24132. return;
  24133. }
  24134. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  24135. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  24136. if (normalDotVelocity == 0) {
  24137. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  24138. return;
  24139. }
  24140. embeddedInPlane = true;
  24141. t0 = 0;
  24142. }
  24143. else {
  24144. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24145. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24146. if (t0 > t1) {
  24147. var temp = t1;
  24148. t1 = t0;
  24149. t0 = temp;
  24150. }
  24151. if (t0 > 1.0 || t1 < 0.0) {
  24152. return;
  24153. }
  24154. if (t0 < 0) {
  24155. t0 = 0;
  24156. }
  24157. if (t0 > 1.0) {
  24158. t0 = 1.0;
  24159. }
  24160. }
  24161. this._collisionPoint.copyFromFloats(0, 0, 0);
  24162. var found = false;
  24163. var t = 1.0;
  24164. if (!embeddedInPlane) {
  24165. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  24166. this._velocity.scaleToRef(t0, this._tempVector);
  24167. this._planeIntersectionPoint.addInPlace(this._tempVector);
  24168. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  24169. found = true;
  24170. t = t0;
  24171. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  24172. }
  24173. }
  24174. if (!found) {
  24175. var velocitySquaredLength = this._velocity.lengthSquared();
  24176. var a = velocitySquaredLength;
  24177. this._basePoint.subtractToRef(p1, this._tempVector);
  24178. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24179. var c = this._tempVector.lengthSquared() - 1.0;
  24180. var lowestRoot = getLowestRoot(a, b, c, t);
  24181. if (lowestRoot.found) {
  24182. t = lowestRoot.root;
  24183. found = true;
  24184. this._collisionPoint.copyFrom(p1);
  24185. }
  24186. this._basePoint.subtractToRef(p2, this._tempVector);
  24187. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24188. c = this._tempVector.lengthSquared() - 1.0;
  24189. lowestRoot = getLowestRoot(a, b, c, t);
  24190. if (lowestRoot.found) {
  24191. t = lowestRoot.root;
  24192. found = true;
  24193. this._collisionPoint.copyFrom(p2);
  24194. }
  24195. this._basePoint.subtractToRef(p3, this._tempVector);
  24196. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24197. c = this._tempVector.lengthSquared() - 1.0;
  24198. lowestRoot = getLowestRoot(a, b, c, t);
  24199. if (lowestRoot.found) {
  24200. t = lowestRoot.root;
  24201. found = true;
  24202. this._collisionPoint.copyFrom(p3);
  24203. }
  24204. p2.subtractToRef(p1, this._edge);
  24205. p1.subtractToRef(this._basePoint, this._baseToVertex);
  24206. var edgeSquaredLength = this._edge.lengthSquared();
  24207. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24208. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24209. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24210. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24211. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24212. lowestRoot = getLowestRoot(a, b, c, t);
  24213. if (lowestRoot.found) {
  24214. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24215. if (f >= 0.0 && f <= 1.0) {
  24216. t = lowestRoot.root;
  24217. found = true;
  24218. this._edge.scaleInPlace(f);
  24219. p1.addToRef(this._edge, this._collisionPoint);
  24220. }
  24221. }
  24222. p3.subtractToRef(p2, this._edge);
  24223. p2.subtractToRef(this._basePoint, this._baseToVertex);
  24224. edgeSquaredLength = this._edge.lengthSquared();
  24225. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24226. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24227. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24228. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24229. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24230. lowestRoot = getLowestRoot(a, b, c, t);
  24231. if (lowestRoot.found) {
  24232. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24233. if (f >= 0.0 && f <= 1.0) {
  24234. t = lowestRoot.root;
  24235. found = true;
  24236. this._edge.scaleInPlace(f);
  24237. p2.addToRef(this._edge, this._collisionPoint);
  24238. }
  24239. }
  24240. p1.subtractToRef(p3, this._edge);
  24241. p3.subtractToRef(this._basePoint, this._baseToVertex);
  24242. edgeSquaredLength = this._edge.lengthSquared();
  24243. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24244. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24245. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24246. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24247. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24248. lowestRoot = getLowestRoot(a, b, c, t);
  24249. if (lowestRoot.found) {
  24250. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24251. if (f >= 0.0 && f <= 1.0) {
  24252. t = lowestRoot.root;
  24253. found = true;
  24254. this._edge.scaleInPlace(f);
  24255. p3.addToRef(this._edge, this._collisionPoint);
  24256. }
  24257. }
  24258. }
  24259. if (found) {
  24260. var distToCollision = t * this._velocity.length();
  24261. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  24262. if (!this.intersectionPoint) {
  24263. this.intersectionPoint = this._collisionPoint.clone();
  24264. }
  24265. else {
  24266. this.intersectionPoint.copyFrom(this._collisionPoint);
  24267. }
  24268. this._nearestDistance = distToCollision;
  24269. this.collisionFound = true;
  24270. }
  24271. }
  24272. };
  24273. /** @hidden */
  24274. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  24275. for (var i = indexStart; i < indexEnd; i += 3) {
  24276. var p1 = pts[indices[i] - decal];
  24277. var p2 = pts[indices[i + 1] - decal];
  24278. var p3 = pts[indices[i + 2] - decal];
  24279. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  24280. }
  24281. };
  24282. /** @hidden */
  24283. Collider.prototype._getResponse = function (pos, vel) {
  24284. pos.addToRef(vel, this._destinationPoint);
  24285. vel.scaleInPlace((this._nearestDistance / vel.length()));
  24286. this._basePoint.addToRef(vel, pos);
  24287. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  24288. this._slidePlaneNormal.normalize();
  24289. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  24290. pos.addInPlace(this._displacementVector);
  24291. this.intersectionPoint.addInPlace(this._displacementVector);
  24292. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  24293. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  24294. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  24295. };
  24296. return Collider;
  24297. }());
  24298. /***/ }),
  24299. /***/ "./Collisions/collisionCoordinator.ts":
  24300. /*!********************************************!*\
  24301. !*** ./Collisions/collisionCoordinator.ts ***!
  24302. \********************************************/
  24303. /*! exports provided: DefaultCollisionCoordinator */
  24304. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24305. "use strict";
  24306. __webpack_require__.r(__webpack_exports__);
  24307. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  24308. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  24309. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24310. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  24311. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24312. /** @hidden */
  24313. var DefaultCollisionCoordinator = /** @class */ (function () {
  24314. function DefaultCollisionCoordinator() {
  24315. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24316. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24317. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24318. }
  24319. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  24320. position.divideToRef(collider._radius, this._scaledPosition);
  24321. displacement.divideToRef(collider._radius, this._scaledVelocity);
  24322. collider.collidedMesh = null;
  24323. collider._retry = 0;
  24324. collider._initialVelocity = this._scaledVelocity;
  24325. collider._initialPosition = this._scaledPosition;
  24326. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  24327. this._finalPosition.multiplyInPlace(collider._radius);
  24328. //run the callback
  24329. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  24330. };
  24331. DefaultCollisionCoordinator.prototype.createCollider = function () {
  24332. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  24333. };
  24334. DefaultCollisionCoordinator.prototype.init = function (scene) {
  24335. this._scene = scene;
  24336. };
  24337. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  24338. if (excludedMesh === void 0) { excludedMesh = null; }
  24339. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  24340. if (collider._retry >= maximumRetry) {
  24341. finalPosition.copyFrom(position);
  24342. return;
  24343. }
  24344. // Check if this is a mesh else camera or -1
  24345. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  24346. collider._initialize(position, velocity, closeDistance);
  24347. // Check all meshes
  24348. for (var index = 0; index < this._scene.meshes.length; index++) {
  24349. var mesh = this._scene.meshes[index];
  24350. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  24351. mesh._checkCollision(collider);
  24352. }
  24353. }
  24354. if (!collider.collisionFound) {
  24355. position.addToRef(velocity, finalPosition);
  24356. return;
  24357. }
  24358. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  24359. collider._getResponse(position, velocity);
  24360. }
  24361. if (velocity.length() <= closeDistance) {
  24362. finalPosition.copyFrom(position);
  24363. return;
  24364. }
  24365. collider._retry++;
  24366. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  24367. };
  24368. return DefaultCollisionCoordinator;
  24369. }());
  24370. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  24371. return new DefaultCollisionCoordinator();
  24372. };
  24373. /***/ }),
  24374. /***/ "./Collisions/index.ts":
  24375. /*!*****************************!*\
  24376. !*** ./Collisions/index.ts ***!
  24377. \*****************************/
  24378. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  24379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24380. "use strict";
  24381. __webpack_require__.r(__webpack_exports__);
  24382. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  24384. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  24385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  24386. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  24387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  24388. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  24390. /***/ }),
  24391. /***/ "./Collisions/intersectionInfo.ts":
  24392. /*!****************************************!*\
  24393. !*** ./Collisions/intersectionInfo.ts ***!
  24394. \****************************************/
  24395. /*! exports provided: IntersectionInfo */
  24396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24397. "use strict";
  24398. __webpack_require__.r(__webpack_exports__);
  24399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  24400. /**
  24401. * @hidden
  24402. */
  24403. var IntersectionInfo = /** @class */ (function () {
  24404. function IntersectionInfo(bu, bv, distance) {
  24405. this.bu = bu;
  24406. this.bv = bv;
  24407. this.distance = distance;
  24408. this.faceId = 0;
  24409. this.subMeshId = 0;
  24410. }
  24411. return IntersectionInfo;
  24412. }());
  24413. /***/ }),
  24414. /***/ "./Collisions/pickingInfo.ts":
  24415. /*!***********************************!*\
  24416. !*** ./Collisions/pickingInfo.ts ***!
  24417. \***********************************/
  24418. /*! exports provided: PickingInfo */
  24419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24420. "use strict";
  24421. __webpack_require__.r(__webpack_exports__);
  24422. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  24423. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24424. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  24425. /**
  24426. * Information about the result of picking within a scene
  24427. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24428. */
  24429. var PickingInfo = /** @class */ (function () {
  24430. function PickingInfo() {
  24431. /** @hidden */
  24432. this._pickingUnavailable = false;
  24433. /**
  24434. * If the pick collided with an object
  24435. */
  24436. this.hit = false;
  24437. /**
  24438. * Distance away where the pick collided
  24439. */
  24440. this.distance = 0;
  24441. /**
  24442. * The location of pick collision
  24443. */
  24444. this.pickedPoint = null;
  24445. /**
  24446. * The mesh corresponding the the pick collision
  24447. */
  24448. this.pickedMesh = null;
  24449. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  24450. this.bu = 0;
  24451. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  24452. this.bv = 0;
  24453. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24454. this.faceId = -1;
  24455. /** Id of the the submesh that was picked */
  24456. this.subMeshId = 0;
  24457. /** If a sprite was picked, this will be the sprite the pick collided with */
  24458. this.pickedSprite = null;
  24459. /**
  24460. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24461. */
  24462. this.originMesh = null;
  24463. /**
  24464. * The ray that was used to perform the picking.
  24465. */
  24466. this.ray = null;
  24467. }
  24468. /**
  24469. * Gets the normal correspodning to the face the pick collided with
  24470. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24471. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24472. * @returns The normal correspodning to the face the pick collided with
  24473. */
  24474. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  24475. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  24476. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  24477. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  24478. return null;
  24479. }
  24480. var indices = this.pickedMesh.getIndices();
  24481. if (!indices) {
  24482. return null;
  24483. }
  24484. var result;
  24485. if (useVerticesNormals) {
  24486. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  24487. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  24488. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  24489. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  24490. normal0 = normal0.scale(this.bu);
  24491. normal1 = normal1.scale(this.bv);
  24492. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  24493. 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);
  24494. }
  24495. else {
  24496. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  24497. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  24498. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  24499. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  24500. var p1p2 = vertex1.subtract(vertex2);
  24501. var p3p2 = vertex3.subtract(vertex2);
  24502. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  24503. }
  24504. if (useWorldCoordinates) {
  24505. var wm = this.pickedMesh.getWorldMatrix();
  24506. if (this.pickedMesh.nonUniformScaling) {
  24507. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  24508. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  24509. wm.setTranslationFromFloats(0, 0, 0);
  24510. wm.invert();
  24511. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  24512. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  24513. }
  24514. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  24515. }
  24516. result.normalize();
  24517. return result;
  24518. };
  24519. /**
  24520. * Gets the texture coordinates of where the pick occured
  24521. * @returns the vector containing the coordnates of the texture
  24522. */
  24523. PickingInfo.prototype.getTextureCoordinates = function () {
  24524. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  24525. return null;
  24526. }
  24527. var indices = this.pickedMesh.getIndices();
  24528. if (!indices) {
  24529. return null;
  24530. }
  24531. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  24532. if (!uvs) {
  24533. return null;
  24534. }
  24535. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  24536. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  24537. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  24538. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  24539. uv1 = uv1.scale(this.bu);
  24540. uv2 = uv2.scale(this.bv);
  24541. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  24542. };
  24543. return PickingInfo;
  24544. }());
  24545. /***/ }),
  24546. /***/ "./Culling/Octrees/index.ts":
  24547. /*!**********************************!*\
  24548. !*** ./Culling/Octrees/index.ts ***!
  24549. \**********************************/
  24550. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  24551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24552. "use strict";
  24553. __webpack_require__.r(__webpack_exports__);
  24554. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  24556. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  24558. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  24559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  24560. /***/ }),
  24561. /***/ "./Culling/Octrees/octree.ts":
  24562. /*!***********************************!*\
  24563. !*** ./Culling/Octrees/octree.ts ***!
  24564. \***********************************/
  24565. /*! exports provided: Octree */
  24566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24567. "use strict";
  24568. __webpack_require__.r(__webpack_exports__);
  24569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  24570. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  24571. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24572. /**
  24573. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  24574. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24575. */
  24576. var Octree = /** @class */ (function () {
  24577. /**
  24578. * Creates a octree
  24579. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24580. * @param creationFunc function to be used to instatiate the octree
  24581. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  24582. * @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.)
  24583. */
  24584. function Octree(creationFunc, maxBlockCapacity,
  24585. /** 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.) */
  24586. maxDepth) {
  24587. if (maxDepth === void 0) { maxDepth = 2; }
  24588. this.maxDepth = maxDepth;
  24589. /**
  24590. * Content stored in the octree
  24591. */
  24592. this.dynamicContent = new Array();
  24593. this._maxBlockCapacity = maxBlockCapacity || 64;
  24594. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  24595. this._creationFunc = creationFunc;
  24596. }
  24597. // Methods
  24598. /**
  24599. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  24600. * @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);
  24601. * @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);
  24602. * @param entries meshes to be added to the octree blocks
  24603. */
  24604. Octree.prototype.update = function (worldMin, worldMax, entries) {
  24605. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  24606. };
  24607. /**
  24608. * Adds a mesh to the octree
  24609. * @param entry Mesh to add to the octree
  24610. */
  24611. Octree.prototype.addMesh = function (entry) {
  24612. for (var index = 0; index < this.blocks.length; index++) {
  24613. var block = this.blocks[index];
  24614. block.addEntry(entry);
  24615. }
  24616. };
  24617. /**
  24618. * Remove an element from the octree
  24619. * @param entry defines the element to remove
  24620. */
  24621. Octree.prototype.removeMesh = function (entry) {
  24622. for (var index = 0; index < this.blocks.length; index++) {
  24623. var block = this.blocks[index];
  24624. block.removeEntry(entry);
  24625. }
  24626. };
  24627. /**
  24628. * Selects an array of meshes within the frustum
  24629. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  24630. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  24631. * @returns array of meshes within the frustum
  24632. */
  24633. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  24634. this._selectionContent.reset();
  24635. for (var index = 0; index < this.blocks.length; index++) {
  24636. var block = this.blocks[index];
  24637. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  24638. }
  24639. if (allowDuplicate) {
  24640. this._selectionContent.concat(this.dynamicContent);
  24641. }
  24642. else {
  24643. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24644. }
  24645. return this._selectionContent;
  24646. };
  24647. /**
  24648. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  24649. * @param sphereCenter defines the bounding sphere center
  24650. * @param sphereRadius defines the bounding sphere radius
  24651. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24652. * @returns an array of objects that intersect the sphere
  24653. */
  24654. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  24655. this._selectionContent.reset();
  24656. for (var index = 0; index < this.blocks.length; index++) {
  24657. var block = this.blocks[index];
  24658. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  24659. }
  24660. if (allowDuplicate) {
  24661. this._selectionContent.concat(this.dynamicContent);
  24662. }
  24663. else {
  24664. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24665. }
  24666. return this._selectionContent;
  24667. };
  24668. /**
  24669. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  24670. * @param ray defines the ray to test with
  24671. * @returns array of intersected objects
  24672. */
  24673. Octree.prototype.intersectsRay = function (ray) {
  24674. this._selectionContent.reset();
  24675. for (var index = 0; index < this.blocks.length; index++) {
  24676. var block = this.blocks[index];
  24677. block.intersectsRay(ray, this._selectionContent);
  24678. }
  24679. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24680. return this._selectionContent;
  24681. };
  24682. /**
  24683. * Adds a mesh into the octree block if it intersects the block
  24684. */
  24685. Octree.CreationFuncForMeshes = function (entry, block) {
  24686. var boundingInfo = entry.getBoundingInfo();
  24687. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24688. block.entries.push(entry);
  24689. }
  24690. };
  24691. /**
  24692. * Adds a submesh into the octree block if it intersects the block
  24693. */
  24694. Octree.CreationFuncForSubMeshes = function (entry, block) {
  24695. var boundingInfo = entry.getBoundingInfo();
  24696. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24697. block.entries.push(entry);
  24698. }
  24699. };
  24700. return Octree;
  24701. }());
  24702. /***/ }),
  24703. /***/ "./Culling/Octrees/octreeBlock.ts":
  24704. /*!****************************************!*\
  24705. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24706. \****************************************/
  24707. /*! exports provided: OctreeBlock */
  24708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24709. "use strict";
  24710. __webpack_require__.r(__webpack_exports__);
  24711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24712. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24713. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24714. /**
  24715. * Class used to store a cell in an octree
  24716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24717. */
  24718. var OctreeBlock = /** @class */ (function () {
  24719. /**
  24720. * Creates a new block
  24721. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24722. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24723. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24724. * @param depth defines the current depth of this block in the octree
  24725. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24726. * @param creationFunc defines a callback to call when an element is added to the block
  24727. */
  24728. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24729. /**
  24730. * Gets the content of the current block
  24731. */
  24732. this.entries = new Array();
  24733. this._boundingVectors = new Array();
  24734. this._capacity = capacity;
  24735. this._depth = depth;
  24736. this._maxDepth = maxDepth;
  24737. this._creationFunc = creationFunc;
  24738. this._minPoint = minPoint;
  24739. this._maxPoint = maxPoint;
  24740. this._boundingVectors.push(minPoint.clone());
  24741. this._boundingVectors.push(maxPoint.clone());
  24742. this._boundingVectors.push(minPoint.clone());
  24743. this._boundingVectors[2].x = maxPoint.x;
  24744. this._boundingVectors.push(minPoint.clone());
  24745. this._boundingVectors[3].y = maxPoint.y;
  24746. this._boundingVectors.push(minPoint.clone());
  24747. this._boundingVectors[4].z = maxPoint.z;
  24748. this._boundingVectors.push(maxPoint.clone());
  24749. this._boundingVectors[5].z = minPoint.z;
  24750. this._boundingVectors.push(maxPoint.clone());
  24751. this._boundingVectors[6].x = minPoint.x;
  24752. this._boundingVectors.push(maxPoint.clone());
  24753. this._boundingVectors[7].y = minPoint.y;
  24754. }
  24755. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24756. // Property
  24757. /**
  24758. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24759. */
  24760. get: function () {
  24761. return this._capacity;
  24762. },
  24763. enumerable: true,
  24764. configurable: true
  24765. });
  24766. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24767. /**
  24768. * Gets the minimum vector (in world space) of the block's bounding box
  24769. */
  24770. get: function () {
  24771. return this._minPoint;
  24772. },
  24773. enumerable: true,
  24774. configurable: true
  24775. });
  24776. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24777. /**
  24778. * Gets the maximum vector (in world space) of the block's bounding box
  24779. */
  24780. get: function () {
  24781. return this._maxPoint;
  24782. },
  24783. enumerable: true,
  24784. configurable: true
  24785. });
  24786. // Methods
  24787. /**
  24788. * Add a new element to this block
  24789. * @param entry defines the element to add
  24790. */
  24791. OctreeBlock.prototype.addEntry = function (entry) {
  24792. if (this.blocks) {
  24793. for (var index = 0; index < this.blocks.length; index++) {
  24794. var block = this.blocks[index];
  24795. block.addEntry(entry);
  24796. }
  24797. return;
  24798. }
  24799. this._creationFunc(entry, this);
  24800. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24801. this.createInnerBlocks();
  24802. }
  24803. };
  24804. /**
  24805. * Remove an element from this block
  24806. * @param entry defines the element to remove
  24807. */
  24808. OctreeBlock.prototype.removeEntry = function (entry) {
  24809. if (this.blocks) {
  24810. for (var index = 0; index < this.blocks.length; index++) {
  24811. var block = this.blocks[index];
  24812. block.removeEntry(entry);
  24813. }
  24814. return;
  24815. }
  24816. var entryIndex = this.entries.indexOf(entry);
  24817. if (entryIndex > -1) {
  24818. this.entries.splice(entryIndex, 1);
  24819. }
  24820. };
  24821. /**
  24822. * Add an array of elements to this block
  24823. * @param entries defines the array of elements to add
  24824. */
  24825. OctreeBlock.prototype.addEntries = function (entries) {
  24826. for (var index = 0; index < entries.length; index++) {
  24827. var mesh = entries[index];
  24828. this.addEntry(mesh);
  24829. }
  24830. };
  24831. /**
  24832. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24833. * @param frustumPlanes defines the frustum planes to test
  24834. * @param selection defines the array to store current content if selection is positive
  24835. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24836. */
  24837. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24838. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24839. if (this.blocks) {
  24840. for (var index = 0; index < this.blocks.length; index++) {
  24841. var block = this.blocks[index];
  24842. block.select(frustumPlanes, selection, allowDuplicate);
  24843. }
  24844. return;
  24845. }
  24846. if (allowDuplicate) {
  24847. selection.concat(this.entries);
  24848. }
  24849. else {
  24850. selection.concatWithNoDuplicate(this.entries);
  24851. }
  24852. }
  24853. };
  24854. /**
  24855. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24856. * @param sphereCenter defines the bounding sphere center
  24857. * @param sphereRadius defines the bounding sphere radius
  24858. * @param selection defines the array to store current content if selection is positive
  24859. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24860. */
  24861. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24862. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24863. if (this.blocks) {
  24864. for (var index = 0; index < this.blocks.length; index++) {
  24865. var block = this.blocks[index];
  24866. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24867. }
  24868. return;
  24869. }
  24870. if (allowDuplicate) {
  24871. selection.concat(this.entries);
  24872. }
  24873. else {
  24874. selection.concatWithNoDuplicate(this.entries);
  24875. }
  24876. }
  24877. };
  24878. /**
  24879. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24880. * @param ray defines the ray to test with
  24881. * @param selection defines the array to store current content if selection is positive
  24882. */
  24883. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24884. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24885. if (this.blocks) {
  24886. for (var index = 0; index < this.blocks.length; index++) {
  24887. var block = this.blocks[index];
  24888. block.intersectsRay(ray, selection);
  24889. }
  24890. return;
  24891. }
  24892. selection.concatWithNoDuplicate(this.entries);
  24893. }
  24894. };
  24895. /**
  24896. * Subdivide the content into child blocks (this block will then be empty)
  24897. */
  24898. OctreeBlock.prototype.createInnerBlocks = function () {
  24899. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24900. };
  24901. /**
  24902. * @hidden
  24903. */
  24904. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24905. target.blocks = new Array();
  24906. 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);
  24907. // Segmenting space
  24908. for (var x = 0; x < 2; x++) {
  24909. for (var y = 0; y < 2; y++) {
  24910. for (var z = 0; z < 2; z++) {
  24911. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24912. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24913. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24914. block.addEntries(entries);
  24915. target.blocks.push(block);
  24916. }
  24917. }
  24918. }
  24919. };
  24920. return OctreeBlock;
  24921. }());
  24922. /***/ }),
  24923. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24924. /*!*************************************************!*\
  24925. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24926. \*************************************************/
  24927. /*! exports provided: OctreeSceneComponent */
  24928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24929. "use strict";
  24930. __webpack_require__.r(__webpack_exports__);
  24931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24932. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24933. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24934. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24935. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24936. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24937. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24938. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24939. if (maxCapacity === void 0) { maxCapacity = 64; }
  24940. if (maxDepth === void 0) { maxDepth = 2; }
  24941. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24942. if (!component) {
  24943. component = new OctreeSceneComponent(this);
  24944. this._addComponent(component);
  24945. }
  24946. if (!this._selectionOctree) {
  24947. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24948. }
  24949. var worldExtends = this.getWorldExtends();
  24950. // Update octree
  24951. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24952. return this._selectionOctree;
  24953. };
  24954. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24955. get: function () {
  24956. return this._selectionOctree;
  24957. },
  24958. enumerable: true,
  24959. configurable: true
  24960. });
  24961. /**
  24962. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24963. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24964. * @param maxCapacity defines the maximum size of each block (64 by default)
  24965. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24966. * @returns the new octree
  24967. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24969. */
  24970. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24971. if (maxCapacity === void 0) { maxCapacity = 64; }
  24972. if (maxDepth === void 0) { maxDepth = 2; }
  24973. var scene = this.getScene();
  24974. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24975. if (!component) {
  24976. component = new OctreeSceneComponent(scene);
  24977. scene._addComponent(component);
  24978. }
  24979. if (!this._submeshesOctree) {
  24980. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24981. }
  24982. this.computeWorldMatrix(true);
  24983. var boundingInfo = this.getBoundingInfo();
  24984. // Update octree
  24985. var bbox = boundingInfo.boundingBox;
  24986. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24987. return this._submeshesOctree;
  24988. };
  24989. /**
  24990. * Defines the octree scene component responsible to manage any octrees
  24991. * in a given scene.
  24992. */
  24993. var OctreeSceneComponent = /** @class */ (function () {
  24994. /**
  24995. * Creates a new instance of the component for the given scene
  24996. * @param scene Defines the scene to register the component in
  24997. */
  24998. function OctreeSceneComponent(scene) {
  24999. /**
  25000. * The component name helpfull to identify the component in the list of scene components.
  25001. */
  25002. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  25003. /**
  25004. * Indicates if the meshes have been checked to make sure they are isEnabled()
  25005. */
  25006. this.checksIsEnabled = true;
  25007. 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));
  25008. this.scene = scene;
  25009. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  25010. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  25011. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  25012. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  25013. }
  25014. /**
  25015. * Registers the component in a given scene
  25016. */
  25017. OctreeSceneComponent.prototype.register = function () {
  25018. var _this = this;
  25019. this.scene.onMeshRemovedObservable.add(function (mesh) {
  25020. var sceneOctree = _this.scene.selectionOctree;
  25021. if (sceneOctree !== undefined && sceneOctree !== null) {
  25022. var index = sceneOctree.dynamicContent.indexOf(mesh);
  25023. if (index !== -1) {
  25024. sceneOctree.dynamicContent.splice(index, 1);
  25025. }
  25026. }
  25027. });
  25028. this.scene.onMeshImportedObservable.add(function (mesh) {
  25029. var sceneOctree = _this.scene.selectionOctree;
  25030. if (sceneOctree !== undefined && sceneOctree !== null) {
  25031. sceneOctree.addMesh(mesh);
  25032. }
  25033. });
  25034. };
  25035. /**
  25036. * Return the list of active meshes
  25037. * @returns the list of active meshes
  25038. */
  25039. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  25040. if (this.scene._selectionOctree) {
  25041. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  25042. return selection;
  25043. }
  25044. return this.scene._getDefaultMeshCandidates();
  25045. };
  25046. /**
  25047. * Return the list of active sub meshes
  25048. * @param mesh The mesh to get the candidates sub meshes from
  25049. * @returns the list of active sub meshes
  25050. */
  25051. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  25052. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  25053. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  25054. return intersections;
  25055. }
  25056. return this.scene._getDefaultSubMeshCandidates(mesh);
  25057. };
  25058. /**
  25059. * Return the list of sub meshes intersecting with a given local ray
  25060. * @param mesh defines the mesh to find the submesh for
  25061. * @param localRay defines the ray in local space
  25062. * @returns the list of intersecting sub meshes
  25063. */
  25064. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  25065. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  25066. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  25067. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  25068. return intersections;
  25069. }
  25070. return this.scene._getDefaultSubMeshCandidates(mesh);
  25071. };
  25072. /**
  25073. * Return the list of sub meshes colliding with a collider
  25074. * @param mesh defines the mesh to find the submesh for
  25075. * @param collider defines the collider to evaluate the collision against
  25076. * @returns the list of colliding sub meshes
  25077. */
  25078. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  25079. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  25080. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  25081. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  25082. return intersections;
  25083. }
  25084. return this.scene._getDefaultSubMeshCandidates(mesh);
  25085. };
  25086. /**
  25087. * Rebuilds the elements related to this component in case of
  25088. * context lost for instance.
  25089. */
  25090. OctreeSceneComponent.prototype.rebuild = function () {
  25091. // Nothing to do here.
  25092. };
  25093. /**
  25094. * Disposes the component and the associated ressources.
  25095. */
  25096. OctreeSceneComponent.prototype.dispose = function () {
  25097. // Nothing to do here.
  25098. };
  25099. return OctreeSceneComponent;
  25100. }());
  25101. /***/ }),
  25102. /***/ "./Culling/boundingBox.ts":
  25103. /*!********************************!*\
  25104. !*** ./Culling/boundingBox.ts ***!
  25105. \********************************/
  25106. /*! exports provided: BoundingBox */
  25107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25108. "use strict";
  25109. __webpack_require__.r(__webpack_exports__);
  25110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  25111. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25112. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25113. /**
  25114. * Class used to store bounding box information
  25115. */
  25116. var BoundingBox = /** @class */ (function () {
  25117. /**
  25118. * Creates a new bounding box
  25119. * @param min defines the minimum vector (in local space)
  25120. * @param max defines the maximum vector (in local space)
  25121. * @param worldMatrix defines the new world matrix
  25122. */
  25123. function BoundingBox(min, max, worldMatrix) {
  25124. /**
  25125. * Gets the 8 vectors representing the bounding box in local space
  25126. */
  25127. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25128. /**
  25129. * Gets the center of the bounding box in local space
  25130. */
  25131. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25132. /**
  25133. * Gets the center of the bounding box in world space
  25134. */
  25135. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25136. /**
  25137. * Gets the extend size in local space
  25138. */
  25139. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25140. /**
  25141. * Gets the extend size in world space
  25142. */
  25143. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25144. /**
  25145. * Gets the OBB (object bounding box) directions
  25146. */
  25147. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25148. /**
  25149. * Gets the 8 vectors representing the bounding box in world space
  25150. */
  25151. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25152. /**
  25153. * Gets the minimum vector in world space
  25154. */
  25155. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25156. /**
  25157. * Gets the maximum vector in world space
  25158. */
  25159. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25160. /**
  25161. * Gets the minimum vector in local space
  25162. */
  25163. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25164. /**
  25165. * Gets the maximum vector in local space
  25166. */
  25167. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25168. this.reConstruct(min, max, worldMatrix);
  25169. }
  25170. // Methods
  25171. /**
  25172. * Recreates the entire bounding box from scratch as if we call the constructor in place
  25173. * @param min defines the new minimum vector (in local space)
  25174. * @param max defines the new maximum vector (in local space)
  25175. * @param worldMatrix defines the new world matrix
  25176. */
  25177. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  25178. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25179. var vectors = this.vectors;
  25180. this.minimum.copyFromFloats(minX, minY, minZ);
  25181. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  25182. vectors[0].copyFromFloats(minX, minY, minZ);
  25183. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  25184. vectors[2].copyFromFloats(maxX, minY, minZ);
  25185. vectors[3].copyFromFloats(minX, maxY, minZ);
  25186. vectors[4].copyFromFloats(minX, minY, maxZ);
  25187. vectors[5].copyFromFloats(maxX, maxY, minZ);
  25188. vectors[6].copyFromFloats(minX, maxY, maxZ);
  25189. vectors[7].copyFromFloats(maxX, minY, maxZ);
  25190. // OBB
  25191. max.addToRef(min, this.center).scaleInPlace(0.5);
  25192. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  25193. this._worldMatrix = worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly;
  25194. this._update(this._worldMatrix);
  25195. };
  25196. /**
  25197. * Scale the current bounding box by applying a scale factor
  25198. * @param factor defines the scale factor to apply
  25199. * @returns the current bounding box
  25200. */
  25201. BoundingBox.prototype.scale = function (factor) {
  25202. var tmpVectors = BoundingBox.TmpVector3;
  25203. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  25204. var len = diff.length();
  25205. diff.normalizeFromLength(len);
  25206. var distance = len * factor;
  25207. var newRadius = diff.scaleInPlace(distance * 0.5);
  25208. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  25209. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  25210. this.reConstruct(min, max, this._worldMatrix);
  25211. return this;
  25212. };
  25213. /**
  25214. * Gets the world matrix of the bounding box
  25215. * @returns a matrix
  25216. */
  25217. BoundingBox.prototype.getWorldMatrix = function () {
  25218. return this._worldMatrix;
  25219. };
  25220. /** @hidden */
  25221. BoundingBox.prototype._update = function (world) {
  25222. var minWorld = this.minimumWorld;
  25223. var maxWorld = this.maximumWorld;
  25224. var directions = this.directions;
  25225. var vectorsWorld = this.vectorsWorld;
  25226. var vectors = this.vectors;
  25227. if (!world.isIdentity()) {
  25228. minWorld.setAll(Number.MAX_VALUE);
  25229. maxWorld.setAll(-Number.MAX_VALUE);
  25230. for (var index = 0; index < 8; ++index) {
  25231. var v = vectorsWorld[index];
  25232. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  25233. minWorld.minimizeInPlace(v);
  25234. maxWorld.maximizeInPlace(v);
  25235. }
  25236. // Extend
  25237. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  25238. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  25239. }
  25240. else {
  25241. minWorld.copyFrom(this.minimum);
  25242. maxWorld.copyFrom(this.maximum);
  25243. for (var index = 0; index < 8; ++index) {
  25244. vectorsWorld[index].copyFrom(vectors[index]);
  25245. }
  25246. // Extend
  25247. this.extendSizeWorld.copyFrom(this.extendSize);
  25248. this.centerWorld.copyFrom(this.center);
  25249. }
  25250. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  25251. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  25252. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  25253. this._worldMatrix = world;
  25254. };
  25255. /**
  25256. * Tests if the bounding box is intersecting the frustum planes
  25257. * @param frustumPlanes defines the frustum planes to test
  25258. * @returns true if there is an intersection
  25259. */
  25260. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  25261. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  25262. };
  25263. /**
  25264. * Tests if the bounding box is entirely inside the frustum planes
  25265. * @param frustumPlanes defines the frustum planes to test
  25266. * @returns true if there is an inclusion
  25267. */
  25268. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25269. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  25270. };
  25271. /**
  25272. * Tests if a point is inside the bounding box
  25273. * @param point defines the point to test
  25274. * @returns true if the point is inside the bounding box
  25275. */
  25276. BoundingBox.prototype.intersectsPoint = function (point) {
  25277. var min = this.minimumWorld;
  25278. var max = this.maximumWorld;
  25279. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25280. var pointX = point.x, pointY = point.y, pointZ = point.z;
  25281. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  25282. if (maxX - pointX < delta || delta > pointX - minX) {
  25283. return false;
  25284. }
  25285. if (maxY - pointY < delta || delta > pointY - minY) {
  25286. return false;
  25287. }
  25288. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  25289. return false;
  25290. }
  25291. return true;
  25292. };
  25293. /**
  25294. * Tests if the bounding box intersects with a bounding sphere
  25295. * @param sphere defines the sphere to test
  25296. * @returns true if there is an intersection
  25297. */
  25298. BoundingBox.prototype.intersectsSphere = function (sphere) {
  25299. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  25300. };
  25301. /**
  25302. * Tests if the bounding box intersects with a box defined by a min and max vectors
  25303. * @param min defines the min vector to use
  25304. * @param max defines the max vector to use
  25305. * @returns true if there is an intersection
  25306. */
  25307. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  25308. var myMin = this.minimumWorld;
  25309. var myMax = this.maximumWorld;
  25310. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  25311. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25312. if (myMaxX < minX || myMinX > maxX) {
  25313. return false;
  25314. }
  25315. if (myMaxY < minY || myMinY > maxY) {
  25316. return false;
  25317. }
  25318. if (myMaxZ < minZ || myMinZ > maxZ) {
  25319. return false;
  25320. }
  25321. return true;
  25322. };
  25323. // Statics
  25324. /**
  25325. * Tests if two bounding boxes are intersections
  25326. * @param box0 defines the first box to test
  25327. * @param box1 defines the second box to test
  25328. * @returns true if there is an intersection
  25329. */
  25330. BoundingBox.Intersects = function (box0, box1) {
  25331. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  25332. };
  25333. /**
  25334. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  25335. * @param minPoint defines the minimum vector of the bounding box
  25336. * @param maxPoint defines the maximum vector of the bounding box
  25337. * @param sphereCenter defines the sphere center
  25338. * @param sphereRadius defines the sphere radius
  25339. * @returns true if there is an intersection
  25340. */
  25341. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  25342. var vector = BoundingBox.TmpVector3[0];
  25343. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  25344. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  25345. return (num <= (sphereRadius * sphereRadius));
  25346. };
  25347. /**
  25348. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  25349. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25350. * @param frustumPlanes defines the frustum planes to test
  25351. * @return true if there is an inclusion
  25352. */
  25353. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  25354. for (var p = 0; p < 6; ++p) {
  25355. var frustumPlane = frustumPlanes[p];
  25356. for (var i = 0; i < 8; ++i) {
  25357. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  25358. return false;
  25359. }
  25360. }
  25361. }
  25362. return true;
  25363. };
  25364. /**
  25365. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  25366. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25367. * @param frustumPlanes defines the frustum planes to test
  25368. * @return true if there is an intersection
  25369. */
  25370. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  25371. for (var p = 0; p < 6; ++p) {
  25372. var canReturnFalse = true;
  25373. var frustumPlane = frustumPlanes[p];
  25374. for (var i = 0; i < 8; ++i) {
  25375. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  25376. canReturnFalse = false;
  25377. break;
  25378. }
  25379. }
  25380. if (canReturnFalse) {
  25381. return false;
  25382. }
  25383. }
  25384. return true;
  25385. };
  25386. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25387. return BoundingBox;
  25388. }());
  25389. /***/ }),
  25390. /***/ "./Culling/boundingInfo.ts":
  25391. /*!*********************************!*\
  25392. !*** ./Culling/boundingInfo.ts ***!
  25393. \*********************************/
  25394. /*! exports provided: BoundingInfo */
  25395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25396. "use strict";
  25397. __webpack_require__.r(__webpack_exports__);
  25398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  25399. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25400. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25401. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  25402. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25403. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25404. var _result0 = { min: 0, max: 0 };
  25405. var _result1 = { min: 0, max: 0 };
  25406. var computeBoxExtents = function (axis, box, result) {
  25407. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  25408. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  25409. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  25410. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  25411. var r = r0 + r1 + r2;
  25412. result.min = p - r;
  25413. result.max = p + r;
  25414. };
  25415. var axisOverlap = function (axis, box0, box1) {
  25416. computeBoxExtents(axis, box0, _result0);
  25417. computeBoxExtents(axis, box1, _result1);
  25418. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  25419. };
  25420. /**
  25421. * Info for a bounding data of a mesh
  25422. */
  25423. var BoundingInfo = /** @class */ (function () {
  25424. /**
  25425. * Constructs bounding info
  25426. * @param minimum min vector of the bounding box/sphere
  25427. * @param maximum max vector of the bounding box/sphere
  25428. * @param worldMatrix defines the new world matrix
  25429. */
  25430. function BoundingInfo(minimum, maximum, worldMatrix) {
  25431. this._isLocked = false;
  25432. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  25433. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  25434. }
  25435. /**
  25436. * Recreates the entire bounding info from scratch as if we call the constructor in place
  25437. * @param min defines the new minimum vector (in local space)
  25438. * @param max defines the new maximum vector (in local space)
  25439. * @param worldMatrix defines the new world matrix
  25440. */
  25441. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  25442. this.boundingBox.reConstruct(min, max, worldMatrix);
  25443. this.boundingSphere.reConstruct(min, max, worldMatrix);
  25444. };
  25445. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  25446. /**
  25447. * min vector of the bounding box/sphere
  25448. */
  25449. get: function () {
  25450. return this.boundingBox.minimum;
  25451. },
  25452. enumerable: true,
  25453. configurable: true
  25454. });
  25455. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  25456. /**
  25457. * max vector of the bounding box/sphere
  25458. */
  25459. get: function () {
  25460. return this.boundingBox.maximum;
  25461. },
  25462. enumerable: true,
  25463. configurable: true
  25464. });
  25465. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  25466. /**
  25467. * If the info is locked and won't be updated to avoid perf overhead
  25468. */
  25469. get: function () {
  25470. return this._isLocked;
  25471. },
  25472. set: function (value) {
  25473. this._isLocked = value;
  25474. },
  25475. enumerable: true,
  25476. configurable: true
  25477. });
  25478. // Methods
  25479. /**
  25480. * Updates the bounding sphere and box
  25481. * @param world world matrix to be used to update
  25482. */
  25483. BoundingInfo.prototype.update = function (world) {
  25484. if (this._isLocked) {
  25485. return;
  25486. }
  25487. this.boundingBox._update(world);
  25488. this.boundingSphere._update(world);
  25489. };
  25490. /**
  25491. * Recreate the bounding info to be centered around a specific point given a specific extend.
  25492. * @param center New center of the bounding info
  25493. * @param extend New extend of the bounding info
  25494. * @returns the current bounding info
  25495. */
  25496. BoundingInfo.prototype.centerOn = function (center, extend) {
  25497. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  25498. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  25499. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25500. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25501. return this;
  25502. };
  25503. /**
  25504. * Scale the current bounding info by applying a scale factor
  25505. * @param factor defines the scale factor to apply
  25506. * @returns the current bounding info
  25507. */
  25508. BoundingInfo.prototype.scale = function (factor) {
  25509. this.boundingBox.scale(factor);
  25510. this.boundingSphere.scale(factor);
  25511. return this;
  25512. };
  25513. /**
  25514. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  25515. * @param frustumPlanes defines the frustum to test
  25516. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  25517. * @returns true if the bounding info is in the frustum planes
  25518. */
  25519. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  25520. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  25521. 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);
  25522. if (inclusionTest) {
  25523. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  25524. return true;
  25525. }
  25526. }
  25527. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  25528. return false;
  25529. }
  25530. 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);
  25531. if (bSphereOnlyTest) {
  25532. return true;
  25533. }
  25534. return this.boundingBox.isInFrustum(frustumPlanes);
  25535. };
  25536. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  25537. /**
  25538. * Gets the world distance between the min and max points of the bounding box
  25539. */
  25540. get: function () {
  25541. var boundingBox = this.boundingBox;
  25542. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  25543. return diag.length();
  25544. },
  25545. enumerable: true,
  25546. configurable: true
  25547. });
  25548. /**
  25549. * Checks if a cullable object (mesh...) is in the camera frustum
  25550. * Unlike isInFrustum this cheks the full bounding box
  25551. * @param frustumPlanes Camera near/planes
  25552. * @returns true if the object is in frustum otherwise false
  25553. */
  25554. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25555. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  25556. };
  25557. /** @hidden */
  25558. BoundingInfo.prototype._checkCollision = function (collider) {
  25559. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  25560. };
  25561. /**
  25562. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  25563. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25564. * @param point the point to check intersection with
  25565. * @returns if the point intersects
  25566. */
  25567. BoundingInfo.prototype.intersectsPoint = function (point) {
  25568. if (!this.boundingSphere.centerWorld) {
  25569. return false;
  25570. }
  25571. if (!this.boundingSphere.intersectsPoint(point)) {
  25572. return false;
  25573. }
  25574. if (!this.boundingBox.intersectsPoint(point)) {
  25575. return false;
  25576. }
  25577. return true;
  25578. };
  25579. /**
  25580. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  25581. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25582. * @param boundingInfo the bounding info to check intersection with
  25583. * @param precise if the intersection should be done using OBB
  25584. * @returns if the bounding info intersects
  25585. */
  25586. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  25587. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  25588. return false;
  25589. }
  25590. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  25591. return false;
  25592. }
  25593. if (!precise) {
  25594. return true;
  25595. }
  25596. var box0 = this.boundingBox;
  25597. var box1 = boundingInfo.boundingBox;
  25598. if (!axisOverlap(box0.directions[0], box0, box1)) {
  25599. return false;
  25600. }
  25601. if (!axisOverlap(box0.directions[1], box0, box1)) {
  25602. return false;
  25603. }
  25604. if (!axisOverlap(box0.directions[2], box0, box1)) {
  25605. return false;
  25606. }
  25607. if (!axisOverlap(box1.directions[0], box0, box1)) {
  25608. return false;
  25609. }
  25610. if (!axisOverlap(box1.directions[1], box0, box1)) {
  25611. return false;
  25612. }
  25613. if (!axisOverlap(box1.directions[2], box0, box1)) {
  25614. return false;
  25615. }
  25616. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  25617. return false;
  25618. }
  25619. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  25620. return false;
  25621. }
  25622. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  25623. return false;
  25624. }
  25625. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  25626. return false;
  25627. }
  25628. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  25629. return false;
  25630. }
  25631. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  25632. return false;
  25633. }
  25634. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  25635. return false;
  25636. }
  25637. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  25638. return false;
  25639. }
  25640. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  25641. return false;
  25642. }
  25643. return true;
  25644. };
  25645. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25646. return BoundingInfo;
  25647. }());
  25648. /***/ }),
  25649. /***/ "./Culling/boundingSphere.ts":
  25650. /*!***********************************!*\
  25651. !*** ./Culling/boundingSphere.ts ***!
  25652. \***********************************/
  25653. /*! exports provided: BoundingSphere */
  25654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25655. "use strict";
  25656. __webpack_require__.r(__webpack_exports__);
  25657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  25658. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25659. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25660. /**
  25661. * Class used to store bounding sphere information
  25662. */
  25663. var BoundingSphere = /** @class */ (function () {
  25664. /**
  25665. * Creates a new bounding sphere
  25666. * @param min defines the minimum vector (in local space)
  25667. * @param max defines the maximum vector (in local space)
  25668. * @param worldMatrix defines the new world matrix
  25669. */
  25670. function BoundingSphere(min, max, worldMatrix) {
  25671. /**
  25672. * Gets the center of the bounding sphere in local space
  25673. */
  25674. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25675. /**
  25676. * Gets the center of the bounding sphere in world space
  25677. */
  25678. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25679. /**
  25680. * Gets the minimum vector in local space
  25681. */
  25682. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25683. /**
  25684. * Gets the maximum vector in local space
  25685. */
  25686. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25687. this.reConstruct(min, max, worldMatrix);
  25688. }
  25689. /**
  25690. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  25691. * @param min defines the new minimum vector (in local space)
  25692. * @param max defines the new maximum vector (in local space)
  25693. * @param worldMatrix defines the new world matrix
  25694. */
  25695. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  25696. this.minimum.copyFrom(min);
  25697. this.maximum.copyFrom(max);
  25698. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  25699. max.addToRef(min, this.center).scaleInPlace(0.5);
  25700. this.radius = distance * 0.5;
  25701. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25702. };
  25703. /**
  25704. * Scale the current bounding sphere by applying a scale factor
  25705. * @param factor defines the scale factor to apply
  25706. * @returns the current bounding box
  25707. */
  25708. BoundingSphere.prototype.scale = function (factor) {
  25709. var newRadius = this.radius * factor;
  25710. var tmpVectors = BoundingSphere.TmpVector3;
  25711. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25712. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25713. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25714. this.reConstruct(min, max, this._worldMatrix);
  25715. return this;
  25716. };
  25717. /**
  25718. * Gets the world matrix of the bounding box
  25719. * @returns a matrix
  25720. */
  25721. BoundingSphere.prototype.getWorldMatrix = function () {
  25722. return this._worldMatrix;
  25723. };
  25724. // Methods
  25725. /** @hidden */
  25726. BoundingSphere.prototype._update = function (worldMatrix) {
  25727. if (!worldMatrix.isIdentity()) {
  25728. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25729. var tempVector = BoundingSphere.TmpVector3[0];
  25730. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25731. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25732. }
  25733. else {
  25734. this.centerWorld.copyFrom(this.center);
  25735. this.radiusWorld = this.radius;
  25736. }
  25737. };
  25738. /**
  25739. * Tests if the bounding sphere is intersecting the frustum planes
  25740. * @param frustumPlanes defines the frustum planes to test
  25741. * @returns true if there is an intersection
  25742. */
  25743. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25744. var center = this.centerWorld;
  25745. var radius = this.radiusWorld;
  25746. for (var i = 0; i < 6; i++) {
  25747. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25748. return false;
  25749. }
  25750. }
  25751. return true;
  25752. };
  25753. /**
  25754. * Tests if the bounding sphere center is in between the frustum planes.
  25755. * Used for optimistic fast inclusion.
  25756. * @param frustumPlanes defines the frustum planes to test
  25757. * @returns true if the sphere center is in between the frustum planes
  25758. */
  25759. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25760. var center = this.centerWorld;
  25761. for (var i = 0; i < 6; i++) {
  25762. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25763. return false;
  25764. }
  25765. }
  25766. return true;
  25767. };
  25768. /**
  25769. * Tests if a point is inside the bounding sphere
  25770. * @param point defines the point to test
  25771. * @returns true if the point is inside the bounding sphere
  25772. */
  25773. BoundingSphere.prototype.intersectsPoint = function (point) {
  25774. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25775. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25776. return false;
  25777. }
  25778. return true;
  25779. };
  25780. // Statics
  25781. /**
  25782. * Checks if two sphere intersct
  25783. * @param sphere0 sphere 0
  25784. * @param sphere1 sphere 1
  25785. * @returns true if the speres intersect
  25786. */
  25787. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25788. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25789. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25790. if (radiusSum * radiusSum < squareDistance) {
  25791. return false;
  25792. }
  25793. return true;
  25794. };
  25795. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25796. return BoundingSphere;
  25797. }());
  25798. /***/ }),
  25799. /***/ "./Culling/index.ts":
  25800. /*!**************************!*\
  25801. !*** ./Culling/index.ts ***!
  25802. \**************************/
  25803. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25805. "use strict";
  25806. __webpack_require__.r(__webpack_exports__);
  25807. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25809. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25811. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25813. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25817. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25819. /***/ }),
  25820. /***/ "./Culling/ray.ts":
  25821. /*!************************!*\
  25822. !*** ./Culling/ray.ts ***!
  25823. \************************/
  25824. /*! exports provided: Ray */
  25825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25826. "use strict";
  25827. __webpack_require__.r(__webpack_exports__);
  25828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25829. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25830. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25831. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25832. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25833. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25834. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25835. /**
  25836. * Class representing a ray with position and direction
  25837. */
  25838. var Ray = /** @class */ (function () {
  25839. /**
  25840. * Creates a new ray
  25841. * @param origin origin point
  25842. * @param direction direction
  25843. * @param length length of the ray
  25844. */
  25845. function Ray(
  25846. /** origin point */
  25847. origin,
  25848. /** direction */
  25849. direction,
  25850. /** length of the ray */
  25851. length) {
  25852. if (length === void 0) { length = Number.MAX_VALUE; }
  25853. this.origin = origin;
  25854. this.direction = direction;
  25855. this.length = length;
  25856. }
  25857. // Methods
  25858. /**
  25859. * Checks if the ray intersects a box
  25860. * @param minimum bound of the box
  25861. * @param maximum bound of the box
  25862. * @param intersectionTreshold extra extend to be added to the box in all direction
  25863. * @returns if the box was hit
  25864. */
  25865. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25866. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25867. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25868. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25869. var d = 0.0;
  25870. var maxValue = Number.MAX_VALUE;
  25871. var inv;
  25872. var min;
  25873. var max;
  25874. var temp;
  25875. if (Math.abs(this.direction.x) < 0.0000001) {
  25876. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25877. return false;
  25878. }
  25879. }
  25880. else {
  25881. inv = 1.0 / this.direction.x;
  25882. min = (newMinimum.x - this.origin.x) * inv;
  25883. max = (newMaximum.x - this.origin.x) * inv;
  25884. if (max === -Infinity) {
  25885. max = Infinity;
  25886. }
  25887. if (min > max) {
  25888. temp = min;
  25889. min = max;
  25890. max = temp;
  25891. }
  25892. d = Math.max(min, d);
  25893. maxValue = Math.min(max, maxValue);
  25894. if (d > maxValue) {
  25895. return false;
  25896. }
  25897. }
  25898. if (Math.abs(this.direction.y) < 0.0000001) {
  25899. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25900. return false;
  25901. }
  25902. }
  25903. else {
  25904. inv = 1.0 / this.direction.y;
  25905. min = (newMinimum.y - this.origin.y) * inv;
  25906. max = (newMaximum.y - this.origin.y) * inv;
  25907. if (max === -Infinity) {
  25908. max = Infinity;
  25909. }
  25910. if (min > max) {
  25911. temp = min;
  25912. min = max;
  25913. max = temp;
  25914. }
  25915. d = Math.max(min, d);
  25916. maxValue = Math.min(max, maxValue);
  25917. if (d > maxValue) {
  25918. return false;
  25919. }
  25920. }
  25921. if (Math.abs(this.direction.z) < 0.0000001) {
  25922. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25923. return false;
  25924. }
  25925. }
  25926. else {
  25927. inv = 1.0 / this.direction.z;
  25928. min = (newMinimum.z - this.origin.z) * inv;
  25929. max = (newMaximum.z - this.origin.z) * inv;
  25930. if (max === -Infinity) {
  25931. max = Infinity;
  25932. }
  25933. if (min > max) {
  25934. temp = min;
  25935. min = max;
  25936. max = temp;
  25937. }
  25938. d = Math.max(min, d);
  25939. maxValue = Math.min(max, maxValue);
  25940. if (d > maxValue) {
  25941. return false;
  25942. }
  25943. }
  25944. return true;
  25945. };
  25946. /**
  25947. * Checks if the ray intersects a box
  25948. * @param box the bounding box to check
  25949. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25950. * @returns if the box was hit
  25951. */
  25952. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25953. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25954. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25955. };
  25956. /**
  25957. * If the ray hits a sphere
  25958. * @param sphere the bounding sphere to check
  25959. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25960. * @returns true if it hits the sphere
  25961. */
  25962. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25963. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25964. var x = sphere.center.x - this.origin.x;
  25965. var y = sphere.center.y - this.origin.y;
  25966. var z = sphere.center.z - this.origin.z;
  25967. var pyth = (x * x) + (y * y) + (z * z);
  25968. var radius = sphere.radius + intersectionTreshold;
  25969. var rr = radius * radius;
  25970. if (pyth <= rr) {
  25971. return true;
  25972. }
  25973. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25974. if (dot < 0.0) {
  25975. return false;
  25976. }
  25977. var temp = pyth - (dot * dot);
  25978. return temp <= rr;
  25979. };
  25980. /**
  25981. * If the ray hits a triange
  25982. * @param vertex0 triangle vertex
  25983. * @param vertex1 triangle vertex
  25984. * @param vertex2 triangle vertex
  25985. * @returns intersection information if hit
  25986. */
  25987. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25988. var edge1 = Ray.TmpVector3[0];
  25989. var edge2 = Ray.TmpVector3[1];
  25990. var pvec = Ray.TmpVector3[2];
  25991. var tvec = Ray.TmpVector3[3];
  25992. var qvec = Ray.TmpVector3[4];
  25993. vertex1.subtractToRef(vertex0, edge1);
  25994. vertex2.subtractToRef(vertex0, edge2);
  25995. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25996. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25997. if (det === 0) {
  25998. return null;
  25999. }
  26000. var invdet = 1 / det;
  26001. this.origin.subtractToRef(vertex0, tvec);
  26002. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  26003. if (bu < 0 || bu > 1.0) {
  26004. return null;
  26005. }
  26006. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  26007. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  26008. if (bv < 0 || bu + bv > 1.0) {
  26009. return null;
  26010. }
  26011. //check if the distance is longer than the predefined length.
  26012. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  26013. if (distance > this.length) {
  26014. return null;
  26015. }
  26016. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  26017. };
  26018. /**
  26019. * Checks if ray intersects a plane
  26020. * @param plane the plane to check
  26021. * @returns the distance away it was hit
  26022. */
  26023. Ray.prototype.intersectsPlane = function (plane) {
  26024. var distance;
  26025. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  26026. if (Math.abs(result1) < 9.99999997475243E-07) {
  26027. return null;
  26028. }
  26029. else {
  26030. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  26031. distance = (-plane.d - result2) / result1;
  26032. if (distance < 0.0) {
  26033. if (distance < -9.99999997475243E-07) {
  26034. return null;
  26035. }
  26036. else {
  26037. return 0;
  26038. }
  26039. }
  26040. return distance;
  26041. }
  26042. };
  26043. /**
  26044. * Checks if ray intersects a mesh
  26045. * @param mesh the mesh to check
  26046. * @param fastCheck if only the bounding box should checked
  26047. * @returns picking info of the intersecton
  26048. */
  26049. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  26050. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26051. mesh.getWorldMatrix().invertToRef(tm);
  26052. if (this._tmpRay) {
  26053. Ray.TransformToRef(this, tm, this._tmpRay);
  26054. }
  26055. else {
  26056. this._tmpRay = Ray.Transform(this, tm);
  26057. }
  26058. return mesh.intersects(this._tmpRay, fastCheck);
  26059. };
  26060. /**
  26061. * Checks if ray intersects a mesh
  26062. * @param meshes the meshes to check
  26063. * @param fastCheck if only the bounding box should checked
  26064. * @param results array to store result in
  26065. * @returns Array of picking infos
  26066. */
  26067. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  26068. if (results) {
  26069. results.length = 0;
  26070. }
  26071. else {
  26072. results = [];
  26073. }
  26074. for (var i = 0; i < meshes.length; i++) {
  26075. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  26076. if (pickInfo.hit) {
  26077. results.push(pickInfo);
  26078. }
  26079. }
  26080. results.sort(this._comparePickingInfo);
  26081. return results;
  26082. };
  26083. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  26084. if (pickingInfoA.distance < pickingInfoB.distance) {
  26085. return -1;
  26086. }
  26087. else if (pickingInfoA.distance > pickingInfoB.distance) {
  26088. return 1;
  26089. }
  26090. else {
  26091. return 0;
  26092. }
  26093. };
  26094. /**
  26095. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  26096. * @param sega the first point of the segment to test the intersection against
  26097. * @param segb the second point of the segment to test the intersection against
  26098. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  26099. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  26100. */
  26101. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  26102. var o = this.origin;
  26103. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26104. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  26105. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26106. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26107. segb.subtractToRef(sega, u);
  26108. this.direction.scaleToRef(Ray.rayl, v);
  26109. o.addToRef(v, rsegb);
  26110. sega.subtractToRef(o, w);
  26111. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  26112. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  26113. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  26114. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  26115. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  26116. var D = a * c - b * b; // always >= 0
  26117. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  26118. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  26119. // compute the line parameters of the two closest points
  26120. if (D < Ray.smallnum) { // the lines are almost parallel
  26121. sN = 0.0; // force using point P0 on segment S1
  26122. sD = 1.0; // to prevent possible division by 0.0 later
  26123. tN = e;
  26124. tD = c;
  26125. }
  26126. else { // get the closest points on the infinite lines
  26127. sN = (b * e - c * d);
  26128. tN = (a * e - b * d);
  26129. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  26130. sN = 0.0;
  26131. tN = e;
  26132. tD = c;
  26133. }
  26134. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  26135. sN = sD;
  26136. tN = e + b;
  26137. tD = c;
  26138. }
  26139. }
  26140. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  26141. tN = 0.0;
  26142. // recompute sc for this edge
  26143. if (-d < 0.0) {
  26144. sN = 0.0;
  26145. }
  26146. else if (-d > a) {
  26147. sN = sD;
  26148. }
  26149. else {
  26150. sN = -d;
  26151. sD = a;
  26152. }
  26153. }
  26154. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  26155. tN = tD;
  26156. // recompute sc for this edge
  26157. if ((-d + b) < 0.0) {
  26158. sN = 0;
  26159. }
  26160. else if ((-d + b) > a) {
  26161. sN = sD;
  26162. }
  26163. else {
  26164. sN = (-d + b);
  26165. sD = a;
  26166. }
  26167. }
  26168. // finally do the division to get sc and tc
  26169. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  26170. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  26171. // get the difference of the two closest points
  26172. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  26173. v.scaleToRef(tc, qtc);
  26174. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  26175. u.scaleToRef(sc, qsc);
  26176. qsc.addInPlace(w);
  26177. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  26178. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  26179. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  26180. if (isIntersected) {
  26181. return qsc.length();
  26182. }
  26183. return -1;
  26184. };
  26185. /**
  26186. * Update the ray from viewport position
  26187. * @param x position
  26188. * @param y y position
  26189. * @param viewportWidth viewport width
  26190. * @param viewportHeight viewport height
  26191. * @param world world matrix
  26192. * @param view view matrix
  26193. * @param projection projection matrix
  26194. * @returns this ray updated
  26195. */
  26196. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26197. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  26198. return this;
  26199. };
  26200. // Statics
  26201. /**
  26202. * Creates a ray with origin and direction of 0,0,0
  26203. * @returns the new ray
  26204. */
  26205. Ray.Zero = function () {
  26206. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  26207. };
  26208. /**
  26209. * Creates a new ray from screen space and viewport
  26210. * @param x position
  26211. * @param y y position
  26212. * @param viewportWidth viewport width
  26213. * @param viewportHeight viewport height
  26214. * @param world world matrix
  26215. * @param view view matrix
  26216. * @param projection projection matrix
  26217. * @returns new ray
  26218. */
  26219. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26220. var result = Ray.Zero();
  26221. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  26222. };
  26223. /**
  26224. * 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
  26225. * transformed to the given world matrix.
  26226. * @param origin The origin point
  26227. * @param end The end point
  26228. * @param world a matrix to transform the ray to. Default is the identity matrix.
  26229. * @returns the new ray
  26230. */
  26231. Ray.CreateNewFromTo = function (origin, end, world) {
  26232. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  26233. var direction = end.subtract(origin);
  26234. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  26235. direction.normalize();
  26236. return Ray.Transform(new Ray(origin, direction, length), world);
  26237. };
  26238. /**
  26239. * Transforms a ray by a matrix
  26240. * @param ray ray to transform
  26241. * @param matrix matrix to apply
  26242. * @returns the resulting new ray
  26243. */
  26244. Ray.Transform = function (ray, matrix) {
  26245. 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));
  26246. Ray.TransformToRef(ray, matrix, result);
  26247. return result;
  26248. };
  26249. /**
  26250. * Transforms a ray by a matrix
  26251. * @param ray ray to transform
  26252. * @param matrix matrix to apply
  26253. * @param result ray to store result in
  26254. */
  26255. Ray.TransformToRef = function (ray, matrix, result) {
  26256. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  26257. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  26258. result.length = ray.length;
  26259. var dir = result.direction;
  26260. var len = dir.length();
  26261. if (!(len === 0 || len === 1)) {
  26262. var num = 1.0 / len;
  26263. dir.x *= num;
  26264. dir.y *= num;
  26265. dir.z *= num;
  26266. result.length *= len;
  26267. }
  26268. };
  26269. /**
  26270. * Unproject a ray from screen space to object space
  26271. * @param sourceX defines the screen space x coordinate to use
  26272. * @param sourceY defines the screen space y coordinate to use
  26273. * @param viewportWidth defines the current width of the viewport
  26274. * @param viewportHeight defines the current height of the viewport
  26275. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  26276. * @param view defines the view matrix to use
  26277. * @param projection defines the projection matrix to use
  26278. */
  26279. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  26280. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26281. world.multiplyToRef(view, matrix);
  26282. matrix.multiplyToRef(projection, matrix);
  26283. matrix.invert();
  26284. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26285. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  26286. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  26287. nearScreenSource.z = -1.0;
  26288. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  26289. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26290. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26291. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  26292. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  26293. this.origin.copyFrom(nearVec3);
  26294. farVec3.subtractToRef(nearVec3, this.direction);
  26295. this.direction.normalize();
  26296. };
  26297. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26298. Ray.smallnum = 0.00000001;
  26299. Ray.rayl = 10e8;
  26300. return Ray;
  26301. }());
  26302. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  26303. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26304. var result = Ray.Zero();
  26305. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  26306. return result;
  26307. };
  26308. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  26309. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26310. var engine = this.getEngine();
  26311. if (!camera) {
  26312. if (!this.activeCamera) {
  26313. throw new Error("Active camera not set");
  26314. }
  26315. camera = this.activeCamera;
  26316. }
  26317. var cameraViewport = camera.viewport;
  26318. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26319. // Moving coordinates to local viewport world
  26320. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26321. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26322. 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());
  26323. return this;
  26324. };
  26325. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  26326. var result = Ray.Zero();
  26327. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  26328. return result;
  26329. };
  26330. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  26331. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26332. return this;
  26333. }
  26334. var engine = this.getEngine();
  26335. if (!camera) {
  26336. if (!this.activeCamera) {
  26337. throw new Error("Active camera not set");
  26338. }
  26339. camera = this.activeCamera;
  26340. }
  26341. var cameraViewport = camera.viewport;
  26342. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26343. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26344. // Moving coordinates to local viewport world
  26345. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26346. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26347. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  26348. return this;
  26349. };
  26350. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  26351. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26352. return null;
  26353. }
  26354. var pickingInfo = null;
  26355. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26356. var mesh = this.meshes[meshIndex];
  26357. if (predicate) {
  26358. if (!predicate(mesh)) {
  26359. continue;
  26360. }
  26361. }
  26362. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26363. continue;
  26364. }
  26365. var world = mesh.getWorldMatrix();
  26366. var ray = rayFunction(world);
  26367. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  26368. if (!result || !result.hit) {
  26369. continue;
  26370. }
  26371. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  26372. continue;
  26373. }
  26374. pickingInfo = result;
  26375. if (fastCheck) {
  26376. break;
  26377. }
  26378. }
  26379. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  26380. };
  26381. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  26382. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26383. return null;
  26384. }
  26385. var pickingInfos = new Array();
  26386. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26387. var mesh = this.meshes[meshIndex];
  26388. if (predicate) {
  26389. if (!predicate(mesh)) {
  26390. continue;
  26391. }
  26392. }
  26393. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26394. continue;
  26395. }
  26396. var world = mesh.getWorldMatrix();
  26397. var ray = rayFunction(world);
  26398. var result = mesh.intersects(ray, false, trianglePredicate);
  26399. if (!result || !result.hit) {
  26400. continue;
  26401. }
  26402. pickingInfos.push(result);
  26403. }
  26404. return pickingInfos;
  26405. };
  26406. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  26407. var _this = this;
  26408. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26409. return null;
  26410. }
  26411. var result = this._internalPick(function (world) {
  26412. if (!_this._tempPickingRay) {
  26413. _this._tempPickingRay = Ray.Zero();
  26414. }
  26415. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  26416. return _this._tempPickingRay;
  26417. }, predicate, fastCheck, trianglePredicate);
  26418. if (result) {
  26419. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  26420. }
  26421. return result;
  26422. };
  26423. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  26424. var _this = this;
  26425. var result = this._internalPick(function (world) {
  26426. if (!_this._pickWithRayInverseMatrix) {
  26427. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26428. }
  26429. world.invertToRef(_this._pickWithRayInverseMatrix);
  26430. if (!_this._cachedRayForTransform) {
  26431. _this._cachedRayForTransform = Ray.Zero();
  26432. }
  26433. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26434. return _this._cachedRayForTransform;
  26435. }, predicate, fastCheck, trianglePredicate);
  26436. if (result) {
  26437. result.ray = ray;
  26438. }
  26439. return result;
  26440. };
  26441. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  26442. var _this = this;
  26443. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  26444. };
  26445. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  26446. var _this = this;
  26447. return this._internalMultiPick(function (world) {
  26448. if (!_this._pickWithRayInverseMatrix) {
  26449. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26450. }
  26451. world.invertToRef(_this._pickWithRayInverseMatrix);
  26452. if (!_this._cachedRayForTransform) {
  26453. _this._cachedRayForTransform = Ray.Zero();
  26454. }
  26455. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26456. return _this._cachedRayForTransform;
  26457. }, predicate, trianglePredicate);
  26458. };
  26459. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  26460. if (length === void 0) { length = 100; }
  26461. if (!transform) {
  26462. transform = this.getWorldMatrix();
  26463. }
  26464. if (!origin) {
  26465. origin = this.position;
  26466. }
  26467. 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);
  26468. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  26469. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  26470. return new Ray(origin, direction, length);
  26471. };
  26472. /***/ }),
  26473. /***/ "./Debug/axesViewer.ts":
  26474. /*!*****************************!*\
  26475. !*** ./Debug/axesViewer.ts ***!
  26476. \*****************************/
  26477. /*! exports provided: AxesViewer */
  26478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26479. "use strict";
  26480. __webpack_require__.r(__webpack_exports__);
  26481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  26482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26483. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26484. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  26485. /**
  26486. * The Axes viewer will show 3 axes in a specific point in space
  26487. */
  26488. var AxesViewer = /** @class */ (function () {
  26489. /**
  26490. * Creates a new AxesViewer
  26491. * @param scene defines the hosting scene
  26492. * @param scaleLines defines a number used to scale line length (1 by default)
  26493. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  26494. * @param xAxis defines the node hierarchy used to render the x-axis
  26495. * @param yAxis defines the node hierarchy used to render the y-axis
  26496. * @param zAxis defines the node hierarchy used to render the z-axis
  26497. */
  26498. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  26499. if (scaleLines === void 0) { scaleLines = 1; }
  26500. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  26501. this._scaleLinesFactor = 4;
  26502. this._instanced = false;
  26503. /**
  26504. * Gets or sets a number used to scale line length
  26505. */
  26506. this.scaleLines = 1;
  26507. this.scaleLines = scaleLines;
  26508. if (!xAxis) {
  26509. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26510. redColoredMaterial.disableLighting = true;
  26511. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  26512. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  26513. }
  26514. if (!yAxis) {
  26515. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26516. greenColoredMaterial.disableLighting = true;
  26517. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  26518. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  26519. }
  26520. if (!zAxis) {
  26521. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26522. blueColoredMaterial.disableLighting = true;
  26523. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  26524. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  26525. }
  26526. this._xAxis = xAxis;
  26527. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26528. this._yAxis = yAxis;
  26529. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26530. this._zAxis = zAxis;
  26531. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26532. if (renderingGroupId != null) {
  26533. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  26534. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  26535. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  26536. }
  26537. this.scene = scene;
  26538. 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());
  26539. }
  26540. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  26541. /** Gets the node hierarchy used to render x-axis */
  26542. get: function () {
  26543. return this._xAxis;
  26544. },
  26545. enumerable: true,
  26546. configurable: true
  26547. });
  26548. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  26549. /** Gets the node hierarchy used to render y-axis */
  26550. get: function () {
  26551. return this._yAxis;
  26552. },
  26553. enumerable: true,
  26554. configurable: true
  26555. });
  26556. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  26557. /** Gets the node hierarchy used to render z-axis */
  26558. get: function () {
  26559. return this._zAxis;
  26560. },
  26561. enumerable: true,
  26562. configurable: true
  26563. });
  26564. /**
  26565. * Force the viewer to update
  26566. * @param position defines the position of the viewer
  26567. * @param xaxis defines the x axis of the viewer
  26568. * @param yaxis defines the y axis of the viewer
  26569. * @param zaxis defines the z axis of the viewer
  26570. */
  26571. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  26572. this._xAxis.position.copyFrom(position);
  26573. this._xAxis.setDirection(xaxis);
  26574. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26575. this._yAxis.position.copyFrom(position);
  26576. this._yAxis.setDirection(yaxis);
  26577. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26578. this._zAxis.position.copyFrom(position);
  26579. this._zAxis.setDirection(zaxis);
  26580. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26581. };
  26582. /**
  26583. * Creates an instance of this axes viewer.
  26584. * @returns a new axes viewer with instanced meshes
  26585. */
  26586. AxesViewer.prototype.createInstance = function () {
  26587. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  26588. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  26589. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  26590. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  26591. axesViewer._instanced = true;
  26592. return axesViewer;
  26593. };
  26594. /** Releases resources */
  26595. AxesViewer.prototype.dispose = function () {
  26596. if (this._xAxis) {
  26597. this._xAxis.dispose(false, !this._instanced);
  26598. delete this._xAxis;
  26599. }
  26600. if (this._yAxis) {
  26601. this._yAxis.dispose(false, !this._instanced);
  26602. delete this._yAxis;
  26603. }
  26604. if (this._zAxis) {
  26605. this._zAxis.dispose(false, !this._instanced);
  26606. delete this._zAxis;
  26607. }
  26608. delete this.scene;
  26609. };
  26610. AxesViewer._SetRenderingGroupId = function (node, id) {
  26611. node.getChildMeshes().forEach(function (mesh) {
  26612. mesh.renderingGroupId = id;
  26613. });
  26614. };
  26615. return AxesViewer;
  26616. }());
  26617. /***/ }),
  26618. /***/ "./Debug/boneAxesViewer.ts":
  26619. /*!*********************************!*\
  26620. !*** ./Debug/boneAxesViewer.ts ***!
  26621. \*********************************/
  26622. /*! exports provided: BoneAxesViewer */
  26623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26624. "use strict";
  26625. __webpack_require__.r(__webpack_exports__);
  26626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  26627. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26628. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  26629. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26630. /**
  26631. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  26632. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  26633. */
  26634. var BoneAxesViewer = /** @class */ (function (_super) {
  26635. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  26636. /**
  26637. * Creates a new BoneAxesViewer
  26638. * @param scene defines the hosting scene
  26639. * @param bone defines the target bone
  26640. * @param mesh defines the target mesh
  26641. * @param scaleLines defines a scaling factor for line length (1 by default)
  26642. */
  26643. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  26644. if (scaleLines === void 0) { scaleLines = 1; }
  26645. var _this = _super.call(this, scene, scaleLines) || this;
  26646. /** Gets current position */
  26647. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26648. /** Gets direction of X axis */
  26649. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26650. /** Gets direction of Y axis */
  26651. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26652. /** Gets direction of Z axis */
  26653. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26654. _this.mesh = mesh;
  26655. _this.bone = bone;
  26656. return _this;
  26657. }
  26658. /**
  26659. * Force the viewer to update
  26660. */
  26661. BoneAxesViewer.prototype.update = function () {
  26662. if (!this.mesh || !this.bone) {
  26663. return;
  26664. }
  26665. var bone = this.bone;
  26666. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  26667. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  26668. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  26669. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  26670. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  26671. };
  26672. /** Releases resources */
  26673. BoneAxesViewer.prototype.dispose = function () {
  26674. if (this.mesh) {
  26675. this.mesh = null;
  26676. this.bone = null;
  26677. _super.prototype.dispose.call(this);
  26678. }
  26679. };
  26680. return BoneAxesViewer;
  26681. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  26682. /***/ }),
  26683. /***/ "./Debug/debugLayer.ts":
  26684. /*!*****************************!*\
  26685. !*** ./Debug/debugLayer.ts ***!
  26686. \*****************************/
  26687. /*! exports provided: DebugLayer */
  26688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26689. "use strict";
  26690. __webpack_require__.r(__webpack_exports__);
  26691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  26692. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26693. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26694. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26695. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26696. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  26697. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  26698. get: function () {
  26699. if (!this._debugLayer) {
  26700. this._debugLayer = new DebugLayer(this);
  26701. }
  26702. return this._debugLayer;
  26703. },
  26704. enumerable: true,
  26705. configurable: true
  26706. });
  26707. /**
  26708. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26709. * what is happening in your scene
  26710. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26711. */
  26712. var DebugLayer = /** @class */ (function () {
  26713. /**
  26714. * Instantiates a new debug layer.
  26715. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26716. * what is happening in your scene
  26717. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26718. * @param scene Defines the scene to inspect
  26719. */
  26720. function DebugLayer(scene) {
  26721. var _this = this;
  26722. this.BJSINSPECTOR = this._getGlobalInspector();
  26723. /**
  26724. * Observable triggered when a property is changed through the inspector.
  26725. */
  26726. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26727. this._scene = scene;
  26728. this._scene.onDisposeObservable.add(function () {
  26729. // Debug layer
  26730. if (_this._scene._debugLayer) {
  26731. _this._scene._debugLayer.hide();
  26732. }
  26733. });
  26734. }
  26735. /** Creates the inspector window. */
  26736. DebugLayer.prototype._createInspector = function (config) {
  26737. if (this.isVisible()) {
  26738. return;
  26739. }
  26740. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26741. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26742. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26743. };
  26744. /**
  26745. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  26746. * @param entity defines the entity to select
  26747. * @param lineContainerTitle defines the specific block to highlight
  26748. */
  26749. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26750. if (this.BJSINSPECTOR) {
  26751. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26752. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26753. }
  26754. };
  26755. /** Get the inspector from bundle or global */
  26756. DebugLayer.prototype._getGlobalInspector = function () {
  26757. // UMD Global name detection from Webpack Bundle UMD Name.
  26758. if (typeof INSPECTOR !== 'undefined') {
  26759. return INSPECTOR;
  26760. }
  26761. // In case of module let s check the global emitted from the Inspector entry point.
  26762. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26763. return BABYLON;
  26764. }
  26765. return undefined;
  26766. };
  26767. /**
  26768. * Get if the inspector is visible or not.
  26769. * @returns true if visible otherwise, false
  26770. */
  26771. DebugLayer.prototype.isVisible = function () {
  26772. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26773. };
  26774. /**
  26775. * Hide the inspector and close its window.
  26776. */
  26777. DebugLayer.prototype.hide = function () {
  26778. if (this.BJSINSPECTOR) {
  26779. this.BJSINSPECTOR.Inspector.Hide();
  26780. }
  26781. };
  26782. /**
  26783. * Launch the debugLayer.
  26784. * @param config Define the configuration of the inspector
  26785. * @return a promise fulfilled when the debug layer is visible
  26786. */
  26787. DebugLayer.prototype.show = function (config) {
  26788. var _this = this;
  26789. return new Promise(function (resolve, reject) {
  26790. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26791. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26792. // Load inspector and add it to the DOM
  26793. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26794. _this._createInspector(config);
  26795. resolve(_this);
  26796. });
  26797. }
  26798. else {
  26799. // Otherwise creates the inspector
  26800. _this._createInspector(config);
  26801. resolve(_this);
  26802. }
  26803. });
  26804. };
  26805. /**
  26806. * Define the url to get the inspector script from.
  26807. * By default it uses the babylonjs CDN.
  26808. * @ignoreNaming
  26809. */
  26810. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26811. return DebugLayer;
  26812. }());
  26813. /***/ }),
  26814. /***/ "./Debug/index.ts":
  26815. /*!************************!*\
  26816. !*** ./Debug/index.ts ***!
  26817. \************************/
  26818. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26819. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26820. "use strict";
  26821. __webpack_require__.r(__webpack_exports__);
  26822. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26824. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26826. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26828. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26830. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26832. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26834. /***/ }),
  26835. /***/ "./Debug/physicsViewer.ts":
  26836. /*!********************************!*\
  26837. !*** ./Debug/physicsViewer.ts ***!
  26838. \********************************/
  26839. /*! exports provided: PhysicsViewer */
  26840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26841. "use strict";
  26842. __webpack_require__.r(__webpack_exports__);
  26843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26844. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26845. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26846. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26847. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26848. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26849. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26850. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26851. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26852. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  26853. /**
  26854. * Used to show the physics impostor around the specific mesh
  26855. */
  26856. var PhysicsViewer = /** @class */ (function () {
  26857. /**
  26858. * Creates a new PhysicsViewer
  26859. * @param scene defines the hosting scene
  26860. */
  26861. function PhysicsViewer(scene) {
  26862. /** @hidden */
  26863. this._impostors = [];
  26864. /** @hidden */
  26865. this._meshes = [];
  26866. /** @hidden */
  26867. this._numMeshes = 0;
  26868. this._debugMeshMeshes = new Array();
  26869. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  26870. var physicEngine = this._scene.getPhysicsEngine();
  26871. if (physicEngine) {
  26872. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26873. }
  26874. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"](this._scene, false);
  26875. this._utilityLayer.pickUtilitySceneFirst = false;
  26876. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26877. }
  26878. /** @hidden */
  26879. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26880. var plugin = this._physicsEnginePlugin;
  26881. for (var i = 0; i < this._numMeshes; i++) {
  26882. var impostor = this._impostors[i];
  26883. if (!impostor) {
  26884. continue;
  26885. }
  26886. if (impostor.isDisposed) {
  26887. this.hideImpostor(this._impostors[i--]);
  26888. }
  26889. else {
  26890. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor) {
  26891. continue;
  26892. }
  26893. var mesh = this._meshes[i];
  26894. if (mesh && plugin) {
  26895. plugin.syncMeshWithImpostor(mesh, impostor);
  26896. }
  26897. }
  26898. }
  26899. };
  26900. /**
  26901. * Renders a specified physic impostor
  26902. * @param impostor defines the impostor to render
  26903. * @param targetMesh defines the mesh represented by the impostor
  26904. * @returns the new debug mesh used to render the impostor
  26905. */
  26906. PhysicsViewer.prototype.showImpostor = function (impostor, targetMesh) {
  26907. if (!this._scene) {
  26908. return null;
  26909. }
  26910. for (var i = 0; i < this._numMeshes; i++) {
  26911. if (this._impostors[i] == impostor) {
  26912. return null;
  26913. }
  26914. }
  26915. var debugMesh = this._getDebugMesh(impostor, targetMesh);
  26916. if (debugMesh) {
  26917. this._impostors[this._numMeshes] = impostor;
  26918. this._meshes[this._numMeshes] = debugMesh;
  26919. if (this._numMeshes === 0) {
  26920. this._renderFunction = this._updateDebugMeshes.bind(this);
  26921. this._scene.registerBeforeRender(this._renderFunction);
  26922. }
  26923. this._numMeshes++;
  26924. }
  26925. return debugMesh;
  26926. };
  26927. /**
  26928. * Hides a specified physic impostor
  26929. * @param impostor defines the impostor to hide
  26930. */
  26931. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26932. if (!impostor || !this._scene || !this._utilityLayer) {
  26933. return;
  26934. }
  26935. var removed = false;
  26936. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26937. for (var i = 0; i < this._numMeshes; i++) {
  26938. if (this._impostors[i] == impostor) {
  26939. var mesh = this._meshes[i];
  26940. if (!mesh) {
  26941. continue;
  26942. }
  26943. utilityLayerScene.removeMesh(mesh);
  26944. mesh.dispose();
  26945. var index = this._debugMeshMeshes.indexOf(mesh);
  26946. if (index > -1) {
  26947. this._debugMeshMeshes.splice(index, 1);
  26948. }
  26949. this._numMeshes--;
  26950. if (this._numMeshes > 0) {
  26951. this._meshes[i] = this._meshes[this._numMeshes];
  26952. this._impostors[i] = this._impostors[this._numMeshes];
  26953. this._meshes[this._numMeshes] = null;
  26954. this._impostors[this._numMeshes] = null;
  26955. }
  26956. else {
  26957. this._meshes[0] = null;
  26958. this._impostors[0] = null;
  26959. }
  26960. removed = true;
  26961. break;
  26962. }
  26963. }
  26964. if (removed && this._numMeshes === 0) {
  26965. this._scene.unregisterBeforeRender(this._renderFunction);
  26966. }
  26967. };
  26968. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26969. if (!this._debugMaterial) {
  26970. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]('', scene);
  26971. this._debugMaterial.wireframe = true;
  26972. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].White();
  26973. this._debugMaterial.disableLighting = true;
  26974. }
  26975. return this._debugMaterial;
  26976. };
  26977. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26978. if (!this._debugBoxMesh) {
  26979. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26980. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26981. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26982. this._debugBoxMesh.setEnabled(false);
  26983. }
  26984. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26985. };
  26986. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26987. if (!this._debugSphereMesh) {
  26988. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26989. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26990. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26991. this._debugSphereMesh.setEnabled(false);
  26992. }
  26993. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26994. };
  26995. PhysicsViewer.prototype._getDebugCylinderMesh = function (scene) {
  26996. if (!this._debugCylinderMesh) {
  26997. this._debugCylinderMesh = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_8__["CylinderBuilder"].CreateCylinder('physicsBodyCylinderViewMesh', { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);
  26998. this._debugCylinderMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26999. this._debugCylinderMesh.material = this._getDebugMaterial(scene);
  27000. this._debugCylinderMesh.setEnabled(false);
  27001. }
  27002. return this._debugCylinderMesh.createInstance('physicsBodyBoxViewInstance');
  27003. };
  27004. PhysicsViewer.prototype._getDebugMeshMesh = function (mesh, scene) {
  27005. var wireframeOver = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](mesh.name, scene, null, mesh);
  27006. wireframeOver.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  27007. wireframeOver.setParent(mesh);
  27008. wireframeOver.material = this._getDebugMaterial(scene);
  27009. this._debugMeshMeshes.push(wireframeOver);
  27010. return wireframeOver;
  27011. };
  27012. PhysicsViewer.prototype._getDebugMesh = function (impostor, targetMesh) {
  27013. var _this = this;
  27014. if (!this._utilityLayer) {
  27015. return null;
  27016. }
  27017. // Only create child impostor debug meshes when evaluating the parent
  27018. if (targetMesh && targetMesh.parent && targetMesh.parent.physicsImpostor) {
  27019. return null;
  27020. }
  27021. var mesh = null;
  27022. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  27023. switch (impostor.type) {
  27024. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].BoxImpostor:
  27025. mesh = this._getDebugBoxMesh(utilityLayerScene);
  27026. impostor.getBoxSizeToRef(mesh.scaling);
  27027. break;
  27028. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].SphereImpostor:
  27029. mesh = this._getDebugSphereMesh(utilityLayerScene);
  27030. var radius = impostor.getRadius();
  27031. mesh.scaling.x = radius * 2;
  27032. mesh.scaling.y = radius * 2;
  27033. mesh.scaling.z = radius * 2;
  27034. break;
  27035. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor:
  27036. if (targetMesh) {
  27037. mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
  27038. }
  27039. break;
  27040. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].NoImpostor:
  27041. if (targetMesh) {
  27042. // Handle compound impostors
  27043. var childMeshes = targetMesh.getChildMeshes().filter(function (c) { return c.physicsImpostor ? 1 : 0; });
  27044. childMeshes.forEach(function (m) {
  27045. var a = _this._getDebugBoxMesh(utilityLayerScene);
  27046. a.parent = m;
  27047. });
  27048. }
  27049. break;
  27050. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].CylinderImpostor:
  27051. mesh = this._getDebugCylinderMesh(utilityLayerScene);
  27052. var bi = impostor.object.getBoundingInfo();
  27053. mesh.scaling.x = bi.boundingBox.maximum.x - bi.boundingBox.minimum.x;
  27054. mesh.scaling.y = bi.boundingBox.maximum.y - bi.boundingBox.minimum.y;
  27055. mesh.scaling.z = bi.boundingBox.maximum.z - bi.boundingBox.minimum.z;
  27056. break;
  27057. }
  27058. return mesh;
  27059. };
  27060. /** Releases all resources */
  27061. PhysicsViewer.prototype.dispose = function () {
  27062. var count = this._numMeshes;
  27063. for (var index = 0; index < count; index++) {
  27064. this.hideImpostor(this._impostors[0]);
  27065. }
  27066. if (this._debugBoxMesh) {
  27067. this._debugBoxMesh.dispose();
  27068. }
  27069. if (this._debugSphereMesh) {
  27070. this._debugSphereMesh.dispose();
  27071. }
  27072. if (this._debugCylinderMesh) {
  27073. this._debugCylinderMesh.dispose();
  27074. }
  27075. if (this._debugMaterial) {
  27076. this._debugMaterial.dispose();
  27077. }
  27078. this._impostors.length = 0;
  27079. this._scene = null;
  27080. this._physicsEnginePlugin = null;
  27081. if (this._utilityLayer) {
  27082. this._utilityLayer.dispose();
  27083. this._utilityLayer = null;
  27084. }
  27085. };
  27086. return PhysicsViewer;
  27087. }());
  27088. /***/ }),
  27089. /***/ "./Debug/rayHelper.ts":
  27090. /*!****************************!*\
  27091. !*** ./Debug/rayHelper.ts ***!
  27092. \****************************/
  27093. /*! exports provided: RayHelper */
  27094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27095. "use strict";
  27096. __webpack_require__.r(__webpack_exports__);
  27097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  27098. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27099. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  27100. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27101. /**
  27102. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  27103. * in order to better appreciate the issue one might have.
  27104. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  27105. */
  27106. var RayHelper = /** @class */ (function () {
  27107. /**
  27108. * Instantiate a new ray helper.
  27109. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  27110. * in order to better appreciate the issue one might have.
  27111. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  27112. * @param ray Defines the ray we are currently tryin to visualize
  27113. */
  27114. function RayHelper(ray) {
  27115. this.ray = ray;
  27116. }
  27117. /**
  27118. * Helper function to create a colored helper in a scene in one line.
  27119. * @param ray Defines the ray we are currently tryin to visualize
  27120. * @param scene Defines the scene the ray is used in
  27121. * @param color Defines the color we want to see the ray in
  27122. * @returns The newly created ray helper.
  27123. */
  27124. RayHelper.CreateAndShow = function (ray, scene, color) {
  27125. var helper = new RayHelper(ray);
  27126. helper.show(scene, color);
  27127. return helper;
  27128. };
  27129. /**
  27130. * Shows the ray we are willing to debug.
  27131. * @param scene Defines the scene the ray needs to be rendered in
  27132. * @param color Defines the color the ray needs to be rendered in
  27133. */
  27134. RayHelper.prototype.show = function (scene, color) {
  27135. if (!this._renderFunction && this.ray) {
  27136. var ray = this.ray;
  27137. this._renderFunction = this._render.bind(this);
  27138. this._scene = scene;
  27139. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  27140. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  27141. if (this._renderFunction) {
  27142. this._scene.registerBeforeRender(this._renderFunction);
  27143. }
  27144. }
  27145. if (color && this._renderLine) {
  27146. this._renderLine.color.copyFrom(color);
  27147. }
  27148. };
  27149. /**
  27150. * Hides the ray we are debugging.
  27151. */
  27152. RayHelper.prototype.hide = function () {
  27153. if (this._renderFunction && this._scene) {
  27154. this._scene.unregisterBeforeRender(this._renderFunction);
  27155. this._scene = null;
  27156. this._renderFunction = null;
  27157. if (this._renderLine) {
  27158. this._renderLine.dispose();
  27159. this._renderLine = null;
  27160. }
  27161. this._renderPoints = [];
  27162. }
  27163. };
  27164. RayHelper.prototype._render = function () {
  27165. var ray = this.ray;
  27166. if (!ray) {
  27167. return;
  27168. }
  27169. var point = this._renderPoints[1];
  27170. var len = Math.min(ray.length, 1000000);
  27171. point.copyFrom(ray.direction);
  27172. point.scaleInPlace(len);
  27173. point.addInPlace(ray.origin);
  27174. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  27175. };
  27176. /**
  27177. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  27178. * @param mesh Defines the mesh we want the helper attached to
  27179. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  27180. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  27181. * @param length Defines the length of the ray
  27182. */
  27183. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  27184. this._attachedToMesh = mesh;
  27185. var ray = this.ray;
  27186. if (!ray) {
  27187. return;
  27188. }
  27189. if (!ray.direction) {
  27190. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27191. }
  27192. if (!ray.origin) {
  27193. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27194. }
  27195. if (length) {
  27196. ray.length = length;
  27197. }
  27198. if (!meshSpaceOrigin) {
  27199. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27200. }
  27201. if (!meshSpaceDirection) {
  27202. // -1 so that this will work with Mesh.lookAt
  27203. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  27204. }
  27205. if (!this._meshSpaceDirection) {
  27206. this._meshSpaceDirection = meshSpaceDirection.clone();
  27207. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  27208. }
  27209. else {
  27210. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  27211. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  27212. }
  27213. if (!this._updateToMeshFunction) {
  27214. this._updateToMeshFunction = this._updateToMesh.bind(this);
  27215. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  27216. }
  27217. this._updateToMesh();
  27218. };
  27219. /**
  27220. * Detach the ray helper from the mesh it has previously been attached to.
  27221. */
  27222. RayHelper.prototype.detachFromMesh = function () {
  27223. if (this._attachedToMesh) {
  27224. if (this._updateToMeshFunction) {
  27225. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  27226. }
  27227. this._attachedToMesh = null;
  27228. this._updateToMeshFunction = null;
  27229. }
  27230. };
  27231. RayHelper.prototype._updateToMesh = function () {
  27232. var ray = this.ray;
  27233. if (!this._attachedToMesh || !ray) {
  27234. return;
  27235. }
  27236. if (this._attachedToMesh._isDisposed) {
  27237. this.detachFromMesh();
  27238. return;
  27239. }
  27240. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  27241. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  27242. };
  27243. /**
  27244. * Dispose the helper and release its associated resources.
  27245. */
  27246. RayHelper.prototype.dispose = function () {
  27247. this.hide();
  27248. this.detachFromMesh();
  27249. this.ray = null;
  27250. };
  27251. return RayHelper;
  27252. }());
  27253. /***/ }),
  27254. /***/ "./Debug/skeletonViewer.ts":
  27255. /*!*********************************!*\
  27256. !*** ./Debug/skeletonViewer.ts ***!
  27257. \*********************************/
  27258. /*! exports provided: SkeletonViewer */
  27259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27260. "use strict";
  27261. __webpack_require__.r(__webpack_exports__);
  27262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  27263. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27264. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27265. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  27266. /**
  27267. * Class used to render a debug view of a given skeleton
  27268. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  27269. */
  27270. var SkeletonViewer = /** @class */ (function () {
  27271. /**
  27272. * Creates a new SkeletonViewer
  27273. * @param skeleton defines the skeleton to render
  27274. * @param mesh defines the mesh attached to the skeleton
  27275. * @param scene defines the hosting scene
  27276. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  27277. * @param renderingGroupId defines the rendering group id to use with the viewer
  27278. */
  27279. function SkeletonViewer(
  27280. /** defines the skeleton to render */
  27281. skeleton,
  27282. /** defines the mesh attached to the skeleton */
  27283. mesh, scene,
  27284. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  27285. autoUpdateBonesMatrices,
  27286. /** defines the rendering group id to use with the viewer */
  27287. renderingGroupId) {
  27288. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  27289. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  27290. this.skeleton = skeleton;
  27291. this.mesh = mesh;
  27292. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  27293. this.renderingGroupId = renderingGroupId;
  27294. /** Gets or sets the color used to render the skeleton */
  27295. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  27296. this._debugLines = new Array();
  27297. this._isEnabled = false;
  27298. this._scene = scene;
  27299. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  27300. this._utilityLayer.pickUtilitySceneFirst = false;
  27301. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  27302. this.update();
  27303. this._renderFunction = this.update.bind(this);
  27304. }
  27305. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  27306. /**
  27307. * Returns the mesh used to render the bones
  27308. */
  27309. get: function () {
  27310. return this._debugMesh;
  27311. },
  27312. enumerable: true,
  27313. configurable: true
  27314. });
  27315. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  27316. get: function () {
  27317. return this._isEnabled;
  27318. },
  27319. /** Gets or sets a boolean indicating if the viewer is enabled */
  27320. set: function (value) {
  27321. if (this._isEnabled === value) {
  27322. return;
  27323. }
  27324. this._isEnabled = value;
  27325. if (value) {
  27326. this._scene.registerBeforeRender(this._renderFunction);
  27327. }
  27328. else {
  27329. this._scene.unregisterBeforeRender(this._renderFunction);
  27330. }
  27331. },
  27332. enumerable: true,
  27333. configurable: true
  27334. });
  27335. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  27336. if (x === void 0) { x = 0; }
  27337. if (y === void 0) { y = 0; }
  27338. if (z === void 0) { z = 0; }
  27339. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  27340. var parentBone = bone.getParent();
  27341. tmat.copyFrom(bone.getLocalMatrix());
  27342. if (x !== 0 || y !== 0 || z !== 0) {
  27343. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  27344. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  27345. tmat2.setTranslationFromFloats(x, y, z);
  27346. tmat2.multiplyToRef(tmat, tmat);
  27347. }
  27348. if (parentBone) {
  27349. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  27350. }
  27351. tmat.multiplyToRef(meshMat, tmat);
  27352. position.x = tmat.m[12];
  27353. position.y = tmat.m[13];
  27354. position.z = tmat.m[14];
  27355. };
  27356. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  27357. var len = bones.length;
  27358. var mesh = this.mesh._effectiveMesh;
  27359. var meshPos = mesh.position;
  27360. for (var i = 0; i < len; i++) {
  27361. var bone = bones[i];
  27362. var points = this._debugLines[i];
  27363. if (!points) {
  27364. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27365. this._debugLines[i] = points;
  27366. }
  27367. this._getBonePosition(points[0], bone, meshMat);
  27368. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  27369. points[0].subtractInPlace(meshPos);
  27370. points[1].subtractInPlace(meshPos);
  27371. }
  27372. };
  27373. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  27374. var len = bones.length;
  27375. var boneNum = 0;
  27376. var mesh = this.mesh._effectiveMesh;
  27377. var meshPos = mesh.position;
  27378. for (var i = len - 1; i >= 0; i--) {
  27379. var childBone = bones[i];
  27380. var parentBone = childBone.getParent();
  27381. if (!parentBone) {
  27382. continue;
  27383. }
  27384. var points = this._debugLines[boneNum];
  27385. if (!points) {
  27386. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27387. this._debugLines[boneNum] = points;
  27388. }
  27389. childBone.getAbsolutePositionToRef(mesh, points[0]);
  27390. parentBone.getAbsolutePositionToRef(mesh, points[1]);
  27391. points[0].subtractInPlace(meshPos);
  27392. points[1].subtractInPlace(meshPos);
  27393. boneNum++;
  27394. }
  27395. };
  27396. /** Update the viewer to sync with current skeleton state */
  27397. SkeletonViewer.prototype.update = function () {
  27398. if (!this._utilityLayer) {
  27399. return;
  27400. }
  27401. if (this.autoUpdateBonesMatrices) {
  27402. this.skeleton.computeAbsoluteTransforms();
  27403. }
  27404. var mesh = this.mesh._effectiveMesh;
  27405. if (this.skeleton.bones[0].length === undefined) {
  27406. this._getLinesForBonesNoLength(this.skeleton.bones, mesh.getWorldMatrix());
  27407. }
  27408. else {
  27409. this._getLinesForBonesWithLength(this.skeleton.bones, mesh.getWorldMatrix());
  27410. }
  27411. var targetScene = this._utilityLayer.utilityLayerScene;
  27412. if (!this._debugMesh) {
  27413. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  27414. this._debugMesh.renderingGroupId = this.renderingGroupId;
  27415. }
  27416. else {
  27417. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  27418. }
  27419. this._debugMesh.position.copyFrom(this.mesh.position);
  27420. this._debugMesh.color = this.color;
  27421. };
  27422. /** Release associated resources */
  27423. SkeletonViewer.prototype.dispose = function () {
  27424. this.isEnabled = false;
  27425. if (this._debugMesh) {
  27426. this.isEnabled = false;
  27427. this._debugMesh.dispose();
  27428. this._debugMesh = null;
  27429. }
  27430. if (this._utilityLayer) {
  27431. this._utilityLayer.dispose();
  27432. this._utilityLayer = null;
  27433. }
  27434. };
  27435. return SkeletonViewer;
  27436. }());
  27437. /***/ }),
  27438. /***/ "./Engines/Extensions/engine.multiview.ts":
  27439. /*!************************************************!*\
  27440. !*** ./Engines/Extensions/engine.multiview.ts ***!
  27441. \************************************************/
  27442. /*! no exports provided */
  27443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27444. "use strict";
  27445. __webpack_require__.r(__webpack_exports__);
  27446. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  27447. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27448. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  27449. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27450. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  27451. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  27452. /* harmony import */ var _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/MultiviewRenderTarget */ "./Materials/Textures/MultiviewRenderTarget.ts");
  27453. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createMultiviewRenderTargetTexture = function (width, height) {
  27454. var gl = this._gl;
  27455. if (!this.getCaps().multiview) {
  27456. throw "Multiview is not supported";
  27457. }
  27458. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  27459. internalTexture.width = width;
  27460. internalTexture.height = height;
  27461. internalTexture._framebuffer = gl.createFramebuffer();
  27462. internalTexture._colorTextureArray = gl.createTexture();
  27463. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._colorTextureArray);
  27464. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, width, height, 2);
  27465. internalTexture._depthStencilTextureArray = gl.createTexture();
  27466. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._depthStencilTextureArray);
  27467. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.DEPTH32F_STENCIL8, width, height, 2);
  27468. internalTexture.isReady = true;
  27469. return internalTexture;
  27470. };
  27471. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.bindMultiviewFramebuffer = function (multiviewTexture) {
  27472. var gl = this._gl;
  27473. var ext = this.getCaps().multiview;
  27474. this.bindFramebuffer(multiviewTexture, undefined, undefined, undefined, true);
  27475. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, multiviewTexture._framebuffer);
  27476. if (multiviewTexture._colorTextureArray && multiviewTexture._depthStencilTextureArray) {
  27477. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, 0, 2);
  27478. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, 0, 2);
  27479. }
  27480. else {
  27481. throw "Invalid multiview frame buffer";
  27482. }
  27483. };
  27484. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._useMultiviewToSingleView = false;
  27485. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._multiviewTexture = null;
  27486. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._resizeOrCreateMultiviewTexture = function (width, height) {
  27487. if (!this._multiviewTexture) {
  27488. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  27489. }
  27490. else if (this._multiviewTexture.getRenderWidth() != width || this._multiviewTexture.getRenderHeight() != height) {
  27491. this._multiviewTexture.dispose();
  27492. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  27493. }
  27494. };
  27495. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._transformMatrixR = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  27496. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._multiviewSceneUbo = null;
  27497. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._createMultiviewUbo = function () {
  27498. this._multiviewSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__["UniformBuffer"](this.getEngine(), undefined, true);
  27499. this._multiviewSceneUbo.addUniform("viewProjection", 16);
  27500. this._multiviewSceneUbo.addUniform("viewProjectionR", 16);
  27501. this._multiviewSceneUbo.addUniform("view", 16);
  27502. };
  27503. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._updateMultiviewUbo = function (viewR, projectionR) {
  27504. if (viewR && projectionR) {
  27505. viewR.multiplyToRef(projectionR, this._transformMatrixR);
  27506. }
  27507. if (viewR && projectionR) {
  27508. viewR.multiplyToRef(projectionR, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  27509. _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
  27510. }
  27511. if (this._multiviewSceneUbo) {
  27512. this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix());
  27513. this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR);
  27514. this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix);
  27515. this._multiviewSceneUbo.update();
  27516. }
  27517. };
  27518. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._renderMultiviewToSingleView = function (camera) {
  27519. // Multiview is only able to be displayed directly for API's such as webXR
  27520. // This displays a multiview image by rendering to the multiview image and then
  27521. // copying the result into the sub cameras instead of rendering them and proceeding as normal from there
  27522. // Render to a multiview texture
  27523. 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));
  27524. if (!this._multiviewSceneUbo) {
  27525. this._createMultiviewUbo();
  27526. }
  27527. camera.outputRenderTarget = camera._multiviewTexture;
  27528. this._renderForCamera(camera);
  27529. camera.outputRenderTarget = null;
  27530. // Consume the multiview texture through a shader for each eye
  27531. for (var index = 0; index < camera._rigCameras.length; index++) {
  27532. var engine = this.getEngine();
  27533. this._activeCamera = camera._rigCameras[index];
  27534. engine.setViewport(this._activeCamera.viewport);
  27535. if (this.postProcessManager) {
  27536. this.postProcessManager._prepareFrame();
  27537. this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate);
  27538. }
  27539. }
  27540. };
  27541. /***/ }),
  27542. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  27543. /*!*****************************************************!*\
  27544. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  27545. \*****************************************************/
  27546. /*! exports provided: _OcclusionDataStorage */
  27547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27548. "use strict";
  27549. __webpack_require__.r(__webpack_exports__);
  27550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  27551. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27552. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  27553. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  27554. /** @hidden */
  27555. var _OcclusionDataStorage = /** @class */ (function () {
  27556. function _OcclusionDataStorage() {
  27557. /** @hidden */
  27558. this.occlusionInternalRetryCounter = 0;
  27559. /** @hidden */
  27560. this.isOcclusionQueryInProgress = false;
  27561. /** @hidden */
  27562. this.isOccluded = false;
  27563. /** @hidden */
  27564. this.occlusionRetryCount = -1;
  27565. /** @hidden */
  27566. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  27567. /** @hidden */
  27568. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  27569. }
  27570. return _OcclusionDataStorage;
  27571. }());
  27572. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  27573. return this._gl.createQuery();
  27574. };
  27575. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  27576. this._gl.deleteQuery(query);
  27577. return this;
  27578. };
  27579. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  27580. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  27581. };
  27582. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  27583. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  27584. };
  27585. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  27586. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27587. this._gl.beginQuery(glAlgorithm, query);
  27588. return this;
  27589. };
  27590. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  27591. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27592. this._gl.endQuery(glAlgorithm);
  27593. return this;
  27594. };
  27595. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  27596. var timerQuery = this.getCaps().timerQuery;
  27597. if (timerQuery.createQueryEXT) {
  27598. return timerQuery.createQueryEXT();
  27599. }
  27600. return this.createQuery();
  27601. };
  27602. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  27603. var timerQuery = this.getCaps().timerQuery;
  27604. if (timerQuery.deleteQueryEXT) {
  27605. timerQuery.deleteQueryEXT(query);
  27606. return;
  27607. }
  27608. this.deleteQuery(query);
  27609. };
  27610. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  27611. var timerQuery = this.getCaps().timerQuery;
  27612. if (timerQuery.getQueryObjectEXT) {
  27613. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  27614. }
  27615. return this.getQueryResult(query);
  27616. };
  27617. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  27618. var timerQuery = this.getCaps().timerQuery;
  27619. if (timerQuery.getQueryObjectEXT) {
  27620. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  27621. }
  27622. return this.isQueryResultAvailable(query);
  27623. };
  27624. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  27625. var caps = this.getCaps();
  27626. var timerQuery = caps.timerQuery;
  27627. if (!timerQuery) {
  27628. return null;
  27629. }
  27630. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  27631. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27632. if (caps.canUseTimestampForTimerQuery) {
  27633. token._startTimeQuery = this._createTimeQuery();
  27634. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  27635. }
  27636. else {
  27637. if (this._currentNonTimestampToken) {
  27638. return this._currentNonTimestampToken;
  27639. }
  27640. token._timeElapsedQuery = this._createTimeQuery();
  27641. if (timerQuery.beginQueryEXT) {
  27642. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27643. }
  27644. else {
  27645. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27646. }
  27647. this._currentNonTimestampToken = token;
  27648. }
  27649. return token;
  27650. };
  27651. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  27652. var caps = this.getCaps();
  27653. var timerQuery = caps.timerQuery;
  27654. if (!timerQuery || !token) {
  27655. return -1;
  27656. }
  27657. if (caps.canUseTimestampForTimerQuery) {
  27658. if (!token._startTimeQuery) {
  27659. return -1;
  27660. }
  27661. if (!token._endTimeQuery) {
  27662. token._endTimeQuery = this._createTimeQuery();
  27663. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  27664. }
  27665. }
  27666. else if (!token._timeElapsedQueryEnded) {
  27667. if (!token._timeElapsedQuery) {
  27668. return -1;
  27669. }
  27670. if (timerQuery.endQueryEXT) {
  27671. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  27672. }
  27673. else {
  27674. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  27675. }
  27676. token._timeElapsedQueryEnded = true;
  27677. }
  27678. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27679. var available = false;
  27680. if (token._endTimeQuery) {
  27681. available = this._getTimeQueryAvailability(token._endTimeQuery);
  27682. }
  27683. else if (token._timeElapsedQuery) {
  27684. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  27685. }
  27686. if (available && !disjoint) {
  27687. var result = 0;
  27688. if (caps.canUseTimestampForTimerQuery) {
  27689. if (!token._startTimeQuery || !token._endTimeQuery) {
  27690. return -1;
  27691. }
  27692. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  27693. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  27694. result = timeEnd - timeStart;
  27695. this._deleteTimeQuery(token._startTimeQuery);
  27696. this._deleteTimeQuery(token._endTimeQuery);
  27697. token._startTimeQuery = null;
  27698. token._endTimeQuery = null;
  27699. }
  27700. else {
  27701. if (!token._timeElapsedQuery) {
  27702. return -1;
  27703. }
  27704. result = this._getTimeQueryResult(token._timeElapsedQuery);
  27705. this._deleteTimeQuery(token._timeElapsedQuery);
  27706. token._timeElapsedQuery = null;
  27707. token._timeElapsedQueryEnded = false;
  27708. this._currentNonTimestampToken = null;
  27709. }
  27710. return result;
  27711. }
  27712. return -1;
  27713. };
  27714. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  27715. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  27716. };
  27717. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  27718. get: function () {
  27719. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  27720. },
  27721. enumerable: false,
  27722. configurable: true
  27723. });
  27724. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  27725. get: function () {
  27726. if (!this.__occlusionDataStorage) {
  27727. this.__occlusionDataStorage = new _OcclusionDataStorage();
  27728. }
  27729. return this.__occlusionDataStorage;
  27730. },
  27731. enumerable: false,
  27732. configurable: true
  27733. });
  27734. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  27735. get: function () {
  27736. return this._occlusionDataStorage.isOccluded;
  27737. },
  27738. set: function (value) {
  27739. this._occlusionDataStorage.isOccluded = value;
  27740. },
  27741. enumerable: true,
  27742. configurable: true
  27743. });
  27744. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  27745. get: function () {
  27746. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  27747. },
  27748. set: function (value) {
  27749. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  27750. },
  27751. enumerable: true,
  27752. configurable: true
  27753. });
  27754. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  27755. get: function () {
  27756. return this._occlusionDataStorage.occlusionType;
  27757. },
  27758. set: function (value) {
  27759. this._occlusionDataStorage.occlusionType = value;
  27760. },
  27761. enumerable: true,
  27762. configurable: true
  27763. });
  27764. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  27765. get: function () {
  27766. return this._occlusionDataStorage.occlusionRetryCount;
  27767. },
  27768. set: function (value) {
  27769. this._occlusionDataStorage.occlusionRetryCount = value;
  27770. },
  27771. enumerable: true,
  27772. configurable: true
  27773. });
  27774. // We also need to update AbstractMesh as there is a portion of the code there
  27775. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  27776. var dataStorage = this._occlusionDataStorage;
  27777. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  27778. dataStorage.isOccluded = false;
  27779. return false;
  27780. }
  27781. var engine = this.getEngine();
  27782. if (engine.webGLVersion < 2) {
  27783. dataStorage.isOccluded = false;
  27784. return false;
  27785. }
  27786. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  27787. dataStorage.isOccluded = false;
  27788. return false;
  27789. }
  27790. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  27791. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  27792. if (isOcclusionQueryAvailable) {
  27793. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  27794. dataStorage.isOcclusionQueryInProgress = false;
  27795. dataStorage.occlusionInternalRetryCounter = 0;
  27796. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  27797. }
  27798. else {
  27799. dataStorage.occlusionInternalRetryCounter++;
  27800. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  27801. dataStorage.isOcclusionQueryInProgress = false;
  27802. dataStorage.occlusionInternalRetryCounter = 0;
  27803. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  27804. // if strict continue the last state of the object.
  27805. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  27806. }
  27807. else {
  27808. return false;
  27809. }
  27810. }
  27811. }
  27812. var scene = this.getScene();
  27813. if (scene.getBoundingBoxRenderer) {
  27814. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  27815. if (!this._occlusionQuery) {
  27816. this._occlusionQuery = engine.createQuery();
  27817. }
  27818. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  27819. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  27820. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  27821. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  27822. }
  27823. return dataStorage.isOccluded;
  27824. };
  27825. /***/ }),
  27826. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  27827. /*!********************************************************!*\
  27828. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  27829. \********************************************************/
  27830. /*! exports provided: _forceTransformFeedbackToBundle */
  27831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27832. "use strict";
  27833. __webpack_require__.r(__webpack_exports__);
  27834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  27835. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27836. /** @hidden */
  27837. var _forceTransformFeedbackToBundle = true;
  27838. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  27839. return this._gl.createTransformFeedback();
  27840. };
  27841. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  27842. this._gl.deleteTransformFeedback(value);
  27843. };
  27844. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  27845. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  27846. };
  27847. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  27848. if (usePoints === void 0) { usePoints = true; }
  27849. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  27850. };
  27851. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  27852. this._gl.endTransformFeedback();
  27853. };
  27854. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  27855. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  27856. };
  27857. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  27858. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  27859. };
  27860. /***/ }),
  27861. /***/ "./Engines/Extensions/index.ts":
  27862. /*!*************************************!*\
  27863. !*** ./Engines/Extensions/index.ts ***!
  27864. \*************************************/
  27865. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  27866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27867. "use strict";
  27868. __webpack_require__.r(__webpack_exports__);
  27869. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  27870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  27871. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  27872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  27873. /***/ }),
  27874. /***/ "./Engines/constants.ts":
  27875. /*!******************************!*\
  27876. !*** ./Engines/constants.ts ***!
  27877. \******************************/
  27878. /*! exports provided: Constants */
  27879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27880. "use strict";
  27881. __webpack_require__.r(__webpack_exports__);
  27882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  27883. /** Defines the cross module used constants to avoid circular dependncies */
  27884. var Constants = /** @class */ (function () {
  27885. function Constants() {
  27886. }
  27887. /** Defines that alpha blending is disabled */
  27888. Constants.ALPHA_DISABLE = 0;
  27889. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27890. Constants.ALPHA_ADD = 1;
  27891. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27892. Constants.ALPHA_COMBINE = 2;
  27893. /** Defines that alpha blending to DEST - SRC * DEST */
  27894. Constants.ALPHA_SUBTRACT = 3;
  27895. /** Defines that alpha blending to SRC * DEST */
  27896. Constants.ALPHA_MULTIPLY = 4;
  27897. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27898. Constants.ALPHA_MAXIMIZED = 5;
  27899. /** Defines that alpha blending to SRC + DEST */
  27900. Constants.ALPHA_ONEONE = 6;
  27901. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27902. Constants.ALPHA_PREMULTIPLIED = 7;
  27903. /**
  27904. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27905. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27906. */
  27907. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27908. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27909. Constants.ALPHA_INTERPOLATE = 9;
  27910. /**
  27911. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27912. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27913. */
  27914. Constants.ALPHA_SCREENMODE = 10;
  27915. /** Defines that the ressource is not delayed*/
  27916. Constants.DELAYLOADSTATE_NONE = 0;
  27917. /** Defines that the ressource was successfully delay loaded */
  27918. Constants.DELAYLOADSTATE_LOADED = 1;
  27919. /** Defines that the ressource is currently delay loading */
  27920. Constants.DELAYLOADSTATE_LOADING = 2;
  27921. /** Defines that the ressource is delayed and has not started loading */
  27922. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27923. // Depht or Stencil test Constants.
  27924. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27925. Constants.NEVER = 0x0200;
  27926. /** 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 */
  27927. Constants.ALWAYS = 0x0207;
  27928. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27929. Constants.LESS = 0x0201;
  27930. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27931. Constants.EQUAL = 0x0202;
  27932. /** 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 */
  27933. Constants.LEQUAL = 0x0203;
  27934. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27935. Constants.GREATER = 0x0204;
  27936. /** 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 */
  27937. Constants.GEQUAL = 0x0206;
  27938. /** 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 */
  27939. Constants.NOTEQUAL = 0x0205;
  27940. // Stencil Actions Constants.
  27941. /** Passed to stencilOperation to specify that stencil value must be kept */
  27942. Constants.KEEP = 0x1E00;
  27943. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27944. Constants.REPLACE = 0x1E01;
  27945. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27946. Constants.INCR = 0x1E02;
  27947. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27948. Constants.DECR = 0x1E03;
  27949. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27950. Constants.INVERT = 0x150A;
  27951. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27952. Constants.INCR_WRAP = 0x8507;
  27953. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27954. Constants.DECR_WRAP = 0x8508;
  27955. /** Texture is not repeating outside of 0..1 UVs */
  27956. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27957. /** Texture is repeating outside of 0..1 UVs */
  27958. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27959. /** Texture is repeating and mirrored */
  27960. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27961. /** ALPHA */
  27962. Constants.TEXTUREFORMAT_ALPHA = 0;
  27963. /** LUMINANCE */
  27964. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27965. /** LUMINANCE_ALPHA */
  27966. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27967. /** RGB */
  27968. Constants.TEXTUREFORMAT_RGB = 4;
  27969. /** RGBA */
  27970. Constants.TEXTUREFORMAT_RGBA = 5;
  27971. /** RED */
  27972. Constants.TEXTUREFORMAT_RED = 6;
  27973. /** RED (2nd reference) */
  27974. Constants.TEXTUREFORMAT_R = 6;
  27975. /** RG */
  27976. Constants.TEXTUREFORMAT_RG = 7;
  27977. /** RED_INTEGER */
  27978. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27979. /** RED_INTEGER (2nd reference) */
  27980. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27981. /** RG_INTEGER */
  27982. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27983. /** RGB_INTEGER */
  27984. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27985. /** RGBA_INTEGER */
  27986. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27987. /** UNSIGNED_BYTE */
  27988. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27989. /** UNSIGNED_BYTE (2nd reference) */
  27990. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27991. /** FLOAT */
  27992. Constants.TEXTURETYPE_FLOAT = 1;
  27993. /** HALF_FLOAT */
  27994. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27995. /** BYTE */
  27996. Constants.TEXTURETYPE_BYTE = 3;
  27997. /** SHORT */
  27998. Constants.TEXTURETYPE_SHORT = 4;
  27999. /** UNSIGNED_SHORT */
  28000. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  28001. /** INT */
  28002. Constants.TEXTURETYPE_INT = 6;
  28003. /** UNSIGNED_INT */
  28004. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  28005. /** UNSIGNED_SHORT_4_4_4_4 */
  28006. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  28007. /** UNSIGNED_SHORT_5_5_5_1 */
  28008. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  28009. /** UNSIGNED_SHORT_5_6_5 */
  28010. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  28011. /** UNSIGNED_INT_2_10_10_10_REV */
  28012. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  28013. /** UNSIGNED_INT_24_8 */
  28014. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  28015. /** UNSIGNED_INT_10F_11F_11F_REV */
  28016. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  28017. /** UNSIGNED_INT_5_9_9_9_REV */
  28018. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  28019. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28020. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  28021. /** nearest is mag = nearest and min = nearest and mip = linear */
  28022. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  28023. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28024. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  28025. /** Trilinear is mag = linear and min = linear and mip = linear */
  28026. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  28027. /** nearest is mag = nearest and min = nearest and mip = linear */
  28028. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  28029. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28030. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  28031. /** Trilinear is mag = linear and min = linear and mip = linear */
  28032. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  28033. /** mag = nearest and min = nearest and mip = nearest */
  28034. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  28035. /** mag = nearest and min = linear and mip = nearest */
  28036. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  28037. /** mag = nearest and min = linear and mip = linear */
  28038. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  28039. /** mag = nearest and min = linear and mip = none */
  28040. Constants.TEXTURE_NEAREST_LINEAR = 7;
  28041. /** mag = nearest and min = nearest and mip = none */
  28042. Constants.TEXTURE_NEAREST_NEAREST = 8;
  28043. /** mag = linear and min = nearest and mip = nearest */
  28044. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  28045. /** mag = linear and min = nearest and mip = linear */
  28046. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  28047. /** mag = linear and min = linear and mip = none */
  28048. Constants.TEXTURE_LINEAR_LINEAR = 11;
  28049. /** mag = linear and min = nearest and mip = none */
  28050. Constants.TEXTURE_LINEAR_NEAREST = 12;
  28051. /** Explicit coordinates mode */
  28052. Constants.TEXTURE_EXPLICIT_MODE = 0;
  28053. /** Spherical coordinates mode */
  28054. Constants.TEXTURE_SPHERICAL_MODE = 1;
  28055. /** Planar coordinates mode */
  28056. Constants.TEXTURE_PLANAR_MODE = 2;
  28057. /** Cubic coordinates mode */
  28058. Constants.TEXTURE_CUBIC_MODE = 3;
  28059. /** Projection coordinates mode */
  28060. Constants.TEXTURE_PROJECTION_MODE = 4;
  28061. /** Skybox coordinates mode */
  28062. Constants.TEXTURE_SKYBOX_MODE = 5;
  28063. /** Inverse Cubic coordinates mode */
  28064. Constants.TEXTURE_INVCUBIC_MODE = 6;
  28065. /** Equirectangular coordinates mode */
  28066. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  28067. /** Equirectangular Fixed coordinates mode */
  28068. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  28069. /** Equirectangular Fixed Mirrored coordinates mode */
  28070. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  28071. // Texture rescaling mode
  28072. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28073. Constants.SCALEMODE_FLOOR = 1;
  28074. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28075. Constants.SCALEMODE_NEAREST = 2;
  28076. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28077. Constants.SCALEMODE_CEILING = 3;
  28078. /**
  28079. * The dirty texture flag value
  28080. */
  28081. Constants.MATERIAL_TextureDirtyFlag = 1;
  28082. /**
  28083. * The dirty light flag value
  28084. */
  28085. Constants.MATERIAL_LightDirtyFlag = 2;
  28086. /**
  28087. * The dirty fresnel flag value
  28088. */
  28089. Constants.MATERIAL_FresnelDirtyFlag = 4;
  28090. /**
  28091. * The dirty attribute flag value
  28092. */
  28093. Constants.MATERIAL_AttributesDirtyFlag = 8;
  28094. /**
  28095. * The dirty misc flag value
  28096. */
  28097. Constants.MATERIAL_MiscDirtyFlag = 16;
  28098. /**
  28099. * The all dirty flag value
  28100. */
  28101. Constants.MATERIAL_AllDirtyFlag = 31;
  28102. /**
  28103. * Returns the triangle fill mode
  28104. */
  28105. Constants.MATERIAL_TriangleFillMode = 0;
  28106. /**
  28107. * Returns the wireframe mode
  28108. */
  28109. Constants.MATERIAL_WireFrameFillMode = 1;
  28110. /**
  28111. * Returns the point fill mode
  28112. */
  28113. Constants.MATERIAL_PointFillMode = 2;
  28114. /**
  28115. * Returns the point list draw mode
  28116. */
  28117. Constants.MATERIAL_PointListDrawMode = 3;
  28118. /**
  28119. * Returns the line list draw mode
  28120. */
  28121. Constants.MATERIAL_LineListDrawMode = 4;
  28122. /**
  28123. * Returns the line loop draw mode
  28124. */
  28125. Constants.MATERIAL_LineLoopDrawMode = 5;
  28126. /**
  28127. * Returns the line strip draw mode
  28128. */
  28129. Constants.MATERIAL_LineStripDrawMode = 6;
  28130. /**
  28131. * Returns the triangle strip draw mode
  28132. */
  28133. Constants.MATERIAL_TriangleStripDrawMode = 7;
  28134. /**
  28135. * Returns the triangle fan draw mode
  28136. */
  28137. Constants.MATERIAL_TriangleFanDrawMode = 8;
  28138. /**
  28139. * Stores the clock-wise side orientation
  28140. */
  28141. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  28142. /**
  28143. * Stores the counter clock-wise side orientation
  28144. */
  28145. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  28146. /**
  28147. * Nothing
  28148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28149. */
  28150. Constants.ACTION_NothingTrigger = 0;
  28151. /**
  28152. * On pick
  28153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28154. */
  28155. Constants.ACTION_OnPickTrigger = 1;
  28156. /**
  28157. * On left pick
  28158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28159. */
  28160. Constants.ACTION_OnLeftPickTrigger = 2;
  28161. /**
  28162. * On right pick
  28163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28164. */
  28165. Constants.ACTION_OnRightPickTrigger = 3;
  28166. /**
  28167. * On center pick
  28168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28169. */
  28170. Constants.ACTION_OnCenterPickTrigger = 4;
  28171. /**
  28172. * On pick down
  28173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28174. */
  28175. Constants.ACTION_OnPickDownTrigger = 5;
  28176. /**
  28177. * On double pick
  28178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28179. */
  28180. Constants.ACTION_OnDoublePickTrigger = 6;
  28181. /**
  28182. * On pick up
  28183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28184. */
  28185. Constants.ACTION_OnPickUpTrigger = 7;
  28186. /**
  28187. * On pick out.
  28188. * This trigger will only be raised if you also declared a OnPickDown
  28189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28190. */
  28191. Constants.ACTION_OnPickOutTrigger = 16;
  28192. /**
  28193. * On long press
  28194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28195. */
  28196. Constants.ACTION_OnLongPressTrigger = 8;
  28197. /**
  28198. * On pointer over
  28199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28200. */
  28201. Constants.ACTION_OnPointerOverTrigger = 9;
  28202. /**
  28203. * On pointer out
  28204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28205. */
  28206. Constants.ACTION_OnPointerOutTrigger = 10;
  28207. /**
  28208. * On every frame
  28209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28210. */
  28211. Constants.ACTION_OnEveryFrameTrigger = 11;
  28212. /**
  28213. * On intersection enter
  28214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28215. */
  28216. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  28217. /**
  28218. * On intersection exit
  28219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28220. */
  28221. Constants.ACTION_OnIntersectionExitTrigger = 13;
  28222. /**
  28223. * On key down
  28224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28225. */
  28226. Constants.ACTION_OnKeyDownTrigger = 14;
  28227. /**
  28228. * On key up
  28229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28230. */
  28231. Constants.ACTION_OnKeyUpTrigger = 15;
  28232. /**
  28233. * Billboard mode will only apply to Y axis
  28234. */
  28235. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  28236. /**
  28237. * Billboard mode will apply to all axes
  28238. */
  28239. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  28240. /**
  28241. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  28242. */
  28243. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  28244. /**
  28245. * Gets or sets base Assets URL
  28246. */
  28247. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  28248. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28249. * Test order :
  28250. * Is the bounding sphere outside the frustum ?
  28251. * If not, are the bounding box vertices outside the frustum ?
  28252. * It not, then the cullable object is in the frustum.
  28253. */
  28254. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  28255. /** Culling strategy : Bounding Sphere Only.
  28256. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28257. * It's also less accurate than the standard because some not visible objects can still be selected.
  28258. * Test : is the bounding sphere outside the frustum ?
  28259. * If not, then the cullable object is in the frustum.
  28260. */
  28261. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  28262. /** Culling strategy : Optimistic Inclusion.
  28263. * This in an inclusion test first, then the standard exclusion test.
  28264. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28265. * 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.
  28266. * Anyway, it's as accurate as the standard strategy.
  28267. * Test :
  28268. * Is the cullable object bounding sphere center in the frustum ?
  28269. * If not, apply the default culling strategy.
  28270. */
  28271. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  28272. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28273. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28274. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28275. * 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.
  28276. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28277. * Test :
  28278. * Is the cullable object bounding sphere center in the frustum ?
  28279. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28280. */
  28281. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  28282. /**
  28283. * No logging while loading
  28284. */
  28285. Constants.SCENELOADER_NO_LOGGING = 0;
  28286. /**
  28287. * Minimal logging while loading
  28288. */
  28289. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  28290. /**
  28291. * Summary logging while loading
  28292. */
  28293. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  28294. /**
  28295. * Detailled logging while loading
  28296. */
  28297. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  28298. return Constants;
  28299. }());
  28300. /***/ }),
  28301. /***/ "./Engines/engine.ts":
  28302. /*!***************************!*\
  28303. !*** ./Engines/engine.ts ***!
  28304. \***************************/
  28305. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  28306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28307. "use strict";
  28308. __webpack_require__.r(__webpack_exports__);
  28309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  28310. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  28311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  28312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  28313. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  28314. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  28315. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  28316. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  28317. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  28318. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  28319. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  28320. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  28321. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  28322. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  28323. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28324. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  28325. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  28326. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  28327. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  28328. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  28329. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  28330. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  28331. /**
  28332. * Keeps track of all the buffer info used in engine.
  28333. */
  28334. var BufferPointer = /** @class */ (function () {
  28335. function BufferPointer() {
  28336. }
  28337. return BufferPointer;
  28338. }());
  28339. /**
  28340. * Interface for attribute information associated with buffer instanciation
  28341. */
  28342. var InstancingAttributeInfo = /** @class */ (function () {
  28343. function InstancingAttributeInfo() {
  28344. }
  28345. return InstancingAttributeInfo;
  28346. }());
  28347. /**
  28348. * Define options used to create a depth texture
  28349. */
  28350. var DepthTextureCreationOptions = /** @class */ (function () {
  28351. function DepthTextureCreationOptions() {
  28352. }
  28353. return DepthTextureCreationOptions;
  28354. }());
  28355. /**
  28356. * Class used to describe the capabilities of the engine relatively to the current browser
  28357. */
  28358. var EngineCapabilities = /** @class */ (function () {
  28359. function EngineCapabilities() {
  28360. }
  28361. return EngineCapabilities;
  28362. }());
  28363. /**
  28364. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28365. */
  28366. var Engine = /** @class */ (function () {
  28367. /**
  28368. * Creates a new engine
  28369. * @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
  28370. * @param antialias defines enable antialiasing (default: false)
  28371. * @param options defines further options to be sent to the getContext() function
  28372. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28373. */
  28374. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  28375. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  28376. var _this = this;
  28377. // Public members
  28378. /**
  28379. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28380. */
  28381. this.forcePOTTextures = false;
  28382. /**
  28383. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28384. */
  28385. this.isFullscreen = false;
  28386. /**
  28387. * Gets a boolean indicating if the pointer is currently locked
  28388. */
  28389. this.isPointerLock = false;
  28390. /**
  28391. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28392. */
  28393. this.cullBackFaces = true;
  28394. /**
  28395. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28396. */
  28397. this.renderEvenInBackground = true;
  28398. /**
  28399. * Gets or sets a boolean indicating that cache can be kept between frames
  28400. */
  28401. this.preventCacheWipeBetweenFrames = false;
  28402. /**
  28403. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28404. **/
  28405. this.enableOfflineSupport = false;
  28406. /**
  28407. * 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)
  28408. **/
  28409. this.disableManifestCheck = false;
  28410. /**
  28411. * Gets the list of created scenes
  28412. */
  28413. this.scenes = new Array();
  28414. /**
  28415. * Event raised when a new scene is created
  28416. */
  28417. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28418. /**
  28419. * Gets the list of created postprocesses
  28420. */
  28421. this.postProcesses = new Array();
  28422. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28423. this.validateShaderPrograms = false;
  28424. // Observables
  28425. /**
  28426. * Observable event triggered each time the rendering canvas is resized
  28427. */
  28428. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28429. /**
  28430. * Observable event triggered each time the canvas loses focus
  28431. */
  28432. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28433. /**
  28434. * Observable event triggered each time the canvas gains focus
  28435. */
  28436. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28437. /**
  28438. * Observable event triggered each time the canvas receives pointerout event
  28439. */
  28440. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28441. /**
  28442. * Observable event triggered before each texture is initialized
  28443. */
  28444. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28445. //WebVR
  28446. this._vrDisplay = undefined;
  28447. this._vrSupported = false;
  28448. this._vrExclusivePointerMode = false;
  28449. // Uniform buffers list
  28450. /**
  28451. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28452. */
  28453. this.disableUniformBuffers = false;
  28454. /** @hidden */
  28455. this._uniformBuffers = new Array();
  28456. // Observables
  28457. /**
  28458. * Observable raised when the engine begins a new frame
  28459. */
  28460. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28461. /**
  28462. * If set, will be used to request the next animation frame for the render loop
  28463. */
  28464. this.customAnimationFrameRequester = null;
  28465. /**
  28466. * Observable raised when the engine ends the current frame
  28467. */
  28468. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28469. /**
  28470. * Observable raised when the engine is about to compile a shader
  28471. */
  28472. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28473. /**
  28474. * Observable raised when the engine has jsut compiled a shader
  28475. */
  28476. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28477. this._windowIsBackground = false;
  28478. this._webGLVersion = 1.0;
  28479. this._highPrecisionShadersAllowed = true;
  28480. /** @hidden */
  28481. this._badOS = false;
  28482. /** @hidden */
  28483. this._badDesktopOS = false;
  28484. /**
  28485. * Observable signaled when VR display mode changes
  28486. */
  28487. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28488. /**
  28489. * Observable signaled when VR request present is complete
  28490. */
  28491. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28492. /**
  28493. * Observable signaled when VR request present starts
  28494. */
  28495. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28496. this._colorWrite = true;
  28497. /** @hidden */
  28498. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28499. this._renderingQueueLaunched = false;
  28500. this._activeRenderLoops = new Array();
  28501. // Deterministic lockstepMaxSteps
  28502. this._deterministicLockstep = false;
  28503. this._lockstepMaxSteps = 4;
  28504. // Lost context
  28505. /**
  28506. * Observable signaled when a context lost event is raised
  28507. */
  28508. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28509. /**
  28510. * Observable signaled when a context restored event is raised
  28511. */
  28512. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28513. this._contextWasLost = false;
  28514. this._doNotHandleContextLost = false;
  28515. // FPS
  28516. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  28517. this._fps = 60;
  28518. this._deltaTime = 0;
  28519. /**
  28520. * Turn this value on if you want to pause FPS computation when in background
  28521. */
  28522. this.disablePerformanceMonitorInBackground = false;
  28523. /**
  28524. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28525. */
  28526. this.disableVertexArrayObjects = false;
  28527. // States
  28528. /** @hidden */
  28529. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_DepthCullingState"]();
  28530. /** @hidden */
  28531. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_StencilState"]();
  28532. /** @hidden */
  28533. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_AlphaState"]();
  28534. /** @hidden */
  28535. this._alphaMode = Engine.ALPHA_DISABLE;
  28536. // Cache
  28537. this._internalTexturesCache = new Array();
  28538. /** @hidden */
  28539. this._activeChannel = 0;
  28540. this._currentTextureChannel = -1;
  28541. /** @hidden */
  28542. this._boundTexturesCache = {};
  28543. this._compiledEffects = {};
  28544. this._vertexAttribArraysEnabled = [];
  28545. this._uintIndicesCurrentlySet = false;
  28546. this._currentBoundBuffer = new Array();
  28547. /** @hidden */
  28548. this._currentFramebuffer = null;
  28549. this._currentBufferPointers = new Array();
  28550. this._currentInstanceLocations = new Array();
  28551. this._currentInstanceBuffers = new Array();
  28552. this._vaoRecordInProgress = false;
  28553. this._mustWipeVertexAttributes = false;
  28554. this._nextFreeTextureSlots = new Array();
  28555. this._maxSimultaneousTextures = 0;
  28556. this._activeRequests = new Array();
  28557. // Hardware supported Compressed Textures
  28558. this._texturesSupported = new Array();
  28559. /**
  28560. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28561. */
  28562. this.premultipliedAlpha = true;
  28563. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  28564. this._onVRFullScreenTriggered = function () {
  28565. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  28566. //get the old size before we change
  28567. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  28568. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  28569. //get the width and height, change the render size
  28570. var leftEye = _this._vrDisplay.getEyeParameters('left');
  28571. _this.setHardwareScalingLevel(1);
  28572. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  28573. }
  28574. else {
  28575. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  28576. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  28577. }
  28578. };
  28579. this._unpackFlipYCached = null;
  28580. /**
  28581. * In case you are sharing the context with other applications, it might
  28582. * be interested to not cache the unpack flip y state to ensure a consistent
  28583. * value would be set.
  28584. */
  28585. this.enableUnpackFlipYCached = true;
  28586. this._boundUniforms = {};
  28587. // Register promises
  28588. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  28589. var canvas = null;
  28590. Engine.Instances.push(this);
  28591. if (!canvasOrContext) {
  28592. return;
  28593. }
  28594. options = options || {};
  28595. if (canvasOrContext.getContext) {
  28596. canvas = canvasOrContext;
  28597. this._renderingCanvas = canvas;
  28598. if (antialias != null) {
  28599. options.antialias = antialias;
  28600. }
  28601. if (options.deterministicLockstep === undefined) {
  28602. options.deterministicLockstep = false;
  28603. }
  28604. if (options.lockstepMaxSteps === undefined) {
  28605. options.lockstepMaxSteps = 4;
  28606. }
  28607. if (options.preserveDrawingBuffer === undefined) {
  28608. options.preserveDrawingBuffer = false;
  28609. }
  28610. if (options.audioEngine === undefined) {
  28611. options.audioEngine = true;
  28612. }
  28613. if (options.stencil === undefined) {
  28614. options.stencil = true;
  28615. }
  28616. if (options.premultipliedAlpha === false) {
  28617. this.premultipliedAlpha = false;
  28618. }
  28619. this._deterministicLockstep = options.deterministicLockstep;
  28620. this._lockstepMaxSteps = options.lockstepMaxSteps;
  28621. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  28622. // Exceptions
  28623. if (navigator && navigator.userAgent) {
  28624. var ua = navigator.userAgent;
  28625. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  28626. var exception = _a[_i];
  28627. var key = exception.key;
  28628. var targets = exception.targets;
  28629. var check = new RegExp(key);
  28630. if (check.test(ua)) {
  28631. if (exception.capture && exception.captureConstraint) {
  28632. var capture = exception.capture;
  28633. var constraint = exception.captureConstraint;
  28634. var regex = new RegExp(capture);
  28635. var matches = regex.exec(ua);
  28636. if (matches && matches.length > 0) {
  28637. var capturedValue = parseInt(matches[matches.length - 1]);
  28638. if (capturedValue >= constraint) {
  28639. continue;
  28640. }
  28641. }
  28642. }
  28643. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  28644. var target = targets_1[_b];
  28645. switch (target) {
  28646. case "uniformBuffer":
  28647. this.disableUniformBuffers = true;
  28648. break;
  28649. case "vao":
  28650. this.disableVertexArrayObjects = true;
  28651. break;
  28652. }
  28653. }
  28654. }
  28655. }
  28656. }
  28657. // GL
  28658. if (!options.disableWebGL2Support) {
  28659. try {
  28660. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  28661. if (this._gl) {
  28662. this._webGLVersion = 2.0;
  28663. // Prevent weird browsers to lie :-)
  28664. if (!this._gl.deleteQuery) {
  28665. this._webGLVersion = 1.0;
  28666. }
  28667. }
  28668. }
  28669. catch (e) {
  28670. // Do nothing
  28671. }
  28672. }
  28673. if (!this._gl) {
  28674. if (!canvas) {
  28675. throw new Error("The provided canvas is null or undefined.");
  28676. }
  28677. try {
  28678. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  28679. }
  28680. catch (e) {
  28681. throw new Error("WebGL not supported");
  28682. }
  28683. }
  28684. if (!this._gl) {
  28685. throw new Error("WebGL not supported");
  28686. }
  28687. // Ensures a consistent color space unpacking of textures cross browser.
  28688. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  28689. this._onCanvasFocus = function () {
  28690. _this.onCanvasFocusObservable.notifyObservers(_this);
  28691. };
  28692. this._onCanvasBlur = function () {
  28693. _this.onCanvasBlurObservable.notifyObservers(_this);
  28694. };
  28695. canvas.addEventListener("focus", this._onCanvasFocus);
  28696. canvas.addEventListener("blur", this._onCanvasBlur);
  28697. this._onBlur = function () {
  28698. if (_this.disablePerformanceMonitorInBackground) {
  28699. _this._performanceMonitor.disable();
  28700. }
  28701. _this._windowIsBackground = true;
  28702. };
  28703. this._onFocus = function () {
  28704. if (_this.disablePerformanceMonitorInBackground) {
  28705. _this._performanceMonitor.enable();
  28706. }
  28707. _this._windowIsBackground = false;
  28708. };
  28709. this._onCanvasPointerOut = function (ev) {
  28710. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  28711. };
  28712. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  28713. window.addEventListener("blur", this._onBlur);
  28714. window.addEventListener("focus", this._onFocus);
  28715. }
  28716. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  28717. // Context lost
  28718. if (!this._doNotHandleContextLost) {
  28719. this._onContextLost = function (evt) {
  28720. evt.preventDefault();
  28721. _this._contextWasLost = true;
  28722. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("WebGL context lost.");
  28723. _this.onContextLostObservable.notifyObservers(_this);
  28724. };
  28725. this._onContextRestored = function () {
  28726. // Adding a timeout to avoid race condition at browser level
  28727. setTimeout(function () {
  28728. // Rebuild gl context
  28729. _this._initGLContext();
  28730. // Rebuild effects
  28731. _this._rebuildEffects();
  28732. // Rebuild textures
  28733. _this._rebuildInternalTextures();
  28734. // Rebuild buffers
  28735. _this._rebuildBuffers();
  28736. // Cache
  28737. _this.wipeCaches(true);
  28738. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("WebGL context successfully restored.");
  28739. _this.onContextRestoredObservable.notifyObservers(_this);
  28740. _this._contextWasLost = false;
  28741. }, 0);
  28742. };
  28743. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  28744. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  28745. }
  28746. if (!options.doNotHandleTouchAction) {
  28747. this._disableTouchAction();
  28748. }
  28749. }
  28750. else {
  28751. this._gl = canvasOrContext;
  28752. this._renderingCanvas = this._gl.canvas;
  28753. if (this._gl.renderbufferStorageMultisample) {
  28754. this._webGLVersion = 2.0;
  28755. }
  28756. var attributes = this._gl.getContextAttributes();
  28757. if (attributes) {
  28758. options.stencil = attributes.stencil;
  28759. }
  28760. }
  28761. if (options.useHighPrecisionFloats !== undefined) {
  28762. this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
  28763. }
  28764. // Viewport
  28765. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  28766. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  28767. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  28768. this.resize();
  28769. this._isStencilEnable = options.stencil ? true : false;
  28770. this._initGLContext();
  28771. if (canvas) {
  28772. var anyDoc_1 = document;
  28773. // Fullscreen
  28774. this._onFullscreenChange = function () {
  28775. if (anyDoc_1.fullscreen !== undefined) {
  28776. _this.isFullscreen = anyDoc_1.fullscreen;
  28777. }
  28778. else if (anyDoc_1.mozFullScreen !== undefined) {
  28779. _this.isFullscreen = anyDoc_1.mozFullScreen;
  28780. }
  28781. else if (anyDoc_1.webkitIsFullScreen !== undefined) {
  28782. _this.isFullscreen = anyDoc_1.webkitIsFullScreen;
  28783. }
  28784. else if (anyDoc_1.msIsFullScreen !== undefined) {
  28785. _this.isFullscreen = anyDoc_1.msIsFullScreen;
  28786. }
  28787. // Pointer lock
  28788. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  28789. canvas.requestPointerLock = canvas.requestPointerLock ||
  28790. canvas.msRequestPointerLock ||
  28791. canvas.mozRequestPointerLock ||
  28792. canvas.webkitRequestPointerLock;
  28793. if (canvas.requestPointerLock) {
  28794. canvas.requestPointerLock();
  28795. }
  28796. }
  28797. };
  28798. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  28799. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  28800. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  28801. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  28802. // Pointer lock
  28803. this._onPointerLockChange = function () {
  28804. _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas ||
  28805. anyDoc_1.webkitPointerLockElement === canvas ||
  28806. anyDoc_1.msPointerLockElement === canvas ||
  28807. anyDoc_1.pointerLockElement === canvas);
  28808. };
  28809. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  28810. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  28811. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  28812. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  28813. this._onVRDisplayPointerRestricted = function () {
  28814. if (canvas) {
  28815. canvas.requestPointerLock();
  28816. }
  28817. };
  28818. this._onVRDisplayPointerUnrestricted = function () {
  28819. if (!anyDoc_1.exitPointerLock) {
  28820. return;
  28821. }
  28822. anyDoc_1.exitPointerLock();
  28823. };
  28824. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  28825. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  28826. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  28827. }
  28828. }
  28829. // Create Audio Engine if needed.
  28830. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  28831. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  28832. }
  28833. // Prepare buffer pointers
  28834. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  28835. this._currentBufferPointers[i] = new BufferPointer();
  28836. }
  28837. // Load WebVR Devices
  28838. if (options.autoEnableWebVR) {
  28839. this.initWebVR();
  28840. }
  28841. // Detect if we are running on a faulty buggy OS.
  28842. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  28843. // Detect if we are running on a faulty buggy desktop OS.
  28844. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  28845. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  28846. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  28847. }
  28848. Object.defineProperty(Engine, "Instances", {
  28849. /** Gets the list of created engines */
  28850. get: function () {
  28851. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].Instances;
  28852. },
  28853. enumerable: true,
  28854. configurable: true
  28855. });
  28856. Object.defineProperty(Engine, "LastCreatedEngine", {
  28857. /**
  28858. * Gets the latest created engine
  28859. */
  28860. get: function () {
  28861. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].LastCreatedEngine;
  28862. },
  28863. enumerable: true,
  28864. configurable: true
  28865. });
  28866. Object.defineProperty(Engine, "LastCreatedScene", {
  28867. /**
  28868. * Gets the latest created scene
  28869. */
  28870. get: function () {
  28871. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].LastCreatedScene;
  28872. },
  28873. enumerable: true,
  28874. configurable: true
  28875. });
  28876. /**
  28877. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28878. * @param flag defines which part of the materials must be marked as dirty
  28879. * @param predicate defines a predicate used to filter which materials should be affected
  28880. */
  28881. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  28882. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  28883. var engine = Engine.Instances[engineIndex];
  28884. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  28885. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  28886. }
  28887. }
  28888. };
  28889. Object.defineProperty(Engine, "NpmPackage", {
  28890. /**
  28891. * Returns the current npm package of the sdk
  28892. */
  28893. // Not mixed with Version for tooling purpose.
  28894. get: function () {
  28895. return "babylonjs@4.0.0-beta.3";
  28896. },
  28897. enumerable: true,
  28898. configurable: true
  28899. });
  28900. Object.defineProperty(Engine, "Version", {
  28901. /**
  28902. * Returns the current version of the framework
  28903. */
  28904. get: function () {
  28905. return "4.0.0-beta.3";
  28906. },
  28907. enumerable: true,
  28908. configurable: true
  28909. });
  28910. Object.defineProperty(Engine.prototype, "description", {
  28911. /**
  28912. * Returns a string describing the current engine
  28913. */
  28914. get: function () {
  28915. var description = "WebGL" + this.webGLVersion;
  28916. if (this._caps.parallelShaderCompile) {
  28917. description += " - Parallel shader compilation";
  28918. }
  28919. return description;
  28920. },
  28921. enumerable: true,
  28922. configurable: true
  28923. });
  28924. Object.defineProperty(Engine, "ShadersRepository", {
  28925. /**
  28926. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28927. */
  28928. get: function () {
  28929. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28930. },
  28931. set: function (value) {
  28932. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28933. },
  28934. enumerable: true,
  28935. configurable: true
  28936. });
  28937. /**
  28938. * Method called to create the default loading screen.
  28939. * This can be overriden in your own app.
  28940. * @param canvas The rendering canvas element
  28941. * @returns The loading screen
  28942. */
  28943. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28944. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__["_DevTools"].WarnImport("LoadingScreen");
  28945. };
  28946. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28947. /**
  28948. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28949. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28950. */
  28951. get: function () {
  28952. return this._vrExclusivePointerMode;
  28953. },
  28954. enumerable: true,
  28955. configurable: true
  28956. });
  28957. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28958. /**
  28959. * Gets a boolean indicating that the engine supports uniform buffers
  28960. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28961. */
  28962. get: function () {
  28963. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28964. },
  28965. enumerable: true,
  28966. configurable: true
  28967. });
  28968. Object.defineProperty(Engine.prototype, "_shouldUseHighPrecisionShader", {
  28969. /** @hidden */
  28970. get: function () {
  28971. return this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed;
  28972. },
  28973. enumerable: true,
  28974. configurable: true
  28975. });
  28976. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28977. /**
  28978. * Gets a boolean indicating that only power of 2 textures are supported
  28979. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28980. */
  28981. get: function () {
  28982. return this._webGLVersion < 2 || this.forcePOTTextures;
  28983. },
  28984. enumerable: true,
  28985. configurable: true
  28986. });
  28987. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28988. /**
  28989. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28991. */
  28992. get: function () {
  28993. return this._doNotHandleContextLost;
  28994. },
  28995. set: function (value) {
  28996. this._doNotHandleContextLost = value;
  28997. },
  28998. enumerable: true,
  28999. configurable: true
  29000. });
  29001. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  29002. /**
  29003. * Gets the performance monitor attached to this engine
  29004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  29005. */
  29006. get: function () {
  29007. return this._performanceMonitor;
  29008. },
  29009. enumerable: true,
  29010. configurable: true
  29011. });
  29012. Object.defineProperty(Engine.prototype, "texturesSupported", {
  29013. /**
  29014. * Gets the list of texture formats supported
  29015. */
  29016. get: function () {
  29017. return this._texturesSupported;
  29018. },
  29019. enumerable: true,
  29020. configurable: true
  29021. });
  29022. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  29023. /**
  29024. * Gets the list of texture formats in use
  29025. */
  29026. get: function () {
  29027. return this._textureFormatInUse;
  29028. },
  29029. enumerable: true,
  29030. configurable: true
  29031. });
  29032. Object.defineProperty(Engine.prototype, "currentViewport", {
  29033. /**
  29034. * Gets the current viewport
  29035. */
  29036. get: function () {
  29037. return this._cachedViewport;
  29038. },
  29039. enumerable: true,
  29040. configurable: true
  29041. });
  29042. Object.defineProperty(Engine.prototype, "emptyTexture", {
  29043. /**
  29044. * Gets the default empty texture
  29045. */
  29046. get: function () {
  29047. if (!this._emptyTexture) {
  29048. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  29049. }
  29050. return this._emptyTexture;
  29051. },
  29052. enumerable: true,
  29053. configurable: true
  29054. });
  29055. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  29056. /**
  29057. * Gets the default empty 3D texture
  29058. */
  29059. get: function () {
  29060. if (!this._emptyTexture3D) {
  29061. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  29062. }
  29063. return this._emptyTexture3D;
  29064. },
  29065. enumerable: true,
  29066. configurable: true
  29067. });
  29068. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  29069. /**
  29070. * Gets the default empty cube texture
  29071. */
  29072. get: function () {
  29073. if (!this._emptyCubeTexture) {
  29074. var faceData = new Uint8Array(4);
  29075. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  29076. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  29077. }
  29078. return this._emptyCubeTexture;
  29079. },
  29080. enumerable: true,
  29081. configurable: true
  29082. });
  29083. Engine.prototype._disableTouchAction = function () {
  29084. if (!this._renderingCanvas) {
  29085. return;
  29086. }
  29087. this._renderingCanvas.setAttribute("touch-action", "none");
  29088. this._renderingCanvas.style.touchAction = "none";
  29089. this._renderingCanvas.style.msTouchAction = "none";
  29090. };
  29091. Engine.prototype._rebuildInternalTextures = function () {
  29092. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  29093. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  29094. var internalTexture = currentState_1[_i];
  29095. internalTexture._rebuild();
  29096. }
  29097. };
  29098. Engine.prototype._rebuildEffects = function () {
  29099. for (var key in this._compiledEffects) {
  29100. var effect = this._compiledEffects[key];
  29101. effect._prepareEffect();
  29102. }
  29103. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  29104. };
  29105. /**
  29106. * Gets a boolean indicating if all created effects are ready
  29107. * @returns true if all effects are ready
  29108. */
  29109. Engine.prototype.areAllEffectsReady = function () {
  29110. for (var key in this._compiledEffects) {
  29111. var effect = this._compiledEffects[key];
  29112. if (!effect.isReady()) {
  29113. return false;
  29114. }
  29115. }
  29116. return true;
  29117. };
  29118. Engine.prototype._rebuildBuffers = function () {
  29119. // Index / Vertex
  29120. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  29121. var scene = _a[_i];
  29122. scene.resetCachedMaterial();
  29123. scene._rebuildGeometries();
  29124. scene._rebuildTextures();
  29125. }
  29126. // Uniforms
  29127. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  29128. var uniformBuffer = _c[_b];
  29129. uniformBuffer._rebuild();
  29130. }
  29131. };
  29132. Engine.prototype._initGLContext = function () {
  29133. // Caps
  29134. this._caps = new EngineCapabilities();
  29135. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  29136. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  29137. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  29138. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  29139. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  29140. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  29141. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  29142. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  29143. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  29144. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  29145. // Infos
  29146. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  29147. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  29148. if (rendererInfo != null) {
  29149. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  29150. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  29151. }
  29152. if (!this._glVendor) {
  29153. this._glVendor = "Unknown vendor";
  29154. }
  29155. if (!this._glRenderer) {
  29156. this._glRenderer = "Unknown renderer";
  29157. }
  29158. // Constants
  29159. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  29160. if (this._gl.RGBA16F !== 0x881A) {
  29161. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  29162. }
  29163. if (this._gl.RGBA32F !== 0x8814) {
  29164. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  29165. }
  29166. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  29167. this._gl.DEPTH24_STENCIL8 = 35056;
  29168. }
  29169. // Extensions
  29170. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  29171. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  29172. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  29173. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  29174. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  29175. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  29176. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  29177. 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');
  29178. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  29179. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  29180. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  29181. this._caps.highPrecisionShaderSupported = false;
  29182. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  29183. if (this._caps.timerQuery) {
  29184. if (this._webGLVersion === 1) {
  29185. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  29186. }
  29187. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  29188. }
  29189. // Checks if some of the format renders first to allow the use of webgl inspector.
  29190. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  29191. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  29192. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  29193. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  29194. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  29195. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  29196. if (this._webGLVersion > 1) {
  29197. this._gl.HALF_FLOAT_OES = 0x140B;
  29198. }
  29199. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  29200. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  29201. this._caps.multiview = this._gl.getExtension('WEBGL_multiview');
  29202. // Draw buffers
  29203. if (this._webGLVersion > 1) {
  29204. this._caps.drawBuffersExtension = true;
  29205. }
  29206. else {
  29207. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  29208. if (drawBuffersExtension !== null) {
  29209. this._caps.drawBuffersExtension = true;
  29210. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  29211. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  29212. for (var i = 0; i < 16; i++) {
  29213. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  29214. }
  29215. }
  29216. else {
  29217. this._caps.drawBuffersExtension = false;
  29218. }
  29219. }
  29220. // Shader compiler threads
  29221. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  29222. // Depth Texture
  29223. if (this._webGLVersion > 1) {
  29224. this._caps.depthTextureExtension = true;
  29225. }
  29226. else {
  29227. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  29228. if (depthTextureExtension != null) {
  29229. this._caps.depthTextureExtension = true;
  29230. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  29231. }
  29232. }
  29233. // Vertex array object
  29234. if (this.disableVertexArrayObjects) {
  29235. this._caps.vertexArrayObject = false;
  29236. }
  29237. else if (this._webGLVersion > 1) {
  29238. this._caps.vertexArrayObject = true;
  29239. }
  29240. else {
  29241. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  29242. if (vertexArrayObjectExtension != null) {
  29243. this._caps.vertexArrayObject = true;
  29244. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  29245. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  29246. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  29247. }
  29248. else {
  29249. this._caps.vertexArrayObject = false;
  29250. }
  29251. }
  29252. // Instances count
  29253. if (this._webGLVersion > 1) {
  29254. this._caps.instancedArrays = true;
  29255. }
  29256. else {
  29257. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  29258. if (instanceExtension != null) {
  29259. this._caps.instancedArrays = true;
  29260. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  29261. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  29262. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  29263. }
  29264. else {
  29265. this._caps.instancedArrays = false;
  29266. }
  29267. }
  29268. // Intelligently add supported compressed formats in order to check for.
  29269. // Check for ASTC support first as it is most powerful and to be very cross platform.
  29270. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  29271. // Likely no hardware which supports both PVR & DXT, so order matters little.
  29272. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  29273. if (this._caps.astc) {
  29274. this.texturesSupported.push('-astc.ktx');
  29275. }
  29276. if (this._caps.s3tc) {
  29277. this.texturesSupported.push('-dxt.ktx');
  29278. }
  29279. if (this._caps.pvrtc) {
  29280. this.texturesSupported.push('-pvrtc.ktx');
  29281. }
  29282. if (this._caps.etc2) {
  29283. this.texturesSupported.push('-etc2.ktx');
  29284. }
  29285. if (this._caps.etc1) {
  29286. this.texturesSupported.push('-etc1.ktx');
  29287. }
  29288. if (this._gl.getShaderPrecisionFormat) {
  29289. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  29290. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  29291. if (vertex_highp && fragment_highp) {
  29292. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  29293. }
  29294. }
  29295. // Depth buffer
  29296. this.setDepthBuffer(true);
  29297. this.setDepthFunctionToLessOrEqual();
  29298. this.setDepthWrite(true);
  29299. // Texture maps
  29300. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  29301. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  29302. this._nextFreeTextureSlots.push(slot);
  29303. }
  29304. };
  29305. Object.defineProperty(Engine.prototype, "webGLVersion", {
  29306. /**
  29307. * Gets version of the current webGL context
  29308. */
  29309. get: function () {
  29310. return this._webGLVersion;
  29311. },
  29312. enumerable: true,
  29313. configurable: true
  29314. });
  29315. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  29316. /**
  29317. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29318. */
  29319. get: function () {
  29320. return this._isStencilEnable;
  29321. },
  29322. enumerable: true,
  29323. configurable: true
  29324. });
  29325. Engine.prototype._prepareWorkingCanvas = function () {
  29326. if (this._workingCanvas) {
  29327. return;
  29328. }
  29329. this._workingCanvas = document.createElement("canvas");
  29330. var context = this._workingCanvas.getContext("2d");
  29331. if (context) {
  29332. this._workingContext = context;
  29333. }
  29334. };
  29335. /**
  29336. * Reset the texture cache to empty state
  29337. */
  29338. Engine.prototype.resetTextureCache = function () {
  29339. for (var key in this._boundTexturesCache) {
  29340. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  29341. continue;
  29342. }
  29343. this._boundTexturesCache[key] = null;
  29344. }
  29345. this._currentTextureChannel = -1;
  29346. };
  29347. /**
  29348. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29349. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29350. * @returns true if engine is in deterministic lock step mode
  29351. */
  29352. Engine.prototype.isDeterministicLockStep = function () {
  29353. return this._deterministicLockstep;
  29354. };
  29355. /**
  29356. * Gets the max steps when engine is running in deterministic lock step
  29357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29358. * @returns the max steps
  29359. */
  29360. Engine.prototype.getLockstepMaxSteps = function () {
  29361. return this._lockstepMaxSteps;
  29362. };
  29363. /**
  29364. * Gets an object containing information about the current webGL context
  29365. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29366. */
  29367. Engine.prototype.getGlInfo = function () {
  29368. return {
  29369. vendor: this._glVendor,
  29370. renderer: this._glRenderer,
  29371. version: this._glVersion
  29372. };
  29373. };
  29374. /**
  29375. * Gets current aspect ratio
  29376. * @param camera defines the camera to use to get the aspect ratio
  29377. * @param useScreen defines if screen size must be used (or the current render target if any)
  29378. * @returns a number defining the aspect ratio
  29379. */
  29380. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  29381. if (useScreen === void 0) { useScreen = false; }
  29382. var viewport = camera.viewport;
  29383. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  29384. };
  29385. /**
  29386. * Gets current screen aspect ratio
  29387. * @returns a number defining the aspect ratio
  29388. */
  29389. Engine.prototype.getScreenAspectRatio = function () {
  29390. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  29391. };
  29392. /**
  29393. * Gets the current render width
  29394. * @param useScreen defines if screen size must be used (or the current render target if any)
  29395. * @returns a number defining the current render width
  29396. */
  29397. Engine.prototype.getRenderWidth = function (useScreen) {
  29398. if (useScreen === void 0) { useScreen = false; }
  29399. if (!useScreen && this._currentRenderTarget) {
  29400. return this._currentRenderTarget.width;
  29401. }
  29402. return this._gl.drawingBufferWidth;
  29403. };
  29404. /**
  29405. * Gets the current render height
  29406. * @param useScreen defines if screen size must be used (or the current render target if any)
  29407. * @returns a number defining the current render height
  29408. */
  29409. Engine.prototype.getRenderHeight = function (useScreen) {
  29410. if (useScreen === void 0) { useScreen = false; }
  29411. if (!useScreen && this._currentRenderTarget) {
  29412. return this._currentRenderTarget.height;
  29413. }
  29414. return this._gl.drawingBufferHeight;
  29415. };
  29416. /**
  29417. * Gets the HTML canvas attached with the current webGL context
  29418. * @returns a HTML canvas
  29419. */
  29420. Engine.prototype.getRenderingCanvas = function () {
  29421. return this._renderingCanvas;
  29422. };
  29423. /**
  29424. * Gets the client rect of the HTML canvas attached with the current webGL context
  29425. * @returns a client rectanglee
  29426. */
  29427. Engine.prototype.getRenderingCanvasClientRect = function () {
  29428. if (!this._renderingCanvas) {
  29429. return null;
  29430. }
  29431. return this._renderingCanvas.getBoundingClientRect();
  29432. };
  29433. /**
  29434. * Defines the hardware scaling level.
  29435. * By default the hardware scaling level is computed from the window device ratio.
  29436. * 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.
  29437. * @param level defines the level to use
  29438. */
  29439. Engine.prototype.setHardwareScalingLevel = function (level) {
  29440. this._hardwareScalingLevel = level;
  29441. this.resize();
  29442. };
  29443. /**
  29444. * Gets the current hardware scaling level.
  29445. * By default the hardware scaling level is computed from the window device ratio.
  29446. * 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.
  29447. * @returns a number indicating the current hardware scaling level
  29448. */
  29449. Engine.prototype.getHardwareScalingLevel = function () {
  29450. return this._hardwareScalingLevel;
  29451. };
  29452. /**
  29453. * Gets the list of loaded textures
  29454. * @returns an array containing all loaded textures
  29455. */
  29456. Engine.prototype.getLoadedTexturesCache = function () {
  29457. return this._internalTexturesCache;
  29458. };
  29459. /**
  29460. * Gets the object containing all engine capabilities
  29461. * @returns the EngineCapabilities object
  29462. */
  29463. Engine.prototype.getCaps = function () {
  29464. return this._caps;
  29465. };
  29466. /**
  29467. * Gets the current depth function
  29468. * @returns a number defining the depth function
  29469. */
  29470. Engine.prototype.getDepthFunction = function () {
  29471. return this._depthCullingState.depthFunc;
  29472. };
  29473. /**
  29474. * Sets the current depth function
  29475. * @param depthFunc defines the function to use
  29476. */
  29477. Engine.prototype.setDepthFunction = function (depthFunc) {
  29478. this._depthCullingState.depthFunc = depthFunc;
  29479. };
  29480. /**
  29481. * Sets the current depth function to GREATER
  29482. */
  29483. Engine.prototype.setDepthFunctionToGreater = function () {
  29484. this._depthCullingState.depthFunc = this._gl.GREATER;
  29485. };
  29486. /**
  29487. * Sets the current depth function to GEQUAL
  29488. */
  29489. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  29490. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  29491. };
  29492. /**
  29493. * Sets the current depth function to LESS
  29494. */
  29495. Engine.prototype.setDepthFunctionToLess = function () {
  29496. this._depthCullingState.depthFunc = this._gl.LESS;
  29497. };
  29498. /**
  29499. * Caches the the state of the stencil buffer
  29500. */
  29501. Engine.prototype.cacheStencilState = function () {
  29502. this._cachedStencilBuffer = this.getStencilBuffer();
  29503. this._cachedStencilFunction = this.getStencilFunction();
  29504. this._cachedStencilMask = this.getStencilMask();
  29505. this._cachedStencilOperationPass = this.getStencilOperationPass();
  29506. this._cachedStencilOperationFail = this.getStencilOperationFail();
  29507. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail();
  29508. this._cachedStencilReference = this.getStencilFunctionReference();
  29509. };
  29510. /**
  29511. * Restores the state of the stencil buffer
  29512. */
  29513. Engine.prototype.restoreStencilState = function () {
  29514. this.setStencilFunction(this._cachedStencilFunction);
  29515. this.setStencilMask(this._cachedStencilMask);
  29516. this.setStencilBuffer(this._cachedStencilBuffer);
  29517. this.setStencilOperationPass(this._cachedStencilOperationPass);
  29518. this.setStencilOperationFail(this._cachedStencilOperationFail);
  29519. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail);
  29520. this.setStencilFunctionReference(this._cachedStencilReference);
  29521. };
  29522. /**
  29523. * Sets the current depth function to LEQUAL
  29524. */
  29525. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  29526. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  29527. };
  29528. /**
  29529. * Gets a boolean indicating if stencil buffer is enabled
  29530. * @returns the current stencil buffer state
  29531. */
  29532. Engine.prototype.getStencilBuffer = function () {
  29533. return this._stencilState.stencilTest;
  29534. };
  29535. /**
  29536. * Enable or disable the stencil buffer
  29537. * @param enable defines if the stencil buffer must be enabled or disabled
  29538. */
  29539. Engine.prototype.setStencilBuffer = function (enable) {
  29540. this._stencilState.stencilTest = enable;
  29541. };
  29542. /**
  29543. * Gets the current stencil mask
  29544. * @returns a number defining the new stencil mask to use
  29545. */
  29546. Engine.prototype.getStencilMask = function () {
  29547. return this._stencilState.stencilMask;
  29548. };
  29549. /**
  29550. * Sets the current stencil mask
  29551. * @param mask defines the new stencil mask to use
  29552. */
  29553. Engine.prototype.setStencilMask = function (mask) {
  29554. this._stencilState.stencilMask = mask;
  29555. };
  29556. /**
  29557. * Gets the current stencil function
  29558. * @returns a number defining the stencil function to use
  29559. */
  29560. Engine.prototype.getStencilFunction = function () {
  29561. return this._stencilState.stencilFunc;
  29562. };
  29563. /**
  29564. * Gets the current stencil reference value
  29565. * @returns a number defining the stencil reference value to use
  29566. */
  29567. Engine.prototype.getStencilFunctionReference = function () {
  29568. return this._stencilState.stencilFuncRef;
  29569. };
  29570. /**
  29571. * Gets the current stencil mask
  29572. * @returns a number defining the stencil mask to use
  29573. */
  29574. Engine.prototype.getStencilFunctionMask = function () {
  29575. return this._stencilState.stencilFuncMask;
  29576. };
  29577. /**
  29578. * Sets the current stencil function
  29579. * @param stencilFunc defines the new stencil function to use
  29580. */
  29581. Engine.prototype.setStencilFunction = function (stencilFunc) {
  29582. this._stencilState.stencilFunc = stencilFunc;
  29583. };
  29584. /**
  29585. * Sets the current stencil reference
  29586. * @param reference defines the new stencil reference to use
  29587. */
  29588. Engine.prototype.setStencilFunctionReference = function (reference) {
  29589. this._stencilState.stencilFuncRef = reference;
  29590. };
  29591. /**
  29592. * Sets the current stencil mask
  29593. * @param mask defines the new stencil mask to use
  29594. */
  29595. Engine.prototype.setStencilFunctionMask = function (mask) {
  29596. this._stencilState.stencilFuncMask = mask;
  29597. };
  29598. /**
  29599. * Gets the current stencil operation when stencil fails
  29600. * @returns a number defining stencil operation to use when stencil fails
  29601. */
  29602. Engine.prototype.getStencilOperationFail = function () {
  29603. return this._stencilState.stencilOpStencilFail;
  29604. };
  29605. /**
  29606. * Gets the current stencil operation when depth fails
  29607. * @returns a number defining stencil operation to use when depth fails
  29608. */
  29609. Engine.prototype.getStencilOperationDepthFail = function () {
  29610. return this._stencilState.stencilOpDepthFail;
  29611. };
  29612. /**
  29613. * Gets the current stencil operation when stencil passes
  29614. * @returns a number defining stencil operation to use when stencil passes
  29615. */
  29616. Engine.prototype.getStencilOperationPass = function () {
  29617. return this._stencilState.stencilOpStencilDepthPass;
  29618. };
  29619. /**
  29620. * Sets the stencil operation to use when stencil fails
  29621. * @param operation defines the stencil operation to use when stencil fails
  29622. */
  29623. Engine.prototype.setStencilOperationFail = function (operation) {
  29624. this._stencilState.stencilOpStencilFail = operation;
  29625. };
  29626. /**
  29627. * Sets the stencil operation to use when depth fails
  29628. * @param operation defines the stencil operation to use when depth fails
  29629. */
  29630. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  29631. this._stencilState.stencilOpDepthFail = operation;
  29632. };
  29633. /**
  29634. * Sets the stencil operation to use when stencil passes
  29635. * @param operation defines the stencil operation to use when stencil passes
  29636. */
  29637. Engine.prototype.setStencilOperationPass = function (operation) {
  29638. this._stencilState.stencilOpStencilDepthPass = operation;
  29639. };
  29640. /**
  29641. * Sets a boolean indicating if the dithering state is enabled or disabled
  29642. * @param value defines the dithering state
  29643. */
  29644. Engine.prototype.setDitheringState = function (value) {
  29645. if (value) {
  29646. this._gl.enable(this._gl.DITHER);
  29647. }
  29648. else {
  29649. this._gl.disable(this._gl.DITHER);
  29650. }
  29651. };
  29652. /**
  29653. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29654. * @param value defines the rasterizer state
  29655. */
  29656. Engine.prototype.setRasterizerState = function (value) {
  29657. if (value) {
  29658. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  29659. }
  29660. else {
  29661. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  29662. }
  29663. };
  29664. /**
  29665. * stop executing a render loop function and remove it from the execution array
  29666. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29667. */
  29668. Engine.prototype.stopRenderLoop = function (renderFunction) {
  29669. if (!renderFunction) {
  29670. this._activeRenderLoops = [];
  29671. return;
  29672. }
  29673. var index = this._activeRenderLoops.indexOf(renderFunction);
  29674. if (index >= 0) {
  29675. this._activeRenderLoops.splice(index, 1);
  29676. }
  29677. };
  29678. /** @hidden */
  29679. Engine.prototype._renderLoop = function () {
  29680. if (!this._contextWasLost) {
  29681. var shouldRender = true;
  29682. if (!this.renderEvenInBackground && this._windowIsBackground) {
  29683. shouldRender = false;
  29684. }
  29685. if (shouldRender) {
  29686. // Start new frame
  29687. this.beginFrame();
  29688. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  29689. var renderFunction = this._activeRenderLoops[index];
  29690. renderFunction();
  29691. }
  29692. // Present
  29693. this.endFrame();
  29694. }
  29695. }
  29696. if (this._activeRenderLoops.length > 0) {
  29697. // Register new frame
  29698. if (this.customAnimationFrameRequester) {
  29699. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  29700. this._frameHandler = this.customAnimationFrameRequester.requestID;
  29701. }
  29702. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29703. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  29704. }
  29705. else {
  29706. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29707. }
  29708. }
  29709. else {
  29710. this._renderingQueueLaunched = false;
  29711. }
  29712. };
  29713. /**
  29714. * Register and execute a render loop. The engine can have more than one render function
  29715. * @param renderFunction defines the function to continuously execute
  29716. */
  29717. Engine.prototype.runRenderLoop = function (renderFunction) {
  29718. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  29719. return;
  29720. }
  29721. this._activeRenderLoops.push(renderFunction);
  29722. if (!this._renderingQueueLaunched) {
  29723. this._renderingQueueLaunched = true;
  29724. this._bindedRenderFunction = this._renderLoop.bind(this);
  29725. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29726. }
  29727. };
  29728. /**
  29729. * Toggle full screen mode
  29730. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29731. */
  29732. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  29733. if (this.isFullscreen) {
  29734. this.exitFullscreen();
  29735. }
  29736. else {
  29737. this.enterFullscreen(requestPointerLock);
  29738. }
  29739. };
  29740. /**
  29741. * Enters full screen mode
  29742. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29743. */
  29744. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  29745. if (!this.isFullscreen) {
  29746. this._pointerLockRequested = requestPointerLock;
  29747. if (this._renderingCanvas) {
  29748. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  29749. }
  29750. }
  29751. };
  29752. /**
  29753. * Exits full screen mode
  29754. */
  29755. Engine.prototype.exitFullscreen = function () {
  29756. if (this.isFullscreen) {
  29757. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  29758. }
  29759. };
  29760. /**
  29761. * Clear the current render buffer or the current render target (if any is set up)
  29762. * @param color defines the color to use
  29763. * @param backBuffer defines if the back buffer must be cleared
  29764. * @param depth defines if the depth buffer must be cleared
  29765. * @param stencil defines if the stencil buffer must be cleared
  29766. */
  29767. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  29768. if (stencil === void 0) { stencil = false; }
  29769. this.applyStates();
  29770. var mode = 0;
  29771. if (backBuffer && color) {
  29772. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  29773. mode |= this._gl.COLOR_BUFFER_BIT;
  29774. }
  29775. if (depth) {
  29776. this._gl.clearDepth(1.0);
  29777. mode |= this._gl.DEPTH_BUFFER_BIT;
  29778. }
  29779. if (stencil) {
  29780. this._gl.clearStencil(0);
  29781. mode |= this._gl.STENCIL_BUFFER_BIT;
  29782. }
  29783. this._gl.clear(mode);
  29784. };
  29785. /**
  29786. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29787. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29788. * @param y defines the y-coordinate of the corner of the clear rectangle
  29789. * @param width defines the width of the clear rectangle
  29790. * @param height defines the height of the clear rectangle
  29791. * @param clearColor defines the clear color
  29792. */
  29793. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  29794. this.enableScissor(x, y, width, height);
  29795. this.clear(clearColor, true, true, true);
  29796. this.disableScissor();
  29797. };
  29798. /**
  29799. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29800. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29801. * @param y defines the y-coordinate of the corner of the clear rectangle
  29802. * @param width defines the width of the clear rectangle
  29803. * @param height defines the height of the clear rectangle
  29804. */
  29805. Engine.prototype.enableScissor = function (x, y, width, height) {
  29806. var gl = this._gl;
  29807. // Change state
  29808. gl.enable(gl.SCISSOR_TEST);
  29809. gl.scissor(x, y, width, height);
  29810. };
  29811. /**
  29812. * Disable previously set scissor test rectangle
  29813. */
  29814. Engine.prototype.disableScissor = function () {
  29815. var gl = this._gl;
  29816. gl.disable(gl.SCISSOR_TEST);
  29817. };
  29818. /** @hidden */
  29819. Engine.prototype._viewport = function (x, y, width, height) {
  29820. if (x !== this._viewportCached.x ||
  29821. y !== this._viewportCached.y ||
  29822. width !== this._viewportCached.z ||
  29823. height !== this._viewportCached.w) {
  29824. this._viewportCached.x = x;
  29825. this._viewportCached.y = y;
  29826. this._viewportCached.z = width;
  29827. this._viewportCached.w = height;
  29828. this._gl.viewport(x, y, width, height);
  29829. }
  29830. };
  29831. /**
  29832. * Set the WebGL's viewport
  29833. * @param viewport defines the viewport element to be used
  29834. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29835. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29836. */
  29837. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  29838. var width = requiredWidth || this.getRenderWidth();
  29839. var height = requiredHeight || this.getRenderHeight();
  29840. var x = viewport.x || 0;
  29841. var y = viewport.y || 0;
  29842. this._cachedViewport = viewport;
  29843. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  29844. };
  29845. /**
  29846. * Directly set the WebGL Viewport
  29847. * @param x defines the x coordinate of the viewport (in screen space)
  29848. * @param y defines the y coordinate of the viewport (in screen space)
  29849. * @param width defines the width of the viewport (in screen space)
  29850. * @param height defines the height of the viewport (in screen space)
  29851. * @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
  29852. */
  29853. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  29854. var currentViewport = this._cachedViewport;
  29855. this._cachedViewport = null;
  29856. this._viewport(x, y, width, height);
  29857. return currentViewport;
  29858. };
  29859. /**
  29860. * Begin a new frame
  29861. */
  29862. Engine.prototype.beginFrame = function () {
  29863. this.onBeginFrameObservable.notifyObservers(this);
  29864. this._measureFps();
  29865. };
  29866. /**
  29867. * Enf the current frame
  29868. */
  29869. Engine.prototype.endFrame = function () {
  29870. // Force a flush in case we are using a bad OS.
  29871. if (this._badOS) {
  29872. this.flushFramebuffer();
  29873. }
  29874. // Submit frame to the vr device, if enabled
  29875. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29876. // TODO: We should only submit the frame if we read frameData successfully.
  29877. try {
  29878. this._vrDisplay.submitFrame();
  29879. }
  29880. catch (e) {
  29881. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  29882. }
  29883. }
  29884. this.onEndFrameObservable.notifyObservers(this);
  29885. };
  29886. /**
  29887. * Resize the view according to the canvas' size
  29888. */
  29889. Engine.prototype.resize = function () {
  29890. // We're not resizing the size of the canvas while in VR mode & presenting
  29891. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  29892. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  29893. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  29894. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  29895. }
  29896. };
  29897. /**
  29898. * Force a specific size of the canvas
  29899. * @param width defines the new canvas' width
  29900. * @param height defines the new canvas' height
  29901. */
  29902. Engine.prototype.setSize = function (width, height) {
  29903. if (!this._renderingCanvas) {
  29904. return;
  29905. }
  29906. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  29907. return;
  29908. }
  29909. this._renderingCanvas.width = width;
  29910. this._renderingCanvas.height = height;
  29911. for (var index = 0; index < this.scenes.length; index++) {
  29912. var scene = this.scenes[index];
  29913. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  29914. var cam = scene.cameras[camIndex];
  29915. cam._currentRenderId = 0;
  29916. }
  29917. }
  29918. if (this.onResizeObservable.hasObservers) {
  29919. this.onResizeObservable.notifyObservers(this);
  29920. }
  29921. };
  29922. // WebVR functions
  29923. /**
  29924. * Gets a boolean indicating if a webVR device was detected
  29925. * @returns true if a webVR device was detected
  29926. */
  29927. Engine.prototype.isVRDevicePresent = function () {
  29928. return !!this._vrDisplay;
  29929. };
  29930. /**
  29931. * Gets the current webVR device
  29932. * @returns the current webVR device (or null)
  29933. */
  29934. Engine.prototype.getVRDevice = function () {
  29935. return this._vrDisplay;
  29936. };
  29937. /**
  29938. * Initializes a webVR display and starts listening to display change events
  29939. * The onVRDisplayChangedObservable will be notified upon these changes
  29940. * @returns The onVRDisplayChangedObservable
  29941. */
  29942. Engine.prototype.initWebVR = function () {
  29943. this.initWebVRAsync();
  29944. return this.onVRDisplayChangedObservable;
  29945. };
  29946. /**
  29947. * Initializes a webVR display and starts listening to display change events
  29948. * The onVRDisplayChangedObservable will be notified upon these changes
  29949. * @returns A promise containing a VRDisplay and if vr is supported
  29950. */
  29951. Engine.prototype.initWebVRAsync = function () {
  29952. var _this = this;
  29953. var notifyObservers = function () {
  29954. var eventArgs = {
  29955. vrDisplay: _this._vrDisplay,
  29956. vrSupported: _this._vrSupported
  29957. };
  29958. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29959. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29960. };
  29961. if (!this._onVrDisplayConnect) {
  29962. this._onVrDisplayConnect = function (event) {
  29963. _this._vrDisplay = event.display;
  29964. notifyObservers();
  29965. };
  29966. this._onVrDisplayDisconnect = function () {
  29967. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29968. _this._vrDisplay = undefined;
  29969. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29970. notifyObservers();
  29971. };
  29972. this._onVrDisplayPresentChange = function () {
  29973. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29974. };
  29975. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29976. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29977. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29978. }
  29979. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29980. this._webVRInitPromise.then(notifyObservers);
  29981. return this._webVRInitPromise;
  29982. };
  29983. /**
  29984. * Call this function to switch to webVR mode
  29985. * Will do nothing if webVR is not supported or if there is no webVR device
  29986. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29987. */
  29988. Engine.prototype.enableVR = function () {
  29989. var _this = this;
  29990. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29991. var onResolved = function () {
  29992. _this.onVRRequestPresentComplete.notifyObservers(true);
  29993. _this._onVRFullScreenTriggered();
  29994. };
  29995. var onRejected = function () {
  29996. _this.onVRRequestPresentComplete.notifyObservers(false);
  29997. };
  29998. this.onVRRequestPresentStart.notifyObservers(this);
  29999. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  30000. }
  30001. };
  30002. /**
  30003. * Call this function to leave webVR mode
  30004. * Will do nothing if webVR is not supported or if there is no webVR device
  30005. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30006. */
  30007. Engine.prototype.disableVR = function () {
  30008. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  30009. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  30010. }
  30011. };
  30012. Engine.prototype._getVRDisplaysAsync = function () {
  30013. var _this = this;
  30014. return new Promise(function (res) {
  30015. if (navigator.getVRDisplays) {
  30016. navigator.getVRDisplays().then(function (devices) {
  30017. _this._vrSupported = true;
  30018. // note that devices may actually be an empty array. This is fine;
  30019. // we expect this._vrDisplay to be undefined in this case.
  30020. _this._vrDisplay = devices[0];
  30021. res({
  30022. vrDisplay: _this._vrDisplay,
  30023. vrSupported: _this._vrSupported
  30024. });
  30025. });
  30026. }
  30027. else {
  30028. _this._vrDisplay = undefined;
  30029. _this._vrSupported = false;
  30030. res({
  30031. vrDisplay: _this._vrDisplay,
  30032. vrSupported: _this._vrSupported
  30033. });
  30034. }
  30035. });
  30036. };
  30037. /**
  30038. * Binds the frame buffer to the specified texture.
  30039. * @param texture The texture to render to or null for the default canvas
  30040. * @param faceIndex The face of the texture to render to in case of cube texture
  30041. * @param requiredWidth The width of the target to render to
  30042. * @param requiredHeight The height of the target to render to
  30043. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30044. * @param depthStencilTexture The depth stencil texture to use to render
  30045. * @param lodLevel defines le lod level to bind to the frame buffer
  30046. */
  30047. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  30048. if (lodLevel === void 0) { lodLevel = 0; }
  30049. if (this._currentRenderTarget) {
  30050. this.unBindFramebuffer(this._currentRenderTarget);
  30051. }
  30052. this._currentRenderTarget = texture;
  30053. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  30054. var gl = this._gl;
  30055. if (texture.isCube) {
  30056. if (faceIndex === undefined) {
  30057. faceIndex = 0;
  30058. }
  30059. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  30060. if (depthStencilTexture) {
  30061. if (depthStencilTexture._generateStencilBuffer) {
  30062. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  30063. }
  30064. else {
  30065. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  30066. }
  30067. }
  30068. }
  30069. if (this._cachedViewport && !forceFullscreenViewport) {
  30070. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  30071. }
  30072. else {
  30073. if (!requiredWidth) {
  30074. requiredWidth = texture.width;
  30075. if (lodLevel) {
  30076. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  30077. }
  30078. }
  30079. if (!requiredHeight) {
  30080. requiredHeight = texture.height;
  30081. if (lodLevel) {
  30082. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  30083. }
  30084. }
  30085. this._viewport(0, 0, requiredWidth, requiredHeight);
  30086. }
  30087. this.wipeCaches();
  30088. };
  30089. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  30090. if (this._currentFramebuffer !== framebuffer) {
  30091. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  30092. this._currentFramebuffer = framebuffer;
  30093. }
  30094. };
  30095. /**
  30096. * Unbind the current render target texture from the webGL context
  30097. * @param texture defines the render target texture to unbind
  30098. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30099. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30100. */
  30101. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  30102. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  30103. this._currentRenderTarget = null;
  30104. // If MSAA, we need to bitblt back to main texture
  30105. var gl = this._gl;
  30106. if (texture._MSAAFramebuffer) {
  30107. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  30108. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  30109. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  30110. }
  30111. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  30112. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30113. gl.generateMipmap(gl.TEXTURE_2D);
  30114. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30115. }
  30116. if (onBeforeUnbind) {
  30117. if (texture._MSAAFramebuffer) {
  30118. // Bind the correct framebuffer
  30119. this.bindUnboundFramebuffer(texture._framebuffer);
  30120. }
  30121. onBeforeUnbind();
  30122. }
  30123. this.bindUnboundFramebuffer(null);
  30124. };
  30125. /**
  30126. * Unbind a list of render target textures from the webGL context
  30127. * This is used only when drawBuffer extension or webGL2 are active
  30128. * @param textures defines the render target textures to unbind
  30129. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30130. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30131. */
  30132. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  30133. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  30134. this._currentRenderTarget = null;
  30135. // If MSAA, we need to bitblt back to main texture
  30136. var gl = this._gl;
  30137. if (textures[0]._MSAAFramebuffer) {
  30138. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  30139. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  30140. var attachments = textures[0]._attachments;
  30141. if (!attachments) {
  30142. attachments = new Array(textures.length);
  30143. textures[0]._attachments = attachments;
  30144. }
  30145. for (var i = 0; i < textures.length; i++) {
  30146. var texture = textures[i];
  30147. for (var j = 0; j < attachments.length; j++) {
  30148. attachments[j] = gl.NONE;
  30149. }
  30150. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30151. gl.readBuffer(attachments[i]);
  30152. gl.drawBuffers(attachments);
  30153. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  30154. }
  30155. for (var i = 0; i < attachments.length; i++) {
  30156. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30157. }
  30158. gl.drawBuffers(attachments);
  30159. }
  30160. for (var i = 0; i < textures.length; i++) {
  30161. var texture = textures[i];
  30162. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  30163. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  30164. gl.generateMipmap(gl.TEXTURE_2D);
  30165. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30166. }
  30167. }
  30168. if (onBeforeUnbind) {
  30169. if (textures[0]._MSAAFramebuffer) {
  30170. // Bind the correct framebuffer
  30171. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  30172. }
  30173. onBeforeUnbind();
  30174. }
  30175. this.bindUnboundFramebuffer(null);
  30176. };
  30177. /**
  30178. * Force the mipmap generation for the given render target texture
  30179. * @param texture defines the render target texture to use
  30180. */
  30181. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  30182. if (texture.generateMipMaps) {
  30183. var gl = this._gl;
  30184. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  30185. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  30186. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  30187. }
  30188. };
  30189. /**
  30190. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30191. */
  30192. Engine.prototype.flushFramebuffer = function () {
  30193. this._gl.flush();
  30194. };
  30195. /**
  30196. * Unbind the current render target and bind the default framebuffer
  30197. */
  30198. Engine.prototype.restoreDefaultFramebuffer = function () {
  30199. if (this._currentRenderTarget) {
  30200. this.unBindFramebuffer(this._currentRenderTarget);
  30201. }
  30202. else {
  30203. this.bindUnboundFramebuffer(null);
  30204. }
  30205. if (this._cachedViewport) {
  30206. this.setViewport(this._cachedViewport);
  30207. }
  30208. this.wipeCaches();
  30209. };
  30210. // UBOs
  30211. /**
  30212. * Create an uniform buffer
  30213. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30214. * @param elements defines the content of the uniform buffer
  30215. * @returns the webGL uniform buffer
  30216. */
  30217. Engine.prototype.createUniformBuffer = function (elements) {
  30218. var ubo = this._gl.createBuffer();
  30219. if (!ubo) {
  30220. throw new Error("Unable to create uniform buffer");
  30221. }
  30222. this.bindUniformBuffer(ubo);
  30223. if (elements instanceof Float32Array) {
  30224. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  30225. }
  30226. else {
  30227. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  30228. }
  30229. this.bindUniformBuffer(null);
  30230. ubo.references = 1;
  30231. return ubo;
  30232. };
  30233. /**
  30234. * Create a dynamic uniform buffer
  30235. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30236. * @param elements defines the content of the uniform buffer
  30237. * @returns the webGL uniform buffer
  30238. */
  30239. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  30240. var ubo = this._gl.createBuffer();
  30241. if (!ubo) {
  30242. throw new Error("Unable to create dynamic uniform buffer");
  30243. }
  30244. this.bindUniformBuffer(ubo);
  30245. if (elements instanceof Float32Array) {
  30246. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  30247. }
  30248. else {
  30249. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  30250. }
  30251. this.bindUniformBuffer(null);
  30252. ubo.references = 1;
  30253. return ubo;
  30254. };
  30255. /**
  30256. * Update an existing uniform buffer
  30257. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30258. * @param uniformBuffer defines the target uniform buffer
  30259. * @param elements defines the content to update
  30260. * @param offset defines the offset in the uniform buffer where update should start
  30261. * @param count defines the size of the data to update
  30262. */
  30263. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  30264. this.bindUniformBuffer(uniformBuffer);
  30265. if (offset === undefined) {
  30266. offset = 0;
  30267. }
  30268. if (count === undefined) {
  30269. if (elements instanceof Float32Array) {
  30270. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  30271. }
  30272. else {
  30273. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  30274. }
  30275. }
  30276. else {
  30277. if (elements instanceof Float32Array) {
  30278. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  30279. }
  30280. else {
  30281. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  30282. }
  30283. }
  30284. this.bindUniformBuffer(null);
  30285. };
  30286. // VBOs
  30287. Engine.prototype._resetVertexBufferBinding = function () {
  30288. this.bindArrayBuffer(null);
  30289. this._cachedVertexBuffers = null;
  30290. };
  30291. /**
  30292. * Creates a vertex buffer
  30293. * @param data the data for the vertex buffer
  30294. * @returns the new WebGL static buffer
  30295. */
  30296. Engine.prototype.createVertexBuffer = function (data) {
  30297. var vbo = this._gl.createBuffer();
  30298. if (!vbo) {
  30299. throw new Error("Unable to create vertex buffer");
  30300. }
  30301. this.bindArrayBuffer(vbo);
  30302. if (data instanceof Array) {
  30303. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  30304. }
  30305. else {
  30306. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  30307. }
  30308. this._resetVertexBufferBinding();
  30309. vbo.references = 1;
  30310. return vbo;
  30311. };
  30312. /**
  30313. * Creates a dynamic vertex buffer
  30314. * @param data the data for the dynamic vertex buffer
  30315. * @returns the new WebGL dynamic buffer
  30316. */
  30317. Engine.prototype.createDynamicVertexBuffer = function (data) {
  30318. var vbo = this._gl.createBuffer();
  30319. if (!vbo) {
  30320. throw new Error("Unable to create dynamic vertex buffer");
  30321. }
  30322. this.bindArrayBuffer(vbo);
  30323. if (data instanceof Array) {
  30324. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  30325. }
  30326. else {
  30327. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  30328. }
  30329. this._resetVertexBufferBinding();
  30330. vbo.references = 1;
  30331. return vbo;
  30332. };
  30333. /**
  30334. * Update a dynamic index buffer
  30335. * @param indexBuffer defines the target index buffer
  30336. * @param indices defines the data to update
  30337. * @param offset defines the offset in the target index buffer where update should start
  30338. */
  30339. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  30340. if (offset === void 0) { offset = 0; }
  30341. // Force cache update
  30342. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  30343. this.bindIndexBuffer(indexBuffer);
  30344. var arrayBuffer;
  30345. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  30346. arrayBuffer = indices;
  30347. }
  30348. else {
  30349. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30350. }
  30351. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  30352. this._resetIndexBufferBinding();
  30353. };
  30354. /**
  30355. * Updates a dynamic vertex buffer.
  30356. * @param vertexBuffer the vertex buffer to update
  30357. * @param data the data used to update the vertex buffer
  30358. * @param byteOffset the byte offset of the data
  30359. * @param byteLength the byte length of the data
  30360. */
  30361. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  30362. this.bindArrayBuffer(vertexBuffer);
  30363. if (byteOffset === undefined) {
  30364. byteOffset = 0;
  30365. }
  30366. if (byteLength === undefined) {
  30367. if (data instanceof Array) {
  30368. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  30369. }
  30370. else {
  30371. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  30372. }
  30373. }
  30374. else {
  30375. if (data instanceof Array) {
  30376. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  30377. }
  30378. else {
  30379. if (data instanceof ArrayBuffer) {
  30380. data = new Uint8Array(data, byteOffset, byteLength);
  30381. }
  30382. else {
  30383. var offset = data.byteOffset + byteOffset;
  30384. if (offset || byteLength !== data.byteLength) {
  30385. data = new Uint8Array(data.buffer, offset, byteLength);
  30386. }
  30387. }
  30388. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30389. }
  30390. }
  30391. this._resetVertexBufferBinding();
  30392. };
  30393. Engine.prototype._resetIndexBufferBinding = function () {
  30394. this.bindIndexBuffer(null);
  30395. this._cachedIndexBuffer = null;
  30396. };
  30397. /**
  30398. * Creates a new index buffer
  30399. * @param indices defines the content of the index buffer
  30400. * @param updatable defines if the index buffer must be updatable
  30401. * @returns a new webGL buffer
  30402. */
  30403. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  30404. var vbo = this._gl.createBuffer();
  30405. if (!vbo) {
  30406. throw new Error("Unable to create index buffer");
  30407. }
  30408. this.bindIndexBuffer(vbo);
  30409. // Check for 32 bits indices
  30410. var arrayBuffer;
  30411. var need32Bits = false;
  30412. if (indices instanceof Uint16Array) {
  30413. arrayBuffer = indices;
  30414. }
  30415. else {
  30416. //check 32 bit support
  30417. if (this._caps.uintIndices) {
  30418. if (indices instanceof Uint32Array) {
  30419. arrayBuffer = indices;
  30420. need32Bits = true;
  30421. }
  30422. else {
  30423. //number[] or Int32Array, check if 32 bit is necessary
  30424. for (var index = 0; index < indices.length; index++) {
  30425. if (indices[index] > 65535) {
  30426. need32Bits = true;
  30427. break;
  30428. }
  30429. }
  30430. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30431. }
  30432. }
  30433. else {
  30434. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  30435. arrayBuffer = new Uint16Array(indices);
  30436. }
  30437. }
  30438. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  30439. this._resetIndexBufferBinding();
  30440. vbo.references = 1;
  30441. vbo.is32Bits = need32Bits;
  30442. return vbo;
  30443. };
  30444. /**
  30445. * Bind a webGL buffer to the webGL context
  30446. * @param buffer defines the buffer to bind
  30447. */
  30448. Engine.prototype.bindArrayBuffer = function (buffer) {
  30449. if (!this._vaoRecordInProgress) {
  30450. this._unbindVertexArrayObject();
  30451. }
  30452. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  30453. };
  30454. /**
  30455. * Bind an uniform buffer to the current webGL context
  30456. * @param buffer defines the buffer to bind
  30457. */
  30458. Engine.prototype.bindUniformBuffer = function (buffer) {
  30459. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  30460. };
  30461. /**
  30462. * Bind a buffer to the current webGL context at a given location
  30463. * @param buffer defines the buffer to bind
  30464. * @param location defines the index where to bind the buffer
  30465. */
  30466. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  30467. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  30468. };
  30469. /**
  30470. * Bind a specific block at a given index in a specific shader program
  30471. * @param shaderProgram defines the shader program
  30472. * @param blockName defines the block name
  30473. * @param index defines the index where to bind the block
  30474. */
  30475. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  30476. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  30477. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  30478. };
  30479. Engine.prototype.bindIndexBuffer = function (buffer) {
  30480. if (!this._vaoRecordInProgress) {
  30481. this._unbindVertexArrayObject();
  30482. }
  30483. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  30484. };
  30485. Engine.prototype.bindBuffer = function (buffer, target) {
  30486. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  30487. this._gl.bindBuffer(target, buffer);
  30488. this._currentBoundBuffer[target] = buffer;
  30489. }
  30490. };
  30491. /**
  30492. * update the bound buffer with the given data
  30493. * @param data defines the data to update
  30494. */
  30495. Engine.prototype.updateArrayBuffer = function (data) {
  30496. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30497. };
  30498. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  30499. var pointer = this._currentBufferPointers[indx];
  30500. var changed = false;
  30501. if (!pointer.active) {
  30502. changed = true;
  30503. pointer.active = true;
  30504. pointer.index = indx;
  30505. pointer.size = size;
  30506. pointer.type = type;
  30507. pointer.normalized = normalized;
  30508. pointer.stride = stride;
  30509. pointer.offset = offset;
  30510. pointer.buffer = buffer;
  30511. }
  30512. else {
  30513. if (pointer.buffer !== buffer) {
  30514. pointer.buffer = buffer;
  30515. changed = true;
  30516. }
  30517. if (pointer.size !== size) {
  30518. pointer.size = size;
  30519. changed = true;
  30520. }
  30521. if (pointer.type !== type) {
  30522. pointer.type = type;
  30523. changed = true;
  30524. }
  30525. if (pointer.normalized !== normalized) {
  30526. pointer.normalized = normalized;
  30527. changed = true;
  30528. }
  30529. if (pointer.stride !== stride) {
  30530. pointer.stride = stride;
  30531. changed = true;
  30532. }
  30533. if (pointer.offset !== offset) {
  30534. pointer.offset = offset;
  30535. changed = true;
  30536. }
  30537. }
  30538. if (changed || this._vaoRecordInProgress) {
  30539. this.bindArrayBuffer(buffer);
  30540. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  30541. }
  30542. };
  30543. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  30544. if (indexBuffer == null) {
  30545. return;
  30546. }
  30547. if (this._cachedIndexBuffer !== indexBuffer) {
  30548. this._cachedIndexBuffer = indexBuffer;
  30549. this.bindIndexBuffer(indexBuffer);
  30550. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  30551. }
  30552. };
  30553. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  30554. var attributes = effect.getAttributesNames();
  30555. if (!this._vaoRecordInProgress) {
  30556. this._unbindVertexArrayObject();
  30557. }
  30558. this.unbindAllAttributes();
  30559. for (var index = 0; index < attributes.length; index++) {
  30560. var order = effect.getAttributeLocation(index);
  30561. if (order >= 0) {
  30562. var vertexBuffer = vertexBuffers[attributes[index]];
  30563. if (!vertexBuffer) {
  30564. continue;
  30565. }
  30566. this._gl.enableVertexAttribArray(order);
  30567. if (!this._vaoRecordInProgress) {
  30568. this._vertexAttribArraysEnabled[order] = true;
  30569. }
  30570. var buffer = vertexBuffer.getBuffer();
  30571. if (buffer) {
  30572. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  30573. if (vertexBuffer.getIsInstanced()) {
  30574. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  30575. if (!this._vaoRecordInProgress) {
  30576. this._currentInstanceLocations.push(order);
  30577. this._currentInstanceBuffers.push(buffer);
  30578. }
  30579. }
  30580. }
  30581. }
  30582. }
  30583. };
  30584. /**
  30585. * Records a vertex array object
  30586. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30587. * @param vertexBuffers defines the list of vertex buffers to store
  30588. * @param indexBuffer defines the index buffer to store
  30589. * @param effect defines the effect to store
  30590. * @returns the new vertex array object
  30591. */
  30592. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  30593. var vao = this._gl.createVertexArray();
  30594. this._vaoRecordInProgress = true;
  30595. this._gl.bindVertexArray(vao);
  30596. this._mustWipeVertexAttributes = true;
  30597. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30598. this.bindIndexBuffer(indexBuffer);
  30599. this._vaoRecordInProgress = false;
  30600. this._gl.bindVertexArray(null);
  30601. return vao;
  30602. };
  30603. /**
  30604. * Bind a specific vertex array object
  30605. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30606. * @param vertexArrayObject defines the vertex array object to bind
  30607. * @param indexBuffer defines the index buffer to bind
  30608. */
  30609. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  30610. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  30611. this._cachedVertexArrayObject = vertexArrayObject;
  30612. this._gl.bindVertexArray(vertexArrayObject);
  30613. this._cachedVertexBuffers = null;
  30614. this._cachedIndexBuffer = null;
  30615. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  30616. this._mustWipeVertexAttributes = true;
  30617. }
  30618. };
  30619. /**
  30620. * Bind webGl buffers directly to the webGL context
  30621. * @param vertexBuffer defines the vertex buffer to bind
  30622. * @param indexBuffer defines the index buffer to bind
  30623. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30624. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30625. * @param effect defines the effect associated with the vertex buffer
  30626. */
  30627. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  30628. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  30629. this._cachedVertexBuffers = vertexBuffer;
  30630. this._cachedEffectForVertexBuffers = effect;
  30631. var attributesCount = effect.getAttributesCount();
  30632. this._unbindVertexArrayObject();
  30633. this.unbindAllAttributes();
  30634. var offset = 0;
  30635. for (var index = 0; index < attributesCount; index++) {
  30636. if (index < vertexDeclaration.length) {
  30637. var order = effect.getAttributeLocation(index);
  30638. if (order >= 0) {
  30639. this._gl.enableVertexAttribArray(order);
  30640. this._vertexAttribArraysEnabled[order] = true;
  30641. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  30642. }
  30643. offset += vertexDeclaration[index] * 4;
  30644. }
  30645. }
  30646. }
  30647. this._bindIndexBufferWithCache(indexBuffer);
  30648. };
  30649. Engine.prototype._unbindVertexArrayObject = function () {
  30650. if (!this._cachedVertexArrayObject) {
  30651. return;
  30652. }
  30653. this._cachedVertexArrayObject = null;
  30654. this._gl.bindVertexArray(null);
  30655. };
  30656. /**
  30657. * Bind a list of vertex buffers to the webGL context
  30658. * @param vertexBuffers defines the list of vertex buffers to bind
  30659. * @param indexBuffer defines the index buffer to bind
  30660. * @param effect defines the effect associated with the vertex buffers
  30661. */
  30662. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  30663. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  30664. this._cachedVertexBuffers = vertexBuffers;
  30665. this._cachedEffectForVertexBuffers = effect;
  30666. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30667. }
  30668. this._bindIndexBufferWithCache(indexBuffer);
  30669. };
  30670. /**
  30671. * Unbind all instance attributes
  30672. */
  30673. Engine.prototype.unbindInstanceAttributes = function () {
  30674. var boundBuffer;
  30675. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  30676. var instancesBuffer = this._currentInstanceBuffers[i];
  30677. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  30678. boundBuffer = instancesBuffer;
  30679. this.bindArrayBuffer(instancesBuffer);
  30680. }
  30681. var offsetLocation = this._currentInstanceLocations[i];
  30682. this._gl.vertexAttribDivisor(offsetLocation, 0);
  30683. }
  30684. this._currentInstanceBuffers.length = 0;
  30685. this._currentInstanceLocations.length = 0;
  30686. };
  30687. /**
  30688. * Release and free the memory of a vertex array object
  30689. * @param vao defines the vertex array object to delete
  30690. */
  30691. Engine.prototype.releaseVertexArrayObject = function (vao) {
  30692. this._gl.deleteVertexArray(vao);
  30693. };
  30694. /** @hidden */
  30695. Engine.prototype._releaseBuffer = function (buffer) {
  30696. buffer.references--;
  30697. if (buffer.references === 0) {
  30698. this._gl.deleteBuffer(buffer);
  30699. return true;
  30700. }
  30701. return false;
  30702. };
  30703. /**
  30704. * Creates a webGL buffer to use with instanciation
  30705. * @param capacity defines the size of the buffer
  30706. * @returns the webGL buffer
  30707. */
  30708. Engine.prototype.createInstancesBuffer = function (capacity) {
  30709. var buffer = this._gl.createBuffer();
  30710. if (!buffer) {
  30711. throw new Error("Unable to create instance buffer");
  30712. }
  30713. buffer.capacity = capacity;
  30714. this.bindArrayBuffer(buffer);
  30715. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  30716. return buffer;
  30717. };
  30718. /**
  30719. * Delete a webGL buffer used with instanciation
  30720. * @param buffer defines the webGL buffer to delete
  30721. */
  30722. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  30723. this._gl.deleteBuffer(buffer);
  30724. };
  30725. /**
  30726. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30727. * @param instancesBuffer defines the webGL buffer to update and bind
  30728. * @param data defines the data to store in the buffer
  30729. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30730. */
  30731. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  30732. this.bindArrayBuffer(instancesBuffer);
  30733. if (data) {
  30734. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30735. }
  30736. if (offsetLocations[0].index !== undefined) {
  30737. var stride = 0;
  30738. for (var i = 0; i < offsetLocations.length; i++) {
  30739. var ai = offsetLocations[i];
  30740. stride += ai.attributeSize * 4;
  30741. }
  30742. for (var i = 0; i < offsetLocations.length; i++) {
  30743. var ai = offsetLocations[i];
  30744. if (!this._vertexAttribArraysEnabled[ai.index]) {
  30745. this._gl.enableVertexAttribArray(ai.index);
  30746. this._vertexAttribArraysEnabled[ai.index] = true;
  30747. }
  30748. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  30749. this._gl.vertexAttribDivisor(ai.index, 1);
  30750. this._currentInstanceLocations.push(ai.index);
  30751. this._currentInstanceBuffers.push(instancesBuffer);
  30752. }
  30753. }
  30754. else {
  30755. for (var index = 0; index < 4; index++) {
  30756. var offsetLocation = offsetLocations[index];
  30757. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  30758. this._gl.enableVertexAttribArray(offsetLocation);
  30759. this._vertexAttribArraysEnabled[offsetLocation] = true;
  30760. }
  30761. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  30762. this._gl.vertexAttribDivisor(offsetLocation, 1);
  30763. this._currentInstanceLocations.push(offsetLocation);
  30764. this._currentInstanceBuffers.push(instancesBuffer);
  30765. }
  30766. }
  30767. };
  30768. /**
  30769. * Apply all cached states (depth, culling, stencil and alpha)
  30770. */
  30771. Engine.prototype.applyStates = function () {
  30772. this._depthCullingState.apply(this._gl);
  30773. this._stencilState.apply(this._gl);
  30774. this._alphaState.apply(this._gl);
  30775. };
  30776. /**
  30777. * Send a draw order
  30778. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30779. * @param indexStart defines the starting index
  30780. * @param indexCount defines the number of index to draw
  30781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30782. */
  30783. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  30784. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  30785. };
  30786. /**
  30787. * Draw a list of points
  30788. * @param verticesStart defines the index of first vertex to draw
  30789. * @param verticesCount defines the count of vertices to draw
  30790. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30791. */
  30792. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  30793. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  30794. };
  30795. /**
  30796. * Draw a list of unindexed primitives
  30797. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30798. * @param verticesStart defines the index of first vertex to draw
  30799. * @param verticesCount defines the count of vertices to draw
  30800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30801. */
  30802. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  30803. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  30804. };
  30805. /**
  30806. * Draw a list of indexed primitives
  30807. * @param fillMode defines the primitive to use
  30808. * @param indexStart defines the starting index
  30809. * @param indexCount defines the number of index to draw
  30810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30811. */
  30812. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  30813. // Apply states
  30814. this.applyStates();
  30815. this._drawCalls.addCount(1, false);
  30816. // Render
  30817. var drawMode = this._drawMode(fillMode);
  30818. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  30819. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  30820. if (instancesCount) {
  30821. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  30822. }
  30823. else {
  30824. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  30825. }
  30826. };
  30827. /**
  30828. * Draw a list of unindexed primitives
  30829. * @param fillMode defines the primitive to use
  30830. * @param verticesStart defines the index of first vertex to draw
  30831. * @param verticesCount defines the count of vertices to draw
  30832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30833. */
  30834. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  30835. // Apply states
  30836. this.applyStates();
  30837. this._drawCalls.addCount(1, false);
  30838. var drawMode = this._drawMode(fillMode);
  30839. if (instancesCount) {
  30840. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  30841. }
  30842. else {
  30843. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  30844. }
  30845. };
  30846. Engine.prototype._drawMode = function (fillMode) {
  30847. switch (fillMode) {
  30848. // Triangle views
  30849. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  30850. return this._gl.TRIANGLES;
  30851. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  30852. return this._gl.POINTS;
  30853. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  30854. return this._gl.LINES;
  30855. // Draw modes
  30856. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  30857. return this._gl.POINTS;
  30858. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  30859. return this._gl.LINES;
  30860. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  30861. return this._gl.LINE_LOOP;
  30862. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  30863. return this._gl.LINE_STRIP;
  30864. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  30865. return this._gl.TRIANGLE_STRIP;
  30866. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  30867. return this._gl.TRIANGLE_FAN;
  30868. default:
  30869. return this._gl.TRIANGLES;
  30870. }
  30871. };
  30872. // Shaders
  30873. /** @hidden */
  30874. Engine.prototype._releaseEffect = function (effect) {
  30875. if (this._compiledEffects[effect._key]) {
  30876. delete this._compiledEffects[effect._key];
  30877. this._deleteProgram(effect.getProgram());
  30878. }
  30879. };
  30880. /** @hidden */
  30881. Engine.prototype._deleteProgram = function (program) {
  30882. if (program) {
  30883. program.__SPECTOR_rebuildProgram = null;
  30884. if (program.transformFeedback) {
  30885. this.deleteTransformFeedback(program.transformFeedback);
  30886. program.transformFeedback = null;
  30887. }
  30888. this._gl.deleteProgram(program);
  30889. }
  30890. };
  30891. /**
  30892. * Create a new effect (used to store vertex/fragment shaders)
  30893. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30894. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30895. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30896. * @param samplers defines an array of string used to represent textures
  30897. * @param defines defines the string containing the defines to use to compile the shaders
  30898. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30899. * @param onCompiled defines a function to call when the effect creation is successful
  30900. * @param onError defines a function to call when the effect creation has failed
  30901. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30902. * @returns the new Effect
  30903. */
  30904. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  30905. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  30906. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  30907. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  30908. if (this._compiledEffects[name]) {
  30909. var compiledEffect = this._compiledEffects[name];
  30910. if (onCompiled && compiledEffect.isReady()) {
  30911. onCompiled(compiledEffect);
  30912. }
  30913. return compiledEffect;
  30914. }
  30915. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  30916. effect._key = name;
  30917. this._compiledEffects[name] = effect;
  30918. return effect;
  30919. };
  30920. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  30921. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  30922. };
  30923. Engine.prototype._compileRawShader = function (source, type) {
  30924. var gl = this._gl;
  30925. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  30926. if (!shader) {
  30927. throw new Error("Something went wrong while compile the shader.");
  30928. }
  30929. gl.shaderSource(shader, source);
  30930. gl.compileShader(shader);
  30931. return shader;
  30932. };
  30933. /**
  30934. * Directly creates a webGL program
  30935. * @param vertexCode defines the vertex shader code to use
  30936. * @param fragmentCode defines the fragment shader code to use
  30937. * @param context defines the webGL context to use (if not set, the current one will be used)
  30938. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30939. * @returns the new webGL program
  30940. */
  30941. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30942. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30943. context = context || this._gl;
  30944. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30945. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30946. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30947. };
  30948. /**
  30949. * Creates a webGL program
  30950. * @param vertexCode defines the vertex shader code to use
  30951. * @param fragmentCode defines the fragment shader code to use
  30952. * @param defines defines the string containing the defines to use to compile the shaders
  30953. * @param context defines the webGL context to use (if not set, the current one will be used)
  30954. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30955. * @returns the new webGL program
  30956. */
  30957. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30958. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30959. context = context || this._gl;
  30960. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30961. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30962. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30963. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30964. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30965. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30966. return program;
  30967. };
  30968. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30969. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30970. var shaderProgram = context.createProgram();
  30971. if (!shaderProgram) {
  30972. throw new Error("Unable to create program");
  30973. }
  30974. if (this._caps.parallelShaderCompile) {
  30975. shaderProgram.isParallelCompiled = true;
  30976. }
  30977. context.attachShader(shaderProgram, vertexShader);
  30978. context.attachShader(shaderProgram, fragmentShader);
  30979. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30980. var transformFeedback = this.createTransformFeedback();
  30981. this.bindTransformFeedback(transformFeedback);
  30982. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30983. shaderProgram.transformFeedback = transformFeedback;
  30984. }
  30985. context.linkProgram(shaderProgram);
  30986. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30987. this.bindTransformFeedback(null);
  30988. }
  30989. shaderProgram.context = context;
  30990. shaderProgram.vertexShader = vertexShader;
  30991. shaderProgram.fragmentShader = fragmentShader;
  30992. if (!shaderProgram.isParallelCompiled) {
  30993. this._finalizeProgram(shaderProgram);
  30994. }
  30995. return shaderProgram;
  30996. };
  30997. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30998. var context = shaderProgram.context;
  30999. var vertexShader = shaderProgram.vertexShader;
  31000. var fragmentShader = shaderProgram.fragmentShader;
  31001. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  31002. if (!linked) { // Get more info
  31003. // Vertex
  31004. if (!this._gl.getShaderParameter(vertexShader, this._gl.COMPILE_STATUS)) {
  31005. var log = this._gl.getShaderInfoLog(vertexShader);
  31006. if (log) {
  31007. throw new Error(log);
  31008. }
  31009. }
  31010. // Fragment
  31011. if (!this._gl.getShaderParameter(fragmentShader, this._gl.COMPILE_STATUS)) {
  31012. var log = this._gl.getShaderInfoLog(fragmentShader);
  31013. if (log) {
  31014. throw new Error(log);
  31015. }
  31016. }
  31017. var error = context.getProgramInfoLog(shaderProgram);
  31018. if (error) {
  31019. throw new Error(error);
  31020. }
  31021. }
  31022. if (this.validateShaderPrograms) {
  31023. context.validateProgram(shaderProgram);
  31024. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  31025. if (!validated) {
  31026. var error = context.getProgramInfoLog(shaderProgram);
  31027. if (error) {
  31028. throw new Error(error);
  31029. }
  31030. }
  31031. }
  31032. context.deleteShader(vertexShader);
  31033. context.deleteShader(fragmentShader);
  31034. shaderProgram.context = undefined;
  31035. shaderProgram.vertexShader = undefined;
  31036. shaderProgram.fragmentShader = undefined;
  31037. if (shaderProgram.onCompiled) {
  31038. shaderProgram.onCompiled();
  31039. shaderProgram.onCompiled = undefined;
  31040. }
  31041. };
  31042. /** @hidden */
  31043. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  31044. if (!shaderProgram.isParallelCompiled) {
  31045. return true;
  31046. }
  31047. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  31048. this._finalizeProgram(shaderProgram);
  31049. return true;
  31050. }
  31051. return false;
  31052. };
  31053. /** @hidden */
  31054. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  31055. if (!shaderProgram.isParallelCompiled) {
  31056. action();
  31057. return;
  31058. }
  31059. shaderProgram.onCompiled = action;
  31060. };
  31061. /**
  31062. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31063. * @param shaderProgram defines the webGL program to use
  31064. * @param uniformsNames defines the list of uniform names
  31065. * @returns an array of webGL uniform locations
  31066. */
  31067. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  31068. var results = new Array();
  31069. for (var index = 0; index < uniformsNames.length; index++) {
  31070. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  31071. }
  31072. return results;
  31073. };
  31074. /**
  31075. * Gets the lsit of active attributes for a given webGL program
  31076. * @param shaderProgram defines the webGL program to use
  31077. * @param attributesNames defines the list of attribute names to get
  31078. * @returns an array of indices indicating the offset of each attribute
  31079. */
  31080. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  31081. var results = [];
  31082. for (var index = 0; index < attributesNames.length; index++) {
  31083. try {
  31084. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  31085. }
  31086. catch (e) {
  31087. results.push(-1);
  31088. }
  31089. }
  31090. return results;
  31091. };
  31092. /**
  31093. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31094. * @param effect defines the effect to activate
  31095. */
  31096. Engine.prototype.enableEffect = function (effect) {
  31097. if (!effect || effect === this._currentEffect) {
  31098. return;
  31099. }
  31100. // Use program
  31101. this.bindSamplers(effect);
  31102. this._currentEffect = effect;
  31103. if (effect.onBind) {
  31104. effect.onBind(effect);
  31105. }
  31106. if (effect._onBindObservable) {
  31107. effect._onBindObservable.notifyObservers(effect);
  31108. }
  31109. };
  31110. /**
  31111. * Set the value of an uniform to an array of int32
  31112. * @param uniform defines the webGL uniform location where to store the value
  31113. * @param array defines the array of int32 to store
  31114. */
  31115. Engine.prototype.setIntArray = function (uniform, array) {
  31116. if (!uniform) {
  31117. return;
  31118. }
  31119. this._gl.uniform1iv(uniform, array);
  31120. };
  31121. /**
  31122. * Set the value of an uniform to an array of int32 (stored as vec2)
  31123. * @param uniform defines the webGL uniform location where to store the value
  31124. * @param array defines the array of int32 to store
  31125. */
  31126. Engine.prototype.setIntArray2 = function (uniform, array) {
  31127. if (!uniform || array.length % 2 !== 0) {
  31128. return;
  31129. }
  31130. this._gl.uniform2iv(uniform, array);
  31131. };
  31132. /**
  31133. * Set the value of an uniform to an array of int32 (stored as vec3)
  31134. * @param uniform defines the webGL uniform location where to store the value
  31135. * @param array defines the array of int32 to store
  31136. */
  31137. Engine.prototype.setIntArray3 = function (uniform, array) {
  31138. if (!uniform || array.length % 3 !== 0) {
  31139. return;
  31140. }
  31141. this._gl.uniform3iv(uniform, array);
  31142. };
  31143. /**
  31144. * Set the value of an uniform to an array of int32 (stored as vec4)
  31145. * @param uniform defines the webGL uniform location where to store the value
  31146. * @param array defines the array of int32 to store
  31147. */
  31148. Engine.prototype.setIntArray4 = function (uniform, array) {
  31149. if (!uniform || array.length % 4 !== 0) {
  31150. return;
  31151. }
  31152. this._gl.uniform4iv(uniform, array);
  31153. };
  31154. /**
  31155. * Set the value of an uniform to an array of float32
  31156. * @param uniform defines the webGL uniform location where to store the value
  31157. * @param array defines the array of float32 to store
  31158. */
  31159. Engine.prototype.setFloatArray = function (uniform, array) {
  31160. if (!uniform) {
  31161. return;
  31162. }
  31163. this._gl.uniform1fv(uniform, array);
  31164. };
  31165. /**
  31166. * Set the value of an uniform to an array of float32 (stored as vec2)
  31167. * @param uniform defines the webGL uniform location where to store the value
  31168. * @param array defines the array of float32 to store
  31169. */
  31170. Engine.prototype.setFloatArray2 = function (uniform, array) {
  31171. if (!uniform || array.length % 2 !== 0) {
  31172. return;
  31173. }
  31174. this._gl.uniform2fv(uniform, array);
  31175. };
  31176. /**
  31177. * Set the value of an uniform to an array of float32 (stored as vec3)
  31178. * @param uniform defines the webGL uniform location where to store the value
  31179. * @param array defines the array of float32 to store
  31180. */
  31181. Engine.prototype.setFloatArray3 = function (uniform, array) {
  31182. if (!uniform || array.length % 3 !== 0) {
  31183. return;
  31184. }
  31185. this._gl.uniform3fv(uniform, array);
  31186. };
  31187. /**
  31188. * Set the value of an uniform to an array of float32 (stored as vec4)
  31189. * @param uniform defines the webGL uniform location where to store the value
  31190. * @param array defines the array of float32 to store
  31191. */
  31192. Engine.prototype.setFloatArray4 = function (uniform, array) {
  31193. if (!uniform || array.length % 4 !== 0) {
  31194. return;
  31195. }
  31196. this._gl.uniform4fv(uniform, array);
  31197. };
  31198. /**
  31199. * Set the value of an uniform to an array of number
  31200. * @param uniform defines the webGL uniform location where to store the value
  31201. * @param array defines the array of number to store
  31202. */
  31203. Engine.prototype.setArray = function (uniform, array) {
  31204. if (!uniform) {
  31205. return;
  31206. }
  31207. this._gl.uniform1fv(uniform, array);
  31208. };
  31209. /**
  31210. * Set the value of an uniform to an array of number (stored as vec2)
  31211. * @param uniform defines the webGL uniform location where to store the value
  31212. * @param array defines the array of number to store
  31213. */
  31214. Engine.prototype.setArray2 = function (uniform, array) {
  31215. if (!uniform || array.length % 2 !== 0) {
  31216. return;
  31217. }
  31218. this._gl.uniform2fv(uniform, array);
  31219. };
  31220. /**
  31221. * Set the value of an uniform to an array of number (stored as vec3)
  31222. * @param uniform defines the webGL uniform location where to store the value
  31223. * @param array defines the array of number to store
  31224. */
  31225. Engine.prototype.setArray3 = function (uniform, array) {
  31226. if (!uniform || array.length % 3 !== 0) {
  31227. return;
  31228. }
  31229. this._gl.uniform3fv(uniform, array);
  31230. };
  31231. /**
  31232. * Set the value of an uniform to an array of number (stored as vec4)
  31233. * @param uniform defines the webGL uniform location where to store the value
  31234. * @param array defines the array of number to store
  31235. */
  31236. Engine.prototype.setArray4 = function (uniform, array) {
  31237. if (!uniform || array.length % 4 !== 0) {
  31238. return;
  31239. }
  31240. this._gl.uniform4fv(uniform, array);
  31241. };
  31242. /**
  31243. * Set the value of an uniform to an array of float32 (stored as matrices)
  31244. * @param uniform defines the webGL uniform location where to store the value
  31245. * @param matrices defines the array of float32 to store
  31246. */
  31247. Engine.prototype.setMatrices = function (uniform, matrices) {
  31248. if (!uniform) {
  31249. return;
  31250. }
  31251. this._gl.uniformMatrix4fv(uniform, false, matrices);
  31252. };
  31253. /**
  31254. * Set the value of an uniform to a matrix
  31255. * @param uniform defines the webGL uniform location where to store the value
  31256. * @param matrix defines the matrix to store
  31257. */
  31258. Engine.prototype.setMatrix = function (uniform, matrix) {
  31259. if (!uniform) {
  31260. return;
  31261. }
  31262. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  31263. };
  31264. /**
  31265. * Set the value of an uniform to a matrix (3x3)
  31266. * @param uniform defines the webGL uniform location where to store the value
  31267. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31268. */
  31269. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  31270. if (!uniform) {
  31271. return;
  31272. }
  31273. this._gl.uniformMatrix3fv(uniform, false, matrix);
  31274. };
  31275. /**
  31276. * Set the value of an uniform to a matrix (2x2)
  31277. * @param uniform defines the webGL uniform location where to store the value
  31278. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31279. */
  31280. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  31281. if (!uniform) {
  31282. return;
  31283. }
  31284. this._gl.uniformMatrix2fv(uniform, false, matrix);
  31285. };
  31286. /**
  31287. * Set the value of an uniform to a number (int)
  31288. * @param uniform defines the webGL uniform location where to store the value
  31289. * @param value defines the int number to store
  31290. */
  31291. Engine.prototype.setInt = function (uniform, value) {
  31292. if (!uniform) {
  31293. return;
  31294. }
  31295. this._gl.uniform1i(uniform, value);
  31296. };
  31297. /**
  31298. * Set the value of an uniform to a number (float)
  31299. * @param uniform defines the webGL uniform location where to store the value
  31300. * @param value defines the float number to store
  31301. */
  31302. Engine.prototype.setFloat = function (uniform, value) {
  31303. if (!uniform) {
  31304. return;
  31305. }
  31306. this._gl.uniform1f(uniform, value);
  31307. };
  31308. /**
  31309. * Set the value of an uniform to a vec2
  31310. * @param uniform defines the webGL uniform location where to store the value
  31311. * @param x defines the 1st component of the value
  31312. * @param y defines the 2nd component of the value
  31313. */
  31314. Engine.prototype.setFloat2 = function (uniform, x, y) {
  31315. if (!uniform) {
  31316. return;
  31317. }
  31318. this._gl.uniform2f(uniform, x, y);
  31319. };
  31320. /**
  31321. * Set the value of an uniform to a vec3
  31322. * @param uniform defines the webGL uniform location where to store the value
  31323. * @param x defines the 1st component of the value
  31324. * @param y defines the 2nd component of the value
  31325. * @param z defines the 3rd component of the value
  31326. */
  31327. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  31328. if (!uniform) {
  31329. return;
  31330. }
  31331. this._gl.uniform3f(uniform, x, y, z);
  31332. };
  31333. /**
  31334. * Set the value of an uniform to a boolean
  31335. * @param uniform defines the webGL uniform location where to store the value
  31336. * @param bool defines the boolean to store
  31337. */
  31338. Engine.prototype.setBool = function (uniform, bool) {
  31339. if (!uniform) {
  31340. return;
  31341. }
  31342. this._gl.uniform1i(uniform, bool);
  31343. };
  31344. /**
  31345. * Set the value of an uniform to a vec4
  31346. * @param uniform defines the webGL uniform location where to store the value
  31347. * @param x defines the 1st component of the value
  31348. * @param y defines the 2nd component of the value
  31349. * @param z defines the 3rd component of the value
  31350. * @param w defines the 4th component of the value
  31351. */
  31352. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  31353. if (!uniform) {
  31354. return;
  31355. }
  31356. this._gl.uniform4f(uniform, x, y, z, w);
  31357. };
  31358. /**
  31359. * Set the value of an uniform to a Color3
  31360. * @param uniform defines the webGL uniform location where to store the value
  31361. * @param color3 defines the color to store
  31362. */
  31363. Engine.prototype.setColor3 = function (uniform, color3) {
  31364. if (!uniform) {
  31365. return;
  31366. }
  31367. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  31368. };
  31369. /**
  31370. * Set the value of an uniform to a Color3 and an alpha value
  31371. * @param uniform defines the webGL uniform location where to store the value
  31372. * @param color3 defines the color to store
  31373. * @param alpha defines the alpha component to store
  31374. */
  31375. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  31376. if (!uniform) {
  31377. return;
  31378. }
  31379. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  31380. };
  31381. /**
  31382. * Sets a Color4 on a uniform variable
  31383. * @param uniform defines the uniform location
  31384. * @param color4 defines the value to be set
  31385. */
  31386. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  31387. if (!uniform) {
  31388. return;
  31389. }
  31390. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  31391. };
  31392. // States
  31393. /**
  31394. * Set various states to the webGL context
  31395. * @param culling defines backface culling state
  31396. * @param zOffset defines the value to apply to zOffset (0 by default)
  31397. * @param force defines if states must be applied even if cache is up to date
  31398. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31399. */
  31400. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  31401. if (zOffset === void 0) { zOffset = 0; }
  31402. if (reverseSide === void 0) { reverseSide = false; }
  31403. // Culling
  31404. if (this._depthCullingState.cull !== culling || force) {
  31405. this._depthCullingState.cull = culling;
  31406. }
  31407. // Cull face
  31408. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  31409. if (this._depthCullingState.cullFace !== cullFace || force) {
  31410. this._depthCullingState.cullFace = cullFace;
  31411. }
  31412. // Z offset
  31413. this.setZOffset(zOffset);
  31414. // Front face
  31415. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  31416. if (this._depthCullingState.frontFace !== frontFace || force) {
  31417. this._depthCullingState.frontFace = frontFace;
  31418. }
  31419. };
  31420. /**
  31421. * Set the z offset to apply to current rendering
  31422. * @param value defines the offset to apply
  31423. */
  31424. Engine.prototype.setZOffset = function (value) {
  31425. this._depthCullingState.zOffset = value;
  31426. };
  31427. /**
  31428. * Gets the current value of the zOffset
  31429. * @returns the current zOffset state
  31430. */
  31431. Engine.prototype.getZOffset = function () {
  31432. return this._depthCullingState.zOffset;
  31433. };
  31434. /**
  31435. * Enable or disable depth buffering
  31436. * @param enable defines the state to set
  31437. */
  31438. Engine.prototype.setDepthBuffer = function (enable) {
  31439. this._depthCullingState.depthTest = enable;
  31440. };
  31441. /**
  31442. * Gets a boolean indicating if depth writing is enabled
  31443. * @returns the current depth writing state
  31444. */
  31445. Engine.prototype.getDepthWrite = function () {
  31446. return this._depthCullingState.depthMask;
  31447. };
  31448. /**
  31449. * Enable or disable depth writing
  31450. * @param enable defines the state to set
  31451. */
  31452. Engine.prototype.setDepthWrite = function (enable) {
  31453. this._depthCullingState.depthMask = enable;
  31454. };
  31455. /**
  31456. * Enable or disable color writing
  31457. * @param enable defines the state to set
  31458. */
  31459. Engine.prototype.setColorWrite = function (enable) {
  31460. this._gl.colorMask(enable, enable, enable, enable);
  31461. this._colorWrite = enable;
  31462. };
  31463. /**
  31464. * Gets a boolean indicating if color writing is enabled
  31465. * @returns the current color writing state
  31466. */
  31467. Engine.prototype.getColorWrite = function () {
  31468. return this._colorWrite;
  31469. };
  31470. /**
  31471. * Sets alpha constants used by some alpha blending modes
  31472. * @param r defines the red component
  31473. * @param g defines the green component
  31474. * @param b defines the blue component
  31475. * @param a defines the alpha component
  31476. */
  31477. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  31478. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  31479. };
  31480. /**
  31481. * Sets the current alpha mode
  31482. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31483. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31484. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31485. */
  31486. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  31487. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  31488. if (this._alphaMode === mode) {
  31489. return;
  31490. }
  31491. switch (mode) {
  31492. case Engine.ALPHA_DISABLE:
  31493. this._alphaState.alphaBlend = false;
  31494. break;
  31495. case Engine.ALPHA_PREMULTIPLIED:
  31496. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31497. this._alphaState.alphaBlend = true;
  31498. break;
  31499. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  31500. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31501. this._alphaState.alphaBlend = true;
  31502. break;
  31503. case Engine.ALPHA_COMBINE:
  31504. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31505. this._alphaState.alphaBlend = true;
  31506. break;
  31507. case Engine.ALPHA_ONEONE:
  31508. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31509. this._alphaState.alphaBlend = true;
  31510. break;
  31511. case Engine.ALPHA_ADD:
  31512. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31513. this._alphaState.alphaBlend = true;
  31514. break;
  31515. case Engine.ALPHA_SUBTRACT:
  31516. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31517. this._alphaState.alphaBlend = true;
  31518. break;
  31519. case Engine.ALPHA_MULTIPLY:
  31520. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  31521. this._alphaState.alphaBlend = true;
  31522. break;
  31523. case Engine.ALPHA_MAXIMIZED:
  31524. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31525. this._alphaState.alphaBlend = true;
  31526. break;
  31527. case Engine.ALPHA_INTERPOLATE:
  31528. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  31529. this._alphaState.alphaBlend = true;
  31530. break;
  31531. case Engine.ALPHA_SCREENMODE:
  31532. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31533. this._alphaState.alphaBlend = true;
  31534. break;
  31535. }
  31536. if (!noDepthWriteChange) {
  31537. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  31538. }
  31539. this._alphaMode = mode;
  31540. };
  31541. /**
  31542. * Gets the current alpha mode
  31543. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31544. * @returns the current alpha mode
  31545. */
  31546. Engine.prototype.getAlphaMode = function () {
  31547. return this._alphaMode;
  31548. };
  31549. // Textures
  31550. /**
  31551. * Clears the list of texture accessible through engine.
  31552. * This can help preventing texture load conflict due to name collision.
  31553. */
  31554. Engine.prototype.clearInternalTexturesCache = function () {
  31555. this._internalTexturesCache = [];
  31556. };
  31557. /**
  31558. * Force the entire cache to be cleared
  31559. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31560. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31561. */
  31562. Engine.prototype.wipeCaches = function (bruteForce) {
  31563. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  31564. return;
  31565. }
  31566. this._currentEffect = null;
  31567. this._viewportCached.x = 0;
  31568. this._viewportCached.y = 0;
  31569. this._viewportCached.z = 0;
  31570. this._viewportCached.w = 0;
  31571. if (bruteForce) {
  31572. this.resetTextureCache();
  31573. this._currentProgram = null;
  31574. this._stencilState.reset();
  31575. this._depthCullingState.reset();
  31576. this.setDepthFunctionToLessOrEqual();
  31577. this._alphaState.reset();
  31578. this._unpackFlipYCached = null;
  31579. }
  31580. this._resetVertexBufferBinding();
  31581. this._cachedIndexBuffer = null;
  31582. this._cachedEffectForVertexBuffers = null;
  31583. this._unbindVertexArrayObject();
  31584. this.bindIndexBuffer(null);
  31585. };
  31586. /**
  31587. * Set the compressed texture format to use, based on the formats you have, and the formats
  31588. * supported by the hardware / browser.
  31589. *
  31590. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31591. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31592. * to API arguments needed to compressed textures. This puts the burden on the container
  31593. * generator to house the arcane code for determining these for current & future formats.
  31594. *
  31595. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31596. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31597. *
  31598. * Note: The result of this call is not taken into account when a texture is base64.
  31599. *
  31600. * @param formatsAvailable defines the list of those format families you have created
  31601. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31602. *
  31603. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31604. * @returns The extension selected.
  31605. */
  31606. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  31607. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  31608. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  31609. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  31610. return this._textureFormatInUse = this._texturesSupported[i];
  31611. }
  31612. }
  31613. }
  31614. // actively set format to nothing, to allow this to be called more than once
  31615. // and possibly fail the 2nd time
  31616. this._textureFormatInUse = null;
  31617. return null;
  31618. };
  31619. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  31620. var gl = this._gl;
  31621. var magFilter = gl.NEAREST;
  31622. var minFilter = gl.NEAREST;
  31623. switch (samplingMode) {
  31624. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  31625. magFilter = gl.LINEAR;
  31626. if (generateMipMaps) {
  31627. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31628. }
  31629. else {
  31630. minFilter = gl.LINEAR;
  31631. }
  31632. break;
  31633. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  31634. magFilter = gl.LINEAR;
  31635. if (generateMipMaps) {
  31636. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31637. }
  31638. else {
  31639. minFilter = gl.LINEAR;
  31640. }
  31641. break;
  31642. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  31643. magFilter = gl.NEAREST;
  31644. if (generateMipMaps) {
  31645. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31646. }
  31647. else {
  31648. minFilter = gl.NEAREST;
  31649. }
  31650. break;
  31651. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  31652. magFilter = gl.NEAREST;
  31653. if (generateMipMaps) {
  31654. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31655. }
  31656. else {
  31657. minFilter = gl.NEAREST;
  31658. }
  31659. break;
  31660. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  31661. magFilter = gl.NEAREST;
  31662. if (generateMipMaps) {
  31663. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31664. }
  31665. else {
  31666. minFilter = gl.LINEAR;
  31667. }
  31668. break;
  31669. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  31670. magFilter = gl.NEAREST;
  31671. if (generateMipMaps) {
  31672. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31673. }
  31674. else {
  31675. minFilter = gl.LINEAR;
  31676. }
  31677. break;
  31678. case Engine.TEXTURE_NEAREST_LINEAR:
  31679. magFilter = gl.NEAREST;
  31680. minFilter = gl.LINEAR;
  31681. break;
  31682. case Engine.TEXTURE_NEAREST_NEAREST:
  31683. magFilter = gl.NEAREST;
  31684. minFilter = gl.NEAREST;
  31685. break;
  31686. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  31687. magFilter = gl.LINEAR;
  31688. if (generateMipMaps) {
  31689. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31690. }
  31691. else {
  31692. minFilter = gl.NEAREST;
  31693. }
  31694. break;
  31695. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  31696. magFilter = gl.LINEAR;
  31697. if (generateMipMaps) {
  31698. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31699. }
  31700. else {
  31701. minFilter = gl.NEAREST;
  31702. }
  31703. break;
  31704. case Engine.TEXTURE_LINEAR_LINEAR:
  31705. magFilter = gl.LINEAR;
  31706. minFilter = gl.LINEAR;
  31707. break;
  31708. case Engine.TEXTURE_LINEAR_NEAREST:
  31709. magFilter = gl.LINEAR;
  31710. minFilter = gl.NEAREST;
  31711. break;
  31712. }
  31713. return {
  31714. min: minFilter,
  31715. mag: magFilter
  31716. };
  31717. };
  31718. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  31719. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  31720. var img;
  31721. var onload = function () {
  31722. loadedImages[index] = img;
  31723. loadedImages._internalCount++;
  31724. if (scene) {
  31725. scene._removePendingData(img);
  31726. }
  31727. if (loadedImages._internalCount === 6) {
  31728. onfinish(loadedImages);
  31729. }
  31730. };
  31731. var onerror = function (message, exception) {
  31732. if (scene) {
  31733. scene._removePendingData(img);
  31734. }
  31735. if (onErrorCallBack) {
  31736. onErrorCallBack(message, exception);
  31737. }
  31738. };
  31739. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  31740. if (scene) {
  31741. scene._addPendingData(img);
  31742. }
  31743. };
  31744. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  31745. if (onError === void 0) { onError = null; }
  31746. var loadedImages = [];
  31747. loadedImages._internalCount = 0;
  31748. for (var index = 0; index < 6; index++) {
  31749. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  31750. }
  31751. };
  31752. /** @hidden */
  31753. Engine.prototype._createTexture = function () {
  31754. var texture = this._gl.createTexture();
  31755. if (!texture) {
  31756. throw new Error("Unable to create texture");
  31757. }
  31758. return texture;
  31759. };
  31760. /**
  31761. * Usually called from Texture.ts.
  31762. * Passed information to create a WebGLTexture
  31763. * @param urlArg defines a value which contains one of the following:
  31764. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31765. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31766. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31767. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31768. * @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)
  31769. * @param scene needed for loading to the correct scene
  31770. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31771. * @param onLoad optional callback to be called upon successful completion
  31772. * @param onError optional callback to be called upon failure
  31773. * @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
  31774. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31775. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31776. * @param forcedExtension defines the extension to use to pick the right loader
  31777. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31778. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31779. */
  31780. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  31781. var _this = this;
  31782. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31783. if (onLoad === void 0) { onLoad = null; }
  31784. if (onError === void 0) { onError = null; }
  31785. if (buffer === void 0) { buffer = null; }
  31786. if (fallback === void 0) { fallback = null; }
  31787. if (format === void 0) { format = null; }
  31788. if (forcedExtension === void 0) { forcedExtension = null; }
  31789. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31790. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  31791. var fromData = url.substr(0, 5) === "data:";
  31792. var fromBlob = url.substr(0, 5) === "blob:";
  31793. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  31794. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_URL);
  31795. // establish the file extension, if possible
  31796. var lastDot = url.lastIndexOf('.');
  31797. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  31798. var loader = null;
  31799. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31800. var availableLoader = _a[_i];
  31801. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  31802. loader = availableLoader;
  31803. break;
  31804. }
  31805. }
  31806. if (loader) {
  31807. url = loader.transformUrl(url, this._textureFormatInUse);
  31808. }
  31809. if (scene) {
  31810. scene._addPendingData(texture);
  31811. }
  31812. texture.url = url;
  31813. texture.generateMipMaps = !noMipmap;
  31814. texture.samplingMode = samplingMode;
  31815. texture.invertY = invertY;
  31816. if (!this._doNotHandleContextLost) {
  31817. // Keep a link to the buffer only if we plan to handle context lost
  31818. texture._buffer = buffer;
  31819. }
  31820. var onLoadObserver = null;
  31821. if (onLoad && !fallback) {
  31822. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  31823. }
  31824. if (!fallback) {
  31825. this._internalTexturesCache.push(texture);
  31826. }
  31827. var onInternalError = function (message, exception) {
  31828. if (scene) {
  31829. scene._removePendingData(texture);
  31830. }
  31831. var customFallback = false;
  31832. if (loader) {
  31833. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  31834. if (fallbackUrl) {
  31835. // Add Back
  31836. customFallback = true;
  31837. excludeLoaders.push(loader);
  31838. _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");
  31839. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  31840. }
  31841. }
  31842. if (!customFallback) {
  31843. if (onLoadObserver) {
  31844. texture.onLoadedObservable.remove(onLoadObserver);
  31845. }
  31846. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  31847. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  31848. }
  31849. }
  31850. if (onError) {
  31851. onError(message || "Unknown error", exception);
  31852. }
  31853. };
  31854. // processing for non-image formats
  31855. if (loader) {
  31856. var callback = function (data) {
  31857. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  31858. if (loadFailed) {
  31859. onInternalError("TextureLoader failed to load data");
  31860. }
  31861. else {
  31862. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  31863. done();
  31864. return false;
  31865. }, samplingMode);
  31866. }
  31867. });
  31868. };
  31869. if (!buffer) {
  31870. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  31871. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  31872. });
  31873. }
  31874. else {
  31875. callback(buffer);
  31876. }
  31877. }
  31878. else {
  31879. var onload = function (img) {
  31880. if (fromBlob && !_this._doNotHandleContextLost) {
  31881. // We need to store the image if we need to rebuild the texture
  31882. // in case of a webgl context lost
  31883. texture._buffer = img;
  31884. }
  31885. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  31886. var gl = _this._gl;
  31887. var isPot = (img.width === potWidth && img.height === potHeight);
  31888. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  31889. if (isPot) {
  31890. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31891. return false;
  31892. }
  31893. var maxTextureSize = _this._caps.maxTextureSize;
  31894. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  31895. _this._prepareWorkingCanvas();
  31896. if (!_this._workingCanvas || !_this._workingContext) {
  31897. return false;
  31898. }
  31899. _this._workingCanvas.width = potWidth;
  31900. _this._workingCanvas.height = potHeight;
  31901. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  31902. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31903. texture.width = potWidth;
  31904. texture.height = potHeight;
  31905. return false;
  31906. }
  31907. else {
  31908. // Using shaders when possible to rescale because canvas.drawImage is lossy
  31909. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_TEMP);
  31910. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  31911. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31912. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31913. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  31914. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31915. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31916. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  31917. _this._releaseTexture(source_1);
  31918. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31919. continuationCallback();
  31920. });
  31921. }
  31922. return true;
  31923. }, samplingMode);
  31924. };
  31925. if (!fromData || isBase64) {
  31926. if (buffer instanceof HTMLImageElement) {
  31927. onload(buffer);
  31928. }
  31929. else {
  31930. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  31931. }
  31932. }
  31933. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  31934. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  31935. }
  31936. else {
  31937. onload(buffer);
  31938. }
  31939. }
  31940. return texture;
  31941. };
  31942. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  31943. var _this = this;
  31944. var rtt = this.createRenderTargetTexture({
  31945. width: destination.width,
  31946. height: destination.height,
  31947. }, {
  31948. generateMipMaps: false,
  31949. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31950. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31951. generateDepthBuffer: false,
  31952. generateStencilBuffer: false
  31953. });
  31954. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31955. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31956. }
  31957. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31958. _this._rescalePostProcess.onApply = function (effect) {
  31959. effect._bindTexture("textureSampler", source);
  31960. };
  31961. var hostingScene = scene;
  31962. if (!hostingScene) {
  31963. hostingScene = _this.scenes[_this.scenes.length - 1];
  31964. }
  31965. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31966. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31967. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31968. _this.unBindFramebuffer(rtt);
  31969. _this._releaseTexture(rtt);
  31970. if (onComplete) {
  31971. onComplete();
  31972. }
  31973. });
  31974. };
  31975. /**
  31976. * Update a raw texture
  31977. * @param texture defines the texture to update
  31978. * @param data defines the data to store in the texture
  31979. * @param format defines the format of the data
  31980. * @param invertY defines if data must be stored with Y axis inverted
  31981. * @param compression defines the compression used (null by default)
  31982. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31983. */
  31984. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31985. if (compression === void 0) { compression = null; }
  31986. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31987. if (!texture) {
  31988. return;
  31989. }
  31990. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31991. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31992. // babylon's internalFormat but gl's texImage2D format
  31993. var internalFormat = this._getInternalFormat(format);
  31994. var textureType = this._getWebGLTextureType(type);
  31995. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31996. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31997. if (!this._doNotHandleContextLost) {
  31998. texture._bufferView = data;
  31999. texture.format = format;
  32000. texture.type = type;
  32001. texture.invertY = invertY;
  32002. texture._compression = compression;
  32003. }
  32004. if (texture.width % 4 !== 0) {
  32005. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32006. }
  32007. if (compression && data) {
  32008. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  32009. }
  32010. else {
  32011. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  32012. }
  32013. if (texture.generateMipMaps) {
  32014. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32015. }
  32016. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32017. // this.resetTextureCache();
  32018. texture.isReady = true;
  32019. };
  32020. /**
  32021. * Creates a raw texture
  32022. * @param data defines the data to store in the texture
  32023. * @param width defines the width of the texture
  32024. * @param height defines the height of the texture
  32025. * @param format defines the format of the data
  32026. * @param generateMipMaps defines if the engine should generate the mip levels
  32027. * @param invertY defines if data must be stored with Y axis inverted
  32028. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32029. * @param compression defines the compression used (null by default)
  32030. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32031. * @returns the raw texture inside an InternalTexture
  32032. */
  32033. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  32034. if (compression === void 0) { compression = null; }
  32035. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32036. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RAW);
  32037. texture.baseWidth = width;
  32038. texture.baseHeight = height;
  32039. texture.width = width;
  32040. texture.height = height;
  32041. texture.format = format;
  32042. texture.generateMipMaps = generateMipMaps;
  32043. texture.samplingMode = samplingMode;
  32044. texture.invertY = invertY;
  32045. texture._compression = compression;
  32046. texture.type = type;
  32047. if (!this._doNotHandleContextLost) {
  32048. texture._bufferView = data;
  32049. }
  32050. this.updateRawTexture(texture, data, format, invertY, compression, type);
  32051. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32052. // Filters
  32053. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32054. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32055. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32056. if (generateMipMaps) {
  32057. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32058. }
  32059. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32060. this._internalTexturesCache.push(texture);
  32061. return texture;
  32062. };
  32063. /** @hidden */
  32064. Engine.prototype._unpackFlipY = function (value) {
  32065. if (this._unpackFlipYCached !== value) {
  32066. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  32067. if (this.enableUnpackFlipYCached) {
  32068. this._unpackFlipYCached = value;
  32069. }
  32070. }
  32071. };
  32072. /** @hidden */
  32073. Engine.prototype._getUnpackAlignement = function () {
  32074. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  32075. };
  32076. /**
  32077. * Creates a dynamic texture
  32078. * @param width defines the width of the texture
  32079. * @param height defines the height of the texture
  32080. * @param generateMipMaps defines if the engine should generate the mip levels
  32081. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32082. * @returns the dynamic texture inside an InternalTexture
  32083. */
  32084. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  32085. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_DYNAMIC);
  32086. texture.baseWidth = width;
  32087. texture.baseHeight = height;
  32088. if (generateMipMaps) {
  32089. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  32090. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  32091. }
  32092. // this.resetTextureCache();
  32093. texture.width = width;
  32094. texture.height = height;
  32095. texture.isReady = false;
  32096. texture.generateMipMaps = generateMipMaps;
  32097. texture.samplingMode = samplingMode;
  32098. this.updateTextureSamplingMode(samplingMode, texture);
  32099. this._internalTexturesCache.push(texture);
  32100. return texture;
  32101. };
  32102. /**
  32103. * Update the sampling mode of a given texture
  32104. * @param samplingMode defines the required sampling mode
  32105. * @param texture defines the texture to update
  32106. */
  32107. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  32108. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  32109. if (texture.isCube) {
  32110. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32111. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32112. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32113. }
  32114. else if (texture.is3D) {
  32115. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32116. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32117. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32118. }
  32119. else {
  32120. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32121. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32122. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32123. }
  32124. texture.samplingMode = samplingMode;
  32125. };
  32126. /**
  32127. * Update the content of a dynamic texture
  32128. * @param texture defines the texture to update
  32129. * @param canvas defines the canvas containing the source
  32130. * @param invertY defines if data must be stored with Y axis inverted
  32131. * @param premulAlpha defines if alpha is stored as premultiplied
  32132. * @param format defines the format of the data
  32133. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32134. */
  32135. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  32136. if (premulAlpha === void 0) { premulAlpha = false; }
  32137. if (forceBindTexture === void 0) { forceBindTexture = false; }
  32138. if (!texture) {
  32139. return;
  32140. }
  32141. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  32142. this._unpackFlipY(invertY);
  32143. if (premulAlpha) {
  32144. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  32145. }
  32146. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  32147. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  32148. if (texture.generateMipMaps) {
  32149. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32150. }
  32151. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32152. if (premulAlpha) {
  32153. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  32154. }
  32155. texture.isReady = true;
  32156. };
  32157. /**
  32158. * Update a video texture
  32159. * @param texture defines the texture to update
  32160. * @param video defines the video element to use
  32161. * @param invertY defines if data must be stored with Y axis inverted
  32162. */
  32163. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  32164. if (!texture || texture._isDisabled) {
  32165. return;
  32166. }
  32167. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32168. this._unpackFlipY(!invertY); // Video are upside down by default
  32169. try {
  32170. // Testing video texture support
  32171. if (this._videoTextureSupported === undefined) {
  32172. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  32173. if (this._gl.getError() !== 0) {
  32174. this._videoTextureSupported = false;
  32175. }
  32176. else {
  32177. this._videoTextureSupported = true;
  32178. }
  32179. }
  32180. // Copy video through the current working canvas if video texture is not supported
  32181. if (!this._videoTextureSupported) {
  32182. if (!texture._workingCanvas) {
  32183. texture._workingCanvas = document.createElement("canvas");
  32184. var context = texture._workingCanvas.getContext("2d");
  32185. if (!context) {
  32186. throw new Error("Unable to get 2d context");
  32187. }
  32188. texture._workingContext = context;
  32189. texture._workingCanvas.width = texture.width;
  32190. texture._workingCanvas.height = texture.height;
  32191. }
  32192. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  32193. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  32194. }
  32195. else {
  32196. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  32197. }
  32198. if (texture.generateMipMaps) {
  32199. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32200. }
  32201. if (!wasPreviouslyBound) {
  32202. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32203. }
  32204. // this.resetTextureCache();
  32205. texture.isReady = true;
  32206. }
  32207. catch (ex) {
  32208. // Something unexpected
  32209. // Let's disable the texture
  32210. texture._isDisabled = true;
  32211. }
  32212. };
  32213. /**
  32214. * Updates a depth texture Comparison Mode and Function.
  32215. * If the comparison Function is equal to 0, the mode will be set to none.
  32216. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32217. * @param texture The texture to set the comparison function for
  32218. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32219. */
  32220. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  32221. if (this.webGLVersion === 1) {
  32222. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("WebGL 1 does not support texture comparison.");
  32223. return;
  32224. }
  32225. var gl = this._gl;
  32226. if (texture.isCube) {
  32227. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32228. if (comparisonFunction === 0) {
  32229. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32230. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32231. }
  32232. else {
  32233. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32234. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32235. }
  32236. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32237. }
  32238. else {
  32239. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32240. if (comparisonFunction === 0) {
  32241. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32242. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32243. }
  32244. else {
  32245. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32246. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32247. }
  32248. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32249. }
  32250. texture._comparisonFunction = comparisonFunction;
  32251. };
  32252. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  32253. var width = size.width || size;
  32254. var height = size.height || size;
  32255. internalTexture.baseWidth = width;
  32256. internalTexture.baseHeight = height;
  32257. internalTexture.width = width;
  32258. internalTexture.height = height;
  32259. internalTexture.isReady = true;
  32260. internalTexture.samples = 1;
  32261. internalTexture.generateMipMaps = false;
  32262. internalTexture._generateDepthBuffer = true;
  32263. internalTexture._generateStencilBuffer = generateStencil;
  32264. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32265. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32266. internalTexture._comparisonFunction = comparisonFunction;
  32267. var gl = this._gl;
  32268. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32269. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  32270. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  32271. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  32272. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32273. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32274. if (comparisonFunction === 0) {
  32275. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32276. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32277. }
  32278. else {
  32279. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32280. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32281. }
  32282. };
  32283. /**
  32284. * Creates a depth stencil texture.
  32285. * This is only available in WebGL 2 or with the depth texture extension available.
  32286. * @param size The size of face edge in the texture.
  32287. * @param options The options defining the texture.
  32288. * @returns The texture
  32289. */
  32290. Engine.prototype.createDepthStencilTexture = function (size, options) {
  32291. if (options.isCube) {
  32292. var width = size.width || size;
  32293. return this._createDepthStencilCubeTexture(width, options);
  32294. }
  32295. else {
  32296. return this._createDepthStencilTexture(size, options);
  32297. }
  32298. };
  32299. /**
  32300. * Creates a depth stencil texture.
  32301. * This is only available in WebGL 2 or with the depth texture extension available.
  32302. * @param size The size of face edge in the texture.
  32303. * @param options The options defining the texture.
  32304. * @returns The texture
  32305. */
  32306. Engine.prototype._createDepthStencilTexture = function (size, options) {
  32307. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  32308. if (!this._caps.depthTextureExtension) {
  32309. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  32310. return internalTexture;
  32311. }
  32312. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32313. var gl = this._gl;
  32314. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  32315. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32316. if (this.webGLVersion > 1) {
  32317. if (internalOptions.generateStencil) {
  32318. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32319. }
  32320. else {
  32321. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32322. }
  32323. }
  32324. else {
  32325. if (internalOptions.generateStencil) {
  32326. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32327. }
  32328. else {
  32329. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32330. }
  32331. }
  32332. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32333. return internalTexture;
  32334. };
  32335. /**
  32336. * Creates a depth stencil cube texture.
  32337. * This is only available in WebGL 2.
  32338. * @param size The size of face edge in the cube texture.
  32339. * @param options The options defining the cube texture.
  32340. * @returns The cube texture
  32341. */
  32342. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  32343. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_UNKNOWN);
  32344. internalTexture.isCube = true;
  32345. if (this.webGLVersion === 1) {
  32346. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  32347. return internalTexture;
  32348. }
  32349. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32350. var gl = this._gl;
  32351. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  32352. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32353. // Create the depth/stencil buffer
  32354. for (var face = 0; face < 6; face++) {
  32355. if (internalOptions.generateStencil) {
  32356. 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);
  32357. }
  32358. else {
  32359. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32360. }
  32361. }
  32362. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32363. return internalTexture;
  32364. };
  32365. /**
  32366. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32367. * @param renderTarget The render target to set the frame buffer for
  32368. */
  32369. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  32370. // Create the framebuffer
  32371. var internalTexture = renderTarget.getInternalTexture();
  32372. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  32373. return;
  32374. }
  32375. var gl = this._gl;
  32376. var depthStencilTexture = renderTarget.depthStencilTexture;
  32377. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  32378. if (depthStencilTexture.isCube) {
  32379. if (depthStencilTexture._generateStencilBuffer) {
  32380. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32381. }
  32382. else {
  32383. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32384. }
  32385. }
  32386. else {
  32387. if (depthStencilTexture._generateStencilBuffer) {
  32388. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32389. }
  32390. else {
  32391. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32392. }
  32393. }
  32394. this.bindUnboundFramebuffer(null);
  32395. };
  32396. /**
  32397. * Creates a new render target texture
  32398. * @param size defines the size of the texture
  32399. * @param options defines the options used to create the texture
  32400. * @returns a new render target texture stored in an InternalTexture
  32401. */
  32402. Engine.prototype.createRenderTargetTexture = function (size, options) {
  32403. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_16__["RenderTargetCreationOptions"]();
  32404. if (options !== undefined && typeof options === "object") {
  32405. fullOptions.generateMipMaps = options.generateMipMaps;
  32406. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32407. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  32408. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  32409. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  32410. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  32411. }
  32412. else {
  32413. fullOptions.generateMipMaps = options;
  32414. fullOptions.generateDepthBuffer = true;
  32415. fullOptions.generateStencilBuffer = false;
  32416. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32417. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32418. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  32419. }
  32420. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32421. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32422. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32423. }
  32424. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32425. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32426. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32427. }
  32428. var gl = this._gl;
  32429. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32430. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32431. var width = size.width || size;
  32432. var height = size.height || size;
  32433. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  32434. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32435. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32436. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32437. }
  32438. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32439. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32440. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32441. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32442. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  32443. // Create the framebuffer
  32444. var currentFrameBuffer = this._currentFramebuffer;
  32445. var framebuffer = gl.createFramebuffer();
  32446. this.bindUnboundFramebuffer(framebuffer);
  32447. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32448. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  32449. if (fullOptions.generateMipMaps) {
  32450. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32451. }
  32452. // Unbind
  32453. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32454. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32455. this.bindUnboundFramebuffer(currentFrameBuffer);
  32456. texture._framebuffer = framebuffer;
  32457. texture.baseWidth = width;
  32458. texture.baseHeight = height;
  32459. texture.width = width;
  32460. texture.height = height;
  32461. texture.isReady = true;
  32462. texture.samples = 1;
  32463. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  32464. texture.samplingMode = fullOptions.samplingMode;
  32465. texture.type = fullOptions.type;
  32466. texture.format = fullOptions.format;
  32467. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32468. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  32469. // this.resetTextureCache();
  32470. this._internalTexturesCache.push(texture);
  32471. return texture;
  32472. };
  32473. /**
  32474. * Create a multi render target texture
  32475. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  32476. * @param size defines the size of the texture
  32477. * @param options defines the creation options
  32478. * @returns the cube texture as an InternalTexture
  32479. */
  32480. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  32481. var generateMipMaps = false;
  32482. var generateDepthBuffer = true;
  32483. var generateStencilBuffer = false;
  32484. var generateDepthTexture = false;
  32485. var textureCount = 1;
  32486. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  32487. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32488. var types = new Array();
  32489. var samplingModes = new Array();
  32490. if (options !== undefined) {
  32491. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  32492. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32493. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  32494. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  32495. textureCount = options.textureCount || 1;
  32496. if (options.types) {
  32497. types = options.types;
  32498. }
  32499. if (options.samplingModes) {
  32500. samplingModes = options.samplingModes;
  32501. }
  32502. }
  32503. var gl = this._gl;
  32504. // Create the framebuffer
  32505. var framebuffer = gl.createFramebuffer();
  32506. this.bindUnboundFramebuffer(framebuffer);
  32507. var width = size.width || size;
  32508. var height = size.height || size;
  32509. var textures = [];
  32510. var attachments = [];
  32511. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  32512. for (var i = 0; i < textureCount; i++) {
  32513. var samplingMode = samplingModes[i] || defaultSamplingMode;
  32514. var type = types[i] || defaultType;
  32515. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32516. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32517. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32518. }
  32519. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32520. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32521. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32522. }
  32523. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32524. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32525. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32526. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32527. }
  32528. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32529. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32530. textures.push(texture);
  32531. attachments.push(attachment);
  32532. gl.activeTexture(gl["TEXTURE" + i]);
  32533. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  32534. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32535. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32536. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32537. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32538. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32539. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32540. if (generateMipMaps) {
  32541. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32542. }
  32543. // Unbind
  32544. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32545. texture._framebuffer = framebuffer;
  32546. texture._depthStencilBuffer = depthStencilBuffer;
  32547. texture.baseWidth = width;
  32548. texture.baseHeight = height;
  32549. texture.width = width;
  32550. texture.height = height;
  32551. texture.isReady = true;
  32552. texture.samples = 1;
  32553. texture.generateMipMaps = generateMipMaps;
  32554. texture.samplingMode = samplingMode;
  32555. texture.type = type;
  32556. texture._generateDepthBuffer = generateDepthBuffer;
  32557. texture._generateStencilBuffer = generateStencilBuffer;
  32558. texture._attachments = attachments;
  32559. this._internalTexturesCache.push(texture);
  32560. }
  32561. if (generateDepthTexture && this._caps.depthTextureExtension) {
  32562. // Depth texture
  32563. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32564. gl.activeTexture(gl.TEXTURE0);
  32565. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  32566. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32567. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32568. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32569. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32570. 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);
  32571. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  32572. depthTexture._framebuffer = framebuffer;
  32573. depthTexture.baseWidth = width;
  32574. depthTexture.baseHeight = height;
  32575. depthTexture.width = width;
  32576. depthTexture.height = height;
  32577. depthTexture.isReady = true;
  32578. depthTexture.samples = 1;
  32579. depthTexture.generateMipMaps = generateMipMaps;
  32580. depthTexture.samplingMode = gl.NEAREST;
  32581. depthTexture._generateDepthBuffer = generateDepthBuffer;
  32582. depthTexture._generateStencilBuffer = generateStencilBuffer;
  32583. textures.push(depthTexture);
  32584. this._internalTexturesCache.push(depthTexture);
  32585. }
  32586. gl.drawBuffers(attachments);
  32587. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32588. this.bindUnboundFramebuffer(null);
  32589. this.resetTextureCache();
  32590. return textures;
  32591. };
  32592. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  32593. if (samples === void 0) { samples = 1; }
  32594. var depthStencilBuffer = null;
  32595. var gl = this._gl;
  32596. // Create the depth/stencil buffer
  32597. if (generateStencilBuffer) {
  32598. depthStencilBuffer = gl.createRenderbuffer();
  32599. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32600. if (samples > 1) {
  32601. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  32602. }
  32603. else {
  32604. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  32605. }
  32606. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32607. }
  32608. else if (generateDepthBuffer) {
  32609. depthStencilBuffer = gl.createRenderbuffer();
  32610. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32611. if (samples > 1) {
  32612. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  32613. }
  32614. else {
  32615. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  32616. }
  32617. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32618. }
  32619. return depthStencilBuffer;
  32620. };
  32621. /**
  32622. * Updates the sample count of a render target texture
  32623. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32624. * @param texture defines the texture to update
  32625. * @param samples defines the sample count to set
  32626. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32627. */
  32628. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  32629. if (this.webGLVersion < 2 || !texture) {
  32630. return 1;
  32631. }
  32632. if (texture.samples === samples) {
  32633. return samples;
  32634. }
  32635. var gl = this._gl;
  32636. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32637. // Dispose previous render buffers
  32638. if (texture._depthStencilBuffer) {
  32639. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32640. texture._depthStencilBuffer = null;
  32641. }
  32642. if (texture._MSAAFramebuffer) {
  32643. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32644. texture._MSAAFramebuffer = null;
  32645. }
  32646. if (texture._MSAARenderBuffer) {
  32647. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32648. texture._MSAARenderBuffer = null;
  32649. }
  32650. if (samples > 1) {
  32651. var framebuffer = gl.createFramebuffer();
  32652. if (!framebuffer) {
  32653. throw new Error("Unable to create multi sampled framebuffer");
  32654. }
  32655. texture._MSAAFramebuffer = framebuffer;
  32656. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  32657. var colorRenderbuffer = gl.createRenderbuffer();
  32658. if (!colorRenderbuffer) {
  32659. throw new Error("Unable to create multi sampled framebuffer");
  32660. }
  32661. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32662. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32663. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  32664. texture._MSAARenderBuffer = colorRenderbuffer;
  32665. }
  32666. else {
  32667. this.bindUnboundFramebuffer(texture._framebuffer);
  32668. }
  32669. texture.samples = samples;
  32670. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  32671. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32672. this.bindUnboundFramebuffer(null);
  32673. return samples;
  32674. };
  32675. /**
  32676. * Update the sample count for a given multiple render target texture
  32677. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32678. * @param textures defines the textures to update
  32679. * @param samples defines the sample count to set
  32680. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32681. */
  32682. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  32683. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  32684. return 1;
  32685. }
  32686. if (textures[0].samples === samples) {
  32687. return samples;
  32688. }
  32689. var gl = this._gl;
  32690. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32691. // Dispose previous render buffers
  32692. if (textures[0]._depthStencilBuffer) {
  32693. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  32694. textures[0]._depthStencilBuffer = null;
  32695. }
  32696. if (textures[0]._MSAAFramebuffer) {
  32697. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  32698. textures[0]._MSAAFramebuffer = null;
  32699. }
  32700. for (var i = 0; i < textures.length; i++) {
  32701. if (textures[i]._MSAARenderBuffer) {
  32702. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  32703. textures[i]._MSAARenderBuffer = null;
  32704. }
  32705. }
  32706. if (samples > 1) {
  32707. var framebuffer = gl.createFramebuffer();
  32708. if (!framebuffer) {
  32709. throw new Error("Unable to create multi sampled framebuffer");
  32710. }
  32711. this.bindUnboundFramebuffer(framebuffer);
  32712. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  32713. var attachments = [];
  32714. for (var i = 0; i < textures.length; i++) {
  32715. var texture = textures[i];
  32716. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32717. var colorRenderbuffer = gl.createRenderbuffer();
  32718. if (!colorRenderbuffer) {
  32719. throw new Error("Unable to create multi sampled framebuffer");
  32720. }
  32721. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32722. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32723. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  32724. texture._MSAAFramebuffer = framebuffer;
  32725. texture._MSAARenderBuffer = colorRenderbuffer;
  32726. texture.samples = samples;
  32727. texture._depthStencilBuffer = depthStencilBuffer;
  32728. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32729. attachments.push(attachment);
  32730. }
  32731. gl.drawBuffers(attachments);
  32732. }
  32733. else {
  32734. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  32735. }
  32736. this.bindUnboundFramebuffer(null);
  32737. return samples;
  32738. };
  32739. /** @hidden */
  32740. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  32741. if (faceIndex === void 0) { faceIndex = 0; }
  32742. if (lod === void 0) { lod = 0; }
  32743. var gl = this._gl;
  32744. var target = gl.TEXTURE_2D;
  32745. if (texture.isCube) {
  32746. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32747. }
  32748. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  32749. };
  32750. /** @hidden */
  32751. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  32752. if (faceIndex === void 0) { faceIndex = 0; }
  32753. if (lod === void 0) { lod = 0; }
  32754. var gl = this._gl;
  32755. var textureType = this._getWebGLTextureType(texture.type);
  32756. var format = this._getInternalFormat(texture.format);
  32757. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32758. this._unpackFlipY(texture.invertY);
  32759. var target = gl.TEXTURE_2D;
  32760. if (texture.isCube) {
  32761. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32762. }
  32763. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  32764. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  32765. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  32766. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  32767. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  32768. };
  32769. /** @hidden */
  32770. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  32771. if (faceIndex === void 0) { faceIndex = 0; }
  32772. if (lod === void 0) { lod = 0; }
  32773. var gl = this._gl;
  32774. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32775. this._bindTextureDirectly(bindTarget, texture, true);
  32776. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  32777. this._bindTextureDirectly(bindTarget, null, true);
  32778. };
  32779. /** @hidden */
  32780. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  32781. if (faceIndex === void 0) { faceIndex = 0; }
  32782. if (lod === void 0) { lod = 0; }
  32783. var gl = this._gl;
  32784. var textureType = this._getWebGLTextureType(texture.type);
  32785. var format = this._getInternalFormat(texture.format);
  32786. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32787. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32788. this._bindTextureDirectly(bindTarget, texture, true);
  32789. this._unpackFlipY(texture.invertY);
  32790. var target = gl.TEXTURE_2D;
  32791. if (texture.isCube) {
  32792. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32793. }
  32794. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  32795. this._bindTextureDirectly(bindTarget, null, true);
  32796. };
  32797. /**
  32798. * Creates a new render target cube texture
  32799. * @param size defines the size of the texture
  32800. * @param options defines the options used to create the texture
  32801. * @returns a new render target cube texture stored in an InternalTexture
  32802. */
  32803. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  32804. 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);
  32805. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  32806. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32807. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32808. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32809. }
  32810. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32811. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32812. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32813. }
  32814. var gl = this._gl;
  32815. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32816. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32817. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  32818. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32819. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32820. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  32821. }
  32822. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32823. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32824. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32825. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32826. for (var face = 0; face < 6; face++) {
  32827. 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);
  32828. }
  32829. // Create the framebuffer
  32830. var framebuffer = gl.createFramebuffer();
  32831. this.bindUnboundFramebuffer(framebuffer);
  32832. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  32833. // MipMaps
  32834. if (fullOptions.generateMipMaps) {
  32835. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32836. }
  32837. // Unbind
  32838. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32839. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32840. this.bindUnboundFramebuffer(null);
  32841. texture._framebuffer = framebuffer;
  32842. texture.width = size;
  32843. texture.height = size;
  32844. texture.isReady = true;
  32845. texture.isCube = true;
  32846. texture.samples = 1;
  32847. texture.generateMipMaps = fullOptions.generateMipMaps;
  32848. texture.samplingMode = fullOptions.samplingMode;
  32849. texture.type = fullOptions.type;
  32850. texture.format = fullOptions.format;
  32851. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32852. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  32853. this._internalTexturesCache.push(texture);
  32854. return texture;
  32855. };
  32856. /**
  32857. * Creates a cube texture
  32858. * @param rootUrl defines the url where the files to load is located
  32859. * @param scene defines the current scene
  32860. * @param files defines the list of files to load (1 per face)
  32861. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  32862. * @param onLoad defines an optional callback raised when the texture is loaded
  32863. * @param onError defines an optional callback raised if there is an issue to load the texture
  32864. * @param format defines the format of the data
  32865. * @param forcedExtension defines the extension to use to pick the right loader
  32866. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  32867. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  32868. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  32869. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  32870. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  32871. * @returns the cube texture as an InternalTexture
  32872. */
  32873. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  32874. var _this = this;
  32875. if (onLoad === void 0) { onLoad = null; }
  32876. if (onError === void 0) { onError = null; }
  32877. if (forcedExtension === void 0) { forcedExtension = null; }
  32878. if (createPolynomials === void 0) { createPolynomials = false; }
  32879. if (lodScale === void 0) { lodScale = 0; }
  32880. if (lodOffset === void 0) { lodOffset = 0; }
  32881. if (fallback === void 0) { fallback = null; }
  32882. if (excludeLoaders === void 0) { excludeLoaders = []; }
  32883. var gl = this._gl;
  32884. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_CUBE);
  32885. texture.isCube = true;
  32886. texture.url = rootUrl;
  32887. texture.generateMipMaps = !noMipmap;
  32888. texture._lodGenerationScale = lodScale;
  32889. texture._lodGenerationOffset = lodOffset;
  32890. if (!this._doNotHandleContextLost) {
  32891. texture._extension = forcedExtension;
  32892. texture._files = files;
  32893. }
  32894. var lastDot = rootUrl.lastIndexOf('.');
  32895. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  32896. var loader = null;
  32897. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  32898. var availableLoader = _a[_i];
  32899. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  32900. loader = availableLoader;
  32901. break;
  32902. }
  32903. }
  32904. var onInternalError = function (request, exception) {
  32905. if (loader) {
  32906. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  32907. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  32908. if (fallbackUrl) {
  32909. excludeLoaders.push(loader);
  32910. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  32911. return;
  32912. }
  32913. }
  32914. if (onError && request) {
  32915. onError(request.status + " " + request.statusText, exception);
  32916. }
  32917. };
  32918. if (loader) {
  32919. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  32920. var onloaddata = function (data) {
  32921. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32922. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  32923. };
  32924. if (files && files.length === 6) {
  32925. if (loader.supportCascades) {
  32926. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  32927. }
  32928. else {
  32929. if (onError) {
  32930. onError("Textures type does not support cascades.");
  32931. }
  32932. else {
  32933. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Texture loader does not support cascades.");
  32934. }
  32935. }
  32936. }
  32937. else {
  32938. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  32939. }
  32940. }
  32941. else {
  32942. if (!files) {
  32943. throw new Error("Cannot load cubemap because files were not defined");
  32944. }
  32945. this._cascadeLoadImgs(scene, function (imgs) {
  32946. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  32947. var height = width;
  32948. _this._prepareWorkingCanvas();
  32949. if (!_this._workingCanvas || !_this._workingContext) {
  32950. return;
  32951. }
  32952. _this._workingCanvas.width = width;
  32953. _this._workingCanvas.height = height;
  32954. var faces = [
  32955. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32956. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32957. ];
  32958. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32959. _this._unpackFlipY(false);
  32960. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32961. for (var index = 0; index < faces.length; index++) {
  32962. if (imgs[index].width !== width || imgs[index].height !== height) {
  32963. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32964. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32965. }
  32966. else {
  32967. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, imgs[index]);
  32968. }
  32969. }
  32970. if (!noMipmap) {
  32971. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32972. }
  32973. _this._setCubeMapTextureParams(!noMipmap);
  32974. texture.width = width;
  32975. texture.height = height;
  32976. texture.isReady = true;
  32977. if (format) {
  32978. texture.format = format;
  32979. }
  32980. texture.onLoadedObservable.notifyObservers(texture);
  32981. texture.onLoadedObservable.clear();
  32982. if (onLoad) {
  32983. onLoad();
  32984. }
  32985. }, files, onError);
  32986. }
  32987. this._internalTexturesCache.push(texture);
  32988. return texture;
  32989. };
  32990. /**
  32991. * @hidden
  32992. */
  32993. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32994. var gl = this._gl;
  32995. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32996. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32997. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32998. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32999. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33000. // this.resetTextureCache();
  33001. };
  33002. /**
  33003. * Update a raw cube texture
  33004. * @param texture defines the texture to udpdate
  33005. * @param data defines the data to store
  33006. * @param format defines the data format
  33007. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  33008. * @param invertY defines if data must be stored with Y axis inverted
  33009. * @param compression defines the compression used (null by default)
  33010. * @param level defines which level of the texture to update
  33011. */
  33012. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  33013. if (compression === void 0) { compression = null; }
  33014. if (level === void 0) { level = 0; }
  33015. texture._bufferViewArray = data;
  33016. texture.format = format;
  33017. texture.type = type;
  33018. texture.invertY = invertY;
  33019. texture._compression = compression;
  33020. var gl = this._gl;
  33021. var textureType = this._getWebGLTextureType(type);
  33022. var internalFormat = this._getInternalFormat(format);
  33023. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  33024. var needConversion = false;
  33025. if (internalFormat === gl.RGB) {
  33026. internalFormat = gl.RGBA;
  33027. needConversion = true;
  33028. }
  33029. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  33030. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33031. if (texture.width % 4 !== 0) {
  33032. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  33033. }
  33034. // Data are known to be in +X +Y +Z -X -Y -Z
  33035. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  33036. var faceData = data[faceIndex];
  33037. if (compression) {
  33038. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  33039. }
  33040. else {
  33041. if (needConversion) {
  33042. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  33043. }
  33044. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  33045. }
  33046. }
  33047. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  33048. if (isPot && texture.generateMipMaps && level === 0) {
  33049. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  33050. }
  33051. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33052. // this.resetTextureCache();
  33053. texture.isReady = true;
  33054. };
  33055. /**
  33056. * Creates a new raw cube texture
  33057. * @param data defines the array of data to use to create each face
  33058. * @param size defines the size of the textures
  33059. * @param format defines the format of the data
  33060. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33061. * @param generateMipMaps defines if the engine should generate the mip levels
  33062. * @param invertY defines if data must be stored with Y axis inverted
  33063. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33064. * @param compression defines the compression used (null by default)
  33065. * @returns the cube texture as an InternalTexture
  33066. */
  33067. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  33068. if (compression === void 0) { compression = null; }
  33069. var gl = this._gl;
  33070. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_CUBERAW);
  33071. texture.isCube = true;
  33072. texture.format = format;
  33073. texture.type = type;
  33074. if (!this._doNotHandleContextLost) {
  33075. texture._bufferViewArray = data;
  33076. }
  33077. var textureType = this._getWebGLTextureType(type);
  33078. var internalFormat = this._getInternalFormat(format);
  33079. if (internalFormat === gl.RGB) {
  33080. internalFormat = gl.RGBA;
  33081. }
  33082. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  33083. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  33084. generateMipMaps = false;
  33085. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  33086. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  33087. }
  33088. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  33089. generateMipMaps = false;
  33090. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  33091. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  33092. }
  33093. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  33094. generateMipMaps = false;
  33095. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  33096. }
  33097. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  33098. generateMipMaps = false;
  33099. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  33100. }
  33101. var width = size;
  33102. var height = width;
  33103. texture.width = width;
  33104. texture.height = height;
  33105. // Double check on POT to generate Mips.
  33106. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  33107. if (!isPot) {
  33108. generateMipMaps = false;
  33109. }
  33110. // Upload data if needed. The texture won't be ready until then.
  33111. if (data) {
  33112. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  33113. }
  33114. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  33115. // Filters
  33116. if (data && generateMipMaps) {
  33117. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  33118. }
  33119. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  33120. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  33121. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  33122. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  33123. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  33124. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33125. texture.generateMipMaps = generateMipMaps;
  33126. return texture;
  33127. };
  33128. /**
  33129. * Creates a new raw cube texture from a specified url
  33130. * @param url defines the url where the data is located
  33131. * @param scene defines the current scene
  33132. * @param size defines the size of the textures
  33133. * @param format defines the format of the data
  33134. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33135. * @param noMipmap defines if the engine should avoid generating the mip levels
  33136. * @param callback defines a callback used to extract texture data from loaded data
  33137. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  33138. * @param onLoad defines a callback called when texture is loaded
  33139. * @param onError defines a callback called if there is an error
  33140. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33141. * @param invertY defines if data must be stored with Y axis inverted
  33142. * @returns the cube texture as an InternalTexture
  33143. */
  33144. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  33145. var _this = this;
  33146. if (onLoad === void 0) { onLoad = null; }
  33147. if (onError === void 0) { onError = null; }
  33148. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33149. if (invertY === void 0) { invertY = false; }
  33150. var gl = this._gl;
  33151. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  33152. scene._addPendingData(texture);
  33153. texture.url = url;
  33154. this._internalTexturesCache.push(texture);
  33155. var onerror = function (request, exception) {
  33156. scene._removePendingData(texture);
  33157. if (onError && request) {
  33158. onError(request.status + " " + request.statusText, exception);
  33159. }
  33160. };
  33161. var internalCallback = function (data) {
  33162. var width = texture.width;
  33163. var faceDataArrays = callback(data);
  33164. if (!faceDataArrays) {
  33165. return;
  33166. }
  33167. if (mipmapGenerator) {
  33168. var textureType = _this._getWebGLTextureType(type);
  33169. var internalFormat = _this._getInternalFormat(format);
  33170. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  33171. var needConversion = false;
  33172. if (internalFormat === gl.RGB) {
  33173. internalFormat = gl.RGBA;
  33174. needConversion = true;
  33175. }
  33176. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  33177. _this._unpackFlipY(false);
  33178. var mipData = mipmapGenerator(faceDataArrays);
  33179. for (var level = 0; level < mipData.length; level++) {
  33180. var mipSize = width >> level;
  33181. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  33182. var mipFaceData = mipData[level][faceIndex];
  33183. if (needConversion) {
  33184. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  33185. }
  33186. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  33187. }
  33188. }
  33189. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33190. }
  33191. else {
  33192. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  33193. }
  33194. texture.isReady = true;
  33195. // this.resetTextureCache();
  33196. scene._removePendingData(texture);
  33197. if (onLoad) {
  33198. onLoad();
  33199. }
  33200. };
  33201. this._loadFile(url, function (data) {
  33202. internalCallback(data);
  33203. }, undefined, scene.offlineProvider, true, onerror);
  33204. return texture;
  33205. };
  33206. /**
  33207. * Update a raw 3D texture
  33208. * @param texture defines the texture to update
  33209. * @param data defines the data to store
  33210. * @param format defines the data format
  33211. * @param invertY defines if data must be stored with Y axis inverted
  33212. * @param compression defines the used compression (can be null)
  33213. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  33214. */
  33215. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  33216. if (compression === void 0) { compression = null; }
  33217. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33218. var internalType = this._getWebGLTextureType(textureType);
  33219. var internalFormat = this._getInternalFormat(format);
  33220. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  33221. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  33222. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33223. if (!this._doNotHandleContextLost) {
  33224. texture._bufferView = data;
  33225. texture.format = format;
  33226. texture.invertY = invertY;
  33227. texture._compression = compression;
  33228. }
  33229. if (texture.width % 4 !== 0) {
  33230. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  33231. }
  33232. if (compression && data) {
  33233. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  33234. }
  33235. else {
  33236. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  33237. }
  33238. if (texture.generateMipMaps) {
  33239. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  33240. }
  33241. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33242. // this.resetTextureCache();
  33243. texture.isReady = true;
  33244. };
  33245. /**
  33246. * Creates a new raw 3D texture
  33247. * @param data defines the data used to create the texture
  33248. * @param width defines the width of the texture
  33249. * @param height defines the height of the texture
  33250. * @param depth defines the depth of the texture
  33251. * @param format defines the format of the texture
  33252. * @param generateMipMaps defines if the engine must generate mip levels
  33253. * @param invertY defines if data must be stored with Y axis inverted
  33254. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33255. * @param compression defines the compressed used (can be null)
  33256. * @param textureType defines the compressed used (can be null)
  33257. * @returns a new raw 3D texture (stored in an InternalTexture)
  33258. */
  33259. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  33260. if (compression === void 0) { compression = null; }
  33261. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33262. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RAW3D);
  33263. texture.baseWidth = width;
  33264. texture.baseHeight = height;
  33265. texture.baseDepth = depth;
  33266. texture.width = width;
  33267. texture.height = height;
  33268. texture.depth = depth;
  33269. texture.format = format;
  33270. texture.type = textureType;
  33271. texture.generateMipMaps = generateMipMaps;
  33272. texture.samplingMode = samplingMode;
  33273. texture.is3D = true;
  33274. if (!this._doNotHandleContextLost) {
  33275. texture._bufferView = data;
  33276. }
  33277. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  33278. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  33279. // Filters
  33280. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  33281. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  33282. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  33283. if (generateMipMaps) {
  33284. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  33285. }
  33286. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33287. this._internalTexturesCache.push(texture);
  33288. return texture;
  33289. };
  33290. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  33291. var gl = this._gl;
  33292. if (!gl) {
  33293. return;
  33294. }
  33295. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  33296. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  33297. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  33298. if (!noMipmap && !isCompressed) {
  33299. gl.generateMipmap(gl.TEXTURE_2D);
  33300. }
  33301. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  33302. // this.resetTextureCache();
  33303. if (scene) {
  33304. scene._removePendingData(texture);
  33305. }
  33306. texture.onLoadedObservable.notifyObservers(texture);
  33307. texture.onLoadedObservable.clear();
  33308. };
  33309. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  33310. var _this = this;
  33311. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33312. var maxTextureSize = this.getCaps().maxTextureSize;
  33313. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  33314. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  33315. var gl = this._gl;
  33316. if (!gl) {
  33317. return;
  33318. }
  33319. if (!texture._webGLTexture) {
  33320. // this.resetTextureCache();
  33321. if (scene) {
  33322. scene._removePendingData(texture);
  33323. }
  33324. return;
  33325. }
  33326. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  33327. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33328. texture.baseWidth = width;
  33329. texture.baseHeight = height;
  33330. texture.width = potWidth;
  33331. texture.height = potHeight;
  33332. texture.isReady = true;
  33333. if (processFunction(potWidth, potHeight, function () {
  33334. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33335. })) {
  33336. // Returning as texture needs extra async steps
  33337. return;
  33338. }
  33339. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33340. };
  33341. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  33342. // Create new RGBA data container.
  33343. var rgbaData;
  33344. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  33345. rgbaData = new Float32Array(width * height * 4);
  33346. }
  33347. else {
  33348. rgbaData = new Uint32Array(width * height * 4);
  33349. }
  33350. // Convert each pixel.
  33351. for (var x = 0; x < width; x++) {
  33352. for (var y = 0; y < height; y++) {
  33353. var index = (y * width + x) * 3;
  33354. var newIndex = (y * width + x) * 4;
  33355. // Map Old Value to new value.
  33356. rgbaData[newIndex + 0] = rgbData[index + 0];
  33357. rgbaData[newIndex + 1] = rgbData[index + 1];
  33358. rgbaData[newIndex + 2] = rgbData[index + 2];
  33359. // Add fully opaque alpha channel.
  33360. rgbaData[newIndex + 3] = 1;
  33361. }
  33362. }
  33363. return rgbaData;
  33364. };
  33365. /** @hidden */
  33366. Engine.prototype._releaseFramebufferObjects = function (texture) {
  33367. var gl = this._gl;
  33368. if (texture._framebuffer) {
  33369. gl.deleteFramebuffer(texture._framebuffer);
  33370. texture._framebuffer = null;
  33371. }
  33372. if (texture._depthStencilBuffer) {
  33373. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  33374. texture._depthStencilBuffer = null;
  33375. }
  33376. if (texture._MSAAFramebuffer) {
  33377. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  33378. texture._MSAAFramebuffer = null;
  33379. }
  33380. if (texture._MSAARenderBuffer) {
  33381. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  33382. texture._MSAARenderBuffer = null;
  33383. }
  33384. };
  33385. /** @hidden */
  33386. Engine.prototype._releaseTexture = function (texture) {
  33387. var gl = this._gl;
  33388. this._releaseFramebufferObjects(texture);
  33389. gl.deleteTexture(texture._webGLTexture);
  33390. // Unbind channels
  33391. this.unbindAllTextures();
  33392. var index = this._internalTexturesCache.indexOf(texture);
  33393. if (index !== -1) {
  33394. this._internalTexturesCache.splice(index, 1);
  33395. }
  33396. // Integrated fixed lod samplers.
  33397. if (texture._lodTextureHigh) {
  33398. texture._lodTextureHigh.dispose();
  33399. }
  33400. if (texture._lodTextureMid) {
  33401. texture._lodTextureMid.dispose();
  33402. }
  33403. if (texture._lodTextureLow) {
  33404. texture._lodTextureLow.dispose();
  33405. }
  33406. // Set output texture of post process to null if the texture has been released/disposed
  33407. this.scenes.forEach(function (scene) {
  33408. scene.postProcesses.forEach(function (postProcess) {
  33409. if (postProcess._outputTexture == texture) {
  33410. postProcess._outputTexture = null;
  33411. }
  33412. });
  33413. scene.cameras.forEach(function (camera) {
  33414. camera._postProcesses.forEach(function (postProcess) {
  33415. if (postProcess) {
  33416. if (postProcess._outputTexture == texture) {
  33417. postProcess._outputTexture = null;
  33418. }
  33419. }
  33420. });
  33421. });
  33422. });
  33423. };
  33424. Engine.prototype.setProgram = function (program) {
  33425. if (this._currentProgram !== program) {
  33426. this._gl.useProgram(program);
  33427. this._currentProgram = program;
  33428. }
  33429. };
  33430. /**
  33431. * Binds an effect to the webGL context
  33432. * @param effect defines the effect to bind
  33433. */
  33434. Engine.prototype.bindSamplers = function (effect) {
  33435. this.setProgram(effect.getProgram());
  33436. var samplers = effect.getSamplers();
  33437. for (var index = 0; index < samplers.length; index++) {
  33438. var uniform = effect.getUniform(samplers[index]);
  33439. if (uniform) {
  33440. this._boundUniforms[index] = uniform;
  33441. }
  33442. }
  33443. this._currentEffect = null;
  33444. };
  33445. Engine.prototype._activateCurrentTexture = function () {
  33446. if (this._currentTextureChannel !== this._activeChannel) {
  33447. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  33448. this._currentTextureChannel = this._activeChannel;
  33449. }
  33450. };
  33451. /** @hidden */
  33452. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  33453. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  33454. if (force === void 0) { force = false; }
  33455. var wasPreviouslyBound = false;
  33456. var isTextureForRendering = texture && texture._associatedChannel > -1;
  33457. if (forTextureDataUpdate && isTextureForRendering) {
  33458. this._activeChannel = texture._associatedChannel;
  33459. }
  33460. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  33461. if (currentTextureBound !== texture || force) {
  33462. this._activateCurrentTexture();
  33463. if (texture && texture.isMultiview) {
  33464. this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);
  33465. }
  33466. else {
  33467. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  33468. }
  33469. this._boundTexturesCache[this._activeChannel] = texture;
  33470. if (texture) {
  33471. texture._associatedChannel = this._activeChannel;
  33472. }
  33473. }
  33474. else if (forTextureDataUpdate) {
  33475. wasPreviouslyBound = true;
  33476. this._activateCurrentTexture();
  33477. }
  33478. if (isTextureForRendering && !forTextureDataUpdate) {
  33479. this._bindSamplerUniformToChannel(texture._associatedChannel, this._activeChannel);
  33480. }
  33481. return wasPreviouslyBound;
  33482. };
  33483. /** @hidden */
  33484. Engine.prototype._bindTexture = function (channel, texture) {
  33485. if (channel === undefined) {
  33486. return;
  33487. }
  33488. if (texture) {
  33489. texture._associatedChannel = channel;
  33490. }
  33491. this._activeChannel = channel;
  33492. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  33493. };
  33494. /**
  33495. * Sets a texture to the webGL context from a postprocess
  33496. * @param channel defines the channel to use
  33497. * @param postProcess defines the source postprocess
  33498. */
  33499. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  33500. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  33501. };
  33502. /**
  33503. * Binds the output of the passed in post process to the texture channel specified
  33504. * @param channel The channel the texture should be bound to
  33505. * @param postProcess The post process which's output should be bound
  33506. */
  33507. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  33508. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  33509. };
  33510. /**
  33511. * Unbind all textures from the webGL context
  33512. */
  33513. Engine.prototype.unbindAllTextures = function () {
  33514. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  33515. this._activeChannel = channel;
  33516. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33517. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33518. if (this.webGLVersion > 1) {
  33519. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33520. }
  33521. }
  33522. };
  33523. /**
  33524. * Sets a texture to the according uniform.
  33525. * @param channel The texture channel
  33526. * @param uniform The uniform to set
  33527. * @param texture The texture to apply
  33528. */
  33529. Engine.prototype.setTexture = function (channel, uniform, texture) {
  33530. if (channel === undefined) {
  33531. return;
  33532. }
  33533. if (uniform) {
  33534. this._boundUniforms[channel] = uniform;
  33535. }
  33536. this._setTexture(channel, texture);
  33537. };
  33538. /**
  33539. * Sets a depth stencil texture from a render target to the according uniform.
  33540. * @param channel The texture channel
  33541. * @param uniform The uniform to set
  33542. * @param texture The render target texture containing the depth stencil texture to apply
  33543. */
  33544. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  33545. if (channel === undefined) {
  33546. return;
  33547. }
  33548. if (uniform) {
  33549. this._boundUniforms[channel] = uniform;
  33550. }
  33551. if (!texture || !texture.depthStencilTexture) {
  33552. this._setTexture(channel, null);
  33553. }
  33554. else {
  33555. this._setTexture(channel, texture, false, true);
  33556. }
  33557. };
  33558. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  33559. var uniform = this._boundUniforms[sourceSlot];
  33560. if (uniform._currentState === destination) {
  33561. return;
  33562. }
  33563. this._gl.uniform1i(uniform, destination);
  33564. uniform._currentState = destination;
  33565. };
  33566. Engine.prototype._getTextureWrapMode = function (mode) {
  33567. switch (mode) {
  33568. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  33569. return this._gl.REPEAT;
  33570. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  33571. return this._gl.CLAMP_TO_EDGE;
  33572. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  33573. return this._gl.MIRRORED_REPEAT;
  33574. }
  33575. return this._gl.REPEAT;
  33576. };
  33577. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  33578. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  33579. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  33580. // Not ready?
  33581. if (!texture) {
  33582. if (this._boundTexturesCache[channel] != null) {
  33583. this._activeChannel = channel;
  33584. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33585. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33586. if (this.webGLVersion > 1) {
  33587. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33588. }
  33589. }
  33590. return false;
  33591. }
  33592. // Video
  33593. if (texture.video) {
  33594. this._activeChannel = channel;
  33595. texture.update();
  33596. }
  33597. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  33598. texture.delayLoad();
  33599. return false;
  33600. }
  33601. var internalTexture;
  33602. if (depthStencilTexture) {
  33603. internalTexture = texture.depthStencilTexture;
  33604. }
  33605. else if (texture.isReady()) {
  33606. internalTexture = texture.getInternalTexture();
  33607. }
  33608. else if (texture.isCube) {
  33609. internalTexture = this.emptyCubeTexture;
  33610. }
  33611. else if (texture.is3D) {
  33612. internalTexture = this.emptyTexture3D;
  33613. }
  33614. else {
  33615. internalTexture = this.emptyTexture;
  33616. }
  33617. if (!isPartOfTextureArray && internalTexture) {
  33618. internalTexture._associatedChannel = channel;
  33619. }
  33620. var needToBind = true;
  33621. if (this._boundTexturesCache[channel] === internalTexture) {
  33622. if (!isPartOfTextureArray) {
  33623. this._bindSamplerUniformToChannel(internalTexture._associatedChannel, channel);
  33624. }
  33625. needToBind = false;
  33626. }
  33627. this._activeChannel = channel;
  33628. if (internalTexture && internalTexture.isMultiview) {
  33629. if (needToBind) {
  33630. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, internalTexture, isPartOfTextureArray);
  33631. }
  33632. }
  33633. else if (internalTexture && internalTexture.is3D) {
  33634. if (needToBind) {
  33635. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  33636. }
  33637. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33638. internalTexture._cachedWrapU = texture.wrapU;
  33639. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33640. }
  33641. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33642. internalTexture._cachedWrapV = texture.wrapV;
  33643. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33644. }
  33645. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  33646. internalTexture._cachedWrapR = texture.wrapR;
  33647. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  33648. }
  33649. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  33650. }
  33651. else if (internalTexture && internalTexture.isCube) {
  33652. if (needToBind) {
  33653. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  33654. }
  33655. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  33656. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  33657. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  33658. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  33659. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  33660. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  33661. }
  33662. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  33663. }
  33664. else {
  33665. if (needToBind) {
  33666. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  33667. }
  33668. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33669. internalTexture._cachedWrapU = texture.wrapU;
  33670. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33671. }
  33672. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33673. internalTexture._cachedWrapV = texture.wrapV;
  33674. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33675. }
  33676. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  33677. }
  33678. return true;
  33679. };
  33680. /**
  33681. * Sets an array of texture to the webGL context
  33682. * @param channel defines the channel where the texture array must be set
  33683. * @param uniform defines the associated uniform location
  33684. * @param textures defines the array of textures to bind
  33685. */
  33686. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  33687. if (channel === undefined || !uniform) {
  33688. return;
  33689. }
  33690. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  33691. this._textureUnits = new Int32Array(textures.length);
  33692. }
  33693. for (var i = 0; i < textures.length; i++) {
  33694. var texture = textures[i].getInternalTexture();
  33695. if (texture) {
  33696. this._textureUnits[channel + i] = channel + i;
  33697. texture._associatedChannel = channel + i;
  33698. }
  33699. else {
  33700. this._textureUnits[channel + i] = -1;
  33701. }
  33702. }
  33703. this._gl.uniform1iv(uniform, this._textureUnits);
  33704. for (var index = 0; index < textures.length; index++) {
  33705. this._setTexture(this._textureUnits[index], textures[index], true);
  33706. }
  33707. };
  33708. /** @hidden */
  33709. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  33710. var internalTexture = texture.getInternalTexture();
  33711. if (!internalTexture) {
  33712. return;
  33713. }
  33714. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  33715. var value = texture.anisotropicFilteringLevel;
  33716. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  33717. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  33718. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  33719. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  33720. }
  33721. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  33722. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  33723. internalTexture._cachedAnisotropicFilteringLevel = value;
  33724. }
  33725. };
  33726. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  33727. this._bindTextureDirectly(target, texture, true, true);
  33728. this._gl.texParameterf(target, parameter, value);
  33729. };
  33730. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  33731. if (texture) {
  33732. this._bindTextureDirectly(target, texture, true, true);
  33733. }
  33734. this._gl.texParameteri(target, parameter, value);
  33735. };
  33736. /**
  33737. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33738. * @param x defines the x coordinate of the rectangle where pixels must be read
  33739. * @param y defines the y coordinate of the rectangle where pixels must be read
  33740. * @param width defines the width of the rectangle where pixels must be read
  33741. * @param height defines the height of the rectangle where pixels must be read
  33742. * @returns a Uint8Array containing RGBA colors
  33743. */
  33744. Engine.prototype.readPixels = function (x, y, width, height) {
  33745. var data = new Uint8Array(height * width * 4);
  33746. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  33747. return data;
  33748. };
  33749. /**
  33750. * Add an externaly attached data from its key.
  33751. * This method call will fail and return false, if such key already exists.
  33752. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33753. * @param key the unique key that identifies the data
  33754. * @param data the data object to associate to the key for this Engine instance
  33755. * @return true if no such key were already present and the data was added successfully, false otherwise
  33756. */
  33757. Engine.prototype.addExternalData = function (key, data) {
  33758. if (!this._externalData) {
  33759. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33760. }
  33761. return this._externalData.add(key, data);
  33762. };
  33763. /**
  33764. * Get an externaly attached data from its key
  33765. * @param key the unique key that identifies the data
  33766. * @return the associated data, if present (can be null), or undefined if not present
  33767. */
  33768. Engine.prototype.getExternalData = function (key) {
  33769. if (!this._externalData) {
  33770. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33771. }
  33772. return this._externalData.get(key);
  33773. };
  33774. /**
  33775. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33776. * @param key the unique key that identifies the data
  33777. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33778. * @return the associated data, can be null if the factory returned null.
  33779. */
  33780. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  33781. if (!this._externalData) {
  33782. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33783. }
  33784. return this._externalData.getOrAddWithFactory(key, factory);
  33785. };
  33786. /**
  33787. * Remove an externaly attached data from the Engine instance
  33788. * @param key the unique key that identifies the data
  33789. * @return true if the data was successfully removed, false if it doesn't exist
  33790. */
  33791. Engine.prototype.removeExternalData = function (key) {
  33792. if (!this._externalData) {
  33793. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33794. }
  33795. return this._externalData.remove(key);
  33796. };
  33797. /**
  33798. * Unbind all vertex attributes from the webGL context
  33799. */
  33800. Engine.prototype.unbindAllAttributes = function () {
  33801. if (this._mustWipeVertexAttributes) {
  33802. this._mustWipeVertexAttributes = false;
  33803. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  33804. this._gl.disableVertexAttribArray(i);
  33805. this._vertexAttribArraysEnabled[i] = false;
  33806. this._currentBufferPointers[i].active = false;
  33807. }
  33808. return;
  33809. }
  33810. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  33811. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  33812. continue;
  33813. }
  33814. this._gl.disableVertexAttribArray(i);
  33815. this._vertexAttribArraysEnabled[i] = false;
  33816. this._currentBufferPointers[i].active = false;
  33817. }
  33818. };
  33819. /**
  33820. * 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
  33821. */
  33822. Engine.prototype.releaseEffects = function () {
  33823. for (var name in this._compiledEffects) {
  33824. this._deleteProgram(this._compiledEffects[name]._program);
  33825. }
  33826. this._compiledEffects = {};
  33827. };
  33828. /**
  33829. * Dispose and release all associated resources
  33830. */
  33831. Engine.prototype.dispose = function () {
  33832. this.hideLoadingUI();
  33833. this.stopRenderLoop();
  33834. this.onNewSceneAddedObservable.clear();
  33835. // Release postProcesses
  33836. while (this.postProcesses.length) {
  33837. this.postProcesses[0].dispose();
  33838. }
  33839. // Empty texture
  33840. if (this._emptyTexture) {
  33841. this._releaseTexture(this._emptyTexture);
  33842. this._emptyTexture = null;
  33843. }
  33844. if (this._emptyCubeTexture) {
  33845. this._releaseTexture(this._emptyCubeTexture);
  33846. this._emptyCubeTexture = null;
  33847. }
  33848. // Rescale PP
  33849. if (this._rescalePostProcess) {
  33850. this._rescalePostProcess.dispose();
  33851. }
  33852. // Release scenes
  33853. while (this.scenes.length) {
  33854. this.scenes[0].dispose();
  33855. }
  33856. // Release audio engine
  33857. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  33858. Engine.audioEngine.dispose();
  33859. }
  33860. // Release effects
  33861. this.releaseEffects();
  33862. // Unbind
  33863. this.unbindAllAttributes();
  33864. this._boundUniforms = [];
  33865. if (this._dummyFramebuffer) {
  33866. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  33867. }
  33868. //WebVR
  33869. this.disableVR();
  33870. // Events
  33871. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  33872. window.removeEventListener("blur", this._onBlur);
  33873. window.removeEventListener("focus", this._onFocus);
  33874. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  33875. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  33876. if (this._renderingCanvas) {
  33877. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  33878. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  33879. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  33880. if (!this._doNotHandleContextLost) {
  33881. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  33882. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  33883. }
  33884. }
  33885. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  33886. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  33887. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  33888. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  33889. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  33890. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  33891. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  33892. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  33893. if (this._onVrDisplayConnect) {
  33894. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  33895. if (this._onVrDisplayDisconnect) {
  33896. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  33897. }
  33898. if (this._onVrDisplayPresentChange) {
  33899. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  33900. }
  33901. this._onVrDisplayConnect = null;
  33902. this._onVrDisplayDisconnect = null;
  33903. }
  33904. }
  33905. // Remove from Instances
  33906. var index = Engine.Instances.indexOf(this);
  33907. if (index >= 0) {
  33908. Engine.Instances.splice(index, 1);
  33909. }
  33910. this._workingCanvas = null;
  33911. this._workingContext = null;
  33912. this._currentBufferPointers = [];
  33913. this._renderingCanvas = null;
  33914. this._currentProgram = null;
  33915. this._bindedRenderFunction = null;
  33916. this.onResizeObservable.clear();
  33917. this.onCanvasBlurObservable.clear();
  33918. this.onCanvasFocusObservable.clear();
  33919. this.onCanvasPointerOutObservable.clear();
  33920. this.onBeginFrameObservable.clear();
  33921. this.onEndFrameObservable.clear();
  33922. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33923. // Abort active requests
  33924. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33925. var request = _a[_i];
  33926. request.abort();
  33927. }
  33928. };
  33929. // Loading screen
  33930. /**
  33931. * Display the loading screen
  33932. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33933. */
  33934. Engine.prototype.displayLoadingUI = function () {
  33935. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  33936. return;
  33937. }
  33938. var loadingScreen = this.loadingScreen;
  33939. if (loadingScreen) {
  33940. loadingScreen.displayLoadingUI();
  33941. }
  33942. };
  33943. /**
  33944. * Hide the loading screen
  33945. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33946. */
  33947. Engine.prototype.hideLoadingUI = function () {
  33948. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  33949. return;
  33950. }
  33951. var loadingScreen = this.loadingScreen;
  33952. if (loadingScreen) {
  33953. loadingScreen.hideLoadingUI();
  33954. }
  33955. };
  33956. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33957. /**
  33958. * Gets the current loading screen object
  33959. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33960. */
  33961. get: function () {
  33962. if (!this._loadingScreen && this._renderingCanvas) {
  33963. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33964. }
  33965. return this._loadingScreen;
  33966. },
  33967. /**
  33968. * Sets the current loading screen object
  33969. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33970. */
  33971. set: function (loadingScreen) {
  33972. this._loadingScreen = loadingScreen;
  33973. },
  33974. enumerable: true,
  33975. configurable: true
  33976. });
  33977. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33978. /**
  33979. * Sets the current loading screen text
  33980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33981. */
  33982. set: function (text) {
  33983. this.loadingScreen.loadingUIText = text;
  33984. },
  33985. enumerable: true,
  33986. configurable: true
  33987. });
  33988. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33989. /**
  33990. * Sets the current loading screen background color
  33991. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33992. */
  33993. set: function (color) {
  33994. this.loadingScreen.loadingUIBackgroundColor = color;
  33995. },
  33996. enumerable: true,
  33997. configurable: true
  33998. });
  33999. /**
  34000. * Attach a new callback raised when context lost event is fired
  34001. * @param callback defines the callback to call
  34002. */
  34003. Engine.prototype.attachContextLostEvent = function (callback) {
  34004. if (this._renderingCanvas) {
  34005. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  34006. }
  34007. };
  34008. /**
  34009. * Attach a new callback raised when context restored event is fired
  34010. * @param callback defines the callback to call
  34011. */
  34012. Engine.prototype.attachContextRestoredEvent = function (callback) {
  34013. if (this._renderingCanvas) {
  34014. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  34015. }
  34016. };
  34017. /**
  34018. * Gets the source code of the vertex shader associated with a specific webGL program
  34019. * @param program defines the program to use
  34020. * @returns a string containing the source code of the vertex shader associated with the program
  34021. */
  34022. Engine.prototype.getVertexShaderSource = function (program) {
  34023. var shaders = this._gl.getAttachedShaders(program);
  34024. if (!shaders) {
  34025. return null;
  34026. }
  34027. return this._gl.getShaderSource(shaders[0]);
  34028. };
  34029. /**
  34030. * Gets the source code of the fragment shader associated with a specific webGL program
  34031. * @param program defines the program to use
  34032. * @returns a string containing the source code of the fragment shader associated with the program
  34033. */
  34034. Engine.prototype.getFragmentShaderSource = function (program) {
  34035. var shaders = this._gl.getAttachedShaders(program);
  34036. if (!shaders) {
  34037. return null;
  34038. }
  34039. return this._gl.getShaderSource(shaders[1]);
  34040. };
  34041. /**
  34042. * Get the current error code of the webGL context
  34043. * @returns the error code
  34044. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34045. */
  34046. Engine.prototype.getError = function () {
  34047. return this._gl.getError();
  34048. };
  34049. // FPS
  34050. /**
  34051. * Gets the current framerate
  34052. * @returns a number representing the framerate
  34053. */
  34054. Engine.prototype.getFps = function () {
  34055. return this._fps;
  34056. };
  34057. /**
  34058. * Gets the time spent between current and previous frame
  34059. * @returns a number representing the delta time in ms
  34060. */
  34061. Engine.prototype.getDeltaTime = function () {
  34062. return this._deltaTime;
  34063. };
  34064. Engine.prototype._measureFps = function () {
  34065. this._performanceMonitor.sampleFrame();
  34066. this._fps = this._performanceMonitor.averageFPS;
  34067. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  34068. };
  34069. /** @hidden */
  34070. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  34071. if (faceIndex === void 0) { faceIndex = -1; }
  34072. if (level === void 0) { level = 0; }
  34073. if (buffer === void 0) { buffer = null; }
  34074. var gl = this._gl;
  34075. if (!this._dummyFramebuffer) {
  34076. var dummy = gl.createFramebuffer();
  34077. if (!dummy) {
  34078. throw new Error("Unable to create dummy framebuffer");
  34079. }
  34080. this._dummyFramebuffer = dummy;
  34081. }
  34082. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  34083. if (faceIndex > -1) {
  34084. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  34085. }
  34086. else {
  34087. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  34088. }
  34089. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  34090. switch (readType) {
  34091. case gl.UNSIGNED_BYTE:
  34092. if (!buffer) {
  34093. buffer = new Uint8Array(4 * width * height);
  34094. }
  34095. readType = gl.UNSIGNED_BYTE;
  34096. break;
  34097. default:
  34098. if (!buffer) {
  34099. buffer = new Float32Array(4 * width * height);
  34100. }
  34101. readType = gl.FLOAT;
  34102. break;
  34103. }
  34104. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  34105. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  34106. return buffer;
  34107. };
  34108. Engine.prototype._canRenderToFloatFramebuffer = function () {
  34109. if (this._webGLVersion > 1) {
  34110. return this._caps.colorBufferFloat;
  34111. }
  34112. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  34113. };
  34114. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  34115. if (this._webGLVersion > 1) {
  34116. return this._caps.colorBufferFloat;
  34117. }
  34118. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  34119. };
  34120. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  34121. Engine.prototype._canRenderToFramebuffer = function (type) {
  34122. var gl = this._gl;
  34123. //clear existing errors
  34124. while (gl.getError() !== gl.NO_ERROR) { }
  34125. var successful = true;
  34126. var texture = gl.createTexture();
  34127. gl.bindTexture(gl.TEXTURE_2D, texture);
  34128. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  34129. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  34130. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  34131. var fb = gl.createFramebuffer();
  34132. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  34133. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  34134. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  34135. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  34136. successful = successful && (gl.getError() === gl.NO_ERROR);
  34137. //try render by clearing frame buffer's color buffer
  34138. if (successful) {
  34139. gl.clear(gl.COLOR_BUFFER_BIT);
  34140. successful = successful && (gl.getError() === gl.NO_ERROR);
  34141. }
  34142. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  34143. if (successful) {
  34144. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  34145. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34146. var readFormat = gl.RGBA;
  34147. var readType = gl.UNSIGNED_BYTE;
  34148. var buffer = new Uint8Array(4);
  34149. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  34150. successful = successful && (gl.getError() === gl.NO_ERROR);
  34151. }
  34152. //clean up
  34153. gl.deleteTexture(texture);
  34154. gl.deleteFramebuffer(fb);
  34155. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34156. //clear accumulated errors
  34157. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  34158. return successful;
  34159. };
  34160. /** @hidden */
  34161. Engine.prototype._getWebGLTextureType = function (type) {
  34162. if (this._webGLVersion === 1) {
  34163. switch (type) {
  34164. case Engine.TEXTURETYPE_FLOAT:
  34165. return this._gl.FLOAT;
  34166. case Engine.TEXTURETYPE_HALF_FLOAT:
  34167. return this._gl.HALF_FLOAT_OES;
  34168. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34169. return this._gl.UNSIGNED_BYTE;
  34170. }
  34171. return this._gl.UNSIGNED_BYTE;
  34172. }
  34173. switch (type) {
  34174. case Engine.TEXTURETYPE_BYTE:
  34175. return this._gl.BYTE;
  34176. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34177. return this._gl.UNSIGNED_BYTE;
  34178. case Engine.TEXTURETYPE_SHORT:
  34179. return this._gl.SHORT;
  34180. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34181. return this._gl.UNSIGNED_SHORT;
  34182. case Engine.TEXTURETYPE_INT:
  34183. return this._gl.INT;
  34184. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34185. return this._gl.UNSIGNED_INT;
  34186. case Engine.TEXTURETYPE_FLOAT:
  34187. return this._gl.FLOAT;
  34188. case Engine.TEXTURETYPE_HALF_FLOAT:
  34189. return this._gl.HALF_FLOAT;
  34190. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34191. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  34192. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34193. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  34194. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34195. return this._gl.UNSIGNED_SHORT_5_6_5;
  34196. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34197. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  34198. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  34199. return this._gl.UNSIGNED_INT_24_8;
  34200. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34201. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  34202. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34203. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  34204. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  34205. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  34206. }
  34207. return this._gl.UNSIGNED_BYTE;
  34208. };
  34209. Engine.prototype._getInternalFormat = function (format) {
  34210. var internalFormat = this._gl.RGBA;
  34211. switch (format) {
  34212. case Engine.TEXTUREFORMAT_ALPHA:
  34213. internalFormat = this._gl.ALPHA;
  34214. break;
  34215. case Engine.TEXTUREFORMAT_LUMINANCE:
  34216. internalFormat = this._gl.LUMINANCE;
  34217. break;
  34218. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34219. internalFormat = this._gl.LUMINANCE_ALPHA;
  34220. break;
  34221. case Engine.TEXTUREFORMAT_RED:
  34222. internalFormat = this._gl.RED;
  34223. break;
  34224. case Engine.TEXTUREFORMAT_RG:
  34225. internalFormat = this._gl.RG;
  34226. break;
  34227. case Engine.TEXTUREFORMAT_RGB:
  34228. internalFormat = this._gl.RGB;
  34229. break;
  34230. case Engine.TEXTUREFORMAT_RGBA:
  34231. internalFormat = this._gl.RGBA;
  34232. break;
  34233. }
  34234. if (this._webGLVersion > 1) {
  34235. switch (format) {
  34236. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34237. internalFormat = this._gl.RED_INTEGER;
  34238. break;
  34239. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34240. internalFormat = this._gl.RG_INTEGER;
  34241. break;
  34242. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34243. internalFormat = this._gl.RGB_INTEGER;
  34244. break;
  34245. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34246. internalFormat = this._gl.RGBA_INTEGER;
  34247. break;
  34248. }
  34249. }
  34250. return internalFormat;
  34251. };
  34252. /** @hidden */
  34253. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  34254. if (this._webGLVersion === 1) {
  34255. if (format !== undefined) {
  34256. switch (format) {
  34257. case Engine.TEXTUREFORMAT_ALPHA:
  34258. return this._gl.ALPHA;
  34259. case Engine.TEXTUREFORMAT_LUMINANCE:
  34260. return this._gl.LUMINANCE;
  34261. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34262. return this._gl.LUMINANCE_ALPHA;
  34263. }
  34264. }
  34265. return this._gl.RGBA;
  34266. }
  34267. switch (type) {
  34268. case Engine.TEXTURETYPE_BYTE:
  34269. switch (format) {
  34270. case Engine.TEXTUREFORMAT_RED:
  34271. return this._gl.R8_SNORM;
  34272. case Engine.TEXTUREFORMAT_RG:
  34273. return this._gl.RG8_SNORM;
  34274. case Engine.TEXTUREFORMAT_RGB:
  34275. return this._gl.RGB8_SNORM;
  34276. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34277. return this._gl.R8I;
  34278. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34279. return this._gl.RG8I;
  34280. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34281. return this._gl.RGB8I;
  34282. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34283. return this._gl.RGBA8I;
  34284. default:
  34285. return this._gl.RGBA8_SNORM;
  34286. }
  34287. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34288. switch (format) {
  34289. case Engine.TEXTUREFORMAT_RED:
  34290. return this._gl.R8;
  34291. case Engine.TEXTUREFORMAT_RG:
  34292. return this._gl.RG8;
  34293. case Engine.TEXTUREFORMAT_RGB:
  34294. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  34295. case Engine.TEXTUREFORMAT_RGBA:
  34296. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  34297. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34298. return this._gl.R8UI;
  34299. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34300. return this._gl.RG8UI;
  34301. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34302. return this._gl.RGB8UI;
  34303. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34304. return this._gl.RGBA8UI;
  34305. case Engine.TEXTUREFORMAT_ALPHA:
  34306. return this._gl.ALPHA;
  34307. case Engine.TEXTUREFORMAT_LUMINANCE:
  34308. return this._gl.LUMINANCE;
  34309. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34310. return this._gl.LUMINANCE_ALPHA;
  34311. default:
  34312. return this._gl.RGBA8;
  34313. }
  34314. case Engine.TEXTURETYPE_SHORT:
  34315. switch (format) {
  34316. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34317. return this._gl.R16I;
  34318. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34319. return this._gl.RG16I;
  34320. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34321. return this._gl.RGB16I;
  34322. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34323. return this._gl.RGBA16I;
  34324. default:
  34325. return this._gl.RGBA16I;
  34326. }
  34327. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34328. switch (format) {
  34329. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34330. return this._gl.R16UI;
  34331. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34332. return this._gl.RG16UI;
  34333. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34334. return this._gl.RGB16UI;
  34335. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34336. return this._gl.RGBA16UI;
  34337. default:
  34338. return this._gl.RGBA16UI;
  34339. }
  34340. case Engine.TEXTURETYPE_INT:
  34341. switch (format) {
  34342. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34343. return this._gl.R32I;
  34344. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34345. return this._gl.RG32I;
  34346. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34347. return this._gl.RGB32I;
  34348. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34349. return this._gl.RGBA32I;
  34350. default:
  34351. return this._gl.RGBA32I;
  34352. }
  34353. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34354. switch (format) {
  34355. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34356. return this._gl.R32UI;
  34357. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34358. return this._gl.RG32UI;
  34359. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34360. return this._gl.RGB32UI;
  34361. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34362. return this._gl.RGBA32UI;
  34363. default:
  34364. return this._gl.RGBA32UI;
  34365. }
  34366. case Engine.TEXTURETYPE_FLOAT:
  34367. switch (format) {
  34368. case Engine.TEXTUREFORMAT_RED:
  34369. return this._gl.R32F; // By default. Other possibility is R16F.
  34370. case Engine.TEXTUREFORMAT_RG:
  34371. return this._gl.RG32F; // By default. Other possibility is RG16F.
  34372. case Engine.TEXTUREFORMAT_RGB:
  34373. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  34374. case Engine.TEXTUREFORMAT_RGBA:
  34375. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  34376. default:
  34377. return this._gl.RGBA32F;
  34378. }
  34379. case Engine.TEXTURETYPE_HALF_FLOAT:
  34380. switch (format) {
  34381. case Engine.TEXTUREFORMAT_RED:
  34382. return this._gl.R16F;
  34383. case Engine.TEXTUREFORMAT_RG:
  34384. return this._gl.RG16F;
  34385. case Engine.TEXTUREFORMAT_RGB:
  34386. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  34387. case Engine.TEXTUREFORMAT_RGBA:
  34388. return this._gl.RGBA16F;
  34389. default:
  34390. return this._gl.RGBA16F;
  34391. }
  34392. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34393. return this._gl.RGB565;
  34394. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34395. return this._gl.R11F_G11F_B10F;
  34396. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34397. return this._gl.RGB9_E5;
  34398. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34399. return this._gl.RGBA4;
  34400. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34401. return this._gl.RGB5_A1;
  34402. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34403. switch (format) {
  34404. case Engine.TEXTUREFORMAT_RGBA:
  34405. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  34406. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34407. return this._gl.RGB10_A2UI;
  34408. default:
  34409. return this._gl.RGB10_A2;
  34410. }
  34411. }
  34412. return this._gl.RGBA8;
  34413. };
  34414. /** @hidden */
  34415. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  34416. if (type === Engine.TEXTURETYPE_FLOAT) {
  34417. return this._gl.RGBA32F;
  34418. }
  34419. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  34420. return this._gl.RGBA16F;
  34421. }
  34422. return this._gl.RGBA8;
  34423. };
  34424. /** @hidden */
  34425. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  34426. var _this = this;
  34427. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  34428. this._activeRequests.push(request);
  34429. request.onCompleteObservable.add(function (request) {
  34430. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  34431. });
  34432. return request;
  34433. };
  34434. /** @hidden */
  34435. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  34436. var _this = this;
  34437. return new Promise(function (resolve, reject) {
  34438. _this._loadFile(url, function (data) {
  34439. resolve(data);
  34440. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  34441. reject(exception);
  34442. });
  34443. });
  34444. };
  34445. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  34446. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  34447. var onload = function (data) {
  34448. loadedFiles[index] = data;
  34449. loadedFiles._internalCount++;
  34450. if (loadedFiles._internalCount === 6) {
  34451. onfinish(loadedFiles);
  34452. }
  34453. };
  34454. var onerror = function (request, exception) {
  34455. if (onErrorCallBack && request) {
  34456. onErrorCallBack(request.status + " " + request.statusText, exception);
  34457. }
  34458. };
  34459. this._loadFile(url, onload, undefined, undefined, true, onerror);
  34460. };
  34461. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  34462. if (onError === void 0) { onError = null; }
  34463. var loadedFiles = [];
  34464. loadedFiles._internalCount = 0;
  34465. for (var index = 0; index < 6; index++) {
  34466. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  34467. }
  34468. };
  34469. // Statics
  34470. /**
  34471. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34472. * @returns true if the engine can be created
  34473. * @ignorenaming
  34474. */
  34475. Engine.isSupported = function () {
  34476. try {
  34477. var tempcanvas = document.createElement("canvas");
  34478. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  34479. return gl != null && !!window.WebGLRenderingContext;
  34480. }
  34481. catch (e) {
  34482. return false;
  34483. }
  34484. };
  34485. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34486. Engine.ExceptionList = [
  34487. { key: "Chrome\/63\.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  34488. { key: "Firefox\/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34489. { key: "Firefox\/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34490. { key: "Chrome\/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34491. { key: "Chrome\/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34492. { key: "Chrome\/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34493. { key: "Mac OS.+Chrome\/71", capture: null, captureConstraint: null, targets: ["vao"] },
  34494. { key: "Mac OS.+Chrome\/72", capture: null, captureConstraint: null, targets: ["vao"] }
  34495. ];
  34496. /**
  34497. * Hidden
  34498. */
  34499. Engine._TextureLoaders = [];
  34500. // Const statics
  34501. /** Defines that alpha blending is disabled */
  34502. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE;
  34503. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34504. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_ADD;
  34505. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34506. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE;
  34507. /** Defines that alpha blending to DEST - SRC * DEST */
  34508. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_SUBTRACT;
  34509. /** Defines that alpha blending to SRC * DEST */
  34510. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_MULTIPLY;
  34511. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34512. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_MAXIMIZED;
  34513. /** Defines that alpha blending to SRC + DEST */
  34514. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_ONEONE;
  34515. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34516. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED;
  34517. /**
  34518. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34519. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34520. */
  34521. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  34522. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34523. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_INTERPOLATE;
  34524. /**
  34525. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34526. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34527. */
  34528. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_SCREENMODE;
  34529. /** Defines that the ressource is not delayed*/
  34530. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_NONE;
  34531. /** Defines that the ressource was successfully delay loaded */
  34532. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_LOADED;
  34533. /** Defines that the ressource is currently delay loading */
  34534. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_LOADING;
  34535. /** Defines that the ressource is delayed and has not started loading */
  34536. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_NOTLOADED;
  34537. // Depht or Stencil test Constants.
  34538. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34539. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].NEVER;
  34540. /** 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 */
  34541. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALWAYS;
  34542. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34543. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].LESS;
  34544. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34545. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].EQUAL;
  34546. /** 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 */
  34547. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].LEQUAL;
  34548. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34549. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].GREATER;
  34550. /** 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 */
  34551. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].GEQUAL;
  34552. /** 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 */
  34553. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].NOTEQUAL;
  34554. // Stencil Actions Constants.
  34555. /** Passed to stencilOperation to specify that stencil value must be kept */
  34556. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].KEEP;
  34557. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34558. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].REPLACE;
  34559. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34560. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INCR;
  34561. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34562. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DECR;
  34563. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34564. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INVERT;
  34565. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34566. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INCR_WRAP;
  34567. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34568. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DECR_WRAP;
  34569. /** Texture is not repeating outside of 0..1 UVs */
  34570. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  34571. /** Texture is repeating outside of 0..1 UVs */
  34572. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  34573. /** Texture is repeating and mirrored */
  34574. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  34575. /** ALPHA */
  34576. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_ALPHA;
  34577. /** LUMINANCE */
  34578. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_LUMINANCE;
  34579. /** LUMINANCE_ALPHA */
  34580. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  34581. /** RGB */
  34582. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGB;
  34583. /** RGBA */
  34584. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGBA;
  34585. /** RED */
  34586. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RED;
  34587. /** RED (2nd reference) */
  34588. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_R;
  34589. /** RG */
  34590. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RG;
  34591. /** RED_INTEGER */
  34592. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  34593. /** RED_INTEGER (2nd reference) */
  34594. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_R_INTEGER;
  34595. /** RG_INTEGER */
  34596. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  34597. /** RGB_INTEGER */
  34598. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  34599. /** RGBA_INTEGER */
  34600. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  34601. /** UNSIGNED_BYTE */
  34602. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  34603. /** UNSIGNED_BYTE (2nd reference) */
  34604. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34605. /** FLOAT */
  34606. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT;
  34607. /** HALF_FLOAT */
  34608. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_HALF_FLOAT;
  34609. /** BYTE */
  34610. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_BYTE;
  34611. /** SHORT */
  34612. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_SHORT;
  34613. /** UNSIGNED_SHORT */
  34614. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  34615. /** INT */
  34616. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_INT;
  34617. /** UNSIGNED_INT */
  34618. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  34619. /** UNSIGNED_SHORT_4_4_4_4 */
  34620. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  34621. /** UNSIGNED_SHORT_5_5_5_1 */
  34622. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  34623. /** UNSIGNED_SHORT_5_6_5 */
  34624. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  34625. /** UNSIGNED_INT_2_10_10_10_REV */
  34626. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  34627. /** UNSIGNED_INT_24_8 */
  34628. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  34629. /** UNSIGNED_INT_10F_11F_11F_REV */
  34630. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  34631. /** UNSIGNED_INT_5_9_9_9_REV */
  34632. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  34633. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34634. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  34635. /** nearest is mag = nearest and min = nearest and mip = linear */
  34636. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  34637. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34638. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  34639. /** Trilinear is mag = linear and min = linear and mip = linear */
  34640. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34641. /** nearest is mag = nearest and min = nearest and mip = linear */
  34642. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  34643. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34644. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  34645. /** Trilinear is mag = linear and min = linear and mip = linear */
  34646. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  34647. /** mag = nearest and min = nearest and mip = nearest */
  34648. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  34649. /** mag = nearest and min = linear and mip = nearest */
  34650. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  34651. /** mag = nearest and min = linear and mip = linear */
  34652. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  34653. /** mag = nearest and min = linear and mip = none */
  34654. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR;
  34655. /** mag = nearest and min = nearest and mip = none */
  34656. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST;
  34657. /** mag = linear and min = nearest and mip = nearest */
  34658. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  34659. /** mag = linear and min = nearest and mip = linear */
  34660. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  34661. /** mag = linear and min = linear and mip = none */
  34662. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR;
  34663. /** mag = linear and min = nearest and mip = none */
  34664. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST;
  34665. /** Explicit coordinates mode */
  34666. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_EXPLICIT_MODE;
  34667. /** Spherical coordinates mode */
  34668. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_SPHERICAL_MODE;
  34669. /** Planar coordinates mode */
  34670. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_PLANAR_MODE;
  34671. /** Cubic coordinates mode */
  34672. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_CUBIC_MODE;
  34673. /** Projection coordinates mode */
  34674. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_PROJECTION_MODE;
  34675. /** Skybox coordinates mode */
  34676. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_SKYBOX_MODE;
  34677. /** Inverse Cubic coordinates mode */
  34678. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_INVCUBIC_MODE;
  34679. /** Equirectangular coordinates mode */
  34680. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  34681. /** Equirectangular Fixed coordinates mode */
  34682. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  34683. /** Equirectangular Fixed Mirrored coordinates mode */
  34684. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  34685. // Texture rescaling mode
  34686. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34687. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_FLOOR;
  34688. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34689. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_NEAREST;
  34690. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34691. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_CEILING;
  34692. // Updatable statics so stick with vars here
  34693. /**
  34694. * Gets or sets the epsilon value used by collision engine
  34695. */
  34696. Engine.CollisionsEpsilon = 0.001;
  34697. /**
  34698. * Method called to create the default rescale post process on each engine.
  34699. */
  34700. Engine._RescalePostProcessFactory = null;
  34701. return Engine;
  34702. }());
  34703. /***/ }),
  34704. /***/ "./Engines/engineStore.ts":
  34705. /*!********************************!*\
  34706. !*** ./Engines/engineStore.ts ***!
  34707. \********************************/
  34708. /*! exports provided: EngineStore */
  34709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34710. "use strict";
  34711. __webpack_require__.r(__webpack_exports__);
  34712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  34713. /**
  34714. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34715. * during the life time of the application.
  34716. */
  34717. var EngineStore = /** @class */ (function () {
  34718. function EngineStore() {
  34719. }
  34720. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  34721. /**
  34722. * Gets the latest created engine
  34723. */
  34724. get: function () {
  34725. if (this.Instances.length === 0) {
  34726. return null;
  34727. }
  34728. return this.Instances[this.Instances.length - 1];
  34729. },
  34730. enumerable: true,
  34731. configurable: true
  34732. });
  34733. Object.defineProperty(EngineStore, "LastCreatedScene", {
  34734. /**
  34735. * Gets the latest created scene
  34736. */
  34737. get: function () {
  34738. var lastCreatedEngine = this.LastCreatedEngine;
  34739. if (!lastCreatedEngine) {
  34740. return null;
  34741. }
  34742. if (lastCreatedEngine.scenes.length === 0) {
  34743. return null;
  34744. }
  34745. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  34746. },
  34747. enumerable: true,
  34748. configurable: true
  34749. });
  34750. /** Gets the list of created engines */
  34751. EngineStore.Instances = new Array();
  34752. return EngineStore;
  34753. }());
  34754. /***/ }),
  34755. /***/ "./Engines/index.ts":
  34756. /*!**************************!*\
  34757. !*** ./Engines/index.ts ***!
  34758. \**************************/
  34759. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  34760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34761. "use strict";
  34762. __webpack_require__.r(__webpack_exports__);
  34763. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  34765. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  34766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  34767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  34768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  34769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  34770. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  34771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  34772. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  34773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  34774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  34775. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  34776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  34777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  34778. /***/ }),
  34779. /***/ "./Engines/nullEngine.ts":
  34780. /*!*******************************!*\
  34781. !*** ./Engines/nullEngine.ts ***!
  34782. \*******************************/
  34783. /*! exports provided: NullEngineOptions, NullEngine */
  34784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34785. "use strict";
  34786. __webpack_require__.r(__webpack_exports__);
  34787. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  34788. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  34789. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34790. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  34791. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  34792. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  34793. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  34794. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34795. /**
  34796. * Options to create the null engine
  34797. */
  34798. var NullEngineOptions = /** @class */ (function () {
  34799. function NullEngineOptions() {
  34800. /**
  34801. * Render width (Default: 512)
  34802. */
  34803. this.renderWidth = 512;
  34804. /**
  34805. * Render height (Default: 256)
  34806. */
  34807. this.renderHeight = 256;
  34808. /**
  34809. * Texture size (Default: 512)
  34810. */
  34811. this.textureSize = 512;
  34812. /**
  34813. * If delta time between frames should be constant
  34814. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34815. */
  34816. this.deterministicLockstep = false;
  34817. /**
  34818. * Maximum about of steps between frames (Default: 4)
  34819. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34820. */
  34821. this.lockstepMaxSteps = 4;
  34822. }
  34823. return NullEngineOptions;
  34824. }());
  34825. /**
  34826. * The null engine class provides support for headless version of babylon.js.
  34827. * This can be used in server side scenario or for testing purposes
  34828. */
  34829. var NullEngine = /** @class */ (function (_super) {
  34830. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  34831. function NullEngine(options) {
  34832. if (options === void 0) { options = new NullEngineOptions(); }
  34833. var _this = _super.call(this, null) || this;
  34834. if (options.deterministicLockstep === undefined) {
  34835. options.deterministicLockstep = false;
  34836. }
  34837. if (options.lockstepMaxSteps === undefined) {
  34838. options.lockstepMaxSteps = 4;
  34839. }
  34840. _this._options = options;
  34841. // Init caps
  34842. // We consider we are on a webgl1 capable device
  34843. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  34844. _this._caps.maxTexturesImageUnits = 16;
  34845. _this._caps.maxVertexTextureImageUnits = 16;
  34846. _this._caps.maxTextureSize = 512;
  34847. _this._caps.maxCubemapTextureSize = 512;
  34848. _this._caps.maxRenderTextureSize = 512;
  34849. _this._caps.maxVertexAttribs = 16;
  34850. _this._caps.maxVaryingVectors = 16;
  34851. _this._caps.maxFragmentUniformVectors = 16;
  34852. _this._caps.maxVertexUniformVectors = 16;
  34853. // Extensions
  34854. _this._caps.standardDerivatives = false;
  34855. _this._caps.astc = null;
  34856. _this._caps.s3tc = null;
  34857. _this._caps.pvrtc = null;
  34858. _this._caps.etc1 = null;
  34859. _this._caps.etc2 = null;
  34860. _this._caps.textureAnisotropicFilterExtension = null;
  34861. _this._caps.maxAnisotropy = 0;
  34862. _this._caps.uintIndices = false;
  34863. _this._caps.fragmentDepthSupported = false;
  34864. _this._caps.highPrecisionShaderSupported = true;
  34865. _this._caps.colorBufferFloat = false;
  34866. _this._caps.textureFloat = false;
  34867. _this._caps.textureFloatLinearFiltering = false;
  34868. _this._caps.textureFloatRender = false;
  34869. _this._caps.textureHalfFloat = false;
  34870. _this._caps.textureHalfFloatLinearFiltering = false;
  34871. _this._caps.textureHalfFloatRender = false;
  34872. _this._caps.textureLOD = false;
  34873. _this._caps.drawBuffersExtension = false;
  34874. _this._caps.depthTextureExtension = false;
  34875. _this._caps.vertexArrayObject = false;
  34876. _this._caps.instancedArrays = false;
  34877. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  34878. // Wrappers
  34879. var theCurrentGlobal = (typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : window);
  34880. if (typeof URL === "undefined") {
  34881. theCurrentGlobal.URL = {
  34882. createObjectURL: function () { },
  34883. revokeObjectURL: function () { }
  34884. };
  34885. }
  34886. if (typeof Blob === "undefined") {
  34887. theCurrentGlobal.Blob = function () { };
  34888. }
  34889. return _this;
  34890. }
  34891. /**
  34892. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34893. */
  34894. NullEngine.prototype.isDeterministicLockStep = function () {
  34895. return this._options.deterministicLockstep;
  34896. };
  34897. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  34898. NullEngine.prototype.getLockstepMaxSteps = function () {
  34899. return this._options.lockstepMaxSteps;
  34900. };
  34901. /**
  34902. * Sets hardware scaling, used to save performance if needed
  34903. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34904. */
  34905. NullEngine.prototype.getHardwareScalingLevel = function () {
  34906. return 1.0;
  34907. };
  34908. NullEngine.prototype.createVertexBuffer = function (vertices) {
  34909. return {
  34910. capacity: 0,
  34911. references: 1,
  34912. is32Bits: false
  34913. };
  34914. };
  34915. NullEngine.prototype.createIndexBuffer = function (indices) {
  34916. return {
  34917. capacity: 0,
  34918. references: 1,
  34919. is32Bits: false
  34920. };
  34921. };
  34922. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34923. if (stencil === void 0) { stencil = false; }
  34924. };
  34925. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34926. if (useScreen === void 0) { useScreen = false; }
  34927. if (!useScreen && this._currentRenderTarget) {
  34928. return this._currentRenderTarget.width;
  34929. }
  34930. return this._options.renderWidth;
  34931. };
  34932. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34933. if (useScreen === void 0) { useScreen = false; }
  34934. if (!useScreen && this._currentRenderTarget) {
  34935. return this._currentRenderTarget.height;
  34936. }
  34937. return this._options.renderHeight;
  34938. };
  34939. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34940. this._cachedViewport = viewport;
  34941. };
  34942. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34943. return {
  34944. transformFeedback: null,
  34945. __SPECTOR_rebuildProgram: null,
  34946. isParallelCompiled: false
  34947. };
  34948. };
  34949. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34950. return [];
  34951. };
  34952. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34953. return [];
  34954. };
  34955. NullEngine.prototype.bindSamplers = function (effect) {
  34956. this._currentEffect = null;
  34957. };
  34958. NullEngine.prototype.enableEffect = function (effect) {
  34959. this._currentEffect = effect;
  34960. if (effect.onBind) {
  34961. effect.onBind(effect);
  34962. }
  34963. if (effect._onBindObservable) {
  34964. effect._onBindObservable.notifyObservers(effect);
  34965. }
  34966. };
  34967. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34968. if (zOffset === void 0) { zOffset = 0; }
  34969. if (reverseSide === void 0) { reverseSide = false; }
  34970. };
  34971. NullEngine.prototype.setIntArray = function (uniform, array) {
  34972. };
  34973. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34974. };
  34975. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34976. };
  34977. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34978. };
  34979. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34980. };
  34981. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34982. };
  34983. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34984. };
  34985. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34986. };
  34987. NullEngine.prototype.setArray = function (uniform, array) {
  34988. };
  34989. NullEngine.prototype.setArray2 = function (uniform, array) {
  34990. };
  34991. NullEngine.prototype.setArray3 = function (uniform, array) {
  34992. };
  34993. NullEngine.prototype.setArray4 = function (uniform, array) {
  34994. };
  34995. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34996. };
  34997. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34998. };
  34999. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  35000. };
  35001. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  35002. };
  35003. NullEngine.prototype.setFloat = function (uniform, value) {
  35004. };
  35005. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  35006. };
  35007. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  35008. };
  35009. NullEngine.prototype.setBool = function (uniform, bool) {
  35010. };
  35011. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  35012. };
  35013. NullEngine.prototype.setColor3 = function (uniform, color3) {
  35014. };
  35015. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  35016. };
  35017. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  35018. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  35019. if (this._alphaMode === mode) {
  35020. return;
  35021. }
  35022. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  35023. if (!noDepthWriteChange) {
  35024. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  35025. }
  35026. this._alphaMode = mode;
  35027. };
  35028. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  35029. };
  35030. NullEngine.prototype.wipeCaches = function (bruteForce) {
  35031. if (this.preventCacheWipeBetweenFrames) {
  35032. return;
  35033. }
  35034. this.resetTextureCache();
  35035. this._currentEffect = null;
  35036. if (bruteForce) {
  35037. this._currentProgram = null;
  35038. this._stencilState.reset();
  35039. this._depthCullingState.reset();
  35040. this._alphaState.reset();
  35041. }
  35042. this._cachedVertexBuffers = null;
  35043. this._cachedIndexBuffer = null;
  35044. this._cachedEffectForVertexBuffers = null;
  35045. };
  35046. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  35047. };
  35048. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  35049. };
  35050. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  35051. };
  35052. /** @hidden */
  35053. NullEngine.prototype._createTexture = function () {
  35054. return {};
  35055. };
  35056. /** @hidden */
  35057. NullEngine.prototype._releaseTexture = function (texture) {
  35058. };
  35059. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  35060. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  35061. if (onLoad === void 0) { onLoad = null; }
  35062. if (onError === void 0) { onError = null; }
  35063. if (buffer === void 0) { buffer = null; }
  35064. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  35065. var url = String(urlArg);
  35066. texture.url = url;
  35067. texture.generateMipMaps = !noMipmap;
  35068. texture.samplingMode = samplingMode;
  35069. texture.invertY = invertY;
  35070. texture.baseWidth = this._options.textureSize;
  35071. texture.baseHeight = this._options.textureSize;
  35072. texture.width = this._options.textureSize;
  35073. texture.height = this._options.textureSize;
  35074. if (format) {
  35075. texture.format = format;
  35076. }
  35077. texture.isReady = true;
  35078. if (onLoad) {
  35079. onLoad();
  35080. }
  35081. this._internalTexturesCache.push(texture);
  35082. return texture;
  35083. };
  35084. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  35085. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  35086. if (options !== undefined && typeof options === "object") {
  35087. fullOptions.generateMipMaps = options.generateMipMaps;
  35088. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  35089. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  35090. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  35091. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  35092. }
  35093. else {
  35094. fullOptions.generateMipMaps = options;
  35095. fullOptions.generateDepthBuffer = true;
  35096. fullOptions.generateStencilBuffer = false;
  35097. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  35098. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  35099. }
  35100. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  35101. var width = size.width || size;
  35102. var height = size.height || size;
  35103. texture._depthStencilBuffer = {};
  35104. texture._framebuffer = {};
  35105. texture.baseWidth = width;
  35106. texture.baseHeight = height;
  35107. texture.width = width;
  35108. texture.height = height;
  35109. texture.isReady = true;
  35110. texture.samples = 1;
  35111. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  35112. texture.samplingMode = fullOptions.samplingMode;
  35113. texture.type = fullOptions.type;
  35114. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  35115. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  35116. this._internalTexturesCache.push(texture);
  35117. return texture;
  35118. };
  35119. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  35120. texture.samplingMode = samplingMode;
  35121. };
  35122. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  35123. if (this._currentRenderTarget) {
  35124. this.unBindFramebuffer(this._currentRenderTarget);
  35125. }
  35126. this._currentRenderTarget = texture;
  35127. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  35128. if (this._cachedViewport && !forceFullscreenViewport) {
  35129. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  35130. }
  35131. };
  35132. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  35133. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  35134. this._currentRenderTarget = null;
  35135. if (onBeforeUnbind) {
  35136. if (texture._MSAAFramebuffer) {
  35137. this._currentFramebuffer = texture._framebuffer;
  35138. }
  35139. onBeforeUnbind();
  35140. }
  35141. this._currentFramebuffer = null;
  35142. };
  35143. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  35144. var vbo = {
  35145. capacity: 1,
  35146. references: 1,
  35147. is32Bits: false
  35148. };
  35149. return vbo;
  35150. };
  35151. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  35152. if (premulAlpha === void 0) { premulAlpha = false; }
  35153. };
  35154. NullEngine.prototype.areAllEffectsReady = function () {
  35155. return true;
  35156. };
  35157. /**
  35158. * @hidden
  35159. * Get the current error code of the webGL context
  35160. * @returns the error code
  35161. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35162. */
  35163. NullEngine.prototype.getError = function () {
  35164. return 0;
  35165. };
  35166. /** @hidden */
  35167. NullEngine.prototype._getUnpackAlignement = function () {
  35168. return 1;
  35169. };
  35170. /** @hidden */
  35171. NullEngine.prototype._unpackFlipY = function (value) {
  35172. };
  35173. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  35174. if (offset === void 0) { offset = 0; }
  35175. };
  35176. /**
  35177. * Updates a dynamic vertex buffer.
  35178. * @param vertexBuffer the vertex buffer to update
  35179. * @param data the data used to update the vertex buffer
  35180. * @param byteOffset the byte offset of the data (optional)
  35181. * @param byteLength the byte length of the data (optional)
  35182. */
  35183. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  35184. };
  35185. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  35186. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  35187. this._boundTexturesCache[this._activeChannel] = texture;
  35188. return true;
  35189. }
  35190. return false;
  35191. };
  35192. /** @hidden */
  35193. NullEngine.prototype._bindTexture = function (channel, texture) {
  35194. if (channel < 0) {
  35195. return;
  35196. }
  35197. this._bindTextureDirectly(0, texture);
  35198. };
  35199. /** @hidden */
  35200. NullEngine.prototype._releaseBuffer = function (buffer) {
  35201. buffer.references--;
  35202. if (buffer.references === 0) {
  35203. return true;
  35204. }
  35205. return false;
  35206. };
  35207. NullEngine.prototype.releaseEffects = function () {
  35208. };
  35209. NullEngine.prototype.displayLoadingUI = function () {
  35210. };
  35211. NullEngine.prototype.hideLoadingUI = function () {
  35212. };
  35213. /** @hidden */
  35214. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  35215. if (faceIndex === void 0) { faceIndex = 0; }
  35216. if (lod === void 0) { lod = 0; }
  35217. };
  35218. /** @hidden */
  35219. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  35220. if (faceIndex === void 0) { faceIndex = 0; }
  35221. if (lod === void 0) { lod = 0; }
  35222. };
  35223. /** @hidden */
  35224. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  35225. if (faceIndex === void 0) { faceIndex = 0; }
  35226. if (lod === void 0) { lod = 0; }
  35227. };
  35228. /** @hidden */
  35229. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  35230. if (faceIndex === void 0) { faceIndex = 0; }
  35231. if (lod === void 0) { lod = 0; }
  35232. };
  35233. return NullEngine;
  35234. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  35235. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  35236. /***/ }),
  35237. /***/ "./Events/clipboardEvents.ts":
  35238. /*!***********************************!*\
  35239. !*** ./Events/clipboardEvents.ts ***!
  35240. \***********************************/
  35241. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  35242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35243. "use strict";
  35244. __webpack_require__.r(__webpack_exports__);
  35245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  35246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  35247. /**
  35248. * Gather the list of clipboard event types as constants.
  35249. */
  35250. var ClipboardEventTypes = /** @class */ (function () {
  35251. function ClipboardEventTypes() {
  35252. }
  35253. /**
  35254. * The clipboard event is fired when a copy command is active (pressed).
  35255. */
  35256. ClipboardEventTypes.COPY = 0x01; //
  35257. /**
  35258. * The clipboard event is fired when a cut command is active (pressed).
  35259. */
  35260. ClipboardEventTypes.CUT = 0x02;
  35261. /**
  35262. * The clipboard event is fired when a paste command is active (pressed).
  35263. */
  35264. ClipboardEventTypes.PASTE = 0x03;
  35265. return ClipboardEventTypes;
  35266. }());
  35267. /**
  35268. * This class is used to store clipboard related info for the onClipboardObservable event.
  35269. */
  35270. var ClipboardInfo = /** @class */ (function () {
  35271. /**
  35272. *Creates an instance of ClipboardInfo.
  35273. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  35274. * @param event Defines the related dom event
  35275. */
  35276. function ClipboardInfo(
  35277. /**
  35278. * Defines the type of event (BABYLON.ClipboardEventTypes)
  35279. */
  35280. type,
  35281. /**
  35282. * Defines the related dom event
  35283. */
  35284. event) {
  35285. this.type = type;
  35286. this.event = event;
  35287. }
  35288. /**
  35289. * Get the clipboard event's type from the keycode.
  35290. * @param keyCode Defines the keyCode for the current keyboard event.
  35291. * @return {number}
  35292. */
  35293. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  35294. var charCode = keyCode;
  35295. //TODO: add codes for extended ASCII
  35296. switch (charCode) {
  35297. case 67: return ClipboardEventTypes.COPY;
  35298. case 86: return ClipboardEventTypes.PASTE;
  35299. case 88: return ClipboardEventTypes.CUT;
  35300. default: return -1;
  35301. }
  35302. };
  35303. return ClipboardInfo;
  35304. }());
  35305. /***/ }),
  35306. /***/ "./Events/index.ts":
  35307. /*!*************************!*\
  35308. !*** ./Events/index.ts ***!
  35309. \*************************/
  35310. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  35311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35312. "use strict";
  35313. __webpack_require__.r(__webpack_exports__);
  35314. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  35315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  35316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  35317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  35318. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  35319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  35320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  35321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  35322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  35323. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  35324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  35325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  35326. /***/ }),
  35327. /***/ "./Events/keyboardEvents.ts":
  35328. /*!**********************************!*\
  35329. !*** ./Events/keyboardEvents.ts ***!
  35330. \**********************************/
  35331. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  35332. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35333. "use strict";
  35334. __webpack_require__.r(__webpack_exports__);
  35335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  35336. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  35337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  35338. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35339. /**
  35340. * Gather the list of keyboard event types as constants.
  35341. */
  35342. var KeyboardEventTypes = /** @class */ (function () {
  35343. function KeyboardEventTypes() {
  35344. }
  35345. /**
  35346. * The keydown event is fired when a key becomes active (pressed).
  35347. */
  35348. KeyboardEventTypes.KEYDOWN = 0x01;
  35349. /**
  35350. * The keyup event is fired when a key has been released.
  35351. */
  35352. KeyboardEventTypes.KEYUP = 0x02;
  35353. return KeyboardEventTypes;
  35354. }());
  35355. /**
  35356. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35357. */
  35358. var KeyboardInfo = /** @class */ (function () {
  35359. /**
  35360. * Instantiates a new keyboard info.
  35361. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35362. * @param type Defines the type of event (KeyboardEventTypes)
  35363. * @param event Defines the related dom event
  35364. */
  35365. function KeyboardInfo(
  35366. /**
  35367. * Defines the type of event (KeyboardEventTypes)
  35368. */
  35369. type,
  35370. /**
  35371. * Defines the related dom event
  35372. */
  35373. event) {
  35374. this.type = type;
  35375. this.event = event;
  35376. }
  35377. return KeyboardInfo;
  35378. }());
  35379. /**
  35380. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35381. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  35382. */
  35383. var KeyboardInfoPre = /** @class */ (function (_super) {
  35384. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  35385. /**
  35386. * Instantiates a new keyboard pre info.
  35387. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35388. * @param type Defines the type of event (KeyboardEventTypes)
  35389. * @param event Defines the related dom event
  35390. */
  35391. function KeyboardInfoPre(
  35392. /**
  35393. * Defines the type of event (KeyboardEventTypes)
  35394. */
  35395. type,
  35396. /**
  35397. * Defines the related dom event
  35398. */
  35399. event) {
  35400. var _this = _super.call(this, type, event) || this;
  35401. _this.type = type;
  35402. _this.event = event;
  35403. _this.skipOnPointerObservable = false;
  35404. return _this;
  35405. }
  35406. return KeyboardInfoPre;
  35407. }(KeyboardInfo));
  35408. /***/ }),
  35409. /***/ "./Events/pointerEvents.ts":
  35410. /*!*********************************!*\
  35411. !*** ./Events/pointerEvents.ts ***!
  35412. \*********************************/
  35413. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  35414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35415. "use strict";
  35416. __webpack_require__.r(__webpack_exports__);
  35417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  35418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  35419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  35420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  35421. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35422. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  35423. /**
  35424. * Gather the list of pointer event types as constants.
  35425. */
  35426. var PointerEventTypes = /** @class */ (function () {
  35427. function PointerEventTypes() {
  35428. }
  35429. /**
  35430. * 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.
  35431. */
  35432. PointerEventTypes.POINTERDOWN = 0x01;
  35433. /**
  35434. * The pointerup event is fired when a pointer is no longer active.
  35435. */
  35436. PointerEventTypes.POINTERUP = 0x02;
  35437. /**
  35438. * The pointermove event is fired when a pointer changes coordinates.
  35439. */
  35440. PointerEventTypes.POINTERMOVE = 0x04;
  35441. /**
  35442. * The pointerwheel event is fired when a mouse wheel has been rotated.
  35443. */
  35444. PointerEventTypes.POINTERWHEEL = 0x08;
  35445. /**
  35446. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  35447. */
  35448. PointerEventTypes.POINTERPICK = 0x10;
  35449. /**
  35450. * The pointertap event is fired when a the object has been touched and released without drag.
  35451. */
  35452. PointerEventTypes.POINTERTAP = 0x20;
  35453. /**
  35454. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  35455. */
  35456. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  35457. return PointerEventTypes;
  35458. }());
  35459. /**
  35460. * Base class of pointer info types.
  35461. */
  35462. var PointerInfoBase = /** @class */ (function () {
  35463. /**
  35464. * Instantiates the base class of pointers info.
  35465. * @param type Defines the type of event (PointerEventTypes)
  35466. * @param event Defines the related dom event
  35467. */
  35468. function PointerInfoBase(
  35469. /**
  35470. * Defines the type of event (PointerEventTypes)
  35471. */
  35472. type,
  35473. /**
  35474. * Defines the related dom event
  35475. */
  35476. event) {
  35477. this.type = type;
  35478. this.event = event;
  35479. }
  35480. return PointerInfoBase;
  35481. }());
  35482. /**
  35483. * This class is used to store pointer related info for the onPrePointerObservable event.
  35484. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  35485. */
  35486. var PointerInfoPre = /** @class */ (function (_super) {
  35487. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  35488. /**
  35489. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  35490. * @param type Defines the type of event (PointerEventTypes)
  35491. * @param event Defines the related dom event
  35492. * @param localX Defines the local x coordinates of the pointer when the event occured
  35493. * @param localY Defines the local y coordinates of the pointer when the event occured
  35494. */
  35495. function PointerInfoPre(type, event, localX, localY) {
  35496. var _this = _super.call(this, type, event) || this;
  35497. /**
  35498. * Ray from a pointer if availible (eg. 6dof controller)
  35499. */
  35500. _this.ray = null;
  35501. _this.skipOnPointerObservable = false;
  35502. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  35503. return _this;
  35504. }
  35505. return PointerInfoPre;
  35506. }(PointerInfoBase));
  35507. /**
  35508. * This type contains all the data related to a pointer event in Babylon.js.
  35509. * 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.
  35510. */
  35511. var PointerInfo = /** @class */ (function (_super) {
  35512. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  35513. /**
  35514. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  35515. * @param type Defines the type of event (PointerEventTypes)
  35516. * @param event Defines the related dom event
  35517. * @param pickInfo Defines the picking info associated to the info (if any)\
  35518. */
  35519. function PointerInfo(type, event,
  35520. /**
  35521. * Defines the picking info associated to the info (if any)\
  35522. */
  35523. pickInfo) {
  35524. var _this = _super.call(this, type, event) || this;
  35525. _this.pickInfo = pickInfo;
  35526. return _this;
  35527. }
  35528. return PointerInfo;
  35529. }(PointerInfoBase));
  35530. /***/ }),
  35531. /***/ "./Gamepads/Controllers/daydreamController.ts":
  35532. /*!****************************************************!*\
  35533. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  35534. \****************************************************/
  35535. /*! exports provided: DaydreamController */
  35536. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35537. "use strict";
  35538. __webpack_require__.r(__webpack_exports__);
  35539. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  35540. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35541. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35542. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35543. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35544. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35545. /**
  35546. * Google Daydream controller
  35547. */
  35548. var DaydreamController = /** @class */ (function (_super) {
  35549. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  35550. /**
  35551. * Creates a new DaydreamController from a gamepad
  35552. * @param vrGamepad the gamepad that the controller should be created from
  35553. */
  35554. function DaydreamController(vrGamepad) {
  35555. var _this = _super.call(this, vrGamepad) || this;
  35556. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  35557. return _this;
  35558. }
  35559. /**
  35560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35561. * @param scene scene in which to add meshes
  35562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35563. */
  35564. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35565. var _this = this;
  35566. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  35567. _this._defaultModel = newMeshes[1];
  35568. _this.attachToMesh(_this._defaultModel);
  35569. if (meshLoaded) {
  35570. meshLoaded(_this._defaultModel);
  35571. }
  35572. });
  35573. };
  35574. /**
  35575. * Called once for each button that changed state since the last frame
  35576. * @param buttonIdx Which button index changed
  35577. * @param state New state of the button
  35578. * @param changes Which properties on the state changed since last frame
  35579. */
  35580. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35581. // Daydream controller only has 1 GamepadButton (on the trackpad).
  35582. if (buttonIdx === 0) {
  35583. var observable = this.onTriggerStateChangedObservable;
  35584. if (observable) {
  35585. observable.notifyObservers(state);
  35586. }
  35587. }
  35588. else {
  35589. // If the app or home buttons are ever made available
  35590. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  35591. }
  35592. };
  35593. /**
  35594. * Base Url for the controller model.
  35595. */
  35596. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35597. /**
  35598. * File name for the controller model.
  35599. */
  35600. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  35601. /**
  35602. * Gamepad Id prefix used to identify Daydream Controller.
  35603. */
  35604. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  35605. return DaydreamController;
  35606. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35607. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35608. canCreate: function (gamepadInfo) {
  35609. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  35610. },
  35611. create: function (gamepadInfo) {
  35612. return new DaydreamController(gamepadInfo);
  35613. }
  35614. });
  35615. /***/ }),
  35616. /***/ "./Gamepads/Controllers/gearVRController.ts":
  35617. /*!**************************************************!*\
  35618. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  35619. \**************************************************/
  35620. /*! exports provided: GearVRController */
  35621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35622. "use strict";
  35623. __webpack_require__.r(__webpack_exports__);
  35624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  35625. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35626. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35627. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35628. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35629. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35630. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35631. /**
  35632. * Gear VR Controller
  35633. */
  35634. var GearVRController = /** @class */ (function (_super) {
  35635. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  35636. /**
  35637. * Creates a new GearVRController from a gamepad
  35638. * @param vrGamepad the gamepad that the controller should be created from
  35639. */
  35640. function GearVRController(vrGamepad) {
  35641. var _this = _super.call(this, vrGamepad) || this;
  35642. _this._buttonIndexToObservableNameMap = [
  35643. 'onPadStateChangedObservable',
  35644. 'onTriggerStateChangedObservable' // Trigger
  35645. ];
  35646. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  35647. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  35648. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  35649. _this._disableTrackPosition(_this._calculatedPosition);
  35650. return _this;
  35651. }
  35652. /**
  35653. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35654. * @param scene scene in which to add meshes
  35655. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35656. */
  35657. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35658. var _this = this;
  35659. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  35660. // Offset the controller so it will rotate around the users wrist
  35661. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  35662. newMeshes[1].parent = mesh;
  35663. newMeshes[1].position.z = -0.15;
  35664. _this._defaultModel = mesh;
  35665. _this.attachToMesh(_this._defaultModel);
  35666. if (meshLoaded) {
  35667. meshLoaded(_this._defaultModel);
  35668. }
  35669. });
  35670. };
  35671. /**
  35672. * Called once for each button that changed state since the last frame
  35673. * @param buttonIdx Which button index changed
  35674. * @param state New state of the button
  35675. * @param changes Which properties on the state changed since last frame
  35676. */
  35677. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35678. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  35679. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  35680. // Only emit events for buttons that we know how to map from index to observable
  35681. var observable = this[observableName];
  35682. if (observable) {
  35683. observable.notifyObservers(state);
  35684. }
  35685. }
  35686. };
  35687. /**
  35688. * Base Url for the controller model.
  35689. */
  35690. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35691. /**
  35692. * File name for the controller model.
  35693. */
  35694. GearVRController.MODEL_FILENAME = 'generic.babylon';
  35695. /**
  35696. * Gamepad Id prefix used to identify this controller.
  35697. */
  35698. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  35699. return GearVRController;
  35700. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  35701. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35702. canCreate: function (gamepadInfo) {
  35703. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  35704. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  35705. },
  35706. create: function (gamepadInfo) {
  35707. return new GearVRController(gamepadInfo);
  35708. }
  35709. });
  35710. /***/ }),
  35711. /***/ "./Gamepads/Controllers/genericController.ts":
  35712. /*!***************************************************!*\
  35713. !*** ./Gamepads/Controllers/genericController.ts ***!
  35714. \***************************************************/
  35715. /*! exports provided: GenericController */
  35716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35717. "use strict";
  35718. __webpack_require__.r(__webpack_exports__);
  35719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  35720. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35721. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35722. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35723. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35724. /**
  35725. * Generic Controller
  35726. */
  35727. var GenericController = /** @class */ (function (_super) {
  35728. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  35729. /**
  35730. * Creates a new GenericController from a gamepad
  35731. * @param vrGamepad the gamepad that the controller should be created from
  35732. */
  35733. function GenericController(vrGamepad) {
  35734. return _super.call(this, vrGamepad) || this;
  35735. }
  35736. /**
  35737. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35738. * @param scene scene in which to add meshes
  35739. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35740. */
  35741. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35742. var _this = this;
  35743. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  35744. _this._defaultModel = newMeshes[1];
  35745. _this.attachToMesh(_this._defaultModel);
  35746. if (meshLoaded) {
  35747. meshLoaded(_this._defaultModel);
  35748. }
  35749. });
  35750. };
  35751. /**
  35752. * Called once for each button that changed state since the last frame
  35753. * @param buttonIdx Which button index changed
  35754. * @param state New state of the button
  35755. * @param changes Which properties on the state changed since last frame
  35756. */
  35757. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35758. console.log("Button id: " + buttonIdx + "state: ");
  35759. console.dir(state);
  35760. };
  35761. /**
  35762. * Base Url for the controller model.
  35763. */
  35764. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35765. /**
  35766. * File name for the controller model.
  35767. */
  35768. GenericController.MODEL_FILENAME = 'generic.babylon';
  35769. return GenericController;
  35770. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35771. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  35772. /***/ }),
  35773. /***/ "./Gamepads/Controllers/index.ts":
  35774. /*!***************************************!*\
  35775. !*** ./Gamepads/Controllers/index.ts ***!
  35776. \***************************************/
  35777. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  35778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35779. "use strict";
  35780. __webpack_require__.r(__webpack_exports__);
  35781. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  35782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35783. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  35784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  35785. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  35787. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  35788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  35789. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  35791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  35792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  35793. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  35794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  35795. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  35797. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  35798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  35799. /***/ }),
  35800. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  35801. /*!*******************************************************!*\
  35802. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  35803. \*******************************************************/
  35804. /*! exports provided: OculusTouchController */
  35805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35806. "use strict";
  35807. __webpack_require__.r(__webpack_exports__);
  35808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  35809. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35810. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35811. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35812. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35813. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35814. /**
  35815. * Oculus Touch Controller
  35816. */
  35817. var OculusTouchController = /** @class */ (function (_super) {
  35818. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  35819. /**
  35820. * Creates a new OculusTouchController from a gamepad
  35821. * @param vrGamepad the gamepad that the controller should be created from
  35822. */
  35823. function OculusTouchController(vrGamepad) {
  35824. var _this = _super.call(this, vrGamepad) || this;
  35825. /**
  35826. * Fired when the secondary trigger on this controller is modified
  35827. */
  35828. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35829. /**
  35830. * Fired when the thumb rest on this controller is modified
  35831. */
  35832. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35833. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  35834. return _this;
  35835. }
  35836. /**
  35837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35838. * @param scene scene in which to add meshes
  35839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35840. */
  35841. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35842. var _this = this;
  35843. var meshName;
  35844. // Hand
  35845. if (this.hand === 'left') {
  35846. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  35847. }
  35848. else { // Right is the default if no hand is specified
  35849. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  35850. }
  35851. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  35852. /*
  35853. Parent Mesh name: oculus_touch_left
  35854. - body
  35855. - trigger
  35856. - thumbstick
  35857. - grip
  35858. - button_y
  35859. - button_x
  35860. - button_enter
  35861. */
  35862. _this._defaultModel = newMeshes[1];
  35863. _this.attachToMesh(_this._defaultModel);
  35864. if (meshLoaded) {
  35865. meshLoaded(_this._defaultModel);
  35866. }
  35867. });
  35868. };
  35869. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  35870. /**
  35871. * Fired when the A button on this controller is modified
  35872. */
  35873. get: function () {
  35874. if (this.hand === 'right') {
  35875. return this.onMainButtonStateChangedObservable;
  35876. }
  35877. else {
  35878. throw new Error('No A button on left hand');
  35879. }
  35880. },
  35881. enumerable: true,
  35882. configurable: true
  35883. });
  35884. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  35885. /**
  35886. * Fired when the B button on this controller is modified
  35887. */
  35888. get: function () {
  35889. if (this.hand === 'right') {
  35890. return this.onSecondaryButtonStateChangedObservable;
  35891. }
  35892. else {
  35893. throw new Error('No B button on left hand');
  35894. }
  35895. },
  35896. enumerable: true,
  35897. configurable: true
  35898. });
  35899. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  35900. /**
  35901. * Fired when the X button on this controller is modified
  35902. */
  35903. get: function () {
  35904. if (this.hand === 'left') {
  35905. return this.onMainButtonStateChangedObservable;
  35906. }
  35907. else {
  35908. throw new Error('No X button on right hand');
  35909. }
  35910. },
  35911. enumerable: true,
  35912. configurable: true
  35913. });
  35914. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  35915. /**
  35916. * Fired when the Y button on this controller is modified
  35917. */
  35918. get: function () {
  35919. if (this.hand === 'left') {
  35920. return this.onSecondaryButtonStateChangedObservable;
  35921. }
  35922. else {
  35923. throw new Error('No Y button on right hand');
  35924. }
  35925. },
  35926. enumerable: true,
  35927. configurable: true
  35928. });
  35929. /**
  35930. * Called once for each button that changed state since the last frame
  35931. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35932. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35933. * 2) secondary trigger (same)
  35934. * 3) A (right) X (left), touch, pressed = value
  35935. * 4) B / Y
  35936. * 5) thumb rest
  35937. * @param buttonIdx Which button index changed
  35938. * @param state New state of the button
  35939. * @param changes Which properties on the state changed since last frame
  35940. */
  35941. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35942. var notifyObject = state; //{ state: state, changes: changes };
  35943. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35944. switch (buttonIdx) {
  35945. case 0:
  35946. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35947. return;
  35948. case 1: // index trigger
  35949. if (this._defaultModel) {
  35950. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35951. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35952. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35953. }
  35954. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35955. return;
  35956. case 2: // secondary trigger
  35957. if (this._defaultModel) {
  35958. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35959. }
  35960. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35961. return;
  35962. case 3:
  35963. if (this._defaultModel) {
  35964. if (notifyObject.pressed) {
  35965. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35966. }
  35967. else {
  35968. (this._defaultModel.getChildren()[1]).position.y = 0;
  35969. }
  35970. }
  35971. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35972. return;
  35973. case 4:
  35974. if (this._defaultModel) {
  35975. if (notifyObject.pressed) {
  35976. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35977. }
  35978. else {
  35979. (this._defaultModel.getChildren()[2]).position.y = 0;
  35980. }
  35981. }
  35982. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35983. return;
  35984. case 5:
  35985. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35986. return;
  35987. }
  35988. };
  35989. /**
  35990. * Base Url for the controller model.
  35991. */
  35992. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35993. /**
  35994. * File name for the left controller model.
  35995. */
  35996. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35997. /**
  35998. * File name for the right controller model.
  35999. */
  36000. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  36001. return OculusTouchController;
  36002. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  36003. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36004. canCreate: function (gamepadInfo) {
  36005. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  36006. },
  36007. create: function (gamepadInfo) {
  36008. return new OculusTouchController(gamepadInfo);
  36009. }
  36010. });
  36011. /***/ }),
  36012. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  36013. /*!*******************************************************!*\
  36014. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  36015. \*******************************************************/
  36016. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  36017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36018. "use strict";
  36019. __webpack_require__.r(__webpack_exports__);
  36020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  36021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  36022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  36023. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36024. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36025. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36026. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36027. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  36028. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36029. /**
  36030. * Defines the types of pose enabled controllers that are supported
  36031. */
  36032. var PoseEnabledControllerType;
  36033. (function (PoseEnabledControllerType) {
  36034. /**
  36035. * HTC Vive
  36036. */
  36037. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  36038. /**
  36039. * Oculus Rift
  36040. */
  36041. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  36042. /**
  36043. * Windows mixed reality
  36044. */
  36045. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  36046. /**
  36047. * Samsung gear VR
  36048. */
  36049. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  36050. /**
  36051. * Google Daydream
  36052. */
  36053. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  36054. /**
  36055. * Generic
  36056. */
  36057. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  36058. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  36059. /**
  36060. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36061. */
  36062. var PoseEnabledControllerHelper = /** @class */ (function () {
  36063. function PoseEnabledControllerHelper() {
  36064. }
  36065. /**
  36066. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36067. * @param vrGamepad the gamepad to initialized
  36068. * @returns a vr controller of the type the gamepad identified as
  36069. */
  36070. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  36071. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  36072. var factory = _a[_i];
  36073. if (factory.canCreate(vrGamepad)) {
  36074. return factory.create(vrGamepad);
  36075. }
  36076. }
  36077. if (this._DefaultControllerFactory) {
  36078. return this._DefaultControllerFactory(vrGamepad);
  36079. }
  36080. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  36081. };
  36082. /** @hidden */
  36083. PoseEnabledControllerHelper._ControllerFactories = [];
  36084. /** @hidden */
  36085. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  36086. return PoseEnabledControllerHelper;
  36087. }());
  36088. /**
  36089. * Defines the PoseEnabledController object that contains state of a vr capable controller
  36090. */
  36091. var PoseEnabledController = /** @class */ (function (_super) {
  36092. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  36093. /**
  36094. * Creates a new PoseEnabledController from a gamepad
  36095. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  36096. */
  36097. function PoseEnabledController(browserGamepad) {
  36098. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  36099. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  36100. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36101. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36102. /**
  36103. * The device position in babylon space
  36104. */
  36105. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36106. /**
  36107. * The device rotation in babylon space
  36108. */
  36109. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36110. /**
  36111. * The scale factor of the device in babylon space
  36112. */
  36113. _this.deviceScaleFactor = 1;
  36114. // Used to convert 6dof controllers to 3dof
  36115. _this._trackPosition = true;
  36116. _this._maxRotationDistFromHeadset = Math.PI / 5;
  36117. _this._draggedRoomRotation = 0;
  36118. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36119. /**
  36120. * Internal, matrix used to convert room space to babylon space
  36121. * @hidden
  36122. */
  36123. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36124. /**
  36125. * Node to be used when casting a ray from the controller
  36126. * @hidden
  36127. */
  36128. _this._pointingPoseNode = null;
  36129. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36130. /**
  36131. * @hidden
  36132. */
  36133. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36134. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  36135. _this.controllerType = PoseEnabledControllerType.GENERIC;
  36136. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36137. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36138. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36139. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36140. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  36141. return _this;
  36142. }
  36143. /**
  36144. * @hidden
  36145. */
  36146. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  36147. if (this._trackPosition) {
  36148. this._calculatedPosition.copyFrom(fixedPosition);
  36149. this._trackPosition = false;
  36150. }
  36151. };
  36152. /**
  36153. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  36154. */
  36155. PoseEnabledController.prototype.update = function () {
  36156. _super.prototype.update.call(this);
  36157. this._updatePoseAndMesh();
  36158. };
  36159. /**
  36160. * Updates only the pose device and mesh without doing any button event checking
  36161. */
  36162. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  36163. var pose = this.browserGamepad.pose;
  36164. this.updateFromDevice(pose);
  36165. 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) {
  36166. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  36167. camera._computeDevicePosition();
  36168. this._deviceToWorld.setTranslation(camera.devicePosition);
  36169. if (camera.deviceRotationQuaternion) {
  36170. var camera = camera;
  36171. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  36172. // Find the radian distance away that the headset is from the controllers rotation
  36173. 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));
  36174. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  36175. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  36176. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  36177. this._draggedRoomRotation += rotationAmount;
  36178. // Rotate controller around headset
  36179. var sin = Math.sin(-rotationAmount);
  36180. var cos = Math.cos(-rotationAmount);
  36181. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  36182. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  36183. }
  36184. }
  36185. }
  36186. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  36187. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  36188. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  36189. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  36190. if (this._mesh) {
  36191. this._mesh.position.copyFrom(this.devicePosition);
  36192. if (this._mesh.rotationQuaternion) {
  36193. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  36194. }
  36195. }
  36196. };
  36197. /**
  36198. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  36199. * @param poseData raw pose fromthe device
  36200. */
  36201. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  36202. if (poseData) {
  36203. this.rawPose = poseData;
  36204. if (poseData.position) {
  36205. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  36206. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  36207. this._deviceRoomPosition.z *= -1;
  36208. }
  36209. if (this._trackPosition) {
  36210. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  36211. }
  36212. this._calculatedPosition.addInPlace(this.position);
  36213. }
  36214. var pose = this.rawPose;
  36215. if (poseData.orientation && pose.orientation) {
  36216. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  36217. if (this._mesh) {
  36218. if (this._mesh.getScene().useRightHandedSystem) {
  36219. this._deviceRoomRotationQuaternion.z *= -1;
  36220. this._deviceRoomRotationQuaternion.w *= -1;
  36221. }
  36222. else {
  36223. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  36224. }
  36225. }
  36226. // if the camera is set, rotate to the camera's rotation
  36227. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  36228. }
  36229. }
  36230. };
  36231. /**
  36232. * Attaches a mesh to the controller
  36233. * @param mesh the mesh to be attached
  36234. */
  36235. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  36236. if (this._mesh) {
  36237. this._mesh.parent = null;
  36238. }
  36239. this._mesh = mesh;
  36240. if (this._poseControlledCamera) {
  36241. this._mesh.parent = this._poseControlledCamera;
  36242. }
  36243. if (!this._mesh.rotationQuaternion) {
  36244. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36245. }
  36246. // 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
  36247. this._updatePoseAndMesh();
  36248. if (this._pointingPoseNode) {
  36249. var parents = [];
  36250. var obj = this._pointingPoseNode;
  36251. while (obj.parent) {
  36252. parents.push(obj.parent);
  36253. obj = obj.parent;
  36254. }
  36255. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  36256. }
  36257. this._meshAttachedObservable.notifyObservers(mesh);
  36258. };
  36259. /**
  36260. * Attaches the controllers mesh to a camera
  36261. * @param camera the camera the mesh should be attached to
  36262. */
  36263. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  36264. this._poseControlledCamera = camera;
  36265. if (this._mesh) {
  36266. this._mesh.parent = this._poseControlledCamera;
  36267. }
  36268. };
  36269. /**
  36270. * Disposes of the controller
  36271. */
  36272. PoseEnabledController.prototype.dispose = function () {
  36273. if (this._mesh) {
  36274. this._mesh.dispose();
  36275. }
  36276. this._mesh = null;
  36277. _super.prototype.dispose.call(this);
  36278. };
  36279. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  36280. /**
  36281. * The mesh that is attached to the controller
  36282. */
  36283. get: function () {
  36284. return this._mesh;
  36285. },
  36286. enumerable: true,
  36287. configurable: true
  36288. });
  36289. /**
  36290. * Gets the ray of the controller in the direction the controller is pointing
  36291. * @param length the length the resulting ray should be
  36292. * @returns a ray in the direction the controller is pointing
  36293. */
  36294. PoseEnabledController.prototype.getForwardRay = function (length) {
  36295. if (length === void 0) { length = 100; }
  36296. if (!this.mesh) {
  36297. 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);
  36298. }
  36299. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  36300. var origin = m.getTranslation();
  36301. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  36302. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  36303. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  36304. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  36305. };
  36306. /**
  36307. * Name of the child mesh that can be used to cast a ray from the controller
  36308. */
  36309. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  36310. return PoseEnabledController;
  36311. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  36312. /***/ }),
  36313. /***/ "./Gamepads/Controllers/viveController.ts":
  36314. /*!************************************************!*\
  36315. !*** ./Gamepads/Controllers/viveController.ts ***!
  36316. \************************************************/
  36317. /*! exports provided: ViveController */
  36318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36319. "use strict";
  36320. __webpack_require__.r(__webpack_exports__);
  36321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  36322. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36323. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36324. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36325. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36326. /**
  36327. * Vive Controller
  36328. */
  36329. var ViveController = /** @class */ (function (_super) {
  36330. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  36331. /**
  36332. * Creates a new ViveController from a gamepad
  36333. * @param vrGamepad the gamepad that the controller should be created from
  36334. */
  36335. function ViveController(vrGamepad) {
  36336. var _this = _super.call(this, vrGamepad) || this;
  36337. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  36338. _this._invertLeftStickY = true;
  36339. return _this;
  36340. }
  36341. /**
  36342. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36343. * @param scene scene in which to add meshes
  36344. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36345. */
  36346. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  36347. var _this = this;
  36348. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  36349. /*
  36350. Parent Mesh name: ViveWand
  36351. - body
  36352. - r_gripper
  36353. - l_gripper
  36354. - menu_button
  36355. - system_button
  36356. - trackpad
  36357. - trigger
  36358. - LED
  36359. */
  36360. _this._defaultModel = newMeshes[1];
  36361. _this.attachToMesh(_this._defaultModel);
  36362. if (meshLoaded) {
  36363. meshLoaded(_this._defaultModel);
  36364. }
  36365. });
  36366. };
  36367. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  36368. /**
  36369. * Fired when the left button on this controller is modified
  36370. */
  36371. get: function () {
  36372. return this.onMainButtonStateChangedObservable;
  36373. },
  36374. enumerable: true,
  36375. configurable: true
  36376. });
  36377. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  36378. /**
  36379. * Fired when the right button on this controller is modified
  36380. */
  36381. get: function () {
  36382. return this.onMainButtonStateChangedObservable;
  36383. },
  36384. enumerable: true,
  36385. configurable: true
  36386. });
  36387. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  36388. /**
  36389. * Fired when the menu button on this controller is modified
  36390. */
  36391. get: function () {
  36392. return this.onSecondaryButtonStateChangedObservable;
  36393. },
  36394. enumerable: true,
  36395. configurable: true
  36396. });
  36397. /**
  36398. * Called once for each button that changed state since the last frame
  36399. * Vive mapping:
  36400. * 0: touchpad
  36401. * 1: trigger
  36402. * 2: left AND right buttons
  36403. * 3: menu button
  36404. * @param buttonIdx Which button index changed
  36405. * @param state New state of the button
  36406. * @param changes Which properties on the state changed since last frame
  36407. */
  36408. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36409. var notifyObject = state; //{ state: state, changes: changes };
  36410. switch (buttonIdx) {
  36411. case 0:
  36412. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  36413. return;
  36414. case 1: // index trigger
  36415. if (this._defaultModel) {
  36416. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  36417. }
  36418. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  36419. return;
  36420. case 2: // left AND right button
  36421. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  36422. return;
  36423. case 3:
  36424. if (this._defaultModel) {
  36425. if (notifyObject.pressed) {
  36426. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36427. }
  36428. else {
  36429. (this._defaultModel.getChildren()[2]).position.y = 0;
  36430. }
  36431. }
  36432. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36433. return;
  36434. }
  36435. };
  36436. /**
  36437. * Base Url for the controller model.
  36438. */
  36439. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  36440. /**
  36441. * File name for the controller model.
  36442. */
  36443. ViveController.MODEL_FILENAME = 'wand.babylon';
  36444. return ViveController;
  36445. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  36446. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36447. canCreate: function (gamepadInfo) {
  36448. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  36449. },
  36450. create: function (gamepadInfo) {
  36451. return new ViveController(gamepadInfo);
  36452. }
  36453. });
  36454. /***/ }),
  36455. /***/ "./Gamepads/Controllers/webVRController.ts":
  36456. /*!*************************************************!*\
  36457. !*** ./Gamepads/Controllers/webVRController.ts ***!
  36458. \*************************************************/
  36459. /*! exports provided: WebVRController */
  36460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36461. "use strict";
  36462. __webpack_require__.r(__webpack_exports__);
  36463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  36464. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36465. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36466. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36467. /**
  36468. * Defines the WebVRController object that represents controllers tracked in 3D space
  36469. */
  36470. var WebVRController = /** @class */ (function (_super) {
  36471. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  36472. /**
  36473. * Creates a new WebVRController from a gamepad
  36474. * @param vrGamepad the gamepad that the WebVRController should be created from
  36475. */
  36476. function WebVRController(vrGamepad) {
  36477. var _this = _super.call(this, vrGamepad) || this;
  36478. // Observables
  36479. /**
  36480. * Fired when the trigger state has changed
  36481. */
  36482. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36483. /**
  36484. * Fired when the main button state has changed
  36485. */
  36486. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36487. /**
  36488. * Fired when the secondary button state has changed
  36489. */
  36490. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36491. /**
  36492. * Fired when the pad state has changed
  36493. */
  36494. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36495. /**
  36496. * Fired when controllers stick values have changed
  36497. */
  36498. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36499. /**
  36500. * X and Y axis corrisponding to the controllers joystick
  36501. */
  36502. _this.pad = { x: 0, y: 0 };
  36503. // avoid GC, store state in a tmp object
  36504. _this._changes = {
  36505. pressChanged: false,
  36506. touchChanged: false,
  36507. valueChanged: false,
  36508. changed: false
  36509. };
  36510. _this._buttons = new Array(vrGamepad.buttons.length);
  36511. _this.hand = vrGamepad.hand;
  36512. return _this;
  36513. }
  36514. /**
  36515. * Fired when a controller button's state has changed
  36516. * @param callback the callback containing the button that was modified
  36517. */
  36518. WebVRController.prototype.onButtonStateChange = function (callback) {
  36519. this._onButtonStateChange = callback;
  36520. };
  36521. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  36522. /**
  36523. * The default controller model for the controller
  36524. */
  36525. get: function () {
  36526. return this._defaultModel;
  36527. },
  36528. enumerable: true,
  36529. configurable: true
  36530. });
  36531. /**
  36532. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  36533. */
  36534. WebVRController.prototype.update = function () {
  36535. _super.prototype.update.call(this);
  36536. for (var index = 0; index < this._buttons.length; index++) {
  36537. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  36538. }
  36539. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  36540. this.pad.x = this.leftStick.x;
  36541. this.pad.y = this.leftStick.y;
  36542. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  36543. }
  36544. };
  36545. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  36546. if (!newState) {
  36547. newState = {
  36548. pressed: false,
  36549. touched: false,
  36550. value: 0
  36551. };
  36552. }
  36553. if (!currentState) {
  36554. this._buttons[buttonIndex] = {
  36555. pressed: newState.pressed,
  36556. touched: newState.touched,
  36557. value: newState.value
  36558. };
  36559. return;
  36560. }
  36561. this._checkChanges(newState, currentState);
  36562. if (this._changes.changed) {
  36563. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  36564. this._handleButtonChange(buttonIndex, newState, this._changes);
  36565. }
  36566. this._buttons[buttonIndex].pressed = newState.pressed;
  36567. this._buttons[buttonIndex].touched = newState.touched;
  36568. // oculus triggers are never 0, thou not touched.
  36569. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  36570. };
  36571. WebVRController.prototype._checkChanges = function (newState, currentState) {
  36572. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  36573. this._changes.touchChanged = newState.touched !== currentState.touched;
  36574. this._changes.valueChanged = newState.value !== currentState.value;
  36575. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  36576. return this._changes;
  36577. };
  36578. /**
  36579. * Disposes of th webVRCOntroller
  36580. */
  36581. WebVRController.prototype.dispose = function () {
  36582. _super.prototype.dispose.call(this);
  36583. this.onTriggerStateChangedObservable.clear();
  36584. this.onMainButtonStateChangedObservable.clear();
  36585. this.onSecondaryButtonStateChangedObservable.clear();
  36586. this.onPadStateChangedObservable.clear();
  36587. this.onPadValuesChangedObservable.clear();
  36588. };
  36589. return WebVRController;
  36590. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  36591. /***/ }),
  36592. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  36593. /*!*********************************************************!*\
  36594. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  36595. \*********************************************************/
  36596. /*! exports provided: WindowsMotionController */
  36597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36598. "use strict";
  36599. __webpack_require__.r(__webpack_exports__);
  36600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  36601. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36602. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  36603. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36604. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36605. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  36606. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36607. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36608. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36609. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  36610. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36611. /**
  36612. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  36613. */
  36614. var LoadedMeshInfo = /** @class */ (function () {
  36615. function LoadedMeshInfo() {
  36616. /**
  36617. * Map of the button meshes contained in the controller
  36618. */
  36619. this.buttonMeshes = {};
  36620. /**
  36621. * Map of the axis meshes contained in the controller
  36622. */
  36623. this.axisMeshes = {};
  36624. }
  36625. return LoadedMeshInfo;
  36626. }());
  36627. /**
  36628. * Defines the WindowsMotionController object that the state of the windows motion controller
  36629. */
  36630. var WindowsMotionController = /** @class */ (function (_super) {
  36631. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  36632. /**
  36633. * Creates a new WindowsMotionController from a gamepad
  36634. * @param vrGamepad the gamepad that the controller should be created from
  36635. */
  36636. function WindowsMotionController(vrGamepad) {
  36637. var _this = _super.call(this, vrGamepad) || this;
  36638. _this._mapping = {
  36639. // Semantic button names
  36640. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  36641. // A mapping of the button name to glTF model node name
  36642. // that should be transformed by button value.
  36643. buttonMeshNames: {
  36644. 'trigger': 'SELECT',
  36645. 'menu': 'MENU',
  36646. 'grip': 'GRASP',
  36647. 'thumbstick': 'THUMBSTICK_PRESS',
  36648. 'trackpad': 'TOUCHPAD_PRESS'
  36649. },
  36650. // This mapping is used to translate from the Motion Controller to Babylon semantics
  36651. buttonObservableNames: {
  36652. 'trigger': 'onTriggerStateChangedObservable',
  36653. 'menu': 'onSecondaryButtonStateChangedObservable',
  36654. 'grip': 'onMainButtonStateChangedObservable',
  36655. 'thumbstick': 'onPadStateChangedObservable',
  36656. 'trackpad': 'onTrackpadChangedObservable'
  36657. },
  36658. // A mapping of the axis name to glTF model node name
  36659. // that should be transformed by axis value.
  36660. // This array mirrors the browserGamepad.axes array, such that
  36661. // the mesh corresponding to axis 0 is in this array index 0.
  36662. axisMeshNames: [
  36663. 'THUMBSTICK_X',
  36664. 'THUMBSTICK_Y',
  36665. 'TOUCHPAD_TOUCH_X',
  36666. 'TOUCHPAD_TOUCH_Y'
  36667. ],
  36668. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  36669. };
  36670. /**
  36671. * Fired when the trackpad on this controller is clicked
  36672. */
  36673. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36674. /**
  36675. * Fired when the trackpad on this controller is modified
  36676. */
  36677. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36678. /**
  36679. * The current x and y values of this controller's trackpad
  36680. */
  36681. _this.trackpad = { x: 0, y: 0 };
  36682. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  36683. _this._loadedMeshInfo = null;
  36684. return _this;
  36685. }
  36686. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  36687. /**
  36688. * Fired when the trigger on this controller is modified
  36689. */
  36690. get: function () {
  36691. return this.onTriggerStateChangedObservable;
  36692. },
  36693. enumerable: true,
  36694. configurable: true
  36695. });
  36696. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  36697. /**
  36698. * Fired when the menu button on this controller is modified
  36699. */
  36700. get: function () {
  36701. return this.onSecondaryButtonStateChangedObservable;
  36702. },
  36703. enumerable: true,
  36704. configurable: true
  36705. });
  36706. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  36707. /**
  36708. * Fired when the grip button on this controller is modified
  36709. */
  36710. get: function () {
  36711. return this.onMainButtonStateChangedObservable;
  36712. },
  36713. enumerable: true,
  36714. configurable: true
  36715. });
  36716. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  36717. /**
  36718. * Fired when the thumbstick button on this controller is modified
  36719. */
  36720. get: function () {
  36721. return this.onPadStateChangedObservable;
  36722. },
  36723. enumerable: true,
  36724. configurable: true
  36725. });
  36726. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  36727. /**
  36728. * Fired when the touchpad button on this controller is modified
  36729. */
  36730. get: function () {
  36731. return this.onTrackpadChangedObservable;
  36732. },
  36733. enumerable: true,
  36734. configurable: true
  36735. });
  36736. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  36737. /**
  36738. * Fired when the touchpad values on this controller are modified
  36739. */
  36740. get: function () {
  36741. return this.onTrackpadValuesChangedObservable;
  36742. },
  36743. enumerable: true,
  36744. configurable: true
  36745. });
  36746. WindowsMotionController.prototype._updateTrackpad = function () {
  36747. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  36748. this.trackpad.x = this.browserGamepad["axes"][2];
  36749. this.trackpad.y = this.browserGamepad["axes"][3];
  36750. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  36751. }
  36752. };
  36753. /**
  36754. * Called once per frame by the engine.
  36755. */
  36756. WindowsMotionController.prototype.update = function () {
  36757. _super.prototype.update.call(this);
  36758. if (this.browserGamepad.axes) {
  36759. this._updateTrackpad();
  36760. // Only need to animate axes if there is a loaded mesh
  36761. if (this._loadedMeshInfo) {
  36762. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  36763. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  36764. }
  36765. }
  36766. }
  36767. };
  36768. /**
  36769. * Called once for each button that changed state since the last frame
  36770. * @param buttonIdx Which button index changed
  36771. * @param state New state of the button
  36772. * @param changes Which properties on the state changed since last frame
  36773. */
  36774. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36775. var buttonName = this._mapping.buttons[buttonIdx];
  36776. if (!buttonName) {
  36777. return;
  36778. }
  36779. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  36780. this._updateTrackpad();
  36781. // Only emit events for buttons that we know how to map from index to name
  36782. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  36783. if (observable) {
  36784. observable.notifyObservers(state);
  36785. }
  36786. this._lerpButtonTransform(buttonName, state.value);
  36787. };
  36788. /**
  36789. * Moves the buttons on the controller mesh based on their current state
  36790. * @param buttonName the name of the button to move
  36791. * @param buttonValue the value of the button which determines the buttons new position
  36792. */
  36793. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  36794. // If there is no loaded mesh, there is nothing to transform.
  36795. if (!this._loadedMeshInfo) {
  36796. return;
  36797. }
  36798. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  36799. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36800. return;
  36801. }
  36802. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  36803. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  36804. };
  36805. /**
  36806. * Moves the axis on the controller mesh based on its current state
  36807. * @param axis the index of the axis
  36808. * @param axisValue the value of the axis which determines the meshes new position
  36809. * @hidden
  36810. */
  36811. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  36812. if (!this._loadedMeshInfo) {
  36813. return;
  36814. }
  36815. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  36816. if (!meshInfo) {
  36817. return;
  36818. }
  36819. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36820. return;
  36821. }
  36822. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  36823. var lerpValue = axisValue * 0.5 + 0.5;
  36824. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  36825. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  36826. };
  36827. /**
  36828. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36829. * @param scene scene in which to add meshes
  36830. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36831. */
  36832. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  36833. var _this = this;
  36834. if (forceDefault === void 0) { forceDefault = false; }
  36835. var path;
  36836. var filename;
  36837. // Checking if GLB loader is present
  36838. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  36839. // Determine the device specific folder based on the ID suffix
  36840. var device = 'default';
  36841. if (this.id && !forceDefault) {
  36842. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  36843. device = ((match && match[0]) || device);
  36844. }
  36845. // Hand
  36846. if (this.hand === 'left') {
  36847. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  36848. }
  36849. else { // Right is the default if no hand is specified
  36850. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  36851. }
  36852. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  36853. }
  36854. else {
  36855. _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");
  36856. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  36857. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  36858. }
  36859. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  36860. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  36861. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  36862. if (!_this._loadedMeshInfo) {
  36863. return;
  36864. }
  36865. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  36866. _this.attachToMesh(_this._defaultModel);
  36867. if (meshLoaded) {
  36868. meshLoaded(_this._defaultModel);
  36869. }
  36870. }, null, function (scene, message) {
  36871. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  36872. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  36873. if (!forceDefault) {
  36874. _this.initControllerMesh(scene, meshLoaded, true);
  36875. }
  36876. });
  36877. };
  36878. /**
  36879. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  36880. * can be transformed by button presses and axes values, based on this._mapping.
  36881. *
  36882. * @param scene scene in which the meshes exist
  36883. * @param meshes list of meshes that make up the controller model to process
  36884. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  36885. */
  36886. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  36887. var loadedMeshInfo = null;
  36888. // Create a new mesh to contain the glTF hierarchy
  36889. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  36890. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  36891. var childMesh = null;
  36892. for (var i = 0; i < meshes.length; i++) {
  36893. var mesh = meshes[i];
  36894. if (!mesh.parent) {
  36895. // Exclude controller meshes from picking results
  36896. mesh.isPickable = false;
  36897. // Handle root node, attach to the new parentMesh
  36898. childMesh = mesh;
  36899. break;
  36900. }
  36901. }
  36902. if (childMesh) {
  36903. childMesh.setParent(parentMesh);
  36904. // Create our mesh info. Note that this method will always return non-null.
  36905. loadedMeshInfo = this.createMeshInfo(parentMesh);
  36906. }
  36907. else {
  36908. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  36909. }
  36910. return loadedMeshInfo;
  36911. };
  36912. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  36913. var loadedMeshInfo = new LoadedMeshInfo();
  36914. var i;
  36915. loadedMeshInfo.rootNode = rootNode;
  36916. // Reset the caches
  36917. loadedMeshInfo.buttonMeshes = {};
  36918. loadedMeshInfo.axisMeshes = {};
  36919. // Button Meshes
  36920. for (i = 0; i < this._mapping.buttons.length; i++) {
  36921. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36922. if (!buttonMeshName) {
  36923. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36924. continue;
  36925. }
  36926. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36927. if (!buttonMesh) {
  36928. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36929. continue;
  36930. }
  36931. var buttonMeshInfo = {
  36932. index: i,
  36933. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36934. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36935. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36936. };
  36937. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36938. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36939. }
  36940. else {
  36941. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36942. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36943. '(VALUE: ' + !!buttonMeshInfo.value +
  36944. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36945. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36946. ')');
  36947. }
  36948. }
  36949. // Axis Meshes
  36950. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36951. var axisMeshName = this._mapping.axisMeshNames[i];
  36952. if (!axisMeshName) {
  36953. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36954. continue;
  36955. }
  36956. var axisMesh = getChildByName(rootNode, axisMeshName);
  36957. if (!axisMesh) {
  36958. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36959. continue;
  36960. }
  36961. var axisMeshInfo = {
  36962. index: i,
  36963. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36964. min: getImmediateChildByName(axisMesh, 'MIN'),
  36965. max: getImmediateChildByName(axisMesh, 'MAX')
  36966. };
  36967. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36968. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36969. }
  36970. else {
  36971. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36972. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36973. '(VALUE: ' + !!axisMeshInfo.value +
  36974. ', MIN: ' + !!axisMeshInfo.min +
  36975. ', MAX:' + !!axisMeshInfo.max +
  36976. ')');
  36977. }
  36978. }
  36979. // Pointing Ray
  36980. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36981. if (!loadedMeshInfo.pointingPoseNode) {
  36982. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36983. }
  36984. else {
  36985. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36986. }
  36987. return loadedMeshInfo;
  36988. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36989. function getChildByName(node, name) {
  36990. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36991. }
  36992. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36993. function getImmediateChildByName(node, name) {
  36994. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36995. }
  36996. };
  36997. /**
  36998. * Gets the ray of the controller in the direction the controller is pointing
  36999. * @param length the length the resulting ray should be
  37000. * @returns a ray in the direction the controller is pointing
  37001. */
  37002. WindowsMotionController.prototype.getForwardRay = function (length) {
  37003. if (length === void 0) { length = 100; }
  37004. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  37005. return _super.prototype.getForwardRay.call(this, length);
  37006. }
  37007. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  37008. var origin = m.getTranslation();
  37009. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  37010. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  37011. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  37012. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  37013. };
  37014. /**
  37015. * Disposes of the controller
  37016. */
  37017. WindowsMotionController.prototype.dispose = function () {
  37018. _super.prototype.dispose.call(this);
  37019. this.onTrackpadChangedObservable.clear();
  37020. };
  37021. /**
  37022. * The base url used to load the left and right controller models
  37023. */
  37024. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  37025. /**
  37026. * The name of the left controller model file
  37027. */
  37028. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  37029. /**
  37030. * The name of the right controller model file
  37031. */
  37032. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  37033. /**
  37034. * The controller name prefix for this controller type
  37035. */
  37036. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  37037. /**
  37038. * The controller id pattern for this controller type
  37039. */
  37040. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  37041. return WindowsMotionController;
  37042. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  37043. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  37044. canCreate: function (gamepadInfo) {
  37045. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  37046. },
  37047. create: function (gamepadInfo) {
  37048. return new WindowsMotionController(gamepadInfo);
  37049. }
  37050. });
  37051. /***/ }),
  37052. /***/ "./Gamepads/gamepad.ts":
  37053. /*!*****************************!*\
  37054. !*** ./Gamepads/gamepad.ts ***!
  37055. \*****************************/
  37056. /*! exports provided: StickValues, Gamepad, GenericPad */
  37057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37058. "use strict";
  37059. __webpack_require__.r(__webpack_exports__);
  37060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  37061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  37062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  37063. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37064. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37065. /**
  37066. * Represents a gamepad control stick position
  37067. */
  37068. var StickValues = /** @class */ (function () {
  37069. /**
  37070. * Initializes the gamepad x and y control stick values
  37071. * @param x The x component of the gamepad control stick value
  37072. * @param y The y component of the gamepad control stick value
  37073. */
  37074. function StickValues(
  37075. /**
  37076. * The x component of the control stick
  37077. */
  37078. x,
  37079. /**
  37080. * The y component of the control stick
  37081. */
  37082. y) {
  37083. this.x = x;
  37084. this.y = y;
  37085. }
  37086. return StickValues;
  37087. }());
  37088. /**
  37089. * Represents a gamepad
  37090. */
  37091. var Gamepad = /** @class */ (function () {
  37092. /**
  37093. * Initializes the gamepad
  37094. * @param id The id of the gamepad
  37095. * @param index The index of the gamepad
  37096. * @param browserGamepad The browser gamepad
  37097. * @param leftStickX The x component of the left joystick
  37098. * @param leftStickY The y component of the left joystick
  37099. * @param rightStickX The x component of the right joystick
  37100. * @param rightStickY The y component of the right joystick
  37101. */
  37102. function Gamepad(
  37103. /**
  37104. * The id of the gamepad
  37105. */
  37106. id,
  37107. /**
  37108. * The index of the gamepad
  37109. */
  37110. index,
  37111. /**
  37112. * The browser gamepad
  37113. */
  37114. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  37115. if (leftStickX === void 0) { leftStickX = 0; }
  37116. if (leftStickY === void 0) { leftStickY = 1; }
  37117. if (rightStickX === void 0) { rightStickX = 2; }
  37118. if (rightStickY === void 0) { rightStickY = 3; }
  37119. this.id = id;
  37120. this.index = index;
  37121. this.browserGamepad = browserGamepad;
  37122. this._leftStick = { x: 0, y: 0 };
  37123. this._rightStick = { x: 0, y: 0 };
  37124. /** @hidden */
  37125. this._isConnected = true;
  37126. /**
  37127. * Specifies whether the left control stick should be Y-inverted
  37128. */
  37129. this._invertLeftStickY = false;
  37130. this.type = Gamepad.GAMEPAD;
  37131. this._leftStickAxisX = leftStickX;
  37132. this._leftStickAxisY = leftStickY;
  37133. this._rightStickAxisX = rightStickX;
  37134. this._rightStickAxisY = rightStickY;
  37135. if (this.browserGamepad.axes.length >= 2) {
  37136. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37137. }
  37138. if (this.browserGamepad.axes.length >= 4) {
  37139. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37140. }
  37141. }
  37142. Object.defineProperty(Gamepad.prototype, "isConnected", {
  37143. /**
  37144. * Specifies if the gamepad has been connected
  37145. */
  37146. get: function () {
  37147. return this._isConnected;
  37148. },
  37149. enumerable: true,
  37150. configurable: true
  37151. });
  37152. /**
  37153. * Callback triggered when the left joystick has changed
  37154. * @param callback
  37155. */
  37156. Gamepad.prototype.onleftstickchanged = function (callback) {
  37157. this._onleftstickchanged = callback;
  37158. };
  37159. /**
  37160. * Callback triggered when the right joystick has changed
  37161. * @param callback
  37162. */
  37163. Gamepad.prototype.onrightstickchanged = function (callback) {
  37164. this._onrightstickchanged = callback;
  37165. };
  37166. Object.defineProperty(Gamepad.prototype, "leftStick", {
  37167. /**
  37168. * Gets the left joystick
  37169. */
  37170. get: function () {
  37171. return this._leftStick;
  37172. },
  37173. /**
  37174. * Sets the left joystick values
  37175. */
  37176. set: function (newValues) {
  37177. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  37178. this._onleftstickchanged(newValues);
  37179. }
  37180. this._leftStick = newValues;
  37181. },
  37182. enumerable: true,
  37183. configurable: true
  37184. });
  37185. Object.defineProperty(Gamepad.prototype, "rightStick", {
  37186. /**
  37187. * Gets the right joystick
  37188. */
  37189. get: function () {
  37190. return this._rightStick;
  37191. },
  37192. /**
  37193. * Sets the right joystick value
  37194. */
  37195. set: function (newValues) {
  37196. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  37197. this._onrightstickchanged(newValues);
  37198. }
  37199. this._rightStick = newValues;
  37200. },
  37201. enumerable: true,
  37202. configurable: true
  37203. });
  37204. /**
  37205. * Updates the gamepad joystick positions
  37206. */
  37207. Gamepad.prototype.update = function () {
  37208. if (this._leftStick) {
  37209. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37210. if (this._invertLeftStickY) {
  37211. this.leftStick.y *= -1;
  37212. }
  37213. }
  37214. if (this._rightStick) {
  37215. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37216. }
  37217. };
  37218. /**
  37219. * Disposes the gamepad
  37220. */
  37221. Gamepad.prototype.dispose = function () {
  37222. };
  37223. /**
  37224. * Represents a gamepad controller
  37225. */
  37226. Gamepad.GAMEPAD = 0;
  37227. /**
  37228. * Represents a generic controller
  37229. */
  37230. Gamepad.GENERIC = 1;
  37231. /**
  37232. * Represents an XBox controller
  37233. */
  37234. Gamepad.XBOX = 2;
  37235. /**
  37236. * Represents a pose-enabled controller
  37237. */
  37238. Gamepad.POSE_ENABLED = 3;
  37239. return Gamepad;
  37240. }());
  37241. /**
  37242. * Represents a generic gamepad
  37243. */
  37244. var GenericPad = /** @class */ (function (_super) {
  37245. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  37246. /**
  37247. * Initializes the generic gamepad
  37248. * @param id The id of the generic gamepad
  37249. * @param index The index of the generic gamepad
  37250. * @param browserGamepad The browser gamepad
  37251. */
  37252. function GenericPad(id, index, browserGamepad) {
  37253. var _this = _super.call(this, id, index, browserGamepad) || this;
  37254. /**
  37255. * Observable triggered when a button has been pressed
  37256. */
  37257. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37258. /**
  37259. * Observable triggered when a button has been released
  37260. */
  37261. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37262. _this.type = Gamepad.GENERIC;
  37263. _this._buttons = new Array(browserGamepad.buttons.length);
  37264. return _this;
  37265. }
  37266. /**
  37267. * Callback triggered when a button has been pressed
  37268. * @param callback Called when a button has been pressed
  37269. */
  37270. GenericPad.prototype.onbuttondown = function (callback) {
  37271. this._onbuttondown = callback;
  37272. };
  37273. /**
  37274. * Callback triggered when a button has been released
  37275. * @param callback Called when a button has been released
  37276. */
  37277. GenericPad.prototype.onbuttonup = function (callback) {
  37278. this._onbuttonup = callback;
  37279. };
  37280. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  37281. if (newValue !== currentValue) {
  37282. if (newValue === 1) {
  37283. if (this._onbuttondown) {
  37284. this._onbuttondown(buttonIndex);
  37285. }
  37286. this.onButtonDownObservable.notifyObservers(buttonIndex);
  37287. }
  37288. if (newValue === 0) {
  37289. if (this._onbuttonup) {
  37290. this._onbuttonup(buttonIndex);
  37291. }
  37292. this.onButtonUpObservable.notifyObservers(buttonIndex);
  37293. }
  37294. }
  37295. return newValue;
  37296. };
  37297. /**
  37298. * Updates the generic gamepad
  37299. */
  37300. GenericPad.prototype.update = function () {
  37301. _super.prototype.update.call(this);
  37302. for (var index = 0; index < this._buttons.length; index++) {
  37303. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  37304. }
  37305. };
  37306. /**
  37307. * Disposes the generic gamepad
  37308. */
  37309. GenericPad.prototype.dispose = function () {
  37310. _super.prototype.dispose.call(this);
  37311. this.onButtonDownObservable.clear();
  37312. this.onButtonUpObservable.clear();
  37313. };
  37314. return GenericPad;
  37315. }(Gamepad));
  37316. /***/ }),
  37317. /***/ "./Gamepads/gamepadManager.ts":
  37318. /*!************************************!*\
  37319. !*** ./Gamepads/gamepadManager.ts ***!
  37320. \************************************/
  37321. /*! exports provided: GamepadManager */
  37322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37323. "use strict";
  37324. __webpack_require__.r(__webpack_exports__);
  37325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  37326. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  37327. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37328. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  37329. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37330. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37331. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37332. /**
  37333. * Manager for handling gamepads
  37334. */
  37335. var GamepadManager = /** @class */ (function () {
  37336. /**
  37337. * Initializes the gamepad manager
  37338. * @param _scene BabylonJS scene
  37339. */
  37340. function GamepadManager(_scene) {
  37341. var _this = this;
  37342. this._scene = _scene;
  37343. this._babylonGamepads = [];
  37344. this._oneGamepadConnected = false;
  37345. /** @hidden */
  37346. this._isMonitoring = false;
  37347. /**
  37348. * observable to be triggered when the gamepad controller has been disconnected
  37349. */
  37350. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37351. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  37352. this._gamepadEventSupported = false;
  37353. }
  37354. else {
  37355. this._gamepadEventSupported = 'GamepadEvent' in window;
  37356. this._gamepadSupport = (navigator.getGamepads ||
  37357. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  37358. }
  37359. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  37360. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  37361. for (var i in _this._babylonGamepads) {
  37362. var gamepad = _this._babylonGamepads[i];
  37363. if (gamepad && gamepad._isConnected) {
  37364. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  37365. }
  37366. }
  37367. });
  37368. this._onGamepadConnectedEvent = function (evt) {
  37369. var gamepad = evt.gamepad;
  37370. if (gamepad.index in _this._babylonGamepads) {
  37371. if (_this._babylonGamepads[gamepad.index].isConnected) {
  37372. return;
  37373. }
  37374. }
  37375. var newGamepad;
  37376. if (_this._babylonGamepads[gamepad.index]) {
  37377. newGamepad = _this._babylonGamepads[gamepad.index];
  37378. newGamepad.browserGamepad = gamepad;
  37379. newGamepad._isConnected = true;
  37380. }
  37381. else {
  37382. newGamepad = _this._addNewGamepad(gamepad);
  37383. }
  37384. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37385. _this._startMonitoringGamepads();
  37386. };
  37387. this._onGamepadDisconnectedEvent = function (evt) {
  37388. var gamepad = evt.gamepad;
  37389. // Remove the gamepad from the list of gamepads to monitor.
  37390. for (var i in _this._babylonGamepads) {
  37391. if (_this._babylonGamepads[i].index === gamepad.index) {
  37392. var disconnectedGamepad = _this._babylonGamepads[i];
  37393. disconnectedGamepad._isConnected = false;
  37394. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  37395. break;
  37396. }
  37397. }
  37398. };
  37399. if (this._gamepadSupport) {
  37400. //first add already-connected gamepads
  37401. this._updateGamepadObjects();
  37402. if (this._babylonGamepads.length) {
  37403. this._startMonitoringGamepads();
  37404. }
  37405. // Checking if the gamepad connected event is supported (like in Firefox)
  37406. if (this._gamepadEventSupported) {
  37407. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  37408. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  37409. }
  37410. else {
  37411. this._startMonitoringGamepads();
  37412. }
  37413. }
  37414. }
  37415. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  37416. /**
  37417. * The gamepads in the game pad manager
  37418. */
  37419. get: function () {
  37420. return this._babylonGamepads;
  37421. },
  37422. enumerable: true,
  37423. configurable: true
  37424. });
  37425. /**
  37426. * Get the gamepad controllers based on type
  37427. * @param type The type of gamepad controller
  37428. * @returns Nullable gamepad
  37429. */
  37430. GamepadManager.prototype.getGamepadByType = function (type) {
  37431. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  37432. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  37433. var gamepad = _a[_i];
  37434. if (gamepad && gamepad.type === type) {
  37435. return gamepad;
  37436. }
  37437. }
  37438. return null;
  37439. };
  37440. /**
  37441. * Disposes the gamepad manager
  37442. */
  37443. GamepadManager.prototype.dispose = function () {
  37444. if (this._gamepadEventSupported) {
  37445. if (this._onGamepadConnectedEvent) {
  37446. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  37447. }
  37448. if (this._onGamepadDisconnectedEvent) {
  37449. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  37450. }
  37451. this._onGamepadConnectedEvent = null;
  37452. this._onGamepadDisconnectedEvent = null;
  37453. }
  37454. this._babylonGamepads.forEach(function (gamepad) {
  37455. gamepad.dispose();
  37456. });
  37457. this.onGamepadConnectedObservable.clear();
  37458. this.onGamepadDisconnectedObservable.clear();
  37459. this._oneGamepadConnected = false;
  37460. this._stopMonitoringGamepads();
  37461. this._babylonGamepads = [];
  37462. };
  37463. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  37464. if (!this._oneGamepadConnected) {
  37465. this._oneGamepadConnected = true;
  37466. }
  37467. var newGamepad;
  37468. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  37469. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  37470. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  37471. }
  37472. // if pose is supported, use the (WebVR) pose enabled controller
  37473. else if (gamepad.pose) {
  37474. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  37475. }
  37476. else {
  37477. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  37478. }
  37479. this._babylonGamepads[newGamepad.index] = newGamepad;
  37480. return newGamepad;
  37481. };
  37482. GamepadManager.prototype._startMonitoringGamepads = function () {
  37483. if (!this._isMonitoring) {
  37484. this._isMonitoring = true;
  37485. //back-comp
  37486. if (!this._scene) {
  37487. this._checkGamepadsStatus();
  37488. }
  37489. }
  37490. };
  37491. GamepadManager.prototype._stopMonitoringGamepads = function () {
  37492. this._isMonitoring = false;
  37493. };
  37494. /** @hidden */
  37495. GamepadManager.prototype._checkGamepadsStatus = function () {
  37496. var _this = this;
  37497. // Hack to be compatible Chrome
  37498. this._updateGamepadObjects();
  37499. for (var i in this._babylonGamepads) {
  37500. var gamepad = this._babylonGamepads[i];
  37501. if (!gamepad || !gamepad.isConnected) {
  37502. continue;
  37503. }
  37504. gamepad.update();
  37505. }
  37506. if (this._isMonitoring && !this._scene) {
  37507. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  37508. }
  37509. };
  37510. // This function is called only on Chrome, which does not properly support
  37511. // connection/disconnection events and forces you to recopy again the gamepad object
  37512. GamepadManager.prototype._updateGamepadObjects = function () {
  37513. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  37514. for (var i = 0; i < gamepads.length; i++) {
  37515. var gamepad = gamepads[i];
  37516. if (gamepad) {
  37517. if (!this._babylonGamepads[gamepad.index]) {
  37518. var newGamepad = this._addNewGamepad(gamepad);
  37519. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37520. }
  37521. else {
  37522. // Forced to copy again this object for Chrome for unknown reason
  37523. this._babylonGamepads[i].browserGamepad = gamepad;
  37524. if (!this._babylonGamepads[i].isConnected) {
  37525. this._babylonGamepads[i]._isConnected = true;
  37526. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  37527. }
  37528. }
  37529. }
  37530. }
  37531. };
  37532. return GamepadManager;
  37533. }());
  37534. /***/ }),
  37535. /***/ "./Gamepads/gamepadSceneComponent.ts":
  37536. /*!*******************************************!*\
  37537. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  37538. \*******************************************/
  37539. /*! exports provided: GamepadSystemSceneComponent */
  37540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37541. "use strict";
  37542. __webpack_require__.r(__webpack_exports__);
  37543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  37544. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  37545. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  37546. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37547. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  37548. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  37549. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  37550. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  37551. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  37552. get: function () {
  37553. if (!this._gamepadManager) {
  37554. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  37555. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  37556. if (!component) {
  37557. component = new GamepadSystemSceneComponent(this);
  37558. this._addComponent(component);
  37559. }
  37560. }
  37561. return this._gamepadManager;
  37562. },
  37563. enumerable: true,
  37564. configurable: true
  37565. });
  37566. /**
  37567. * Adds a gamepad to the free camera inputs manager
  37568. */
  37569. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  37570. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  37571. return this;
  37572. };
  37573. /**
  37574. * Adds a gamepad to the arc rotate camera inputs manager
  37575. */
  37576. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  37577. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  37578. return this;
  37579. };
  37580. /**
  37581. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37582. */
  37583. var GamepadSystemSceneComponent = /** @class */ (function () {
  37584. /**
  37585. * Creates a new instance of the component for the given scene
  37586. * @param scene Defines the scene to register the component in
  37587. */
  37588. function GamepadSystemSceneComponent(scene) {
  37589. /**
  37590. * The component name helpfull to identify the component in the list of scene components.
  37591. */
  37592. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  37593. this.scene = scene;
  37594. }
  37595. /**
  37596. * Registers the component in a given scene
  37597. */
  37598. GamepadSystemSceneComponent.prototype.register = function () {
  37599. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  37600. };
  37601. /**
  37602. * Rebuilds the elements related to this component in case of
  37603. * context lost for instance.
  37604. */
  37605. GamepadSystemSceneComponent.prototype.rebuild = function () {
  37606. // Nothing to do for gamepads
  37607. };
  37608. /**
  37609. * Disposes the component and the associated ressources
  37610. */
  37611. GamepadSystemSceneComponent.prototype.dispose = function () {
  37612. var gamepadManager = this.scene._gamepadManager;
  37613. if (gamepadManager) {
  37614. gamepadManager.dispose();
  37615. this.scene._gamepadManager = null;
  37616. }
  37617. };
  37618. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  37619. var gamepadManager = this.scene._gamepadManager;
  37620. if (gamepadManager && gamepadManager._isMonitoring) {
  37621. gamepadManager._checkGamepadsStatus();
  37622. }
  37623. };
  37624. return GamepadSystemSceneComponent;
  37625. }());
  37626. /***/ }),
  37627. /***/ "./Gamepads/index.ts":
  37628. /*!***************************!*\
  37629. !*** ./Gamepads/index.ts ***!
  37630. \***************************/
  37631. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37633. "use strict";
  37634. __webpack_require__.r(__webpack_exports__);
  37635. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  37636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  37638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  37639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  37640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  37641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  37642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  37643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  37644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  37645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  37646. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  37648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  37649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  37650. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  37652. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  37653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  37654. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  37656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  37657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  37658. /***/ }),
  37659. /***/ "./Gamepads/xboxGamepad.ts":
  37660. /*!*********************************!*\
  37661. !*** ./Gamepads/xboxGamepad.ts ***!
  37662. \*********************************/
  37663. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37665. "use strict";
  37666. __webpack_require__.r(__webpack_exports__);
  37667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  37668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  37669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  37670. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37671. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37672. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37673. /**
  37674. * Defines supported buttons for XBox360 compatible gamepads
  37675. */
  37676. var Xbox360Button;
  37677. (function (Xbox360Button) {
  37678. /** A */
  37679. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  37680. /** B */
  37681. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  37682. /** X */
  37683. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  37684. /** Y */
  37685. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  37686. /** Start */
  37687. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  37688. /** Back */
  37689. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  37690. /** Left button */
  37691. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  37692. /** Right button */
  37693. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  37694. /** Left stick */
  37695. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  37696. /** Right stick */
  37697. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  37698. })(Xbox360Button || (Xbox360Button = {}));
  37699. /** Defines values for XBox360 DPad */
  37700. var Xbox360Dpad;
  37701. (function (Xbox360Dpad) {
  37702. /** Up */
  37703. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  37704. /** Down */
  37705. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  37706. /** Left */
  37707. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  37708. /** Right */
  37709. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  37710. })(Xbox360Dpad || (Xbox360Dpad = {}));
  37711. /**
  37712. * Defines a XBox360 gamepad
  37713. */
  37714. var Xbox360Pad = /** @class */ (function (_super) {
  37715. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  37716. /**
  37717. * Creates a new XBox360 gamepad object
  37718. * @param id defines the id of this gamepad
  37719. * @param index defines its index
  37720. * @param gamepad defines the internal HTML gamepad object
  37721. * @param xboxOne defines if it is a XBox One gamepad
  37722. */
  37723. function Xbox360Pad(id, index, gamepad, xboxOne) {
  37724. if (xboxOne === void 0) { xboxOne = false; }
  37725. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  37726. _this._leftTrigger = 0;
  37727. _this._rightTrigger = 0;
  37728. /** Observable raised when a button is pressed */
  37729. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37730. /** Observable raised when a button is released */
  37731. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37732. /** Observable raised when a pad is pressed */
  37733. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37734. /** Observable raised when a pad is released */
  37735. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37736. _this._buttonA = 0;
  37737. _this._buttonB = 0;
  37738. _this._buttonX = 0;
  37739. _this._buttonY = 0;
  37740. _this._buttonBack = 0;
  37741. _this._buttonStart = 0;
  37742. _this._buttonLB = 0;
  37743. _this._buttonRB = 0;
  37744. _this._buttonLeftStick = 0;
  37745. _this._buttonRightStick = 0;
  37746. _this._dPadUp = 0;
  37747. _this._dPadDown = 0;
  37748. _this._dPadLeft = 0;
  37749. _this._dPadRight = 0;
  37750. _this._isXboxOnePad = false;
  37751. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  37752. _this._isXboxOnePad = xboxOne;
  37753. return _this;
  37754. }
  37755. /**
  37756. * Defines the callback to call when left trigger is pressed
  37757. * @param callback defines the callback to use
  37758. */
  37759. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  37760. this._onlefttriggerchanged = callback;
  37761. };
  37762. /**
  37763. * Defines the callback to call when right trigger is pressed
  37764. * @param callback defines the callback to use
  37765. */
  37766. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  37767. this._onrighttriggerchanged = callback;
  37768. };
  37769. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  37770. /**
  37771. * Gets the left trigger value
  37772. */
  37773. get: function () {
  37774. return this._leftTrigger;
  37775. },
  37776. /**
  37777. * Sets the left trigger value
  37778. */
  37779. set: function (newValue) {
  37780. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  37781. this._onlefttriggerchanged(newValue);
  37782. }
  37783. this._leftTrigger = newValue;
  37784. },
  37785. enumerable: true,
  37786. configurable: true
  37787. });
  37788. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  37789. /**
  37790. * Gets the right trigger value
  37791. */
  37792. get: function () {
  37793. return this._rightTrigger;
  37794. },
  37795. /**
  37796. * Sets the right trigger value
  37797. */
  37798. set: function (newValue) {
  37799. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  37800. this._onrighttriggerchanged(newValue);
  37801. }
  37802. this._rightTrigger = newValue;
  37803. },
  37804. enumerable: true,
  37805. configurable: true
  37806. });
  37807. /**
  37808. * Defines the callback to call when a button is pressed
  37809. * @param callback defines the callback to use
  37810. */
  37811. Xbox360Pad.prototype.onbuttondown = function (callback) {
  37812. this._onbuttondown = callback;
  37813. };
  37814. /**
  37815. * Defines the callback to call when a button is released
  37816. * @param callback defines the callback to use
  37817. */
  37818. Xbox360Pad.prototype.onbuttonup = function (callback) {
  37819. this._onbuttonup = callback;
  37820. };
  37821. /**
  37822. * Defines the callback to call when a pad is pressed
  37823. * @param callback defines the callback to use
  37824. */
  37825. Xbox360Pad.prototype.ondpaddown = function (callback) {
  37826. this._ondpaddown = callback;
  37827. };
  37828. /**
  37829. * Defines the callback to call when a pad is released
  37830. * @param callback defines the callback to use
  37831. */
  37832. Xbox360Pad.prototype.ondpadup = function (callback) {
  37833. this._ondpadup = callback;
  37834. };
  37835. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  37836. if (newValue !== currentValue) {
  37837. if (newValue === 1) {
  37838. if (this._onbuttondown) {
  37839. this._onbuttondown(buttonType);
  37840. }
  37841. this.onButtonDownObservable.notifyObservers(buttonType);
  37842. }
  37843. if (newValue === 0) {
  37844. if (this._onbuttonup) {
  37845. this._onbuttonup(buttonType);
  37846. }
  37847. this.onButtonUpObservable.notifyObservers(buttonType);
  37848. }
  37849. }
  37850. return newValue;
  37851. };
  37852. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  37853. if (newValue !== currentValue) {
  37854. if (newValue === 1) {
  37855. if (this._ondpaddown) {
  37856. this._ondpaddown(buttonType);
  37857. }
  37858. this.onPadDownObservable.notifyObservers(buttonType);
  37859. }
  37860. if (newValue === 0) {
  37861. if (this._ondpadup) {
  37862. this._ondpadup(buttonType);
  37863. }
  37864. this.onPadUpObservable.notifyObservers(buttonType);
  37865. }
  37866. }
  37867. return newValue;
  37868. };
  37869. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  37870. /**
  37871. * Gets the value of the `A` button
  37872. */
  37873. get: function () {
  37874. return this._buttonA;
  37875. },
  37876. /**
  37877. * Sets the value of the `A` button
  37878. */
  37879. set: function (value) {
  37880. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  37881. },
  37882. enumerable: true,
  37883. configurable: true
  37884. });
  37885. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  37886. /**
  37887. * Gets the value of the `B` button
  37888. */
  37889. get: function () {
  37890. return this._buttonB;
  37891. },
  37892. /**
  37893. * Sets the value of the `B` button
  37894. */
  37895. set: function (value) {
  37896. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  37897. },
  37898. enumerable: true,
  37899. configurable: true
  37900. });
  37901. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  37902. /**
  37903. * Gets the value of the `X` button
  37904. */
  37905. get: function () {
  37906. return this._buttonX;
  37907. },
  37908. /**
  37909. * Sets the value of the `X` button
  37910. */
  37911. set: function (value) {
  37912. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  37913. },
  37914. enumerable: true,
  37915. configurable: true
  37916. });
  37917. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37918. /**
  37919. * Gets the value of the `Y` button
  37920. */
  37921. get: function () {
  37922. return this._buttonY;
  37923. },
  37924. /**
  37925. * Sets the value of the `Y` button
  37926. */
  37927. set: function (value) {
  37928. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37929. },
  37930. enumerable: true,
  37931. configurable: true
  37932. });
  37933. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37934. /**
  37935. * Gets the value of the `Start` button
  37936. */
  37937. get: function () {
  37938. return this._buttonStart;
  37939. },
  37940. /**
  37941. * Sets the value of the `Start` button
  37942. */
  37943. set: function (value) {
  37944. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37945. },
  37946. enumerable: true,
  37947. configurable: true
  37948. });
  37949. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37950. /**
  37951. * Gets the value of the `Back` button
  37952. */
  37953. get: function () {
  37954. return this._buttonBack;
  37955. },
  37956. /**
  37957. * Sets the value of the `Back` button
  37958. */
  37959. set: function (value) {
  37960. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37961. },
  37962. enumerable: true,
  37963. configurable: true
  37964. });
  37965. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37966. /**
  37967. * Gets the value of the `Left` button
  37968. */
  37969. get: function () {
  37970. return this._buttonLB;
  37971. },
  37972. /**
  37973. * Sets the value of the `Left` button
  37974. */
  37975. set: function (value) {
  37976. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37977. },
  37978. enumerable: true,
  37979. configurable: true
  37980. });
  37981. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37982. /**
  37983. * Gets the value of the `Right` button
  37984. */
  37985. get: function () {
  37986. return this._buttonRB;
  37987. },
  37988. /**
  37989. * Sets the value of the `Right` button
  37990. */
  37991. set: function (value) {
  37992. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37993. },
  37994. enumerable: true,
  37995. configurable: true
  37996. });
  37997. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37998. /**
  37999. * Gets the value of the Left joystick
  38000. */
  38001. get: function () {
  38002. return this._buttonLeftStick;
  38003. },
  38004. /**
  38005. * Sets the value of the Left joystick
  38006. */
  38007. set: function (value) {
  38008. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  38009. },
  38010. enumerable: true,
  38011. configurable: true
  38012. });
  38013. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  38014. /**
  38015. * Gets the value of the Right joystick
  38016. */
  38017. get: function () {
  38018. return this._buttonRightStick;
  38019. },
  38020. /**
  38021. * Sets the value of the Right joystick
  38022. */
  38023. set: function (value) {
  38024. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  38025. },
  38026. enumerable: true,
  38027. configurable: true
  38028. });
  38029. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  38030. /**
  38031. * Gets the value of D-pad up
  38032. */
  38033. get: function () {
  38034. return this._dPadUp;
  38035. },
  38036. /**
  38037. * Sets the value of D-pad up
  38038. */
  38039. set: function (value) {
  38040. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  38041. },
  38042. enumerable: true,
  38043. configurable: true
  38044. });
  38045. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  38046. /**
  38047. * Gets the value of D-pad down
  38048. */
  38049. get: function () {
  38050. return this._dPadDown;
  38051. },
  38052. /**
  38053. * Sets the value of D-pad down
  38054. */
  38055. set: function (value) {
  38056. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  38057. },
  38058. enumerable: true,
  38059. configurable: true
  38060. });
  38061. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  38062. /**
  38063. * Gets the value of D-pad left
  38064. */
  38065. get: function () {
  38066. return this._dPadLeft;
  38067. },
  38068. /**
  38069. * Sets the value of D-pad left
  38070. */
  38071. set: function (value) {
  38072. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  38073. },
  38074. enumerable: true,
  38075. configurable: true
  38076. });
  38077. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  38078. /**
  38079. * Gets the value of D-pad right
  38080. */
  38081. get: function () {
  38082. return this._dPadRight;
  38083. },
  38084. /**
  38085. * Sets the value of D-pad right
  38086. */
  38087. set: function (value) {
  38088. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  38089. },
  38090. enumerable: true,
  38091. configurable: true
  38092. });
  38093. /**
  38094. * Force the gamepad to synchronize with device values
  38095. */
  38096. Xbox360Pad.prototype.update = function () {
  38097. _super.prototype.update.call(this);
  38098. if (this._isXboxOnePad) {
  38099. this.buttonA = this.browserGamepad.buttons[0].value;
  38100. this.buttonB = this.browserGamepad.buttons[1].value;
  38101. this.buttonX = this.browserGamepad.buttons[2].value;
  38102. this.buttonY = this.browserGamepad.buttons[3].value;
  38103. this.buttonLB = this.browserGamepad.buttons[4].value;
  38104. this.buttonRB = this.browserGamepad.buttons[5].value;
  38105. this.leftTrigger = this.browserGamepad.axes[2];
  38106. this.rightTrigger = this.browserGamepad.axes[5];
  38107. this.buttonBack = this.browserGamepad.buttons[9].value;
  38108. this.buttonStart = this.browserGamepad.buttons[8].value;
  38109. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  38110. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  38111. this.dPadUp = this.browserGamepad.buttons[11].value;
  38112. this.dPadDown = this.browserGamepad.buttons[12].value;
  38113. this.dPadLeft = this.browserGamepad.buttons[13].value;
  38114. this.dPadRight = this.browserGamepad.buttons[14].value;
  38115. }
  38116. else {
  38117. this.buttonA = this.browserGamepad.buttons[0].value;
  38118. this.buttonB = this.browserGamepad.buttons[1].value;
  38119. this.buttonX = this.browserGamepad.buttons[2].value;
  38120. this.buttonY = this.browserGamepad.buttons[3].value;
  38121. this.buttonLB = this.browserGamepad.buttons[4].value;
  38122. this.buttonRB = this.browserGamepad.buttons[5].value;
  38123. this.leftTrigger = this.browserGamepad.buttons[6].value;
  38124. this.rightTrigger = this.browserGamepad.buttons[7].value;
  38125. this.buttonBack = this.browserGamepad.buttons[8].value;
  38126. this.buttonStart = this.browserGamepad.buttons[9].value;
  38127. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  38128. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  38129. this.dPadUp = this.browserGamepad.buttons[12].value;
  38130. this.dPadDown = this.browserGamepad.buttons[13].value;
  38131. this.dPadLeft = this.browserGamepad.buttons[14].value;
  38132. this.dPadRight = this.browserGamepad.buttons[15].value;
  38133. }
  38134. };
  38135. /**
  38136. * Disposes the gamepad
  38137. */
  38138. Xbox360Pad.prototype.dispose = function () {
  38139. _super.prototype.dispose.call(this);
  38140. this.onButtonDownObservable.clear();
  38141. this.onButtonUpObservable.clear();
  38142. this.onPadDownObservable.clear();
  38143. this.onPadUpObservable.clear();
  38144. };
  38145. return Xbox360Pad;
  38146. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  38147. /***/ }),
  38148. /***/ "./Gizmos/axisDragGizmo.ts":
  38149. /*!*********************************!*\
  38150. !*** ./Gizmos/axisDragGizmo.ts ***!
  38151. \*********************************/
  38152. /*! exports provided: AxisDragGizmo */
  38153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38154. "use strict";
  38155. __webpack_require__.r(__webpack_exports__);
  38156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  38157. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38158. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38159. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38160. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  38161. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38162. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38163. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38164. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38165. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38166. /**
  38167. * Single axis drag gizmo
  38168. */
  38169. var AxisDragGizmo = /** @class */ (function (_super) {
  38170. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  38171. /**
  38172. * Creates an AxisDragGizmo
  38173. * @param gizmoLayer The utility layer the gizmo will be added to
  38174. * @param dragAxis The axis which the gizmo will be able to drag on
  38175. * @param color The color of the gizmo
  38176. */
  38177. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  38178. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38179. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38180. var _this = _super.call(this, gizmoLayer) || this;
  38181. _this._pointerObserver = null;
  38182. /**
  38183. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38184. */
  38185. _this.snapDistance = 0;
  38186. /**
  38187. * Event that fires each time the gizmo snaps to a new location.
  38188. * * snapDistance is the the change in distance
  38189. */
  38190. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38191. // Create Material
  38192. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38193. coloredMaterial.diffuseColor = color;
  38194. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38195. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38196. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38197. // Build mesh on root node
  38198. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  38199. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38200. arrow.scaling.scaleInPlace(1 / 3);
  38201. arrow.parent = _this._rootMesh;
  38202. var currentSnapDragDistance = 0;
  38203. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38204. var tmpSnapEvent = { snapDistance: 0 };
  38205. // Add drag behavior to handle events when the gizmo is dragged
  38206. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38207. _this.dragBehavior.moveAttached = false;
  38208. _this._rootMesh.addBehavior(_this.dragBehavior);
  38209. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38210. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38211. _this.dragBehavior.onDragObservable.add(function (event) {
  38212. if (_this.attachedMesh) {
  38213. // Convert delta to local translation if it has a parent
  38214. if (_this.attachedMesh.parent) {
  38215. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38216. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  38217. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  38218. }
  38219. else {
  38220. localDelta.copyFrom(event.delta);
  38221. }
  38222. // Snapping logic
  38223. if (_this.snapDistance == 0) {
  38224. _this.attachedMesh.position.addInPlace(localDelta);
  38225. }
  38226. else {
  38227. currentSnapDragDistance += event.dragDistance;
  38228. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38229. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38230. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38231. localDelta.normalizeToRef(tmpVector);
  38232. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  38233. _this.attachedMesh.position.addInPlace(tmpVector);
  38234. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38235. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38236. }
  38237. }
  38238. }
  38239. });
  38240. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38241. if (_this._customMeshSet) {
  38242. return;
  38243. }
  38244. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38245. var material = isHovered ? hoverMaterial : coloredMaterial;
  38246. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38247. m.material = material;
  38248. if (m.color) {
  38249. m.color = material.diffuseColor;
  38250. }
  38251. });
  38252. });
  38253. var light = gizmoLayer._getSharedGizmoLight();
  38254. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  38255. return _this;
  38256. }
  38257. /** @hidden */
  38258. AxisDragGizmo._CreateArrow = function (scene, material) {
  38259. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38260. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375, tessellation: 96 }, scene);
  38261. var line = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, scene);
  38262. line.material = material;
  38263. cylinder.parent = arrow;
  38264. line.parent = arrow;
  38265. // Position arrow pointing in its drag axis
  38266. cylinder.material = material;
  38267. cylinder.rotation.x = Math.PI / 2;
  38268. cylinder.position.z += 0.3;
  38269. line.position.z += 0.275 / 2;
  38270. line.rotation.x = Math.PI / 2;
  38271. return arrow;
  38272. };
  38273. /** @hidden */
  38274. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  38275. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38276. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  38277. var mesh = _a[_i];
  38278. var childInstance = mesh.createInstance(mesh.name);
  38279. childInstance.parent = instance;
  38280. }
  38281. return instance;
  38282. };
  38283. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  38284. if (this.dragBehavior) {
  38285. this.dragBehavior.enabled = value ? true : false;
  38286. }
  38287. };
  38288. /**
  38289. * Disposes of the gizmo
  38290. */
  38291. AxisDragGizmo.prototype.dispose = function () {
  38292. this.onSnapObservable.clear();
  38293. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38294. this.dragBehavior.detach();
  38295. _super.prototype.dispose.call(this);
  38296. };
  38297. return AxisDragGizmo;
  38298. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38299. /***/ }),
  38300. /***/ "./Gizmos/axisScaleGizmo.ts":
  38301. /*!**********************************!*\
  38302. !*** ./Gizmos/axisScaleGizmo.ts ***!
  38303. \**********************************/
  38304. /*! exports provided: AxisScaleGizmo */
  38305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38306. "use strict";
  38307. __webpack_require__.r(__webpack_exports__);
  38308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  38309. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38310. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38311. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38312. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38313. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38314. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38315. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38316. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38317. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38318. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38319. /**
  38320. * Single axis scale gizmo
  38321. */
  38322. var AxisScaleGizmo = /** @class */ (function (_super) {
  38323. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  38324. /**
  38325. * Creates an AxisScaleGizmo
  38326. * @param gizmoLayer The utility layer the gizmo will be added to
  38327. * @param dragAxis The axis which the gizmo will be able to scale on
  38328. * @param color The color of the gizmo
  38329. */
  38330. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  38331. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38332. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38333. var _this = _super.call(this, gizmoLayer) || this;
  38334. _this._pointerObserver = null;
  38335. /**
  38336. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38337. */
  38338. _this.snapDistance = 0;
  38339. /**
  38340. * Event that fires each time the gizmo snaps to a new location.
  38341. * * snapDistance is the the change in distance
  38342. */
  38343. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38344. /**
  38345. * If the scaling operation should be done on all axis (default: false)
  38346. */
  38347. _this.uniformScaling = false;
  38348. // Create Material
  38349. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38350. _this._coloredMaterial.diffuseColor = color;
  38351. _this._coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38352. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38353. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38354. // Build mesh on root node
  38355. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38356. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  38357. 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);
  38358. arrowTail.material = _this._coloredMaterial;
  38359. arrow.addChild(arrowMesh);
  38360. arrow.addChild(arrowTail);
  38361. // Position arrow pointing in its drag axis
  38362. arrowMesh.scaling.scaleInPlace(0.1);
  38363. arrowMesh.material = _this._coloredMaterial;
  38364. arrowMesh.rotation.x = Math.PI / 2;
  38365. arrowMesh.position.z += 0.3;
  38366. arrowTail.position.z += 0.275 / 2;
  38367. arrowTail.rotation.x = Math.PI / 2;
  38368. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38369. _this._rootMesh.addChild(arrow);
  38370. arrow.scaling.scaleInPlace(1 / 3);
  38371. // Add drag behavior to handle events when the gizmo is dragged
  38372. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38373. _this.dragBehavior.moveAttached = false;
  38374. _this._rootMesh.addBehavior(_this.dragBehavior);
  38375. var currentSnapDragDistance = 0;
  38376. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38377. var tmpSnapEvent = { snapDistance: 0 };
  38378. _this.dragBehavior.onDragObservable.add(function (event) {
  38379. if (_this.attachedMesh) {
  38380. // Snapping logic
  38381. var snapped = false;
  38382. var dragSteps = 0;
  38383. if (_this.uniformScaling) {
  38384. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  38385. if (tmpVector.y < 0) {
  38386. tmpVector.scaleInPlace(-1);
  38387. }
  38388. }
  38389. else {
  38390. tmpVector.copyFrom(dragAxis);
  38391. }
  38392. if (_this.snapDistance == 0) {
  38393. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  38394. }
  38395. else {
  38396. currentSnapDragDistance += event.dragDistance;
  38397. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38398. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38399. if (currentSnapDragDistance < 0) {
  38400. dragSteps *= -1;
  38401. }
  38402. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38403. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  38404. snapped = true;
  38405. }
  38406. else {
  38407. tmpVector.scaleInPlace(0);
  38408. }
  38409. }
  38410. _this.attachedMesh.scaling.addInPlace(tmpVector);
  38411. if (snapped) {
  38412. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38413. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38414. }
  38415. }
  38416. });
  38417. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38418. if (_this._customMeshSet) {
  38419. return;
  38420. }
  38421. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38422. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  38423. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38424. m.material = material;
  38425. if (m.color) {
  38426. m.color = material.diffuseColor;
  38427. }
  38428. });
  38429. });
  38430. var light = gizmoLayer._getSharedGizmoLight();
  38431. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes());
  38432. return _this;
  38433. }
  38434. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  38435. if (this.dragBehavior) {
  38436. this.dragBehavior.enabled = value ? true : false;
  38437. }
  38438. };
  38439. /**
  38440. * Disposes of the gizmo
  38441. */
  38442. AxisScaleGizmo.prototype.dispose = function () {
  38443. this.onSnapObservable.clear();
  38444. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38445. this.dragBehavior.detach();
  38446. _super.prototype.dispose.call(this);
  38447. };
  38448. /**
  38449. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38450. * @param mesh The mesh to replace the default mesh of the gizmo
  38451. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  38452. */
  38453. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  38454. var _this = this;
  38455. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  38456. _super.prototype.setCustomMesh.call(this, mesh);
  38457. if (useGizmoMaterial) {
  38458. this._rootMesh.getChildMeshes().forEach(function (m) {
  38459. m.material = _this._coloredMaterial;
  38460. if (m.color) {
  38461. m.color = _this._coloredMaterial.diffuseColor;
  38462. }
  38463. });
  38464. this._customMeshSet = false;
  38465. }
  38466. };
  38467. return AxisScaleGizmo;
  38468. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  38469. /***/ }),
  38470. /***/ "./Gizmos/boundingBoxGizmo.ts":
  38471. /*!************************************!*\
  38472. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  38473. \************************************/
  38474. /*! exports provided: BoundingBoxGizmo */
  38475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38476. "use strict";
  38477. __webpack_require__.r(__webpack_exports__);
  38478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  38479. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38480. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38481. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38482. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38483. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38484. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38485. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  38486. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38487. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38488. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38489. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38490. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38491. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38492. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  38493. /**
  38494. * Bounding box gizmo
  38495. */
  38496. var BoundingBoxGizmo = /** @class */ (function (_super) {
  38497. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  38498. /**
  38499. * Creates an BoundingBoxGizmo
  38500. * @param gizmoLayer The utility layer the gizmo will be added to
  38501. * @param color The color of the gizmo
  38502. */
  38503. function BoundingBoxGizmo(color, gizmoLayer) {
  38504. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  38505. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  38506. var _this = _super.call(this, gizmoLayer) || this;
  38507. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  38508. _this._renderObserver = null;
  38509. _this._pointerObserver = null;
  38510. _this._scaleDragSpeed = 0.2;
  38511. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38512. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  38513. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  38514. /**
  38515. * 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)
  38516. */
  38517. _this.ignoreChildren = false;
  38518. /**
  38519. * 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)
  38520. */
  38521. _this.includeChildPredicate = null;
  38522. /**
  38523. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38524. */
  38525. _this.rotationSphereSize = 0.1;
  38526. /**
  38527. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38528. */
  38529. _this.scaleBoxSize = 0.1;
  38530. /**
  38531. * 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)
  38532. */
  38533. _this.fixedDragMeshScreenSize = false;
  38534. /**
  38535. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38536. */
  38537. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  38538. /**
  38539. * Fired when a rotation sphere or scale box is dragged
  38540. */
  38541. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38542. /**
  38543. * Fired when a scale box is dragged
  38544. */
  38545. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38546. /**
  38547. * Fired when a scale box drag is ended
  38548. */
  38549. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38550. /**
  38551. * Fired when a rotation sphere is dragged
  38552. */
  38553. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38554. /**
  38555. * Fired when a rotation sphere drag is ended
  38556. */
  38557. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38558. /**
  38559. * 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)
  38560. */
  38561. _this.scalePivot = null;
  38562. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  38563. // Dragging
  38564. _this._dragMesh = null;
  38565. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  38566. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  38567. _this._updateScale = false;
  38568. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  38569. // Create Materials
  38570. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38571. _this.coloredMaterial.disableLighting = true;
  38572. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38573. _this.hoverColoredMaterial.disableLighting = true;
  38574. // Build bounding box out of lines
  38575. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38576. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38577. var lines = [];
  38578. 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));
  38579. 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));
  38580. 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));
  38581. 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));
  38582. 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));
  38583. 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));
  38584. 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));
  38585. 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));
  38586. 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));
  38587. 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));
  38588. 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));
  38589. 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));
  38590. lines.forEach(function (l) {
  38591. l.color = color;
  38592. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  38593. l.isPickable = false;
  38594. _this._lineBoundingBox.addChild(l);
  38595. });
  38596. _this._rootMesh.addChild(_this._lineBoundingBox);
  38597. _this.setColor(color);
  38598. // Create rotation spheres
  38599. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38600. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38601. var _loop_1 = function (i_1) {
  38602. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  38603. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38604. sphere.material = this_1.coloredMaterial;
  38605. // Drag behavior
  38606. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  38607. _dragBehavior.moveAttached = false;
  38608. _dragBehavior.updateDragPlane = false;
  38609. sphere.addBehavior(_dragBehavior);
  38610. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  38611. var totalTurnAmountOfDrag = 0;
  38612. _dragBehavior.onDragStartObservable.add(function () {
  38613. startingTurnDirection.copyFrom(sphere.forward);
  38614. totalTurnAmountOfDrag = 0;
  38615. });
  38616. _dragBehavior.onDragObservable.add(function (event) {
  38617. _this.onRotationSphereDragObservable.notifyObservers({});
  38618. if (_this.attachedMesh) {
  38619. var originalParent = _this.attachedMesh.parent;
  38620. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38621. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38622. return;
  38623. }
  38624. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38625. var worldDragDirection = startingTurnDirection;
  38626. // Project the world right on to the drag plane
  38627. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  38628. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  38629. // project drag delta on to the resulting drag axis and rotate based on that
  38630. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  38631. // Make rotation relative to size of mesh.
  38632. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38633. // Rotate based on axis
  38634. if (!_this.attachedMesh.rotationQuaternion) {
  38635. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38636. }
  38637. if (!_this._anchorMesh.rotationQuaternion) {
  38638. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  38639. }
  38640. // Do not allow the object to turn more than a full circle
  38641. totalTurnAmountOfDrag += projectDist;
  38642. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  38643. if (i_1 >= 8) {
  38644. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  38645. }
  38646. else if (i_1 >= 4) {
  38647. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  38648. }
  38649. else {
  38650. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  38651. }
  38652. // Rotate around center of bounding box
  38653. _this._anchorMesh.addChild(_this.attachedMesh);
  38654. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  38655. _this._anchorMesh.removeChild(_this.attachedMesh);
  38656. _this.attachedMesh.setParent(originalParent);
  38657. }
  38658. _this.updateBoundingBox();
  38659. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38660. }
  38661. _this._updateDummy();
  38662. });
  38663. // Selection/deselection
  38664. _dragBehavior.onDragStartObservable.add(function () {
  38665. _this.onDragStartObservable.notifyObservers({});
  38666. _this._selectNode(sphere);
  38667. });
  38668. _dragBehavior.onDragEndObservable.add(function () {
  38669. _this.onRotationSphereDragEndObservable.notifyObservers({});
  38670. _this._selectNode(null);
  38671. _this._updateDummy();
  38672. });
  38673. this_1._rotateSpheresParent.addChild(sphere);
  38674. };
  38675. var this_1 = this, _dragBehavior;
  38676. for (var i_1 = 0; i_1 < 12; i_1++) {
  38677. _loop_1(i_1);
  38678. }
  38679. _this._rootMesh.addChild(_this._rotateSpheresParent);
  38680. // Create scale cubes
  38681. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38682. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38683. for (var i = 0; i < 2; i++) {
  38684. for (var j = 0; j < 2; j++) {
  38685. var _loop_2 = function () {
  38686. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  38687. box.material = this_2.coloredMaterial;
  38688. // Dragging logic
  38689. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  38690. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38691. _dragBehavior.moveAttached = false;
  38692. box.addBehavior(_dragBehavior);
  38693. _dragBehavior.onDragObservable.add(function (event) {
  38694. _this.onScaleBoxDragObservable.notifyObservers({});
  38695. if (_this.attachedMesh) {
  38696. var originalParent = _this.attachedMesh.parent;
  38697. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38698. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38699. return;
  38700. }
  38701. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38702. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38703. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  38704. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  38705. _this.updateBoundingBox();
  38706. if (_this.scalePivot) {
  38707. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  38708. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  38709. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  38710. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38711. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38712. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  38713. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38714. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  38715. }
  38716. else {
  38717. // Scale from the position of the opposite corner
  38718. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  38719. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38720. }
  38721. _this._anchorMesh.addChild(_this.attachedMesh);
  38722. _this._anchorMesh.scaling.addInPlace(deltaScale);
  38723. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  38724. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  38725. }
  38726. _this._anchorMesh.removeChild(_this.attachedMesh);
  38727. _this.attachedMesh.setParent(originalParent);
  38728. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38729. }
  38730. _this._updateDummy();
  38731. });
  38732. // Selection/deselection
  38733. _dragBehavior.onDragStartObservable.add(function () {
  38734. _this.onDragStartObservable.notifyObservers({});
  38735. _this._selectNode(box);
  38736. });
  38737. _dragBehavior.onDragEndObservable.add(function () {
  38738. _this.onScaleBoxDragEndObservable.notifyObservers({});
  38739. _this._selectNode(null);
  38740. _this._updateDummy();
  38741. });
  38742. this_2._scaleBoxesParent.addChild(box);
  38743. };
  38744. var this_2 = this, _dragBehavior;
  38745. for (var k = 0; k < 2; k++) {
  38746. _loop_2();
  38747. }
  38748. }
  38749. }
  38750. _this._rootMesh.addChild(_this._scaleBoxesParent);
  38751. // Hover color change
  38752. var pointerIds = new Array();
  38753. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38754. if (!pointerIds[pointerInfo.event.pointerId]) {
  38755. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  38756. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  38757. pointerIds[pointerInfo.event.pointerId] = mesh;
  38758. mesh.material = _this.hoverColoredMaterial;
  38759. }
  38760. });
  38761. }
  38762. else {
  38763. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  38764. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  38765. delete pointerIds[pointerInfo.event.pointerId];
  38766. }
  38767. }
  38768. });
  38769. // Update bounding box positions
  38770. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  38771. // Only update the bouding box if scaling has changed
  38772. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  38773. _this.updateBoundingBox();
  38774. }
  38775. else if (_this.fixedDragMeshScreenSize) {
  38776. _this._updateRotationSpheres();
  38777. _this._updateScaleBoxes();
  38778. }
  38779. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  38780. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  38781. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  38782. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  38783. }
  38784. });
  38785. _this.updateBoundingBox();
  38786. return _this;
  38787. }
  38788. /**
  38789. * Sets the color of the bounding box gizmo
  38790. * @param color the color to set
  38791. */
  38792. BoundingBoxGizmo.prototype.setColor = function (color) {
  38793. this.coloredMaterial.emissiveColor = color;
  38794. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  38795. this._lineBoundingBox.getChildren().forEach(function (l) {
  38796. if (l.color) {
  38797. l.color = color;
  38798. }
  38799. });
  38800. };
  38801. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  38802. var _this = this;
  38803. if (value) {
  38804. // Reset anchor mesh to match attached mesh's scale
  38805. // This is needed to avoid invalid box/sphere position on first drag
  38806. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  38807. var originalParent = value.parent;
  38808. this._anchorMesh.addChild(value);
  38809. this._anchorMesh.removeChild(value);
  38810. value.setParent(originalParent);
  38811. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  38812. this.updateBoundingBox();
  38813. value.getChildMeshes(false).forEach(function (m) {
  38814. m.markAsDirty("scaling");
  38815. });
  38816. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  38817. _this._updateDummy();
  38818. });
  38819. }
  38820. };
  38821. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  38822. this._rotateSpheresParent.getChildMeshes()
  38823. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  38824. m.isVisible = (!selectedMesh || m == selectedMesh);
  38825. });
  38826. };
  38827. /**
  38828. * Updates the bounding box information for the Gizmo
  38829. */
  38830. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  38831. if (this.attachedMesh) {
  38832. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  38833. // Store original parent
  38834. var originalParent = this.attachedMesh.parent;
  38835. this.attachedMesh.setParent(null);
  38836. // Store original skelton override mesh
  38837. var originalSkeletonOverrideMesh = null;
  38838. if (this.attachedMesh.skeleton) {
  38839. originalSkeletonOverrideMesh = this.attachedMesh.skeleton.overrideMesh;
  38840. this.attachedMesh.skeleton.overrideMesh = null;
  38841. }
  38842. this._update();
  38843. // Rotate based on axis
  38844. if (!this.attachedMesh.rotationQuaternion) {
  38845. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  38846. }
  38847. if (!this._anchorMesh.rotationQuaternion) {
  38848. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  38849. }
  38850. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38851. // Store original position and reset mesh to origin before computing the bounding box
  38852. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38853. this._tmpVector.copyFrom(this.attachedMesh.position);
  38854. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  38855. this.attachedMesh.position.set(0, 0, 0);
  38856. // Update bounding dimensions/positions
  38857. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  38858. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  38859. // Update gizmo to match bounding box scaling and rotation
  38860. // The position set here is the offset from the origin for the boundingbox when the attached mesh is at the origin
  38861. // The position of the gizmo is then set to the attachedMesh in gizmo._update
  38862. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  38863. 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);
  38864. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  38865. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  38866. this._lineBoundingBox.computeWorldMatrix();
  38867. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  38868. // Restore position/rotation values
  38869. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  38870. this.attachedMesh.position.copyFrom(this._tmpVector);
  38871. // Restore original parent
  38872. this.attachedMesh.setParent(originalParent);
  38873. // Restore original skeleton override mesh
  38874. if (this.attachedMesh.skeleton) {
  38875. this.attachedMesh.skeleton.overrideMesh = originalSkeletonOverrideMesh;
  38876. }
  38877. }
  38878. this._updateRotationSpheres();
  38879. this._updateScaleBoxes();
  38880. if (this.attachedMesh) {
  38881. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  38882. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  38883. }
  38884. };
  38885. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  38886. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  38887. for (var i = 0; i < 3; i++) {
  38888. for (var j = 0; j < 2; j++) {
  38889. for (var k = 0; k < 2; k++) {
  38890. var index = ((i * 4) + (j * 2)) + k;
  38891. if (i == 0) {
  38892. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38893. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38894. 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));
  38895. }
  38896. if (i == 1) {
  38897. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  38898. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38899. 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));
  38900. }
  38901. if (i == 2) {
  38902. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  38903. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38904. 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));
  38905. }
  38906. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38907. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38908. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38909. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38910. }
  38911. else {
  38912. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  38913. }
  38914. }
  38915. }
  38916. }
  38917. };
  38918. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  38919. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  38920. for (var i = 0; i < 2; i++) {
  38921. for (var j = 0; j < 2; j++) {
  38922. for (var k = 0; k < 2; k++) {
  38923. var index = ((i * 4) + (j * 2)) + k;
  38924. if (scaleBoxes[index]) {
  38925. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38926. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38927. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38928. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38929. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38930. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38931. }
  38932. else {
  38933. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  38934. }
  38935. }
  38936. }
  38937. }
  38938. }
  38939. };
  38940. /**
  38941. * Enables rotation on the specified axis and disables rotation on the others
  38942. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38943. */
  38944. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38945. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38946. if (i < 4) {
  38947. m.setEnabled(axis.indexOf("x") != -1);
  38948. }
  38949. else if (i < 8) {
  38950. m.setEnabled(axis.indexOf("y") != -1);
  38951. }
  38952. else {
  38953. m.setEnabled(axis.indexOf("z") != -1);
  38954. }
  38955. });
  38956. };
  38957. /**
  38958. * Enables/disables scaling
  38959. * @param enable if scaling should be enabled
  38960. */
  38961. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38962. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38963. m.setEnabled(enable);
  38964. });
  38965. };
  38966. BoundingBoxGizmo.prototype._updateDummy = function () {
  38967. if (this._dragMesh) {
  38968. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38969. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38970. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38971. }
  38972. };
  38973. /**
  38974. * Enables a pointer drag behavior on the bounding box of the gizmo
  38975. */
  38976. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38977. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38978. this._dragMesh.visibility = 0;
  38979. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38980. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38981. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38982. };
  38983. /**
  38984. * Disposes of the gizmo
  38985. */
  38986. BoundingBoxGizmo.prototype.dispose = function () {
  38987. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38988. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38989. this._lineBoundingBox.dispose();
  38990. this._rotateSpheresParent.dispose();
  38991. this._scaleBoxesParent.dispose();
  38992. if (this._dragMesh) {
  38993. this._dragMesh.dispose();
  38994. }
  38995. _super.prototype.dispose.call(this);
  38996. };
  38997. /**
  38998. * 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)
  38999. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  39000. * @returns the bounding box mesh with the passed in mesh as a child
  39001. */
  39002. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  39003. var makeNotPickable = function (root) {
  39004. root.isPickable = false;
  39005. root.getChildMeshes().forEach(function (c) {
  39006. makeNotPickable(c);
  39007. });
  39008. };
  39009. makeNotPickable(mesh);
  39010. // Reset position to get boudning box from origin with no rotation
  39011. if (!mesh.rotationQuaternion) {
  39012. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  39013. }
  39014. var oldPos = mesh.position.clone();
  39015. var oldRot = mesh.rotationQuaternion.clone();
  39016. mesh.rotationQuaternion.set(0, 0, 0, 1);
  39017. mesh.position.set(0, 0, 0);
  39018. // Update bounding dimensions/positions
  39019. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  39020. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  39021. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  39022. // Adjust scale to avoid undefined behavior when adding child
  39023. if (box.scaling.y === 0) {
  39024. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  39025. }
  39026. if (box.scaling.x === 0) {
  39027. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  39028. }
  39029. if (box.scaling.z === 0) {
  39030. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  39031. }
  39032. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  39033. // Restore original positions
  39034. mesh.addChild(box);
  39035. mesh.rotationQuaternion.copyFrom(oldRot);
  39036. mesh.position.copyFrom(oldPos);
  39037. // Reverse parenting
  39038. mesh.removeChild(box);
  39039. box.addChild(mesh);
  39040. box.visibility = 0;
  39041. return box;
  39042. };
  39043. /**
  39044. * CustomMeshes are not supported by this gizmo
  39045. * @param mesh The mesh to replace the default mesh of the gizmo
  39046. */
  39047. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  39048. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  39049. };
  39050. return BoundingBoxGizmo;
  39051. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  39052. /***/ }),
  39053. /***/ "./Gizmos/gizmo.ts":
  39054. /*!*************************!*\
  39055. !*** ./Gizmos/gizmo.ts ***!
  39056. \*************************/
  39057. /*! exports provided: Gizmo */
  39058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39059. "use strict";
  39060. __webpack_require__.r(__webpack_exports__);
  39061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  39062. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39063. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39064. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39065. /**
  39066. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39067. */
  39068. var Gizmo = /** @class */ (function () {
  39069. /**
  39070. * Creates a gizmo
  39071. * @param gizmoLayer The utility layer the gizmo will be added to
  39072. */
  39073. function Gizmo(
  39074. /** The utility layer the gizmo will be added to */
  39075. gizmoLayer) {
  39076. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39077. var _this = this;
  39078. this.gizmoLayer = gizmoLayer;
  39079. /**
  39080. * Ratio for the scale of the gizmo (Default: 1)
  39081. */
  39082. this.scaleRatio = 1;
  39083. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  39084. /**
  39085. * If a custom mesh has been set (Default: false)
  39086. */
  39087. this._customMeshSet = false;
  39088. /**
  39089. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39090. */
  39091. this.updateGizmoRotationToMatchAttachedMesh = true;
  39092. /**
  39093. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39094. */
  39095. this.updateGizmoPositionToMatchAttachedMesh = true;
  39096. /**
  39097. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39098. */
  39099. this._updateScale = true;
  39100. this._interactionsEnabled = true;
  39101. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  39102. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  39103. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  39104. _this._update();
  39105. });
  39106. this.attachedMesh = null;
  39107. }
  39108. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  39109. /**
  39110. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39111. * * When set, interactions will be enabled
  39112. */
  39113. get: function () {
  39114. return this._attachedMesh;
  39115. },
  39116. set: function (value) {
  39117. this._attachedMesh = value;
  39118. this._rootMesh.setEnabled(value ? true : false);
  39119. this._attachedMeshChanged(value);
  39120. },
  39121. enumerable: true,
  39122. configurable: true
  39123. });
  39124. /**
  39125. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39126. * @param mesh The mesh to replace the default mesh of the gizmo
  39127. */
  39128. Gizmo.prototype.setCustomMesh = function (mesh) {
  39129. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  39130. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  39131. }
  39132. this._rootMesh.getChildMeshes().forEach(function (c) {
  39133. c.dispose();
  39134. });
  39135. mesh.parent = this._rootMesh;
  39136. this._customMeshSet = true;
  39137. };
  39138. Gizmo.prototype._attachedMeshChanged = function (value) {
  39139. };
  39140. /**
  39141. * @hidden
  39142. * Updates the gizmo to match the attached mesh's position/rotation
  39143. */
  39144. Gizmo.prototype._update = function () {
  39145. if (this.attachedMesh) {
  39146. var effectiveMesh = this.attachedMesh._effectiveMesh || this.attachedMesh;
  39147. if (this.updateGizmoRotationToMatchAttachedMesh) {
  39148. if (!this._rootMesh.rotationQuaternion) {
  39149. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  39150. }
  39151. effectiveMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  39152. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  39153. }
  39154. else if (this._rootMesh.rotationQuaternion) {
  39155. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  39156. }
  39157. if (this.updateGizmoPositionToMatchAttachedMesh) {
  39158. this._rootMesh.position.copyFrom(effectiveMesh.absolutePosition);
  39159. }
  39160. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  39161. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  39162. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  39163. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  39164. }
  39165. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  39166. var dist = this._tempVector.length() * this.scaleRatio;
  39167. this._rootMesh.scaling.set(dist, dist, dist);
  39168. }
  39169. }
  39170. };
  39171. /**
  39172. * Disposes of the gizmo
  39173. */
  39174. Gizmo.prototype.dispose = function () {
  39175. this._rootMesh.dispose();
  39176. if (this._beforeRenderObserver) {
  39177. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  39178. }
  39179. };
  39180. return Gizmo;
  39181. }());
  39182. /***/ }),
  39183. /***/ "./Gizmos/gizmoManager.ts":
  39184. /*!********************************!*\
  39185. !*** ./Gizmos/gizmoManager.ts ***!
  39186. \********************************/
  39187. /*! exports provided: GizmoManager */
  39188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39189. "use strict";
  39190. __webpack_require__.r(__webpack_exports__);
  39191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  39192. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39193. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  39194. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39195. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39196. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39197. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  39198. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39199. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39200. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39201. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39202. /**
  39203. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  39204. */
  39205. var GizmoManager = /** @class */ (function () {
  39206. /**
  39207. * Instatiates a gizmo manager
  39208. * @param scene the scene to overlay the gizmos on top of
  39209. */
  39210. function GizmoManager(scene) {
  39211. var _this = this;
  39212. this.scene = scene;
  39213. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  39214. this.clearGizmoOnEmptyPointerEvent = false;
  39215. /** Fires an event when the manager is attached to a mesh */
  39216. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  39217. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  39218. this._pointerObserver = null;
  39219. this._attachedMesh = null;
  39220. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  39221. /**
  39222. * When bounding box gizmo is enabled, this can be used to track drag/end events
  39223. */
  39224. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  39225. /**
  39226. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  39227. */
  39228. this.attachableMeshes = null;
  39229. /**
  39230. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  39231. */
  39232. this.usePointerToAttachGizmos = true;
  39233. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  39234. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  39235. this._defaultUtilityLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"].DefaultUtilityLayer;
  39236. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  39237. // Instatiate/dispose gizmos based on pointer actions
  39238. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  39239. if (!_this.usePointerToAttachGizmos) {
  39240. return;
  39241. }
  39242. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  39243. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  39244. var node = pointerInfo.pickInfo.pickedMesh;
  39245. if (_this.attachableMeshes == null) {
  39246. // Attach to the most parent node
  39247. while (node && node.parent != null) {
  39248. node = node.parent;
  39249. }
  39250. }
  39251. else {
  39252. // Attach to the parent node that is an attachableMesh
  39253. var found = false;
  39254. _this.attachableMeshes.forEach(function (mesh) {
  39255. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  39256. node = mesh;
  39257. found = true;
  39258. }
  39259. });
  39260. if (!found) {
  39261. node = null;
  39262. }
  39263. }
  39264. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  39265. if (_this._attachedMesh != node) {
  39266. _this.attachToMesh(node);
  39267. }
  39268. }
  39269. else {
  39270. if (_this.clearGizmoOnEmptyPointerEvent) {
  39271. _this.attachToMesh(null);
  39272. }
  39273. }
  39274. }
  39275. else {
  39276. if (_this.clearGizmoOnEmptyPointerEvent) {
  39277. _this.attachToMesh(null);
  39278. }
  39279. }
  39280. }
  39281. });
  39282. }
  39283. /**
  39284. * Attaches a set of gizmos to the specified mesh
  39285. * @param mesh The mesh the gizmo's should be attached to
  39286. */
  39287. GizmoManager.prototype.attachToMesh = function (mesh) {
  39288. if (this._attachedMesh) {
  39289. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39290. }
  39291. this._attachedMesh = mesh;
  39292. for (var key in this.gizmos) {
  39293. var gizmo = (this.gizmos[key]);
  39294. if (gizmo && this._gizmosEnabled[key]) {
  39295. gizmo.attachedMesh = mesh;
  39296. }
  39297. }
  39298. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  39299. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39300. }
  39301. this.onAttachedToMeshObservable.notifyObservers(mesh);
  39302. };
  39303. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  39304. get: function () {
  39305. return this._gizmosEnabled.positionGizmo;
  39306. },
  39307. /**
  39308. * If the position gizmo is enabled
  39309. */
  39310. set: function (value) {
  39311. if (value) {
  39312. if (!this.gizmos.positionGizmo) {
  39313. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  39314. }
  39315. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  39316. }
  39317. else if (this.gizmos.positionGizmo) {
  39318. this.gizmos.positionGizmo.attachedMesh = null;
  39319. }
  39320. this._gizmosEnabled.positionGizmo = value;
  39321. },
  39322. enumerable: true,
  39323. configurable: true
  39324. });
  39325. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  39326. get: function () {
  39327. return this._gizmosEnabled.rotationGizmo;
  39328. },
  39329. /**
  39330. * If the rotation gizmo is enabled
  39331. */
  39332. set: function (value) {
  39333. if (value) {
  39334. if (!this.gizmos.rotationGizmo) {
  39335. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  39336. }
  39337. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  39338. }
  39339. else if (this.gizmos.rotationGizmo) {
  39340. this.gizmos.rotationGizmo.attachedMesh = null;
  39341. }
  39342. this._gizmosEnabled.rotationGizmo = value;
  39343. },
  39344. enumerable: true,
  39345. configurable: true
  39346. });
  39347. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  39348. get: function () {
  39349. return this._gizmosEnabled.scaleGizmo;
  39350. },
  39351. /**
  39352. * If the scale gizmo is enabled
  39353. */
  39354. set: function (value) {
  39355. if (value) {
  39356. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  39357. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  39358. }
  39359. else if (this.gizmos.scaleGizmo) {
  39360. this.gizmos.scaleGizmo.attachedMesh = null;
  39361. }
  39362. this._gizmosEnabled.scaleGizmo = value;
  39363. },
  39364. enumerable: true,
  39365. configurable: true
  39366. });
  39367. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  39368. get: function () {
  39369. return this._gizmosEnabled.boundingBoxGizmo;
  39370. },
  39371. /**
  39372. * If the boundingBox gizmo is enabled
  39373. */
  39374. set: function (value) {
  39375. if (value) {
  39376. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  39377. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  39378. if (this._attachedMesh) {
  39379. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39380. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39381. }
  39382. }
  39383. else if (this.gizmos.boundingBoxGizmo) {
  39384. if (this._attachedMesh) {
  39385. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39386. }
  39387. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  39388. }
  39389. this._gizmosEnabled.boundingBoxGizmo = value;
  39390. },
  39391. enumerable: true,
  39392. configurable: true
  39393. });
  39394. /**
  39395. * Disposes of the gizmo manager
  39396. */
  39397. GizmoManager.prototype.dispose = function () {
  39398. this.scene.onPointerObservable.remove(this._pointerObserver);
  39399. for (var key in this.gizmos) {
  39400. var gizmo = (this.gizmos[key]);
  39401. if (gizmo) {
  39402. gizmo.dispose();
  39403. }
  39404. }
  39405. this._defaultKeepDepthUtilityLayer.dispose();
  39406. this.boundingBoxDragBehavior.detach();
  39407. this.onAttachedToMeshObservable.clear();
  39408. };
  39409. return GizmoManager;
  39410. }());
  39411. /***/ }),
  39412. /***/ "./Gizmos/index.ts":
  39413. /*!*************************!*\
  39414. !*** ./Gizmos/index.ts ***!
  39415. \*************************/
  39416. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  39417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39418. "use strict";
  39419. __webpack_require__.r(__webpack_exports__);
  39420. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  39422. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  39424. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  39426. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  39428. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  39429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  39430. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  39432. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  39434. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  39436. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  39438. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  39439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  39440. /***/ }),
  39441. /***/ "./Gizmos/lightGizmo.ts":
  39442. /*!******************************!*\
  39443. !*** ./Gizmos/lightGizmo.ts ***!
  39444. \******************************/
  39445. /*! exports provided: LightGizmo */
  39446. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39447. "use strict";
  39448. __webpack_require__.r(__webpack_exports__);
  39449. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  39450. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39451. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39452. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39453. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39454. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39455. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39456. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39457. /* harmony import */ var _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/directionalLight */ "./Lights/directionalLight.ts");
  39458. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39459. /* harmony import */ var _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  39460. /* harmony import */ var _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Lights/spotLight */ "./Lights/spotLight.ts");
  39461. /**
  39462. * Gizmo that enables viewing a light
  39463. */
  39464. var LightGizmo = /** @class */ (function (_super) {
  39465. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  39466. /**
  39467. * Creates a LightGizmo
  39468. * @param gizmoLayer The utility layer the gizmo will be added to
  39469. */
  39470. function LightGizmo(gizmoLayer) {
  39471. var _this = _super.call(this, gizmoLayer) || this;
  39472. _this._light = null;
  39473. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  39474. _this._material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("light", _this.gizmoLayer.originalScene);
  39475. _this._material.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.5, 0.5, 0.5);
  39476. _this._material.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.1, 0.1, 0.1);
  39477. return _this;
  39478. }
  39479. Object.defineProperty(LightGizmo.prototype, "light", {
  39480. get: function () {
  39481. return this._light;
  39482. },
  39483. /**
  39484. * The light that the gizmo is attached to
  39485. */
  39486. set: function (light) {
  39487. var _this = this;
  39488. this._light = light;
  39489. if (light) {
  39490. // Create the mesh for the given light type
  39491. if (this._lightMesh) {
  39492. this._lightMesh.dispose();
  39493. }
  39494. if (light instanceof _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__["HemisphericLight"]) {
  39495. this._lightMesh = LightGizmo._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene);
  39496. }
  39497. else if (light instanceof _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__["DirectionalLight"]) {
  39498. this._lightMesh = LightGizmo._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene);
  39499. }
  39500. else if (light instanceof _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__["SpotLight"]) {
  39501. this._lightMesh = LightGizmo._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene);
  39502. }
  39503. else {
  39504. this._lightMesh = LightGizmo._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene);
  39505. }
  39506. this._lightMesh.getChildMeshes(false).forEach(function (m) {
  39507. m.material = _this._material;
  39508. });
  39509. this._lightMesh.parent = this._rootMesh;
  39510. // Add lighting to the light gizmo
  39511. var gizmoLight = this.gizmoLayer._getSharedGizmoLight();
  39512. gizmoLight.includedOnlyMeshes = gizmoLight.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(false));
  39513. // Get update position and direction if the light has it
  39514. if (light.position) {
  39515. this.attachedMesh.position.copyFrom(light.position);
  39516. }
  39517. if (light.direction) {
  39518. this._lightMesh.setDirection(light.direction);
  39519. }
  39520. }
  39521. },
  39522. enumerable: true,
  39523. configurable: true
  39524. });
  39525. /**
  39526. * @hidden
  39527. * Updates the gizmo to match the attached mesh's position/rotation
  39528. */
  39529. LightGizmo.prototype._update = function () {
  39530. _super.prototype._update.call(this);
  39531. if (!this._light) {
  39532. return;
  39533. }
  39534. if (this._light.position) {
  39535. this._light.position.copyFrom(this.attachedMesh.position);
  39536. }
  39537. if (this._light.direction) {
  39538. this._light.direction.copyFrom(this._lightMesh.forward);
  39539. }
  39540. if (!this._light.isEnabled()) {
  39541. this._material.diffuseColor.set(0, 0, 0);
  39542. }
  39543. else {
  39544. this._material.diffuseColor.set(this._light.diffuse.r / 3, this._light.diffuse.g / 3, this._light.diffuse.b / 3);
  39545. }
  39546. };
  39547. LightGizmo._CreateHemisphericLightMesh = function (scene) {
  39548. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("hemisphereLight", scene);
  39549. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 1 }, scene);
  39550. hemisphere.position.z = -0.15;
  39551. hemisphere.rotation.x = Math.PI / 2;
  39552. hemisphere.parent = root;
  39553. var lines = this._createLightLines(3, scene);
  39554. lines.parent = root;
  39555. lines.position.z - 0.15;
  39556. root.scaling.scaleInPlace(LightGizmo._Scale);
  39557. root.rotation.x = Math.PI / 2;
  39558. return root;
  39559. };
  39560. LightGizmo._CreatePointLightMesh = function (scene) {
  39561. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("pointLight", scene);
  39562. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39563. sphere.rotation.x = Math.PI / 2;
  39564. sphere.parent = root;
  39565. var lines = this._createLightLines(5, scene);
  39566. lines.parent = root;
  39567. root.scaling.scaleInPlace(LightGizmo._Scale);
  39568. root.rotation.x = Math.PI / 2;
  39569. return root;
  39570. };
  39571. LightGizmo._CreateSpotLightMesh = function (scene) {
  39572. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("spotLight", scene);
  39573. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39574. sphere.parent = root;
  39575. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 2 }, scene);
  39576. hemisphere.parent = root;
  39577. hemisphere.rotation.x = -Math.PI / 2;
  39578. var lines = this._createLightLines(2, scene);
  39579. lines.parent = root;
  39580. root.scaling.scaleInPlace(LightGizmo._Scale);
  39581. root.rotation.x = Math.PI / 2;
  39582. return root;
  39583. };
  39584. LightGizmo._CreateDirectionalLightMesh = function (scene) {
  39585. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("directionalLight", scene);
  39586. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](root.name, scene);
  39587. mesh.parent = root;
  39588. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { diameter: 1.2, segments: 10 }, scene);
  39589. sphere.parent = mesh;
  39590. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 6, 0.3, 0.3, 6, 1, scene);
  39591. line.parent = mesh;
  39592. var left = line.clone(root.name);
  39593. left.scaling.y = 0.5;
  39594. left.position.x += 1.25;
  39595. var right = line.clone(root.name);
  39596. right.scaling.y = 0.5;
  39597. right.position.x += -1.25;
  39598. var arrowHead = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 1, 0, 0.6, 6, 1, scene);
  39599. arrowHead.position.y += 3;
  39600. arrowHead.parent = mesh;
  39601. var left = arrowHead.clone(root.name);
  39602. left.position.y = 1.5;
  39603. left.position.x += 1.25;
  39604. var right = arrowHead.clone(root.name);
  39605. right.position.y = 1.5;
  39606. right.position.x += -1.25;
  39607. mesh.scaling.scaleInPlace(LightGizmo._Scale);
  39608. mesh.rotation.z = Math.PI / 2;
  39609. mesh.rotation.y = Math.PI / 2;
  39610. return root;
  39611. };
  39612. // Static helper methods
  39613. LightGizmo._Scale = 0.007;
  39614. /**
  39615. * Creates the lines for a light mesh
  39616. */
  39617. LightGizmo._createLightLines = function (levels, scene) {
  39618. var distFromSphere = 1.2;
  39619. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("root", scene);
  39620. root.rotation.x = Math.PI / 2;
  39621. // Create the top line, this will be cloned for all other lines
  39622. var linePivot = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("linePivot", scene);
  39623. linePivot.parent = root;
  39624. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("line", 2, 0.2, 0.3, 6, 1, scene);
  39625. line.position.y = line.scaling.y / 2 + distFromSphere;
  39626. line.parent = linePivot;
  39627. if (levels < 2) {
  39628. return linePivot;
  39629. }
  39630. for (var i = 0; i < 4; i++) {
  39631. var l = linePivot.clone("lineParentClone");
  39632. l.rotation.z = Math.PI / 4;
  39633. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39634. l.getChildMeshes()[0].scaling.y = 0.5;
  39635. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39636. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39637. }
  39638. if (levels < 3) {
  39639. return root;
  39640. }
  39641. for (var i = 0; i < 4; i++) {
  39642. var l = linePivot.clone("linePivotClone");
  39643. l.rotation.z = Math.PI / 2;
  39644. l.rotation.y = (Math.PI / 2 * i);
  39645. }
  39646. if (levels < 4) {
  39647. return root;
  39648. }
  39649. for (var i = 0; i < 4; i++) {
  39650. var l = linePivot.clone("linePivotClone");
  39651. l.rotation.z = Math.PI + (Math.PI / 4);
  39652. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39653. l.getChildMeshes()[0].scaling.y = 0.5;
  39654. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39655. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39656. }
  39657. if (levels < 5) {
  39658. return root;
  39659. }
  39660. var l = linePivot.clone("linePivotClone");
  39661. l.rotation.z = Math.PI;
  39662. return root;
  39663. };
  39664. return LightGizmo;
  39665. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39666. /***/ }),
  39667. /***/ "./Gizmos/planeRotationGizmo.ts":
  39668. /*!**************************************!*\
  39669. !*** ./Gizmos/planeRotationGizmo.ts ***!
  39670. \**************************************/
  39671. /*! exports provided: PlaneRotationGizmo */
  39672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39673. "use strict";
  39674. __webpack_require__.r(__webpack_exports__);
  39675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  39676. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39677. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39678. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39679. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39680. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39681. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  39682. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39683. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39684. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39685. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  39686. /**
  39687. * Single plane rotation gizmo
  39688. */
  39689. var PlaneRotationGizmo = /** @class */ (function (_super) {
  39690. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  39691. /**
  39692. * Creates a PlaneRotationGizmo
  39693. * @param gizmoLayer The utility layer the gizmo will be added to
  39694. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  39695. * @param color The color of the gizmo
  39696. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39697. */
  39698. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  39699. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  39700. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39701. if (tessellation === void 0) { tessellation = 32; }
  39702. var _this = _super.call(this, gizmoLayer) || this;
  39703. _this._pointerObserver = null;
  39704. /**
  39705. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  39706. */
  39707. _this.snapDistance = 0;
  39708. /**
  39709. * Event that fires each time the gizmo snaps to a new location.
  39710. * * snapDistance is the the change in distance
  39711. */
  39712. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39713. // Create Material
  39714. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39715. coloredMaterial.diffuseColor = color;
  39716. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  39717. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39718. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  39719. // Build mesh on root node
  39720. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  39721. var drag = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.03, tessellation, gizmoLayer.utilityLayerScene);
  39722. drag.visibility = 0;
  39723. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.005, tessellation, gizmoLayer.utilityLayerScene);
  39724. rotationMesh.material = coloredMaterial;
  39725. // Position arrow pointing in its drag axis
  39726. rotationMesh.rotation.x = Math.PI / 2;
  39727. drag.rotation.x = Math.PI / 2;
  39728. parentMesh.addChild(rotationMesh);
  39729. parentMesh.addChild(drag);
  39730. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  39731. _this._rootMesh.addChild(parentMesh);
  39732. parentMesh.scaling.scaleInPlace(1 / 3);
  39733. // Add drag behavior to handle events when the gizmo is dragged
  39734. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  39735. _this.dragBehavior.moveAttached = false;
  39736. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  39737. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  39738. _this._rootMesh.addBehavior(_this.dragBehavior);
  39739. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39740. _this.dragBehavior.onDragStartObservable.add(function (e) {
  39741. if (_this.attachedMesh) {
  39742. lastDragPosition.copyFrom(e.dragPlanePoint);
  39743. }
  39744. });
  39745. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39746. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39747. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39748. var tmpSnapEvent = { snapDistance: 0 };
  39749. var currentSnapDragDistance = 0;
  39750. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39751. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39752. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  39753. _this.dragBehavior.onDragObservable.add(function (event) {
  39754. if (_this.attachedMesh) {
  39755. if (!_this.attachedMesh.rotationQuaternion) {
  39756. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  39757. }
  39758. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  39759. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  39760. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  39761. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  39762. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  39763. var angle = Math.atan2(cross.length(), dot);
  39764. planeNormalTowardsCamera.copyFrom(planeNormal);
  39765. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  39766. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39767. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  39768. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  39769. }
  39770. // Flip up vector depending on which side the camera is on
  39771. if (gizmoLayer.utilityLayerScene.activeCamera) {
  39772. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  39773. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  39774. planeNormalTowardsCamera.scaleInPlace(-1);
  39775. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  39776. }
  39777. }
  39778. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  39779. if (halfCircleSide) {
  39780. angle = -angle;
  39781. }
  39782. // Snapping logic
  39783. var snapped = false;
  39784. if (_this.snapDistance != 0) {
  39785. currentSnapDragDistance += angle;
  39786. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  39787. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  39788. if (currentSnapDragDistance < 0) {
  39789. dragSteps *= -1;
  39790. }
  39791. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  39792. angle = _this.snapDistance * dragSteps;
  39793. snapped = true;
  39794. }
  39795. else {
  39796. angle = 0;
  39797. }
  39798. }
  39799. // If the mesh has a parent, convert needed world rotation to local rotation
  39800. tmpMatrix.reset();
  39801. if (_this.attachedMesh.parent) {
  39802. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  39803. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  39804. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  39805. }
  39806. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  39807. var quaternionCoefficient = Math.sin(angle / 2);
  39808. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  39809. // 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
  39810. if (tmpMatrix.determinant() > 0) {
  39811. amountToRotate.toEulerAnglesToRef(tmpVector);
  39812. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  39813. }
  39814. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39815. // Rotate selected mesh quaternion over fixed axis
  39816. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  39817. }
  39818. else {
  39819. // Rotate selected mesh quaternion over rotated axis
  39820. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  39821. }
  39822. lastDragPosition.copyFrom(event.dragPlanePoint);
  39823. if (snapped) {
  39824. tmpSnapEvent.snapDistance = angle;
  39825. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  39826. }
  39827. }
  39828. });
  39829. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  39830. if (_this._customMeshSet) {
  39831. return;
  39832. }
  39833. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  39834. var material = isHovered ? hoverMaterial : coloredMaterial;
  39835. _this._rootMesh.getChildMeshes().forEach(function (m) {
  39836. m.material = material;
  39837. if (m.color) {
  39838. m.color = material.diffuseColor;
  39839. }
  39840. });
  39841. });
  39842. var light = gizmoLayer._getSharedGizmoLight();
  39843. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  39844. return _this;
  39845. }
  39846. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  39847. if (this.dragBehavior) {
  39848. this.dragBehavior.enabled = value ? true : false;
  39849. }
  39850. };
  39851. /**
  39852. * Disposes of the gizmo
  39853. */
  39854. PlaneRotationGizmo.prototype.dispose = function () {
  39855. this.onSnapObservable.clear();
  39856. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  39857. this.dragBehavior.detach();
  39858. _super.prototype.dispose.call(this);
  39859. };
  39860. return PlaneRotationGizmo;
  39861. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  39862. /***/ }),
  39863. /***/ "./Gizmos/positionGizmo.ts":
  39864. /*!*********************************!*\
  39865. !*** ./Gizmos/positionGizmo.ts ***!
  39866. \*********************************/
  39867. /*! exports provided: PositionGizmo */
  39868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39869. "use strict";
  39870. __webpack_require__.r(__webpack_exports__);
  39871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  39872. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39873. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39874. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39875. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39876. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39877. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39878. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39879. /**
  39880. * Gizmo that enables dragging a mesh along 3 axis
  39881. */
  39882. var PositionGizmo = /** @class */ (function (_super) {
  39883. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  39884. /**
  39885. * Creates a PositionGizmo
  39886. * @param gizmoLayer The utility layer the gizmo will be added to
  39887. */
  39888. function PositionGizmo(gizmoLayer) {
  39889. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39890. var _this = _super.call(this, gizmoLayer) || this;
  39891. /** Fires an event when any of it's sub gizmos are dragged */
  39892. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39893. /** Fires an event when any of it's sub gizmos are released from dragging */
  39894. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39895. _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);
  39896. _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);
  39897. _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);
  39898. // Relay drag events
  39899. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39900. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39901. _this.onDragStartObservable.notifyObservers({});
  39902. });
  39903. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39904. _this.onDragEndObservable.notifyObservers({});
  39905. });
  39906. });
  39907. _this.attachedMesh = null;
  39908. return _this;
  39909. }
  39910. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  39911. get: function () {
  39912. return this.xGizmo.attachedMesh;
  39913. },
  39914. set: function (mesh) {
  39915. if (this.xGizmo) {
  39916. this.xGizmo.attachedMesh = mesh;
  39917. this.yGizmo.attachedMesh = mesh;
  39918. this.zGizmo.attachedMesh = mesh;
  39919. }
  39920. },
  39921. enumerable: true,
  39922. configurable: true
  39923. });
  39924. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39925. get: function () {
  39926. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39927. },
  39928. set: function (value) {
  39929. if (this.xGizmo) {
  39930. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39931. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39932. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39933. }
  39934. },
  39935. enumerable: true,
  39936. configurable: true
  39937. });
  39938. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  39939. get: function () {
  39940. return this.xGizmo.snapDistance;
  39941. },
  39942. /**
  39943. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39944. */
  39945. set: function (value) {
  39946. if (this.xGizmo) {
  39947. this.xGizmo.snapDistance = value;
  39948. this.yGizmo.snapDistance = value;
  39949. this.zGizmo.snapDistance = value;
  39950. }
  39951. },
  39952. enumerable: true,
  39953. configurable: true
  39954. });
  39955. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  39956. get: function () {
  39957. return this.xGizmo.scaleRatio;
  39958. },
  39959. /**
  39960. * Ratio for the scale of the gizmo (Default: 1)
  39961. */
  39962. set: function (value) {
  39963. if (this.xGizmo) {
  39964. this.xGizmo.scaleRatio = value;
  39965. this.yGizmo.scaleRatio = value;
  39966. this.zGizmo.scaleRatio = value;
  39967. }
  39968. },
  39969. enumerable: true,
  39970. configurable: true
  39971. });
  39972. /**
  39973. * Disposes of the gizmo
  39974. */
  39975. PositionGizmo.prototype.dispose = function () {
  39976. this.xGizmo.dispose();
  39977. this.yGizmo.dispose();
  39978. this.zGizmo.dispose();
  39979. this.onDragStartObservable.clear();
  39980. this.onDragEndObservable.clear();
  39981. };
  39982. /**
  39983. * CustomMeshes are not supported by this gizmo
  39984. * @param mesh The mesh to replace the default mesh of the gizmo
  39985. */
  39986. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  39987. _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)");
  39988. };
  39989. return PositionGizmo;
  39990. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39991. /***/ }),
  39992. /***/ "./Gizmos/rotationGizmo.ts":
  39993. /*!*********************************!*\
  39994. !*** ./Gizmos/rotationGizmo.ts ***!
  39995. \*********************************/
  39996. /*! exports provided: RotationGizmo */
  39997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39998. "use strict";
  39999. __webpack_require__.r(__webpack_exports__);
  40000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  40001. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40002. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40003. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40004. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40005. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40006. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  40007. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40008. /**
  40009. * Gizmo that enables rotating a mesh along 3 axis
  40010. */
  40011. var RotationGizmo = /** @class */ (function (_super) {
  40012. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  40013. /**
  40014. * Creates a RotationGizmo
  40015. * @param gizmoLayer The utility layer the gizmo will be added to
  40016. * @param tessellation Amount of tessellation to be used when creating rotation circles
  40017. */
  40018. function RotationGizmo(gizmoLayer, tessellation) {
  40019. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40020. if (tessellation === void 0) { tessellation = 32; }
  40021. var _this = _super.call(this, gizmoLayer) || this;
  40022. /** Fires an event when any of it's sub gizmos are dragged */
  40023. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40024. /** Fires an event when any of it's sub gizmos are released from dragging */
  40025. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40026. _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);
  40027. _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);
  40028. _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);
  40029. // Relay drag events
  40030. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  40031. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40032. _this.onDragStartObservable.notifyObservers({});
  40033. });
  40034. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40035. _this.onDragEndObservable.notifyObservers({});
  40036. });
  40037. });
  40038. _this.attachedMesh = null;
  40039. return _this;
  40040. }
  40041. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  40042. get: function () {
  40043. return this.xGizmo.attachedMesh;
  40044. },
  40045. set: function (mesh) {
  40046. if (this.xGizmo) {
  40047. this.xGizmo.attachedMesh = mesh;
  40048. this.yGizmo.attachedMesh = mesh;
  40049. this.zGizmo.attachedMesh = mesh;
  40050. }
  40051. },
  40052. enumerable: true,
  40053. configurable: true
  40054. });
  40055. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40056. get: function () {
  40057. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40058. },
  40059. set: function (value) {
  40060. if (this.xGizmo) {
  40061. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40062. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40063. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40064. }
  40065. },
  40066. enumerable: true,
  40067. configurable: true
  40068. });
  40069. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  40070. get: function () {
  40071. return this.xGizmo.snapDistance;
  40072. },
  40073. /**
  40074. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40075. */
  40076. set: function (value) {
  40077. if (this.xGizmo) {
  40078. this.xGizmo.snapDistance = value;
  40079. this.yGizmo.snapDistance = value;
  40080. this.zGizmo.snapDistance = value;
  40081. }
  40082. },
  40083. enumerable: true,
  40084. configurable: true
  40085. });
  40086. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  40087. get: function () {
  40088. return this.xGizmo.scaleRatio;
  40089. },
  40090. /**
  40091. * Ratio for the scale of the gizmo (Default: 1)
  40092. */
  40093. set: function (value) {
  40094. if (this.xGizmo) {
  40095. this.xGizmo.scaleRatio = value;
  40096. this.yGizmo.scaleRatio = value;
  40097. this.zGizmo.scaleRatio = value;
  40098. }
  40099. },
  40100. enumerable: true,
  40101. configurable: true
  40102. });
  40103. /**
  40104. * Disposes of the gizmo
  40105. */
  40106. RotationGizmo.prototype.dispose = function () {
  40107. this.xGizmo.dispose();
  40108. this.yGizmo.dispose();
  40109. this.zGizmo.dispose();
  40110. this.onDragStartObservable.clear();
  40111. this.onDragEndObservable.clear();
  40112. };
  40113. /**
  40114. * CustomMeshes are not supported by this gizmo
  40115. * @param mesh The mesh to replace the default mesh of the gizmo
  40116. */
  40117. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  40118. _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)");
  40119. };
  40120. return RotationGizmo;
  40121. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  40122. /***/ }),
  40123. /***/ "./Gizmos/scaleGizmo.ts":
  40124. /*!******************************!*\
  40125. !*** ./Gizmos/scaleGizmo.ts ***!
  40126. \******************************/
  40127. /*! exports provided: ScaleGizmo */
  40128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40129. "use strict";
  40130. __webpack_require__.r(__webpack_exports__);
  40131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  40132. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40133. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40134. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40135. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40136. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  40137. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40138. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  40139. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40140. /**
  40141. * Gizmo that enables scaling a mesh along 3 axis
  40142. */
  40143. var ScaleGizmo = /** @class */ (function (_super) {
  40144. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  40145. /**
  40146. * Creates a ScaleGizmo
  40147. * @param gizmoLayer The utility layer the gizmo will be added to
  40148. */
  40149. function ScaleGizmo(gizmoLayer) {
  40150. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40151. var _this = _super.call(this, gizmoLayer) || this;
  40152. /** Fires an event when any of it's sub gizmos are dragged */
  40153. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40154. /** Fires an event when any of it's sub gizmos are released from dragging */
  40155. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40156. _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);
  40157. _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);
  40158. _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);
  40159. // Create uniform scale gizmo
  40160. _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);
  40161. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  40162. _this.uniformScaleGizmo.uniformScaling = true;
  40163. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40164. uniformScalingMesh.scaling.scaleInPlace(0.02);
  40165. uniformScalingMesh.visibility = 0;
  40166. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40167. octahedron.scaling.scaleInPlace(0.007);
  40168. uniformScalingMesh.addChild(octahedron);
  40169. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  40170. var light = gizmoLayer._getSharedGizmoLight();
  40171. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(octahedron);
  40172. // Relay drag events
  40173. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  40174. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40175. _this.onDragStartObservable.notifyObservers({});
  40176. });
  40177. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40178. _this.onDragEndObservable.notifyObservers({});
  40179. });
  40180. });
  40181. _this.attachedMesh = null;
  40182. return _this;
  40183. }
  40184. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  40185. get: function () {
  40186. return this.xGizmo.attachedMesh;
  40187. },
  40188. set: function (mesh) {
  40189. if (this.xGizmo) {
  40190. this.xGizmo.attachedMesh = mesh;
  40191. this.yGizmo.attachedMesh = mesh;
  40192. this.zGizmo.attachedMesh = mesh;
  40193. this.uniformScaleGizmo.attachedMesh = mesh;
  40194. }
  40195. },
  40196. enumerable: true,
  40197. configurable: true
  40198. });
  40199. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40200. get: function () {
  40201. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40202. },
  40203. set: function (value) {
  40204. if (!value) {
  40205. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  40206. }
  40207. if (this.xGizmo) {
  40208. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40209. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40210. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40211. }
  40212. },
  40213. enumerable: true,
  40214. configurable: true
  40215. });
  40216. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  40217. get: function () {
  40218. return this.xGizmo.snapDistance;
  40219. },
  40220. /**
  40221. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40222. */
  40223. set: function (value) {
  40224. if (this.xGizmo) {
  40225. this.xGizmo.snapDistance = value;
  40226. this.yGizmo.snapDistance = value;
  40227. this.zGizmo.snapDistance = value;
  40228. this.uniformScaleGizmo.snapDistance = value;
  40229. }
  40230. },
  40231. enumerable: true,
  40232. configurable: true
  40233. });
  40234. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  40235. get: function () {
  40236. return this.xGizmo.scaleRatio;
  40237. },
  40238. /**
  40239. * Ratio for the scale of the gizmo (Default: 1)
  40240. */
  40241. set: function (value) {
  40242. if (this.xGizmo) {
  40243. this.xGizmo.scaleRatio = value;
  40244. this.yGizmo.scaleRatio = value;
  40245. this.zGizmo.scaleRatio = value;
  40246. this.uniformScaleGizmo.scaleRatio = value;
  40247. }
  40248. },
  40249. enumerable: true,
  40250. configurable: true
  40251. });
  40252. /**
  40253. * Disposes of the gizmo
  40254. */
  40255. ScaleGizmo.prototype.dispose = function () {
  40256. this.xGizmo.dispose();
  40257. this.yGizmo.dispose();
  40258. this.zGizmo.dispose();
  40259. this.uniformScaleGizmo.dispose();
  40260. this.onDragStartObservable.clear();
  40261. this.onDragEndObservable.clear();
  40262. };
  40263. return ScaleGizmo;
  40264. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  40265. /***/ }),
  40266. /***/ "./Helpers/environmentHelper.ts":
  40267. /*!**************************************!*\
  40268. !*** ./Helpers/environmentHelper.ts ***!
  40269. \**************************************/
  40270. /*! exports provided: EnvironmentHelper */
  40271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40272. "use strict";
  40273. __webpack_require__.r(__webpack_exports__);
  40274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  40275. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40276. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40277. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40278. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40279. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40280. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  40281. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40282. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  40283. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  40284. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40285. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40286. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  40287. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40288. /**
  40289. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  40290. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  40291. * It also helps with the default setup of your imageProcessing configuration.
  40292. */
  40293. var EnvironmentHelper = /** @class */ (function () {
  40294. /**
  40295. * constructor
  40296. * @param options Defines the options we want to customize the helper
  40297. * @param scene The scene to add the material to
  40298. */
  40299. function EnvironmentHelper(options, scene) {
  40300. var _this = this;
  40301. this._errorHandler = function (message, exception) {
  40302. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  40303. };
  40304. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  40305. this._scene = scene;
  40306. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40307. this._setupBackground();
  40308. this._setupImageProcessing();
  40309. }
  40310. /**
  40311. * Creates the default options for the helper.
  40312. */
  40313. EnvironmentHelper._getDefaultOptions = function () {
  40314. return {
  40315. createGround: true,
  40316. groundSize: 15,
  40317. groundTexture: this._groundTextureCDNUrl,
  40318. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40319. groundOpacity: 0.9,
  40320. enableGroundShadow: true,
  40321. groundShadowLevel: 0.5,
  40322. enableGroundMirror: false,
  40323. groundMirrorSizeRatio: 0.3,
  40324. groundMirrorBlurKernel: 64,
  40325. groundMirrorAmount: 1,
  40326. groundMirrorFresnelWeight: 1,
  40327. groundMirrorFallOffDistance: 0,
  40328. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  40329. groundYBias: 0.00001,
  40330. createSkybox: true,
  40331. skyboxSize: 20,
  40332. skyboxTexture: this._skyboxTextureCDNUrl,
  40333. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40334. backgroundYRotation: 0,
  40335. sizeAuto: true,
  40336. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  40337. setupImageProcessing: true,
  40338. environmentTexture: this._environmentTextureCDNUrl,
  40339. cameraExposure: 0.8,
  40340. cameraContrast: 1.2,
  40341. toneMappingEnabled: true,
  40342. };
  40343. };
  40344. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  40345. /**
  40346. * Gets the root mesh created by the helper.
  40347. */
  40348. get: function () {
  40349. return this._rootMesh;
  40350. },
  40351. enumerable: true,
  40352. configurable: true
  40353. });
  40354. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  40355. /**
  40356. * Gets the skybox created by the helper.
  40357. */
  40358. get: function () {
  40359. return this._skybox;
  40360. },
  40361. enumerable: true,
  40362. configurable: true
  40363. });
  40364. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  40365. /**
  40366. * Gets the skybox texture created by the helper.
  40367. */
  40368. get: function () {
  40369. return this._skyboxTexture;
  40370. },
  40371. enumerable: true,
  40372. configurable: true
  40373. });
  40374. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  40375. /**
  40376. * Gets the skybox material created by the helper.
  40377. */
  40378. get: function () {
  40379. return this._skyboxMaterial;
  40380. },
  40381. enumerable: true,
  40382. configurable: true
  40383. });
  40384. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  40385. /**
  40386. * Gets the ground mesh created by the helper.
  40387. */
  40388. get: function () {
  40389. return this._ground;
  40390. },
  40391. enumerable: true,
  40392. configurable: true
  40393. });
  40394. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  40395. /**
  40396. * Gets the ground texture created by the helper.
  40397. */
  40398. get: function () {
  40399. return this._groundTexture;
  40400. },
  40401. enumerable: true,
  40402. configurable: true
  40403. });
  40404. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  40405. /**
  40406. * Gets the ground mirror created by the helper.
  40407. */
  40408. get: function () {
  40409. return this._groundMirror;
  40410. },
  40411. enumerable: true,
  40412. configurable: true
  40413. });
  40414. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  40415. /**
  40416. * Gets the ground mirror render list to helps pushing the meshes
  40417. * you wish in the ground reflection.
  40418. */
  40419. get: function () {
  40420. if (this._groundMirror) {
  40421. return this._groundMirror.renderList;
  40422. }
  40423. return null;
  40424. },
  40425. enumerable: true,
  40426. configurable: true
  40427. });
  40428. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  40429. /**
  40430. * Gets the ground material created by the helper.
  40431. */
  40432. get: function () {
  40433. return this._groundMaterial;
  40434. },
  40435. enumerable: true,
  40436. configurable: true
  40437. });
  40438. /**
  40439. * Updates the background according to the new options
  40440. * @param options
  40441. */
  40442. EnvironmentHelper.prototype.updateOptions = function (options) {
  40443. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  40444. if (this._ground && !newOptions.createGround) {
  40445. this._ground.dispose();
  40446. this._ground = null;
  40447. }
  40448. if (this._groundMaterial && !newOptions.createGround) {
  40449. this._groundMaterial.dispose();
  40450. this._groundMaterial = null;
  40451. }
  40452. if (this._groundTexture) {
  40453. if (this._options.groundTexture != newOptions.groundTexture) {
  40454. this._groundTexture.dispose();
  40455. this._groundTexture = null;
  40456. }
  40457. }
  40458. if (this._skybox && !newOptions.createSkybox) {
  40459. this._skybox.dispose();
  40460. this._skybox = null;
  40461. }
  40462. if (this._skyboxMaterial && !newOptions.createSkybox) {
  40463. this._skyboxMaterial.dispose();
  40464. this._skyboxMaterial = null;
  40465. }
  40466. if (this._skyboxTexture) {
  40467. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  40468. this._skyboxTexture.dispose();
  40469. this._skyboxTexture = null;
  40470. }
  40471. }
  40472. if (this._groundMirror && !newOptions.enableGroundMirror) {
  40473. this._groundMirror.dispose();
  40474. this._groundMirror = null;
  40475. }
  40476. if (this._scene.environmentTexture) {
  40477. if (this._options.environmentTexture != newOptions.environmentTexture) {
  40478. this._scene.environmentTexture.dispose();
  40479. }
  40480. }
  40481. this._options = newOptions;
  40482. this._setupBackground();
  40483. this._setupImageProcessing();
  40484. };
  40485. /**
  40486. * Sets the primary color of all the available elements.
  40487. * @param color the main color to affect to the ground and the background
  40488. */
  40489. EnvironmentHelper.prototype.setMainColor = function (color) {
  40490. if (this.groundMaterial) {
  40491. this.groundMaterial.primaryColor = color;
  40492. }
  40493. if (this.skyboxMaterial) {
  40494. this.skyboxMaterial.primaryColor = color;
  40495. }
  40496. if (this.groundMirror) {
  40497. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  40498. }
  40499. };
  40500. /**
  40501. * Setup the image processing according to the specified options.
  40502. */
  40503. EnvironmentHelper.prototype._setupImageProcessing = function () {
  40504. if (this._options.setupImageProcessing) {
  40505. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  40506. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  40507. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  40508. this._setupEnvironmentTexture();
  40509. }
  40510. };
  40511. /**
  40512. * Setup the environment texture according to the specified options.
  40513. */
  40514. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  40515. if (this._scene.environmentTexture) {
  40516. return;
  40517. }
  40518. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40519. this._scene.environmentTexture = this._options.environmentTexture;
  40520. return;
  40521. }
  40522. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  40523. this._scene.environmentTexture = environmentTexture;
  40524. };
  40525. /**
  40526. * Setup the background according to the specified options.
  40527. */
  40528. EnvironmentHelper.prototype._setupBackground = function () {
  40529. if (!this._rootMesh) {
  40530. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  40531. }
  40532. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  40533. var sceneSize = this._getSceneSize();
  40534. if (this._options.createGround) {
  40535. this._setupGround(sceneSize);
  40536. this._setupGroundMaterial();
  40537. this._setupGroundDiffuseTexture();
  40538. if (this._options.enableGroundMirror) {
  40539. this._setupGroundMirrorTexture(sceneSize);
  40540. }
  40541. this._setupMirrorInGroundMaterial();
  40542. }
  40543. if (this._options.createSkybox) {
  40544. this._setupSkybox(sceneSize);
  40545. this._setupSkyboxMaterial();
  40546. this._setupSkyboxReflectionTexture();
  40547. }
  40548. this._rootMesh.position.x = sceneSize.rootPosition.x;
  40549. this._rootMesh.position.z = sceneSize.rootPosition.z;
  40550. this._rootMesh.position.y = sceneSize.rootPosition.y;
  40551. };
  40552. /**
  40553. * Get the scene sizes according to the setup.
  40554. */
  40555. EnvironmentHelper.prototype._getSceneSize = function () {
  40556. var _this = this;
  40557. var groundSize = this._options.groundSize;
  40558. var skyboxSize = this._options.skyboxSize;
  40559. var rootPosition = this._options.rootPosition;
  40560. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  40561. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40562. }
  40563. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  40564. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  40565. });
  40566. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  40567. if (this._options.sizeAuto) {
  40568. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  40569. this._scene.activeCamera.upperRadiusLimit) {
  40570. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  40571. skyboxSize = groundSize;
  40572. }
  40573. var sceneDiagonalLenght = sceneDiagonal.length();
  40574. if (sceneDiagonalLenght > groundSize) {
  40575. groundSize = sceneDiagonalLenght * 2;
  40576. skyboxSize = groundSize;
  40577. }
  40578. // 10 % bigger.
  40579. groundSize *= 1.1;
  40580. skyboxSize *= 1.5;
  40581. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  40582. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  40583. }
  40584. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40585. };
  40586. /**
  40587. * Setup the ground according to the specified options.
  40588. */
  40589. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  40590. var _this = this;
  40591. if (!this._ground || this._ground.isDisposed()) {
  40592. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  40593. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  40594. this._ground.parent = this._rootMesh;
  40595. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  40596. }
  40597. this._ground.receiveShadows = this._options.enableGroundShadow;
  40598. };
  40599. /**
  40600. * Setup the ground material according to the specified options.
  40601. */
  40602. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  40603. if (!this._groundMaterial) {
  40604. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  40605. }
  40606. this._groundMaterial.alpha = this._options.groundOpacity;
  40607. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  40608. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  40609. this._groundMaterial.primaryColor = this._options.groundColor;
  40610. this._groundMaterial.useRGBColor = false;
  40611. this._groundMaterial.enableNoise = true;
  40612. if (this._ground) {
  40613. this._ground.material = this._groundMaterial;
  40614. }
  40615. };
  40616. /**
  40617. * Setup the ground diffuse texture according to the specified options.
  40618. */
  40619. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  40620. if (!this._groundMaterial) {
  40621. return;
  40622. }
  40623. if (this._groundTexture) {
  40624. return;
  40625. }
  40626. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40627. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  40628. return;
  40629. }
  40630. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40631. diffuseTexture.gammaSpace = false;
  40632. diffuseTexture.hasAlpha = true;
  40633. this._groundMaterial.diffuseTexture = diffuseTexture;
  40634. };
  40635. /**
  40636. * Setup the ground mirror texture according to the specified options.
  40637. */
  40638. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  40639. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  40640. if (!this._groundMirror) {
  40641. 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);
  40642. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  40643. this._groundMirror.anisotropicFilteringLevel = 1;
  40644. this._groundMirror.wrapU = wrapping;
  40645. this._groundMirror.wrapV = wrapping;
  40646. this._groundMirror.gammaSpace = false;
  40647. if (this._groundMirror.renderList) {
  40648. for (var i = 0; i < this._scene.meshes.length; i++) {
  40649. var mesh = this._scene.meshes[i];
  40650. if (mesh !== this._ground &&
  40651. mesh !== this._skybox &&
  40652. mesh !== this._rootMesh) {
  40653. this._groundMirror.renderList.push(mesh);
  40654. }
  40655. }
  40656. }
  40657. }
  40658. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  40659. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  40660. };
  40661. /**
  40662. * Setup the ground to receive the mirror texture.
  40663. */
  40664. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  40665. if (this._groundMaterial) {
  40666. this._groundMaterial.reflectionTexture = this._groundMirror;
  40667. this._groundMaterial.reflectionFresnel = true;
  40668. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  40669. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  40670. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  40671. }
  40672. };
  40673. /**
  40674. * Setup the skybox according to the specified options.
  40675. */
  40676. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  40677. var _this = this;
  40678. if (!this._skybox || this._skybox.isDisposed()) {
  40679. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  40680. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  40681. }
  40682. this._skybox.parent = this._rootMesh;
  40683. };
  40684. /**
  40685. * Setup the skybox material according to the specified options.
  40686. */
  40687. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  40688. if (!this._skybox) {
  40689. return;
  40690. }
  40691. if (!this._skyboxMaterial) {
  40692. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  40693. }
  40694. this._skyboxMaterial.useRGBColor = false;
  40695. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  40696. this._skyboxMaterial.enableNoise = true;
  40697. this._skybox.material = this._skyboxMaterial;
  40698. };
  40699. /**
  40700. * Setup the skybox reflection texture according to the specified options.
  40701. */
  40702. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  40703. if (!this._skyboxMaterial) {
  40704. return;
  40705. }
  40706. if (this._skyboxTexture) {
  40707. return;
  40708. }
  40709. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40710. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  40711. return;
  40712. }
  40713. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40714. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  40715. this._skyboxTexture.gammaSpace = false;
  40716. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  40717. };
  40718. /**
  40719. * Dispose all the elements created by the Helper.
  40720. */
  40721. EnvironmentHelper.prototype.dispose = function () {
  40722. if (this._groundMaterial) {
  40723. this._groundMaterial.dispose(true, true);
  40724. }
  40725. if (this._skyboxMaterial) {
  40726. this._skyboxMaterial.dispose(true, true);
  40727. }
  40728. this._rootMesh.dispose(false);
  40729. };
  40730. /**
  40731. * Default ground texture URL.
  40732. */
  40733. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  40734. /**
  40735. * Default skybox texture URL.
  40736. */
  40737. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  40738. /**
  40739. * Default environment texture URL.
  40740. */
  40741. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  40742. return EnvironmentHelper;
  40743. }());
  40744. /***/ }),
  40745. /***/ "./Helpers/index.ts":
  40746. /*!**************************!*\
  40747. !*** ./Helpers/index.ts ***!
  40748. \**************************/
  40749. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  40750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40751. "use strict";
  40752. __webpack_require__.r(__webpack_exports__);
  40753. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  40755. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  40756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  40757. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  40758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  40759. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  40760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  40761. /***/ }),
  40762. /***/ "./Helpers/photoDome.ts":
  40763. /*!******************************!*\
  40764. !*** ./Helpers/photoDome.ts ***!
  40765. \******************************/
  40766. /*! exports provided: PhotoDome */
  40767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40768. "use strict";
  40769. __webpack_require__.r(__webpack_exports__);
  40770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  40771. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40772. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40773. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40774. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40775. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40776. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40777. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40778. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40779. /**
  40780. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  40781. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  40782. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  40783. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40784. */
  40785. var PhotoDome = /** @class */ (function (_super) {
  40786. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  40787. /**
  40788. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  40789. * @param name Element's name, child elements will append suffixes for their own names.
  40790. * @param urlsOfPhoto defines the url of the photo to display
  40791. * @param options defines an object containing optional or exposed sub element properties
  40792. * @param onError defines a callback called when an error occured while loading the texture
  40793. */
  40794. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  40795. if (onError === void 0) { onError = null; }
  40796. var _this = _super.call(this, name, scene) || this;
  40797. _this._useDirectMapping = false;
  40798. /**
  40799. * Observable raised when an error occured while loading the 360 image
  40800. */
  40801. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40802. // set defaults and manage values
  40803. name = name || "photoDome";
  40804. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40805. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40806. if (options.useDirectMapping === undefined) {
  40807. _this._useDirectMapping = true;
  40808. }
  40809. else {
  40810. _this._useDirectMapping = options.useDirectMapping;
  40811. }
  40812. if (options.faceForward === undefined) {
  40813. options.faceForward = true;
  40814. }
  40815. _this._setReady(false);
  40816. // create
  40817. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40818. _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);
  40819. // configure material
  40820. material.opacityFresnel = false;
  40821. material.useEquirectangularFOV = true;
  40822. material.fovMultiplier = 1.0;
  40823. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  40824. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  40825. if (onError) {
  40826. onError(message, exception);
  40827. }
  40828. });
  40829. _this.photoTexture.onLoadObservable.addOnce(function () {
  40830. _this._setReady(true);
  40831. });
  40832. // configure mesh
  40833. _this._mesh.material = material;
  40834. _this._mesh.parent = _this;
  40835. // Initial rotation
  40836. if (options.faceForward && scene.activeCamera) {
  40837. var camera = scene.activeCamera;
  40838. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  40839. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  40840. direction.normalize();
  40841. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  40842. }
  40843. return _this;
  40844. }
  40845. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  40846. /**
  40847. * Gets or sets the texture being displayed on the sphere
  40848. */
  40849. get: function () {
  40850. return this._photoTexture;
  40851. },
  40852. set: function (value) {
  40853. if (this._photoTexture === value) {
  40854. return;
  40855. }
  40856. this._photoTexture = value;
  40857. if (this._useDirectMapping) {
  40858. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40859. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40860. this._material.diffuseTexture = this._photoTexture;
  40861. }
  40862. else {
  40863. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40864. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40865. this._material.reflectionTexture = this._photoTexture;
  40866. }
  40867. },
  40868. enumerable: true,
  40869. configurable: true
  40870. });
  40871. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  40872. /**
  40873. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40874. * Also see the options.resolution property.
  40875. */
  40876. get: function () {
  40877. return this._material.fovMultiplier;
  40878. },
  40879. set: function (value) {
  40880. this._material.fovMultiplier = value;
  40881. },
  40882. enumerable: true,
  40883. configurable: true
  40884. });
  40885. /**
  40886. * Releases resources associated with this node.
  40887. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40888. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40889. */
  40890. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40891. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40892. this._photoTexture.dispose();
  40893. this._mesh.dispose();
  40894. this._material.dispose();
  40895. this.onLoadErrorObservable.clear();
  40896. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40897. };
  40898. return PhotoDome;
  40899. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  40900. /***/ }),
  40901. /***/ "./Helpers/sceneHelpers.ts":
  40902. /*!*********************************!*\
  40903. !*** ./Helpers/sceneHelpers.ts ***!
  40904. \*********************************/
  40905. /*! exports provided: _forceSceneHelpersToBundle */
  40906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40907. "use strict";
  40908. __webpack_require__.r(__webpack_exports__);
  40909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  40910. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40911. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  40912. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40913. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40914. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40915. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40916. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  40917. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  40918. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40919. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  40920. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40921. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  40922. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  40923. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  40924. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  40925. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  40926. /* harmony import */ var _Materials_Textures_Loaders_ddsTextureLoader__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  40927. /* harmony import */ var _Materials_Textures_Loaders_envTextureLoader__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/Loaders/envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  40928. /* harmony import */ var _Materials_Textures_Loaders_ktxTextureLoader__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  40929. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40930. /** @hidden */
  40931. var _forceSceneHelpersToBundle = true;
  40932. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  40933. if (replace === void 0) { replace = false; }
  40934. // Dispose existing light in replace mode.
  40935. if (replace) {
  40936. if (this.lights) {
  40937. for (var i = 0; i < this.lights.length; i++) {
  40938. this.lights[i].dispose();
  40939. }
  40940. }
  40941. }
  40942. // Light
  40943. if (this.lights.length === 0) {
  40944. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  40945. }
  40946. };
  40947. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  40948. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40949. if (replace === void 0) { replace = false; }
  40950. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40951. // Dispose existing camera in replace mode.
  40952. if (replace) {
  40953. if (this.activeCamera) {
  40954. this.activeCamera.dispose();
  40955. this.activeCamera = null;
  40956. }
  40957. }
  40958. // Camera
  40959. if (!this.activeCamera) {
  40960. var worldExtends = this.getWorldExtends();
  40961. var worldSize = worldExtends.max.subtract(worldExtends.min);
  40962. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  40963. var camera;
  40964. var radius = worldSize.length() * 1.5;
  40965. // empty scene scenario!
  40966. if (!isFinite(radius)) {
  40967. radius = 1;
  40968. worldCenter.copyFromFloats(0, 0, 0);
  40969. }
  40970. if (createArcRotateCamera) {
  40971. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  40972. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  40973. arcRotateCamera.wheelPrecision = 100 / radius;
  40974. camera = arcRotateCamera;
  40975. }
  40976. else {
  40977. 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);
  40978. freeCamera.setTarget(worldCenter);
  40979. camera = freeCamera;
  40980. }
  40981. camera.minZ = radius * 0.01;
  40982. camera.maxZ = radius * 1000;
  40983. camera.speed = radius * 0.2;
  40984. this.activeCamera = camera;
  40985. var canvas = this.getEngine().getRenderingCanvas();
  40986. if (attachCameraControls && canvas) {
  40987. camera.attachControl(canvas);
  40988. }
  40989. }
  40990. };
  40991. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  40992. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40993. if (replace === void 0) { replace = false; }
  40994. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40995. this.createDefaultLight(replace);
  40996. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  40997. };
  40998. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  40999. if (pbr === void 0) { pbr = false; }
  41000. if (scale === void 0) { scale = 1000; }
  41001. if (blur === void 0) { blur = 0; }
  41002. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  41003. if (!environmentTexture) {
  41004. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  41005. return null;
  41006. }
  41007. if (setGlobalEnvTexture) {
  41008. if (environmentTexture) {
  41009. this.environmentTexture = environmentTexture;
  41010. }
  41011. }
  41012. // Skybox
  41013. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  41014. if (pbr) {
  41015. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  41016. hdrSkyboxMaterial.backFaceCulling = false;
  41017. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  41018. if (hdrSkyboxMaterial.reflectionTexture) {
  41019. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  41020. }
  41021. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  41022. hdrSkyboxMaterial.disableLighting = true;
  41023. hdrSkyboxMaterial.twoSidedLighting = true;
  41024. hdrSkybox.infiniteDistance = true;
  41025. hdrSkybox.material = hdrSkyboxMaterial;
  41026. }
  41027. else {
  41028. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  41029. skyboxMaterial.backFaceCulling = false;
  41030. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  41031. if (skyboxMaterial.reflectionTexture) {
  41032. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  41033. }
  41034. skyboxMaterial.disableLighting = true;
  41035. hdrSkybox.infiniteDistance = true;
  41036. hdrSkybox.material = skyboxMaterial;
  41037. }
  41038. hdrSkybox.isPickable = false;
  41039. return hdrSkybox;
  41040. };
  41041. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  41042. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  41043. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  41044. }
  41045. return null;
  41046. };
  41047. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  41048. if (webVROptions === void 0) { webVROptions = {}; }
  41049. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  41050. };
  41051. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  41052. var _this = this;
  41053. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  41054. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  41055. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  41056. .then(function (ui) {
  41057. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  41058. return helper;
  41059. });
  41060. });
  41061. };
  41062. /***/ }),
  41063. /***/ "./Helpers/videoDome.ts":
  41064. /*!******************************!*\
  41065. !*** ./Helpers/videoDome.ts ***!
  41066. \******************************/
  41067. /*! exports provided: VideoDome */
  41068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41069. "use strict";
  41070. __webpack_require__.r(__webpack_exports__);
  41071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  41072. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41073. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  41074. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  41075. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41076. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  41077. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  41078. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  41079. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41080. /**
  41081. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  41082. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  41083. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  41084. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  41085. */
  41086. var VideoDome = /** @class */ (function (_super) {
  41087. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  41088. /**
  41089. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  41090. * @param name Element's name, child elements will append suffixes for their own names.
  41091. * @param urlsOrVideo defines the url(s) or the video element to use
  41092. * @param options An object containing optional or exposed sub element properties
  41093. */
  41094. function VideoDome(name, urlsOrVideo, options, scene) {
  41095. var _this = _super.call(this, name, scene) || this;
  41096. _this._useDirectMapping = false;
  41097. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  41098. /**
  41099. * Oberserver used in Stereoscopic VR Mode.
  41100. */
  41101. _this._onBeforeCameraRenderObserver = null;
  41102. scene = _this.getScene();
  41103. // set defaults and manage values
  41104. name = name || "videoDome";
  41105. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  41106. options.clickToPlay = Boolean(options.clickToPlay);
  41107. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  41108. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  41109. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  41110. if (options.useDirectMapping === undefined) {
  41111. _this._useDirectMapping = true;
  41112. }
  41113. else {
  41114. _this._useDirectMapping = options.useDirectMapping;
  41115. }
  41116. if (options.faceForward === undefined) {
  41117. options.faceForward = true;
  41118. }
  41119. _this._setReady(false);
  41120. // create
  41121. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  41122. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  41123. 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);
  41124. _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);
  41125. texture.onLoadObservable.addOnce(function () {
  41126. _this._setReady(true);
  41127. });
  41128. // configure material
  41129. material.useEquirectangularFOV = true;
  41130. material.fovMultiplier = 1.0;
  41131. material.opacityFresnel = false;
  41132. if (_this._useDirectMapping) {
  41133. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41134. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41135. material.diffuseTexture = texture;
  41136. }
  41137. else {
  41138. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  41139. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41140. material.reflectionTexture = texture;
  41141. }
  41142. // configure mesh
  41143. _this._mesh.material = material;
  41144. _this._mesh.parent = _this;
  41145. // optional configuration
  41146. if (options.clickToPlay) {
  41147. scene.onPointerUp = function () {
  41148. _this._videoTexture.video.play();
  41149. };
  41150. }
  41151. // Initial rotation
  41152. if (options.faceForward && scene.activeCamera) {
  41153. var camera = scene.activeCamera;
  41154. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  41155. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  41156. direction.normalize();
  41157. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  41158. }
  41159. return _this;
  41160. }
  41161. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  41162. /**
  41163. * Gets the video texture being displayed on the sphere
  41164. */
  41165. get: function () {
  41166. return this._videoTexture;
  41167. },
  41168. enumerable: true,
  41169. configurable: true
  41170. });
  41171. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  41172. /**
  41173. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41174. * Also see the options.resolution property.
  41175. */
  41176. get: function () {
  41177. return this._material.fovMultiplier;
  41178. },
  41179. set: function (value) {
  41180. this._material.fovMultiplier = value;
  41181. },
  41182. enumerable: true,
  41183. configurable: true
  41184. });
  41185. Object.defineProperty(VideoDome.prototype, "videoMode", {
  41186. /**
  41187. * Gets or set the current video mode for the video. It can be:
  41188. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  41189. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41190. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41191. */
  41192. get: function () {
  41193. return this._videoMode;
  41194. },
  41195. set: function (value) {
  41196. if (this._videoMode === value) {
  41197. return;
  41198. }
  41199. this._changeVideoMode(value);
  41200. },
  41201. enumerable: true,
  41202. configurable: true
  41203. });
  41204. VideoDome.prototype._changeVideoMode = function (value) {
  41205. var _this = this;
  41206. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41207. this._videoMode = value;
  41208. // Default Setup and Reset.
  41209. this._videoTexture.uScale = 1;
  41210. this._videoTexture.vScale = 1;
  41211. this._videoTexture.uOffset = 0;
  41212. this._videoTexture.vOffset = 0;
  41213. switch (value) {
  41214. case VideoDome.MODE_SIDEBYSIDE:
  41215. this._videoTexture.uScale = 0.5;
  41216. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41217. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  41218. });
  41219. break;
  41220. case VideoDome.MODE_TOPBOTTOM:
  41221. this._videoTexture.vScale = 0.5;
  41222. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41223. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  41224. });
  41225. break;
  41226. }
  41227. };
  41228. /**
  41229. * Releases resources associated with this node.
  41230. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  41231. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  41232. */
  41233. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  41234. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  41235. this._videoTexture.dispose();
  41236. this._mesh.dispose();
  41237. this._material.dispose();
  41238. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41239. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  41240. };
  41241. /**
  41242. * Define the video source as a Monoscopic panoramic 360 video.
  41243. */
  41244. VideoDome.MODE_MONOSCOPIC = 0;
  41245. /**
  41246. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41247. */
  41248. VideoDome.MODE_TOPBOTTOM = 1;
  41249. /**
  41250. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41251. */
  41252. VideoDome.MODE_SIDEBYSIDE = 2;
  41253. return VideoDome;
  41254. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  41255. /***/ }),
  41256. /***/ "./Instrumentation/engineInstrumentation.ts":
  41257. /*!**************************************************!*\
  41258. !*** ./Instrumentation/engineInstrumentation.ts ***!
  41259. \**************************************************/
  41260. /*! exports provided: EngineInstrumentation */
  41261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41262. "use strict";
  41263. __webpack_require__.r(__webpack_exports__);
  41264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  41265. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41266. /**
  41267. * This class can be used to get instrumentation data from a Babylon engine
  41268. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41269. */
  41270. var EngineInstrumentation = /** @class */ (function () {
  41271. /**
  41272. * Instantiates a new engine instrumentation.
  41273. * This class can be used to get instrumentation data from a Babylon engine
  41274. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41275. * @param engine Defines the engine to instrument
  41276. */
  41277. function EngineInstrumentation(
  41278. /**
  41279. * Define the instrumented engine.
  41280. */
  41281. engine) {
  41282. this.engine = engine;
  41283. this._captureGPUFrameTime = false;
  41284. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41285. this._captureShaderCompilationTime = false;
  41286. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41287. // Observers
  41288. this._onBeginFrameObserver = null;
  41289. this._onEndFrameObserver = null;
  41290. this._onBeforeShaderCompilationObserver = null;
  41291. this._onAfterShaderCompilationObserver = null;
  41292. }
  41293. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  41294. // Properties
  41295. /**
  41296. * Gets the perf counter used for GPU frame time
  41297. */
  41298. get: function () {
  41299. return this._gpuFrameTime;
  41300. },
  41301. enumerable: true,
  41302. configurable: true
  41303. });
  41304. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  41305. /**
  41306. * Gets the GPU frame time capture status
  41307. */
  41308. get: function () {
  41309. return this._captureGPUFrameTime;
  41310. },
  41311. /**
  41312. * Enable or disable the GPU frame time capture
  41313. */
  41314. set: function (value) {
  41315. var _this = this;
  41316. if (value === this._captureGPUFrameTime) {
  41317. return;
  41318. }
  41319. this._captureGPUFrameTime = value;
  41320. if (value) {
  41321. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  41322. if (!_this._gpuFrameTimeToken) {
  41323. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  41324. }
  41325. });
  41326. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  41327. if (!_this._gpuFrameTimeToken) {
  41328. return;
  41329. }
  41330. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  41331. if (time > -1) {
  41332. _this._gpuFrameTimeToken = null;
  41333. _this._gpuFrameTime.fetchNewFrame();
  41334. _this._gpuFrameTime.addCount(time, true);
  41335. }
  41336. });
  41337. }
  41338. else {
  41339. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  41340. this._onBeginFrameObserver = null;
  41341. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  41342. this._onEndFrameObserver = null;
  41343. }
  41344. },
  41345. enumerable: true,
  41346. configurable: true
  41347. });
  41348. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  41349. /**
  41350. * Gets the perf counter used for shader compilation time
  41351. */
  41352. get: function () {
  41353. return this._shaderCompilationTime;
  41354. },
  41355. enumerable: true,
  41356. configurable: true
  41357. });
  41358. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  41359. /**
  41360. * Gets the shader compilation time capture status
  41361. */
  41362. get: function () {
  41363. return this._captureShaderCompilationTime;
  41364. },
  41365. /**
  41366. * Enable or disable the shader compilation time capture
  41367. */
  41368. set: function (value) {
  41369. var _this = this;
  41370. if (value === this._captureShaderCompilationTime) {
  41371. return;
  41372. }
  41373. this._captureShaderCompilationTime = value;
  41374. if (value) {
  41375. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  41376. _this._shaderCompilationTime.fetchNewFrame();
  41377. _this._shaderCompilationTime.beginMonitoring();
  41378. });
  41379. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  41380. _this._shaderCompilationTime.endMonitoring();
  41381. });
  41382. }
  41383. else {
  41384. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41385. this._onBeforeShaderCompilationObserver = null;
  41386. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41387. this._onAfterShaderCompilationObserver = null;
  41388. }
  41389. },
  41390. enumerable: true,
  41391. configurable: true
  41392. });
  41393. /**
  41394. * Dispose and release associated resources.
  41395. */
  41396. EngineInstrumentation.prototype.dispose = function () {
  41397. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  41398. this._onBeginFrameObserver = null;
  41399. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  41400. this._onEndFrameObserver = null;
  41401. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41402. this._onBeforeShaderCompilationObserver = null;
  41403. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41404. this._onAfterShaderCompilationObserver = null;
  41405. this.engine = null;
  41406. };
  41407. return EngineInstrumentation;
  41408. }());
  41409. /***/ }),
  41410. /***/ "./Instrumentation/index.ts":
  41411. /*!**********************************!*\
  41412. !*** ./Instrumentation/index.ts ***!
  41413. \**********************************/
  41414. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  41415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41416. "use strict";
  41417. __webpack_require__.r(__webpack_exports__);
  41418. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  41419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  41420. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  41421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  41422. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  41423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  41424. /***/ }),
  41425. /***/ "./Instrumentation/sceneInstrumentation.ts":
  41426. /*!*************************************************!*\
  41427. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  41428. \*************************************************/
  41429. /*! exports provided: SceneInstrumentation */
  41430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41431. "use strict";
  41432. __webpack_require__.r(__webpack_exports__);
  41433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  41434. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41435. /**
  41436. * This class can be used to get instrumentation data from a Babylon engine
  41437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41438. */
  41439. var SceneInstrumentation = /** @class */ (function () {
  41440. /**
  41441. * Instantiates a new scene instrumentation.
  41442. * This class can be used to get instrumentation data from a Babylon engine
  41443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41444. * @param scene Defines the scene to instrument
  41445. */
  41446. function SceneInstrumentation(
  41447. /**
  41448. * Defines the scene to instrument
  41449. */
  41450. scene) {
  41451. var _this = this;
  41452. this.scene = scene;
  41453. this._captureActiveMeshesEvaluationTime = false;
  41454. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41455. this._captureRenderTargetsRenderTime = false;
  41456. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41457. this._captureFrameTime = false;
  41458. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41459. this._captureRenderTime = false;
  41460. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41461. this._captureInterFrameTime = false;
  41462. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41463. this._captureParticlesRenderTime = false;
  41464. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41465. this._captureSpritesRenderTime = false;
  41466. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41467. this._capturePhysicsTime = false;
  41468. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41469. this._captureAnimationsTime = false;
  41470. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41471. this._captureCameraRenderTime = false;
  41472. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41473. // Observers
  41474. this._onBeforeActiveMeshesEvaluationObserver = null;
  41475. this._onAfterActiveMeshesEvaluationObserver = null;
  41476. this._onBeforeRenderTargetsRenderObserver = null;
  41477. this._onAfterRenderTargetsRenderObserver = null;
  41478. this._onAfterRenderObserver = null;
  41479. this._onBeforeDrawPhaseObserver = null;
  41480. this._onAfterDrawPhaseObserver = null;
  41481. this._onBeforeAnimationsObserver = null;
  41482. this._onBeforeParticlesRenderingObserver = null;
  41483. this._onAfterParticlesRenderingObserver = null;
  41484. this._onBeforeSpritesRenderingObserver = null;
  41485. this._onAfterSpritesRenderingObserver = null;
  41486. this._onBeforePhysicsObserver = null;
  41487. this._onAfterPhysicsObserver = null;
  41488. this._onAfterAnimationsObserver = null;
  41489. this._onBeforeCameraRenderObserver = null;
  41490. this._onAfterCameraRenderObserver = null;
  41491. // Before render
  41492. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  41493. if (_this._captureActiveMeshesEvaluationTime) {
  41494. _this._activeMeshesEvaluationTime.fetchNewFrame();
  41495. }
  41496. if (_this._captureRenderTargetsRenderTime) {
  41497. _this._renderTargetsRenderTime.fetchNewFrame();
  41498. }
  41499. if (_this._captureFrameTime) {
  41500. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  41501. _this._frameTime.beginMonitoring();
  41502. }
  41503. if (_this._captureInterFrameTime) {
  41504. _this._interFrameTime.endMonitoring();
  41505. }
  41506. if (_this._captureParticlesRenderTime) {
  41507. _this._particlesRenderTime.fetchNewFrame();
  41508. }
  41509. if (_this._captureSpritesRenderTime) {
  41510. _this._spritesRenderTime.fetchNewFrame();
  41511. }
  41512. if (_this._captureAnimationsTime) {
  41513. _this._animationsTime.beginMonitoring();
  41514. }
  41515. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  41516. });
  41517. // After render
  41518. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  41519. if (_this._captureFrameTime) {
  41520. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  41521. _this._frameTime.endMonitoring();
  41522. }
  41523. if (_this._captureRenderTime) {
  41524. _this._renderTime.endMonitoring(false);
  41525. }
  41526. if (_this._captureInterFrameTime) {
  41527. _this._interFrameTime.beginMonitoring();
  41528. }
  41529. });
  41530. }
  41531. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  41532. // Properties
  41533. /**
  41534. * Gets the perf counter used for active meshes evaluation time
  41535. */
  41536. get: function () {
  41537. return this._activeMeshesEvaluationTime;
  41538. },
  41539. enumerable: true,
  41540. configurable: true
  41541. });
  41542. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  41543. /**
  41544. * Gets the active meshes evaluation time capture status
  41545. */
  41546. get: function () {
  41547. return this._captureActiveMeshesEvaluationTime;
  41548. },
  41549. /**
  41550. * Enable or disable the active meshes evaluation time capture
  41551. */
  41552. set: function (value) {
  41553. var _this = this;
  41554. if (value === this._captureActiveMeshesEvaluationTime) {
  41555. return;
  41556. }
  41557. this._captureActiveMeshesEvaluationTime = value;
  41558. if (value) {
  41559. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  41560. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  41561. _this._activeMeshesEvaluationTime.beginMonitoring();
  41562. });
  41563. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  41564. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  41565. _this._activeMeshesEvaluationTime.endMonitoring();
  41566. });
  41567. }
  41568. else {
  41569. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41570. this._onBeforeActiveMeshesEvaluationObserver = null;
  41571. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41572. this._onAfterActiveMeshesEvaluationObserver = null;
  41573. }
  41574. },
  41575. enumerable: true,
  41576. configurable: true
  41577. });
  41578. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  41579. /**
  41580. * Gets the perf counter used for render targets render time
  41581. */
  41582. get: function () {
  41583. return this._renderTargetsRenderTime;
  41584. },
  41585. enumerable: true,
  41586. configurable: true
  41587. });
  41588. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  41589. /**
  41590. * Gets the render targets render time capture status
  41591. */
  41592. get: function () {
  41593. return this._captureRenderTargetsRenderTime;
  41594. },
  41595. /**
  41596. * Enable or disable the render targets render time capture
  41597. */
  41598. set: function (value) {
  41599. var _this = this;
  41600. if (value === this._captureRenderTargetsRenderTime) {
  41601. return;
  41602. }
  41603. this._captureRenderTargetsRenderTime = value;
  41604. if (value) {
  41605. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  41606. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  41607. _this._renderTargetsRenderTime.beginMonitoring();
  41608. });
  41609. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  41610. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  41611. _this._renderTargetsRenderTime.endMonitoring(false);
  41612. });
  41613. }
  41614. else {
  41615. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41616. this._onBeforeRenderTargetsRenderObserver = null;
  41617. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41618. this._onAfterRenderTargetsRenderObserver = null;
  41619. }
  41620. },
  41621. enumerable: true,
  41622. configurable: true
  41623. });
  41624. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  41625. /**
  41626. * Gets the perf counter used for particles render time
  41627. */
  41628. get: function () {
  41629. return this._particlesRenderTime;
  41630. },
  41631. enumerable: true,
  41632. configurable: true
  41633. });
  41634. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  41635. /**
  41636. * Gets the particles render time capture status
  41637. */
  41638. get: function () {
  41639. return this._captureParticlesRenderTime;
  41640. },
  41641. /**
  41642. * Enable or disable the particles render time capture
  41643. */
  41644. set: function (value) {
  41645. var _this = this;
  41646. if (value === this._captureParticlesRenderTime) {
  41647. return;
  41648. }
  41649. this._captureParticlesRenderTime = value;
  41650. if (value) {
  41651. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  41652. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  41653. _this._particlesRenderTime.beginMonitoring();
  41654. });
  41655. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  41656. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  41657. _this._particlesRenderTime.endMonitoring(false);
  41658. });
  41659. }
  41660. else {
  41661. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41662. this._onBeforeParticlesRenderingObserver = null;
  41663. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41664. this._onAfterParticlesRenderingObserver = null;
  41665. }
  41666. },
  41667. enumerable: true,
  41668. configurable: true
  41669. });
  41670. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  41671. /**
  41672. * Gets the perf counter used for sprites render time
  41673. */
  41674. get: function () {
  41675. return this._spritesRenderTime;
  41676. },
  41677. enumerable: true,
  41678. configurable: true
  41679. });
  41680. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  41681. /**
  41682. * Gets the sprites render time capture status
  41683. */
  41684. get: function () {
  41685. return this._captureSpritesRenderTime;
  41686. },
  41687. /**
  41688. * Enable or disable the sprites render time capture
  41689. */
  41690. set: function (value) {
  41691. var _this = this;
  41692. if (value === this._captureSpritesRenderTime) {
  41693. return;
  41694. }
  41695. this._captureSpritesRenderTime = value;
  41696. if (!this.scene.spriteManagers) {
  41697. return;
  41698. }
  41699. if (value) {
  41700. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  41701. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  41702. _this._spritesRenderTime.beginMonitoring();
  41703. });
  41704. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  41705. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  41706. _this._spritesRenderTime.endMonitoring(false);
  41707. });
  41708. }
  41709. else {
  41710. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41711. this._onBeforeSpritesRenderingObserver = null;
  41712. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41713. this._onAfterSpritesRenderingObserver = null;
  41714. }
  41715. },
  41716. enumerable: true,
  41717. configurable: true
  41718. });
  41719. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  41720. /**
  41721. * Gets the perf counter used for physics time
  41722. */
  41723. get: function () {
  41724. return this._physicsTime;
  41725. },
  41726. enumerable: true,
  41727. configurable: true
  41728. });
  41729. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  41730. /**
  41731. * Gets the physics time capture status
  41732. */
  41733. get: function () {
  41734. return this._capturePhysicsTime;
  41735. },
  41736. /**
  41737. * Enable or disable the physics time capture
  41738. */
  41739. set: function (value) {
  41740. var _this = this;
  41741. if (value === this._capturePhysicsTime) {
  41742. return;
  41743. }
  41744. if (!this.scene.onBeforePhysicsObservable) {
  41745. return;
  41746. }
  41747. this._capturePhysicsTime = value;
  41748. if (value) {
  41749. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  41750. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  41751. _this._physicsTime.beginMonitoring();
  41752. });
  41753. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  41754. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  41755. _this._physicsTime.endMonitoring();
  41756. });
  41757. }
  41758. else {
  41759. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41760. this._onBeforePhysicsObserver = null;
  41761. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41762. this._onAfterPhysicsObserver = null;
  41763. }
  41764. },
  41765. enumerable: true,
  41766. configurable: true
  41767. });
  41768. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  41769. /**
  41770. * Gets the perf counter used for animations time
  41771. */
  41772. get: function () {
  41773. return this._animationsTime;
  41774. },
  41775. enumerable: true,
  41776. configurable: true
  41777. });
  41778. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  41779. /**
  41780. * Gets the animations time capture status
  41781. */
  41782. get: function () {
  41783. return this._captureAnimationsTime;
  41784. },
  41785. /**
  41786. * Enable or disable the animations time capture
  41787. */
  41788. set: function (value) {
  41789. var _this = this;
  41790. if (value === this._captureAnimationsTime) {
  41791. return;
  41792. }
  41793. this._captureAnimationsTime = value;
  41794. if (value) {
  41795. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  41796. _this._animationsTime.endMonitoring();
  41797. });
  41798. }
  41799. else {
  41800. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41801. this._onAfterAnimationsObserver = null;
  41802. }
  41803. },
  41804. enumerable: true,
  41805. configurable: true
  41806. });
  41807. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  41808. /**
  41809. * Gets the perf counter used for frame time capture
  41810. */
  41811. get: function () {
  41812. return this._frameTime;
  41813. },
  41814. enumerable: true,
  41815. configurable: true
  41816. });
  41817. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  41818. /**
  41819. * Gets the frame time capture status
  41820. */
  41821. get: function () {
  41822. return this._captureFrameTime;
  41823. },
  41824. /**
  41825. * Enable or disable the frame time capture
  41826. */
  41827. set: function (value) {
  41828. this._captureFrameTime = value;
  41829. },
  41830. enumerable: true,
  41831. configurable: true
  41832. });
  41833. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  41834. /**
  41835. * Gets the perf counter used for inter-frames time capture
  41836. */
  41837. get: function () {
  41838. return this._interFrameTime;
  41839. },
  41840. enumerable: true,
  41841. configurable: true
  41842. });
  41843. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  41844. /**
  41845. * Gets the inter-frames time capture status
  41846. */
  41847. get: function () {
  41848. return this._captureInterFrameTime;
  41849. },
  41850. /**
  41851. * Enable or disable the inter-frames time capture
  41852. */
  41853. set: function (value) {
  41854. this._captureInterFrameTime = value;
  41855. },
  41856. enumerable: true,
  41857. configurable: true
  41858. });
  41859. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  41860. /**
  41861. * Gets the perf counter used for render time capture
  41862. */
  41863. get: function () {
  41864. return this._renderTime;
  41865. },
  41866. enumerable: true,
  41867. configurable: true
  41868. });
  41869. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  41870. /**
  41871. * Gets the render time capture status
  41872. */
  41873. get: function () {
  41874. return this._captureRenderTime;
  41875. },
  41876. /**
  41877. * Enable or disable the render time capture
  41878. */
  41879. set: function (value) {
  41880. var _this = this;
  41881. if (value === this._captureRenderTime) {
  41882. return;
  41883. }
  41884. this._captureRenderTime = value;
  41885. if (value) {
  41886. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  41887. _this._renderTime.beginMonitoring();
  41888. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  41889. });
  41890. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  41891. _this._renderTime.endMonitoring(false);
  41892. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  41893. });
  41894. }
  41895. else {
  41896. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41897. this._onBeforeDrawPhaseObserver = null;
  41898. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41899. this._onAfterDrawPhaseObserver = null;
  41900. }
  41901. },
  41902. enumerable: true,
  41903. configurable: true
  41904. });
  41905. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  41906. /**
  41907. * Gets the perf counter used for camera render time capture
  41908. */
  41909. get: function () {
  41910. return this._cameraRenderTime;
  41911. },
  41912. enumerable: true,
  41913. configurable: true
  41914. });
  41915. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  41916. /**
  41917. * Gets the camera render time capture status
  41918. */
  41919. get: function () {
  41920. return this._captureCameraRenderTime;
  41921. },
  41922. /**
  41923. * Enable or disable the camera render time capture
  41924. */
  41925. set: function (value) {
  41926. var _this = this;
  41927. if (value === this._captureCameraRenderTime) {
  41928. return;
  41929. }
  41930. this._captureCameraRenderTime = value;
  41931. if (value) {
  41932. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  41933. _this._cameraRenderTime.beginMonitoring();
  41934. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  41935. });
  41936. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  41937. _this._cameraRenderTime.endMonitoring(false);
  41938. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  41939. });
  41940. }
  41941. else {
  41942. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41943. this._onBeforeCameraRenderObserver = null;
  41944. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41945. this._onAfterCameraRenderObserver = null;
  41946. }
  41947. },
  41948. enumerable: true,
  41949. configurable: true
  41950. });
  41951. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  41952. /**
  41953. * Gets the perf counter used for draw calls
  41954. */
  41955. get: function () {
  41956. return this.scene.getEngine()._drawCalls;
  41957. },
  41958. enumerable: true,
  41959. configurable: true
  41960. });
  41961. /**
  41962. * Dispose and release associated resources.
  41963. */
  41964. SceneInstrumentation.prototype.dispose = function () {
  41965. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41966. this._onAfterRenderObserver = null;
  41967. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41968. this._onBeforeActiveMeshesEvaluationObserver = null;
  41969. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41970. this._onAfterActiveMeshesEvaluationObserver = null;
  41971. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41972. this._onBeforeRenderTargetsRenderObserver = null;
  41973. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41974. this._onAfterRenderTargetsRenderObserver = null;
  41975. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  41976. this._onBeforeAnimationsObserver = null;
  41977. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41978. this._onBeforeParticlesRenderingObserver = null;
  41979. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41980. this._onAfterParticlesRenderingObserver = null;
  41981. if (this._onBeforeSpritesRenderingObserver) {
  41982. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41983. this._onBeforeSpritesRenderingObserver = null;
  41984. }
  41985. if (this._onAfterSpritesRenderingObserver) {
  41986. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41987. this._onAfterSpritesRenderingObserver = null;
  41988. }
  41989. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41990. this._onBeforeDrawPhaseObserver = null;
  41991. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41992. this._onAfterDrawPhaseObserver = null;
  41993. if (this._onBeforePhysicsObserver) {
  41994. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41995. this._onBeforePhysicsObserver = null;
  41996. }
  41997. if (this._onAfterPhysicsObserver) {
  41998. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41999. this._onAfterPhysicsObserver = null;
  42000. }
  42001. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  42002. this._onAfterAnimationsObserver = null;
  42003. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  42004. this._onBeforeCameraRenderObserver = null;
  42005. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  42006. this._onAfterCameraRenderObserver = null;
  42007. this.scene = null;
  42008. };
  42009. return SceneInstrumentation;
  42010. }());
  42011. /***/ }),
  42012. /***/ "./Instrumentation/timeToken.ts":
  42013. /*!**************************************!*\
  42014. !*** ./Instrumentation/timeToken.ts ***!
  42015. \**************************************/
  42016. /*! exports provided: _TimeToken */
  42017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42018. "use strict";
  42019. __webpack_require__.r(__webpack_exports__);
  42020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  42021. /**
  42022. * @hidden
  42023. **/
  42024. var _TimeToken = /** @class */ (function () {
  42025. function _TimeToken() {
  42026. this._timeElapsedQueryEnded = false;
  42027. }
  42028. return _TimeToken;
  42029. }());
  42030. /***/ }),
  42031. /***/ "./Layers/effectLayer.ts":
  42032. /*!*******************************!*\
  42033. !*** ./Layers/effectLayer.ts ***!
  42034. \*******************************/
  42035. /*! exports provided: EffectLayer */
  42036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42037. "use strict";
  42038. __webpack_require__.r(__webpack_exports__);
  42039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  42040. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42041. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42042. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42043. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42044. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42045. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42046. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42047. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42048. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42049. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42050. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  42051. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42052. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  42053. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  42054. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  42055. /**
  42056. * The effect layer Helps adding post process effect blended with the main pass.
  42057. *
  42058. * This can be for instance use to generate glow or higlight effects on the scene.
  42059. *
  42060. * The effect layer class can not be used directly and is intented to inherited from to be
  42061. * customized per effects.
  42062. */
  42063. var EffectLayer = /** @class */ (function () {
  42064. /**
  42065. * Instantiates a new effect Layer and references it in the scene.
  42066. * @param name The name of the layer
  42067. * @param scene The scene to use the layer in
  42068. */
  42069. function EffectLayer(
  42070. /** The Friendly of the effect in the scene */
  42071. name, scene) {
  42072. this._vertexBuffers = {};
  42073. this._maxSize = 0;
  42074. this._mainTextureDesiredSize = { width: 0, height: 0 };
  42075. this._shouldRender = true;
  42076. this._postProcesses = [];
  42077. this._textures = [];
  42078. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  42079. /**
  42080. * The clear color of the texture used to generate the glow map.
  42081. */
  42082. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  42083. /**
  42084. * Specifies wether the highlight layer is enabled or not.
  42085. */
  42086. this.isEnabled = true;
  42087. /**
  42088. * An event triggered when the effect layer has been disposed.
  42089. */
  42090. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42091. /**
  42092. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  42093. */
  42094. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42095. /**
  42096. * An event triggered when the generated texture is being merged in the scene.
  42097. */
  42098. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42099. /**
  42100. * An event triggered when the generated texture has been merged in the scene.
  42101. */
  42102. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42103. /**
  42104. * An event triggered when the efffect layer changes its size.
  42105. */
  42106. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42107. this.name = name;
  42108. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  42109. EffectLayer._SceneComponentInitialization(this._scene);
  42110. this._engine = this._scene.getEngine();
  42111. this._maxSize = this._engine.getCaps().maxTextureSize;
  42112. this._scene.effectLayers.push(this);
  42113. // Generate Buffers
  42114. this._generateIndexBuffer();
  42115. this._genrateVertexBuffer();
  42116. }
  42117. Object.defineProperty(EffectLayer.prototype, "camera", {
  42118. /**
  42119. * Gets the camera attached to the layer.
  42120. */
  42121. get: function () {
  42122. return this._effectLayerOptions.camera;
  42123. },
  42124. enumerable: true,
  42125. configurable: true
  42126. });
  42127. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  42128. /**
  42129. * Gets the rendering group id the layer should render in.
  42130. */
  42131. get: function () {
  42132. return this._effectLayerOptions.renderingGroupId;
  42133. },
  42134. enumerable: true,
  42135. configurable: true
  42136. });
  42137. /**
  42138. * Initializes the effect layer with the required options.
  42139. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  42140. */
  42141. EffectLayer.prototype._init = function (options) {
  42142. // Adapt options
  42143. 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);
  42144. this._setMainTextureSize();
  42145. this._createMainTexture();
  42146. this._createTextureAndPostProcesses();
  42147. this._mergeEffect = this._createMergeEffect();
  42148. };
  42149. /**
  42150. * Generates the index buffer of the full screen quad blending to the main canvas.
  42151. */
  42152. EffectLayer.prototype._generateIndexBuffer = function () {
  42153. // Indices
  42154. var indices = [];
  42155. indices.push(0);
  42156. indices.push(1);
  42157. indices.push(2);
  42158. indices.push(0);
  42159. indices.push(2);
  42160. indices.push(3);
  42161. this._indexBuffer = this._engine.createIndexBuffer(indices);
  42162. };
  42163. /**
  42164. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  42165. */
  42166. EffectLayer.prototype._genrateVertexBuffer = function () {
  42167. // VBO
  42168. var vertices = [];
  42169. vertices.push(1, 1);
  42170. vertices.push(-1, 1);
  42171. vertices.push(-1, -1);
  42172. vertices.push(1, -1);
  42173. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  42174. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  42175. };
  42176. /**
  42177. * Sets the main texture desired size which is the closest power of two
  42178. * of the engine canvas size.
  42179. */
  42180. EffectLayer.prototype._setMainTextureSize = function () {
  42181. if (this._effectLayerOptions.mainTextureFixedSize) {
  42182. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  42183. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  42184. }
  42185. else {
  42186. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  42187. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  42188. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  42189. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  42190. }
  42191. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  42192. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  42193. };
  42194. /**
  42195. * Creates the main texture for the effect layer.
  42196. */
  42197. EffectLayer.prototype._createMainTexture = function () {
  42198. var _this = this;
  42199. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  42200. width: this._mainTextureDesiredSize.width,
  42201. height: this._mainTextureDesiredSize.height
  42202. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  42203. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  42204. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42205. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42206. this._mainTexture.anisotropicFilteringLevel = 1;
  42207. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  42208. this._mainTexture.renderParticles = false;
  42209. this._mainTexture.renderList = null;
  42210. this._mainTexture.ignoreCameraViewport = true;
  42211. // Custom render function
  42212. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  42213. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  42214. var index;
  42215. var engine = _this._scene.getEngine();
  42216. if (depthOnlySubMeshes.length) {
  42217. engine.setColorWrite(false);
  42218. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  42219. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  42220. }
  42221. engine.setColorWrite(true);
  42222. }
  42223. for (index = 0; index < opaqueSubMeshes.length; index++) {
  42224. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  42225. }
  42226. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  42227. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  42228. }
  42229. for (index = 0; index < transparentSubMeshes.length; index++) {
  42230. _this._renderSubMesh(transparentSubMeshes.data[index]);
  42231. }
  42232. };
  42233. this._mainTexture.onClearObservable.add(function (engine) {
  42234. engine.clear(_this.neutralColor, true, true, true);
  42235. });
  42236. };
  42237. /**
  42238. * Adds specific effects defines.
  42239. * @param defines The defines to add specifics to.
  42240. */
  42241. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  42242. // Nothing to add by default.
  42243. };
  42244. /**
  42245. * Checks for the readiness of the element composing the layer.
  42246. * @param subMesh the mesh to check for
  42247. * @param useInstances specify wether or not to use instances to render the mesh
  42248. * @param emissiveTexture the associated emissive texture used to generate the glow
  42249. * @return true if ready otherwise, false
  42250. */
  42251. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  42252. var material = subMesh.getMaterial();
  42253. if (!material) {
  42254. return false;
  42255. }
  42256. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  42257. return false;
  42258. }
  42259. var defines = [];
  42260. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42261. var mesh = subMesh.getMesh();
  42262. var uv1 = false;
  42263. var uv2 = false;
  42264. // Diffuse
  42265. if (material) {
  42266. var needAlphaTest = material.needAlphaTesting();
  42267. var diffuseTexture = material.getAlphaTestTexture();
  42268. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42269. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42270. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42271. defines.push("#define DIFFUSE");
  42272. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42273. diffuseTexture.coordinatesIndex === 1) {
  42274. defines.push("#define DIFFUSEUV2");
  42275. uv2 = true;
  42276. }
  42277. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42278. defines.push("#define DIFFUSEUV1");
  42279. uv1 = true;
  42280. }
  42281. if (needAlphaTest) {
  42282. defines.push("#define ALPHATEST");
  42283. defines.push("#define ALPHATESTVALUE 0.4");
  42284. }
  42285. }
  42286. var opacityTexture = material.opacityTexture;
  42287. if (opacityTexture) {
  42288. defines.push("#define OPACITY");
  42289. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42290. opacityTexture.coordinatesIndex === 1) {
  42291. defines.push("#define OPACITYUV2");
  42292. uv2 = true;
  42293. }
  42294. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42295. defines.push("#define OPACITYUV1");
  42296. uv1 = true;
  42297. }
  42298. }
  42299. }
  42300. // Emissive
  42301. if (emissiveTexture) {
  42302. defines.push("#define EMISSIVE");
  42303. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42304. emissiveTexture.coordinatesIndex === 1) {
  42305. defines.push("#define EMISSIVEUV2");
  42306. uv2 = true;
  42307. }
  42308. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42309. defines.push("#define EMISSIVEUV1");
  42310. uv1 = true;
  42311. }
  42312. }
  42313. // Vertex
  42314. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  42315. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  42316. defines.push("#define VERTEXALPHA");
  42317. }
  42318. if (uv1) {
  42319. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  42320. defines.push("#define UV1");
  42321. }
  42322. if (uv2) {
  42323. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  42324. defines.push("#define UV2");
  42325. }
  42326. // Bones
  42327. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  42328. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  42329. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  42330. if (mesh.numBoneInfluencers > 4) {
  42331. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  42332. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  42333. }
  42334. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  42335. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  42336. }
  42337. else {
  42338. defines.push("#define NUM_BONE_INFLUENCERS 0");
  42339. }
  42340. // Morph targets
  42341. var manager = mesh.morphTargetManager;
  42342. var morphInfluencers = 0;
  42343. if (manager) {
  42344. if (manager.numInfluencers > 0) {
  42345. defines.push("#define MORPHTARGETS");
  42346. morphInfluencers = manager.numInfluencers;
  42347. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  42348. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  42349. }
  42350. }
  42351. // Instances
  42352. if (useInstances) {
  42353. defines.push("#define INSTANCES");
  42354. attribs.push("world0");
  42355. attribs.push("world1");
  42356. attribs.push("world2");
  42357. attribs.push("world3");
  42358. }
  42359. this._addCustomEffectDefines(defines);
  42360. // Get correct effect
  42361. var join = defines.join("\n");
  42362. if (this._cachedDefines !== join) {
  42363. this._cachedDefines = join;
  42364. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  42365. "color", "morphTargetInfluences",
  42366. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  42367. }
  42368. return this._effectLayerMapGenerationEffect.isReady();
  42369. };
  42370. /**
  42371. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  42372. */
  42373. EffectLayer.prototype.render = function () {
  42374. var currentEffect = this._mergeEffect;
  42375. // Check
  42376. if (!currentEffect.isReady()) {
  42377. return;
  42378. }
  42379. for (var i = 0; i < this._postProcesses.length; i++) {
  42380. if (!this._postProcesses[i].isReady()) {
  42381. return;
  42382. }
  42383. }
  42384. var engine = this._scene.getEngine();
  42385. this.onBeforeComposeObservable.notifyObservers(this);
  42386. // Render
  42387. engine.enableEffect(currentEffect);
  42388. engine.setState(false);
  42389. // VBOs
  42390. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42391. // Cache
  42392. var previousAlphaMode = engine.getAlphaMode();
  42393. // Go Blend.
  42394. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  42395. // Blends the map on the main canvas.
  42396. this._internalRender(currentEffect);
  42397. // Restore Alpha
  42398. engine.setAlphaMode(previousAlphaMode);
  42399. this.onAfterComposeObservable.notifyObservers(this);
  42400. // Handle size changes.
  42401. var size = this._mainTexture.getSize();
  42402. this._setMainTextureSize();
  42403. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  42404. // Recreate RTT and post processes on size change.
  42405. this.onSizeChangedObservable.notifyObservers(this);
  42406. this._disposeTextureAndPostProcesses();
  42407. this._createMainTexture();
  42408. this._createTextureAndPostProcesses();
  42409. }
  42410. };
  42411. /**
  42412. * Determine if a given mesh will be used in the current effect.
  42413. * @param mesh mesh to test
  42414. * @returns true if the mesh will be used
  42415. */
  42416. EffectLayer.prototype.hasMesh = function (mesh) {
  42417. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  42418. return true;
  42419. }
  42420. return false;
  42421. };
  42422. /**
  42423. * Returns true if the layer contains information to display, otherwise false.
  42424. * @returns true if the glow layer should be rendered
  42425. */
  42426. EffectLayer.prototype.shouldRender = function () {
  42427. return this.isEnabled && this._shouldRender;
  42428. };
  42429. /**
  42430. * Returns true if the mesh should render, otherwise false.
  42431. * @param mesh The mesh to render
  42432. * @returns true if it should render otherwise false
  42433. */
  42434. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  42435. return true;
  42436. };
  42437. /**
  42438. * Returns true if the mesh can be rendered, otherwise false.
  42439. * @param mesh The mesh to render
  42440. * @param material The material used on the mesh
  42441. * @returns true if it can be rendered otherwise false
  42442. */
  42443. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  42444. return !material.needAlphaBlendingForMesh(mesh);
  42445. };
  42446. /**
  42447. * Returns true if the mesh should render, otherwise false.
  42448. * @param mesh The mesh to render
  42449. * @returns true if it should render otherwise false
  42450. */
  42451. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  42452. return true;
  42453. };
  42454. /**
  42455. * Renders the submesh passed in parameter to the generation map.
  42456. */
  42457. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  42458. var _this = this;
  42459. if (!this.shouldRender()) {
  42460. return;
  42461. }
  42462. var material = subMesh.getMaterial();
  42463. var mesh = subMesh.getRenderingMesh();
  42464. var scene = this._scene;
  42465. var engine = scene.getEngine();
  42466. if (!material) {
  42467. return;
  42468. }
  42469. // Do not block in blend mode.
  42470. if (!this._canRenderMesh(mesh, material)) {
  42471. return;
  42472. }
  42473. // Culling
  42474. engine.setState(material.backFaceCulling);
  42475. // Managing instances
  42476. var batch = mesh._getInstancesRenderList(subMesh._id);
  42477. if (batch.mustReturn) {
  42478. return;
  42479. }
  42480. // Early Exit per mesh
  42481. if (!this._shouldRenderMesh(mesh)) {
  42482. return;
  42483. }
  42484. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  42485. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  42486. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  42487. engine.enableEffect(this._effectLayerMapGenerationEffect);
  42488. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  42489. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  42490. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  42491. var needAlphaTest = material.needAlphaTesting();
  42492. var diffuseTexture = material.getAlphaTestTexture();
  42493. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42494. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42495. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42496. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  42497. var textureMatrix = diffuseTexture.getTextureMatrix();
  42498. if (textureMatrix) {
  42499. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  42500. }
  42501. }
  42502. var opacityTexture = material.opacityTexture;
  42503. if (opacityTexture) {
  42504. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  42505. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  42506. var textureMatrix = opacityTexture.getTextureMatrix();
  42507. if (textureMatrix) {
  42508. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  42509. }
  42510. }
  42511. // Glow emissive only
  42512. if (this._emissiveTextureAndColor.texture) {
  42513. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  42514. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  42515. }
  42516. // Bones
  42517. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  42518. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  42519. }
  42520. // Morph targets
  42521. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  42522. // Draw
  42523. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  42524. }
  42525. else {
  42526. // Need to reset refresh rate of the main map
  42527. this._mainTexture.resetRefreshCounter();
  42528. }
  42529. };
  42530. /**
  42531. * Rebuild the required buffers.
  42532. * @hidden Internal use only.
  42533. */
  42534. EffectLayer.prototype._rebuild = function () {
  42535. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42536. if (vb) {
  42537. vb._rebuild();
  42538. }
  42539. this._generateIndexBuffer();
  42540. };
  42541. /**
  42542. * Dispose only the render target textures and post process.
  42543. */
  42544. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  42545. this._mainTexture.dispose();
  42546. for (var i = 0; i < this._postProcesses.length; i++) {
  42547. if (this._postProcesses[i]) {
  42548. this._postProcesses[i].dispose();
  42549. }
  42550. }
  42551. this._postProcesses = [];
  42552. for (var i = 0; i < this._textures.length; i++) {
  42553. if (this._textures[i]) {
  42554. this._textures[i].dispose();
  42555. }
  42556. }
  42557. this._textures = [];
  42558. };
  42559. /**
  42560. * Dispose the highlight layer and free resources.
  42561. */
  42562. EffectLayer.prototype.dispose = function () {
  42563. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42564. if (vertexBuffer) {
  42565. vertexBuffer.dispose();
  42566. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  42567. }
  42568. if (this._indexBuffer) {
  42569. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42570. this._indexBuffer = null;
  42571. }
  42572. // Clean textures and post processes
  42573. this._disposeTextureAndPostProcesses();
  42574. // Remove from scene
  42575. var index = this._scene.effectLayers.indexOf(this, 0);
  42576. if (index > -1) {
  42577. this._scene.effectLayers.splice(index, 1);
  42578. }
  42579. // Callback
  42580. this.onDisposeObservable.notifyObservers(this);
  42581. this.onDisposeObservable.clear();
  42582. this.onBeforeRenderMainTextureObservable.clear();
  42583. this.onBeforeComposeObservable.clear();
  42584. this.onAfterComposeObservable.clear();
  42585. this.onSizeChangedObservable.clear();
  42586. };
  42587. /**
  42588. * Gets the class name of the effect layer
  42589. * @returns the string with the class name of the effect layer
  42590. */
  42591. EffectLayer.prototype.getClassName = function () {
  42592. return "EffectLayer";
  42593. };
  42594. /**
  42595. * Creates an effect layer from parsed effect layer data
  42596. * @param parsedEffectLayer defines effect layer data
  42597. * @param scene defines the current scene
  42598. * @param rootUrl defines the root URL containing the effect layer information
  42599. * @returns a parsed effect Layer
  42600. */
  42601. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  42602. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  42603. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  42604. };
  42605. /** @hidden */
  42606. EffectLayer._SceneComponentInitialization = function (_) {
  42607. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  42608. };
  42609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42611. ], EffectLayer.prototype, "name", void 0);
  42612. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42613. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  42614. ], EffectLayer.prototype, "neutralColor", void 0);
  42615. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42616. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42617. ], EffectLayer.prototype, "isEnabled", void 0);
  42618. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  42620. ], EffectLayer.prototype, "camera", null);
  42621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42623. ], EffectLayer.prototype, "renderingGroupId", null);
  42624. return EffectLayer;
  42625. }());
  42626. /***/ }),
  42627. /***/ "./Layers/effectLayerSceneComponent.ts":
  42628. /*!*********************************************!*\
  42629. !*** ./Layers/effectLayerSceneComponent.ts ***!
  42630. \*********************************************/
  42631. /*! exports provided: EffectLayerSceneComponent */
  42632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42633. "use strict";
  42634. __webpack_require__.r(__webpack_exports__);
  42635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  42636. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  42637. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42638. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42639. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42640. // Adds the parser to the scene parsers.
  42641. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  42642. if (parsedData.effectLayers) {
  42643. if (!container.effectLayers) {
  42644. container.effectLayers = new Array();
  42645. }
  42646. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  42647. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  42648. container.effectLayers.push(effectLayer);
  42649. }
  42650. }
  42651. });
  42652. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  42653. var index = this.effectLayers.indexOf(toRemove);
  42654. if (index !== -1) {
  42655. this.effectLayers.splice(index, 1);
  42656. }
  42657. return index;
  42658. };
  42659. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  42660. this.effectLayers.push(newEffectLayer);
  42661. };
  42662. /**
  42663. * Defines the layer scene component responsible to manage any effect layers
  42664. * in a given scene.
  42665. */
  42666. var EffectLayerSceneComponent = /** @class */ (function () {
  42667. /**
  42668. * Creates a new instance of the component for the given scene
  42669. * @param scene Defines the scene to register the component in
  42670. */
  42671. function EffectLayerSceneComponent(scene) {
  42672. /**
  42673. * The component name helpfull to identify the component in the list of scene components.
  42674. */
  42675. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  42676. this._renderEffects = false;
  42677. this._needStencil = false;
  42678. this._previousStencilState = false;
  42679. this.scene = scene;
  42680. this._engine = scene.getEngine();
  42681. scene.effectLayers = new Array();
  42682. }
  42683. /**
  42684. * Registers the component in a given scene
  42685. */
  42686. EffectLayerSceneComponent.prototype.register = function () {
  42687. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  42688. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  42689. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  42690. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  42691. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  42692. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  42693. };
  42694. /**
  42695. * Rebuilds the elements related to this component in case of
  42696. * context lost for instance.
  42697. */
  42698. EffectLayerSceneComponent.prototype.rebuild = function () {
  42699. var layers = this.scene.effectLayers;
  42700. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42701. var effectLayer = layers_1[_i];
  42702. effectLayer._rebuild();
  42703. }
  42704. };
  42705. /**
  42706. * Serializes the component data to the specified json object
  42707. * @param serializationObject The object to serialize to
  42708. */
  42709. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  42710. // Effect layers
  42711. serializationObject.effectLayers = [];
  42712. var layers = this.scene.effectLayers;
  42713. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42714. var effectLayer = layers_2[_i];
  42715. if (effectLayer.serialize) {
  42716. serializationObject.effectLayers.push(effectLayer.serialize());
  42717. }
  42718. }
  42719. };
  42720. /**
  42721. * Adds all the element from the container to the scene
  42722. * @param container the container holding the elements
  42723. */
  42724. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  42725. var _this = this;
  42726. if (!container.effectLayers) {
  42727. return;
  42728. }
  42729. container.effectLayers.forEach(function (o) {
  42730. _this.scene.addEffectLayer(o);
  42731. });
  42732. };
  42733. /**
  42734. * Removes all the elements in the container from the scene
  42735. * @param container contains the elements to remove
  42736. * @param dispose if the removed element should be disposed (default: false)
  42737. */
  42738. EffectLayerSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  42739. var _this = this;
  42740. if (!container.effectLayers) {
  42741. return;
  42742. }
  42743. container.effectLayers.forEach(function (o) {
  42744. _this.scene.removeEffectLayer(o);
  42745. if (dispose) {
  42746. o.dispose();
  42747. }
  42748. });
  42749. };
  42750. /**
  42751. * Disposes the component and the associated ressources.
  42752. */
  42753. EffectLayerSceneComponent.prototype.dispose = function () {
  42754. var layers = this.scene.effectLayers;
  42755. while (layers.length) {
  42756. layers[0].dispose();
  42757. }
  42758. };
  42759. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  42760. var layers = this.scene.effectLayers;
  42761. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  42762. var layer = layers_3[_i];
  42763. if (!layer.hasMesh(mesh)) {
  42764. continue;
  42765. }
  42766. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  42767. var subMesh = _b[_a];
  42768. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  42769. return false;
  42770. }
  42771. }
  42772. }
  42773. return true;
  42774. };
  42775. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  42776. this._renderEffects = false;
  42777. this._needStencil = false;
  42778. var needRebind = false;
  42779. var layers = this.scene.effectLayers;
  42780. if (layers && layers.length > 0) {
  42781. this._previousStencilState = this._engine.getStencilBuffer();
  42782. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  42783. var effectLayer = layers_4[_i];
  42784. if (effectLayer.shouldRender() &&
  42785. (!effectLayer.camera ||
  42786. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  42787. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  42788. this._renderEffects = true;
  42789. this._needStencil = this._needStencil || effectLayer.needStencil();
  42790. var renderTarget = effectLayer._mainTexture;
  42791. if (renderTarget._shouldRender()) {
  42792. this.scene.incrementRenderId();
  42793. renderTarget.render(false, false);
  42794. needRebind = true;
  42795. }
  42796. }
  42797. }
  42798. this.scene.incrementRenderId();
  42799. }
  42800. return needRebind;
  42801. };
  42802. EffectLayerSceneComponent.prototype._setStencil = function () {
  42803. // Activate effect Layer stencil
  42804. if (this._needStencil) {
  42805. this._engine.setStencilBuffer(true);
  42806. }
  42807. };
  42808. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  42809. // Restore effect Layer stencil
  42810. if (this._needStencil) {
  42811. this._engine.setStencilBuffer(this._previousStencilState);
  42812. }
  42813. };
  42814. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  42815. if (this._renderEffects) {
  42816. this._engine.setDepthBuffer(false);
  42817. var layers = this.scene.effectLayers;
  42818. for (var i = 0; i < layers.length; i++) {
  42819. var effectLayer = layers[i];
  42820. if (effectLayer.renderingGroupId === renderingGroupId) {
  42821. if (effectLayer.shouldRender()) {
  42822. effectLayer.render();
  42823. }
  42824. }
  42825. }
  42826. this._engine.setDepthBuffer(true);
  42827. }
  42828. };
  42829. EffectLayerSceneComponent.prototype._drawCamera = function () {
  42830. if (this._renderEffects) {
  42831. this._draw(-1);
  42832. }
  42833. };
  42834. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  42835. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  42836. this._draw(index);
  42837. }
  42838. };
  42839. return EffectLayerSceneComponent;
  42840. }());
  42841. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  42842. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  42843. if (!component) {
  42844. component = new EffectLayerSceneComponent(scene);
  42845. scene._addComponent(component);
  42846. }
  42847. };
  42848. /***/ }),
  42849. /***/ "./Layers/glowLayer.ts":
  42850. /*!*****************************!*\
  42851. !*** ./Layers/glowLayer.ts ***!
  42852. \*****************************/
  42853. /*! exports provided: GlowLayer */
  42854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42855. "use strict";
  42856. __webpack_require__.r(__webpack_exports__);
  42857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  42858. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42859. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42860. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42861. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42862. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42863. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42864. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42865. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42866. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42867. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42868. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42869. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42870. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42871. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42872. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42873. /* harmony import */ var _Layers_effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Layers/effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42874. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  42875. for (var index = 0; index < this.effectLayers.length; index++) {
  42876. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  42877. return this.effectLayers[index];
  42878. }
  42879. }
  42880. return null;
  42881. };
  42882. /**
  42883. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  42884. *
  42885. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42886. * glowy meshes to your scene.
  42887. *
  42888. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  42889. */
  42890. var GlowLayer = /** @class */ (function (_super) {
  42891. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  42892. /**
  42893. * Instantiates a new glow Layer and references it to the scene.
  42894. * @param name The name of the layer
  42895. * @param scene The scene to use the layer in
  42896. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  42897. */
  42898. function GlowLayer(name, scene, options) {
  42899. var _this = _super.call(this, name, scene) || this;
  42900. _this._intensity = 1.0;
  42901. _this._includedOnlyMeshes = [];
  42902. _this._excludedMeshes = [];
  42903. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  42904. // Adapt options
  42905. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  42906. // Initialize the layer
  42907. _this._init({
  42908. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  42909. camera: _this._options.camera,
  42910. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42911. mainTextureRatio: _this._options.mainTextureRatio,
  42912. renderingGroupId: _this._options.renderingGroupId
  42913. });
  42914. return _this;
  42915. }
  42916. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  42917. /**
  42918. * Gets the kernel size of the blur.
  42919. */
  42920. get: function () {
  42921. return this._horizontalBlurPostprocess1.kernel;
  42922. },
  42923. /**
  42924. * Sets the kernel size of the blur.
  42925. */
  42926. set: function (value) {
  42927. this._horizontalBlurPostprocess1.kernel = value;
  42928. this._verticalBlurPostprocess1.kernel = value;
  42929. this._horizontalBlurPostprocess2.kernel = value;
  42930. this._verticalBlurPostprocess2.kernel = value;
  42931. },
  42932. enumerable: true,
  42933. configurable: true
  42934. });
  42935. Object.defineProperty(GlowLayer.prototype, "intensity", {
  42936. /**
  42937. * Gets the glow intensity.
  42938. */
  42939. get: function () {
  42940. return this._intensity;
  42941. },
  42942. /**
  42943. * Sets the glow intensity.
  42944. */
  42945. set: function (value) {
  42946. this._intensity = value;
  42947. },
  42948. enumerable: true,
  42949. configurable: true
  42950. });
  42951. /**
  42952. * Get the effect name of the layer.
  42953. * @return The effect name
  42954. */
  42955. GlowLayer.prototype.getEffectName = function () {
  42956. return GlowLayer.EffectName;
  42957. };
  42958. /**
  42959. * Create the merge effect. This is the shader use to blit the information back
  42960. * to the main canvas at the end of the scene rendering.
  42961. */
  42962. GlowLayer.prototype._createMergeEffect = function () {
  42963. // Effect
  42964. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  42965. };
  42966. /**
  42967. * Creates the render target textures and post processes used in the glow layer.
  42968. */
  42969. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  42970. var _this = this;
  42971. var blurTextureWidth = this._mainTextureDesiredSize.width;
  42972. var blurTextureHeight = this._mainTextureDesiredSize.height;
  42973. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42974. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42975. var textureType = 0;
  42976. if (this._engine.getCaps().textureHalfFloatRender) {
  42977. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42978. }
  42979. else {
  42980. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42981. }
  42982. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  42983. width: blurTextureWidth,
  42984. height: blurTextureHeight
  42985. }, this._scene, false, true, textureType);
  42986. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42987. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42988. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42989. this._blurTexture1.renderParticles = false;
  42990. this._blurTexture1.ignoreCameraViewport = true;
  42991. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  42992. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  42993. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  42994. width: blurTextureWidth2,
  42995. height: blurTextureHeight2
  42996. }, this._scene, false, true, textureType);
  42997. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42998. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42999. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  43000. this._blurTexture2.renderParticles = false;
  43001. this._blurTexture2.ignoreCameraViewport = true;
  43002. this._textures = [this._blurTexture1, this._blurTexture2];
  43003. 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, {
  43004. width: blurTextureWidth,
  43005. height: blurTextureHeight
  43006. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43007. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  43008. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  43009. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  43010. effect.setTexture("textureSampler", _this._mainTexture);
  43011. });
  43012. 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, {
  43013. width: blurTextureWidth,
  43014. height: blurTextureHeight
  43015. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43016. 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, {
  43017. width: blurTextureWidth2,
  43018. height: blurTextureHeight2
  43019. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43020. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  43021. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  43022. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  43023. effect.setTexture("textureSampler", _this._blurTexture1);
  43024. });
  43025. 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, {
  43026. width: blurTextureWidth2,
  43027. height: blurTextureHeight2
  43028. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43029. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  43030. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  43031. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  43032. this._mainTexture.samples = this._options.mainTextureSamples;
  43033. this._mainTexture.onAfterUnbindObservable.add(function () {
  43034. var internalTexture = _this._blurTexture1.getInternalTexture();
  43035. if (internalTexture) {
  43036. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  43037. internalTexture = _this._blurTexture2.getInternalTexture();
  43038. if (internalTexture) {
  43039. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  43040. }
  43041. }
  43042. });
  43043. // Prevent autoClear.
  43044. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43045. };
  43046. /**
  43047. * Checks for the readiness of the element composing the layer.
  43048. * @param subMesh the mesh to check for
  43049. * @param useInstances specify wether or not to use instances to render the mesh
  43050. * @param emissiveTexture the associated emissive texture used to generate the glow
  43051. * @return true if ready otherwise, false
  43052. */
  43053. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  43054. var material = subMesh.getMaterial();
  43055. var mesh = subMesh.getRenderingMesh();
  43056. if (!material || !mesh) {
  43057. return false;
  43058. }
  43059. var emissiveTexture = material.emissiveTexture;
  43060. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43061. };
  43062. /**
  43063. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43064. */
  43065. GlowLayer.prototype.needStencil = function () {
  43066. return false;
  43067. };
  43068. /**
  43069. * Returns true if the mesh can be rendered, otherwise false.
  43070. * @param mesh The mesh to render
  43071. * @param material The material used on the mesh
  43072. * @returns true if it can be rendered otherwise false
  43073. */
  43074. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  43075. return true;
  43076. };
  43077. /**
  43078. * Implementation specific of rendering the generating effect on the main canvas.
  43079. * @param effect The effect used to render through
  43080. */
  43081. GlowLayer.prototype._internalRender = function (effect) {
  43082. // Texture
  43083. effect.setTexture("textureSampler", this._blurTexture1);
  43084. effect.setTexture("textureSampler2", this._blurTexture2);
  43085. effect.setFloat("offset", this._intensity);
  43086. // Cache
  43087. var engine = this._engine;
  43088. var previousStencilBuffer = engine.getStencilBuffer();
  43089. // Draw order
  43090. engine.setStencilBuffer(false);
  43091. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  43092. // Draw order
  43093. engine.setStencilBuffer(previousStencilBuffer);
  43094. };
  43095. /**
  43096. * Sets the required values for both the emissive texture and and the main color.
  43097. */
  43098. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43099. var textureLevel = 1.0;
  43100. if (this.customEmissiveTextureSelector) {
  43101. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  43102. }
  43103. else {
  43104. if (material) {
  43105. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43106. if (this._emissiveTextureAndColor.texture) {
  43107. textureLevel = this._emissiveTextureAndColor.texture.level;
  43108. }
  43109. }
  43110. else {
  43111. this._emissiveTextureAndColor.texture = null;
  43112. }
  43113. }
  43114. if (this.customEmissiveColorSelector) {
  43115. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  43116. }
  43117. else {
  43118. if (material.emissiveColor) {
  43119. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  43120. }
  43121. else {
  43122. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43123. }
  43124. }
  43125. };
  43126. /**
  43127. * Returns true if the mesh should render, otherwise false.
  43128. * @param mesh The mesh to render
  43129. * @returns true if it should render otherwise false
  43130. */
  43131. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  43132. return this.hasMesh(mesh);
  43133. };
  43134. /**
  43135. * Adds specific effects defines.
  43136. * @param defines The defines to add specifics to.
  43137. */
  43138. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  43139. defines.push("#define GLOW");
  43140. };
  43141. /**
  43142. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  43143. * @param mesh The mesh to exclude from the glow layer
  43144. */
  43145. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  43146. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  43147. this._excludedMeshes.push(mesh.uniqueId);
  43148. }
  43149. };
  43150. /**
  43151. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  43152. * @param mesh The mesh to remove
  43153. */
  43154. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  43155. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  43156. if (index !== -1) {
  43157. this._excludedMeshes.splice(index, 1);
  43158. }
  43159. };
  43160. /**
  43161. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  43162. * @param mesh The mesh to include in the glow layer
  43163. */
  43164. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  43165. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  43166. this._includedOnlyMeshes.push(mesh.uniqueId);
  43167. }
  43168. };
  43169. /**
  43170. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  43171. * @param mesh The mesh to remove
  43172. */
  43173. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  43174. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  43175. if (index !== -1) {
  43176. this._includedOnlyMeshes.splice(index, 1);
  43177. }
  43178. };
  43179. /**
  43180. * Determine if a given mesh will be used in the glow layer
  43181. * @param mesh The mesh to test
  43182. * @returns true if the mesh will be highlighted by the current glow layer
  43183. */
  43184. GlowLayer.prototype.hasMesh = function (mesh) {
  43185. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43186. return false;
  43187. }
  43188. // Included Mesh
  43189. if (this._includedOnlyMeshes.length) {
  43190. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  43191. }
  43192. // Excluded Mesh
  43193. if (this._excludedMeshes.length) {
  43194. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  43195. }
  43196. return true;
  43197. };
  43198. /**
  43199. * Free any resources and references associated to a mesh.
  43200. * Internal use
  43201. * @param mesh The mesh to free.
  43202. * @hidden
  43203. */
  43204. GlowLayer.prototype._disposeMesh = function (mesh) {
  43205. this.removeIncludedOnlyMesh(mesh);
  43206. this.removeExcludedMesh(mesh);
  43207. };
  43208. /**
  43209. * Gets the class name of the effect layer
  43210. * @returns the string with the class name of the effect layer
  43211. */
  43212. GlowLayer.prototype.getClassName = function () {
  43213. return "GlowLayer";
  43214. };
  43215. /**
  43216. * Serializes this glow layer
  43217. * @returns a serialized glow layer object
  43218. */
  43219. GlowLayer.prototype.serialize = function () {
  43220. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43221. serializationObject.customType = "BABYLON.GlowLayer";
  43222. var index;
  43223. // Included meshes
  43224. serializationObject.includedMeshes = [];
  43225. if (this._includedOnlyMeshes.length) {
  43226. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  43227. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  43228. if (mesh) {
  43229. serializationObject.includedMeshes.push(mesh.id);
  43230. }
  43231. }
  43232. }
  43233. // Excluded meshes
  43234. serializationObject.excludedMeshes = [];
  43235. if (this._excludedMeshes.length) {
  43236. for (index = 0; index < this._excludedMeshes.length; index++) {
  43237. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  43238. if (mesh) {
  43239. serializationObject.excludedMeshes.push(mesh.id);
  43240. }
  43241. }
  43242. }
  43243. return serializationObject;
  43244. };
  43245. /**
  43246. * Creates a Glow Layer from parsed glow layer data
  43247. * @param parsedGlowLayer defines glow layer data
  43248. * @param scene defines the current scene
  43249. * @param rootUrl defines the root URL containing the glow layer information
  43250. * @returns a parsed Glow Layer
  43251. */
  43252. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  43253. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  43254. var index;
  43255. // Excluded meshes
  43256. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  43257. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  43258. if (mesh) {
  43259. gl.addExcludedMesh(mesh);
  43260. }
  43261. }
  43262. // Included meshes
  43263. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  43264. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  43265. if (mesh) {
  43266. gl.addIncludedOnlyMesh(mesh);
  43267. }
  43268. }
  43269. return gl;
  43270. };
  43271. /**
  43272. * Effect Name of the layer.
  43273. */
  43274. GlowLayer.EffectName = "GlowLayer";
  43275. /**
  43276. * The default blur kernel size used for the glow.
  43277. */
  43278. GlowLayer.DefaultBlurKernelSize = 32;
  43279. /**
  43280. * The default texture size ratio used for the glow.
  43281. */
  43282. GlowLayer.DefaultTextureRatio = 0.5;
  43283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43285. ], GlowLayer.prototype, "blurKernelSize", null);
  43286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43288. ], GlowLayer.prototype, "intensity", null);
  43289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43291. ], GlowLayer.prototype, "_options", void 0);
  43292. return GlowLayer;
  43293. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  43294. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  43295. /***/ }),
  43296. /***/ "./Layers/highlightLayer.ts":
  43297. /*!**********************************!*\
  43298. !*** ./Layers/highlightLayer.ts ***!
  43299. \**********************************/
  43300. /*! exports provided: HighlightLayer */
  43301. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43302. "use strict";
  43303. __webpack_require__.r(__webpack_exports__);
  43304. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  43305. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43306. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  43307. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43308. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43309. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43310. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43311. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43312. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43313. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43314. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  43315. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  43316. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  43317. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43318. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43319. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43320. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  43321. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  43322. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  43323. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  43324. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  43325. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  43326. for (var index = 0; index < this.effectLayers.length; index++) {
  43327. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  43328. return this.effectLayers[index];
  43329. }
  43330. }
  43331. return null;
  43332. };
  43333. /**
  43334. * Special Glow Blur post process only blurring the alpha channel
  43335. * It enforces keeping the most luminous color in the color channel.
  43336. */
  43337. var GlowBlurPostProcess = /** @class */ (function (_super) {
  43338. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  43339. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  43340. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  43341. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  43342. _this.direction = direction;
  43343. _this.kernel = kernel;
  43344. _this.onApplyObservable.add(function (effect) {
  43345. effect.setFloat2("screenSize", _this.width, _this.height);
  43346. effect.setVector2("direction", _this.direction);
  43347. effect.setFloat("blurWidth", _this.kernel);
  43348. });
  43349. return _this;
  43350. }
  43351. return GlowBlurPostProcess;
  43352. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  43353. /**
  43354. * The highlight layer Helps adding a glow effect around a mesh.
  43355. *
  43356. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43357. * glowy meshes to your scene.
  43358. *
  43359. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  43360. */
  43361. var HighlightLayer = /** @class */ (function (_super) {
  43362. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  43363. /**
  43364. * Instantiates a new highlight Layer and references it to the scene..
  43365. * @param name The name of the layer
  43366. * @param scene The scene to use the layer in
  43367. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  43368. */
  43369. function HighlightLayer(name, scene, options) {
  43370. var _this = _super.call(this, name, scene) || this;
  43371. _this.name = name;
  43372. /**
  43373. * Specifies whether or not the inner glow is ACTIVE in the layer.
  43374. */
  43375. _this.innerGlow = true;
  43376. /**
  43377. * Specifies whether or not the outer glow is ACTIVE in the layer.
  43378. */
  43379. _this.outerGlow = true;
  43380. /**
  43381. * An event triggered when the highlight layer is being blurred.
  43382. */
  43383. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43384. /**
  43385. * An event triggered when the highlight layer has been blurred.
  43386. */
  43387. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43388. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  43389. _this._meshes = {};
  43390. _this._excludedMeshes = {};
  43391. _this.neutralColor = HighlightLayer.NeutralColor;
  43392. // Warn on stencil
  43393. if (!_this._engine.isStencilEnable) {
  43394. _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 }");
  43395. }
  43396. // Adapt options
  43397. _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);
  43398. // Initialize the layer
  43399. _this._init({
  43400. alphaBlendingMode: _this._options.alphaBlendingMode,
  43401. camera: _this._options.camera,
  43402. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  43403. mainTextureRatio: _this._options.mainTextureRatio,
  43404. renderingGroupId: _this._options.renderingGroupId
  43405. });
  43406. // Do not render as long as no meshes have been added
  43407. _this._shouldRender = false;
  43408. return _this;
  43409. }
  43410. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  43411. /**
  43412. * Gets the horizontal size of the blur.
  43413. */
  43414. get: function () {
  43415. return this._horizontalBlurPostprocess.kernel;
  43416. },
  43417. /**
  43418. * Specifies the horizontal size of the blur.
  43419. */
  43420. set: function (value) {
  43421. this._horizontalBlurPostprocess.kernel = value;
  43422. },
  43423. enumerable: true,
  43424. configurable: true
  43425. });
  43426. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  43427. /**
  43428. * Gets the vertical size of the blur.
  43429. */
  43430. get: function () {
  43431. return this._verticalBlurPostprocess.kernel;
  43432. },
  43433. /**
  43434. * Specifies the vertical size of the blur.
  43435. */
  43436. set: function (value) {
  43437. this._verticalBlurPostprocess.kernel = value;
  43438. },
  43439. enumerable: true,
  43440. configurable: true
  43441. });
  43442. /**
  43443. * Get the effect name of the layer.
  43444. * @return The effect name
  43445. */
  43446. HighlightLayer.prototype.getEffectName = function () {
  43447. return HighlightLayer.EffectName;
  43448. };
  43449. /**
  43450. * Create the merge effect. This is the shader use to blit the information back
  43451. * to the main canvas at the end of the scene rendering.
  43452. */
  43453. HighlightLayer.prototype._createMergeEffect = function () {
  43454. // Effect
  43455. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  43456. };
  43457. /**
  43458. * Creates the render target textures and post processes used in the highlight layer.
  43459. */
  43460. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  43461. var _this = this;
  43462. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  43463. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  43464. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  43465. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  43466. var textureType = 0;
  43467. if (this._engine.getCaps().textureHalfFloatRender) {
  43468. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43469. }
  43470. else {
  43471. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43472. }
  43473. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  43474. width: blurTextureWidth,
  43475. height: blurTextureHeight
  43476. }, this._scene, false, true, textureType);
  43477. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43478. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43479. this._blurTexture.anisotropicFilteringLevel = 16;
  43480. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  43481. this._blurTexture.renderParticles = false;
  43482. this._blurTexture.ignoreCameraViewport = true;
  43483. this._textures = [this._blurTexture];
  43484. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  43485. 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());
  43486. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  43487. effect.setTexture("textureSampler", _this._mainTexture);
  43488. });
  43489. 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());
  43490. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43491. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43492. });
  43493. 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());
  43494. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  43495. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43496. });
  43497. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43498. }
  43499. else {
  43500. 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, {
  43501. width: blurTextureWidth,
  43502. height: blurTextureHeight
  43503. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43504. this._horizontalBlurPostprocess.width = blurTextureWidth;
  43505. this._horizontalBlurPostprocess.height = blurTextureHeight;
  43506. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43507. effect.setTexture("textureSampler", _this._mainTexture);
  43508. });
  43509. 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, {
  43510. width: blurTextureWidth,
  43511. height: blurTextureHeight
  43512. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43513. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43514. }
  43515. this._mainTexture.onAfterUnbindObservable.add(function () {
  43516. _this.onBeforeBlurObservable.notifyObservers(_this);
  43517. var internalTexture = _this._blurTexture.getInternalTexture();
  43518. if (internalTexture) {
  43519. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  43520. }
  43521. _this.onAfterBlurObservable.notifyObservers(_this);
  43522. });
  43523. // Prevent autoClear.
  43524. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43525. };
  43526. /**
  43527. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43528. */
  43529. HighlightLayer.prototype.needStencil = function () {
  43530. return true;
  43531. };
  43532. /**
  43533. * Checks for the readiness of the element composing the layer.
  43534. * @param subMesh the mesh to check for
  43535. * @param useInstances specify wether or not to use instances to render the mesh
  43536. * @param emissiveTexture the associated emissive texture used to generate the glow
  43537. * @return true if ready otherwise, false
  43538. */
  43539. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  43540. var material = subMesh.getMaterial();
  43541. var mesh = subMesh.getRenderingMesh();
  43542. if (!material || !mesh || !this._meshes) {
  43543. return false;
  43544. }
  43545. var emissiveTexture = null;
  43546. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43547. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43548. emissiveTexture = material.emissiveTexture;
  43549. }
  43550. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43551. };
  43552. /**
  43553. * Implementation specific of rendering the generating effect on the main canvas.
  43554. * @param effect The effect used to render through
  43555. */
  43556. HighlightLayer.prototype._internalRender = function (effect) {
  43557. // Texture
  43558. effect.setTexture("textureSampler", this._blurTexture);
  43559. // Cache
  43560. var engine = this._engine;
  43561. engine.cacheStencilState();
  43562. // Stencil operations
  43563. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  43564. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43565. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43566. // Draw order
  43567. engine.setStencilMask(0x00);
  43568. engine.setStencilBuffer(true);
  43569. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  43570. // 2 passes inner outer
  43571. if (this.outerGlow) {
  43572. effect.setFloat("offset", 0);
  43573. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  43574. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43575. }
  43576. if (this.innerGlow) {
  43577. effect.setFloat("offset", 1);
  43578. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  43579. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43580. }
  43581. // Restore Cache
  43582. engine.restoreStencilState();
  43583. };
  43584. /**
  43585. * Returns true if the layer contains information to display, otherwise false.
  43586. */
  43587. HighlightLayer.prototype.shouldRender = function () {
  43588. if (_super.prototype.shouldRender.call(this)) {
  43589. return this._meshes ? true : false;
  43590. }
  43591. return false;
  43592. };
  43593. /**
  43594. * Returns true if the mesh should render, otherwise false.
  43595. * @param mesh The mesh to render
  43596. * @returns true if it should render otherwise false
  43597. */
  43598. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  43599. // Excluded Mesh
  43600. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  43601. return false;
  43602. }
  43603. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43604. return false;
  43605. }
  43606. return true;
  43607. };
  43608. /**
  43609. * Sets the required values for both the emissive texture and and the main color.
  43610. */
  43611. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43612. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43613. if (highlightLayerMesh) {
  43614. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  43615. }
  43616. else {
  43617. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43618. }
  43619. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43620. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43621. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  43622. }
  43623. else {
  43624. this._emissiveTextureAndColor.texture = null;
  43625. }
  43626. };
  43627. /**
  43628. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43629. * @param mesh The mesh to exclude from the highlight layer
  43630. */
  43631. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  43632. if (!this._excludedMeshes) {
  43633. return;
  43634. }
  43635. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43636. if (!meshExcluded) {
  43637. this._excludedMeshes[mesh.uniqueId] = {
  43638. mesh: mesh,
  43639. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  43640. mesh.getEngine().setStencilBuffer(false);
  43641. }),
  43642. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  43643. mesh.getEngine().setStencilBuffer(true);
  43644. }),
  43645. };
  43646. }
  43647. };
  43648. /**
  43649. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43650. * @param mesh The mesh to highlight
  43651. */
  43652. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  43653. if (!this._excludedMeshes) {
  43654. return;
  43655. }
  43656. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43657. if (meshExcluded) {
  43658. if (meshExcluded.beforeBind) {
  43659. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  43660. }
  43661. if (meshExcluded.afterRender) {
  43662. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  43663. }
  43664. }
  43665. this._excludedMeshes[mesh.uniqueId] = null;
  43666. };
  43667. /**
  43668. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43669. * @param mesh mesh to test
  43670. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43671. */
  43672. HighlightLayer.prototype.hasMesh = function (mesh) {
  43673. if (!this._meshes) {
  43674. return false;
  43675. }
  43676. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43677. return false;
  43678. }
  43679. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  43680. };
  43681. /**
  43682. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43683. * @param mesh The mesh to highlight
  43684. * @param color The color of the highlight
  43685. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43686. */
  43687. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  43688. var _this = this;
  43689. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  43690. if (!this._meshes) {
  43691. return;
  43692. }
  43693. var meshHighlight = this._meshes[mesh.uniqueId];
  43694. if (meshHighlight) {
  43695. meshHighlight.color = color;
  43696. }
  43697. else {
  43698. this._meshes[mesh.uniqueId] = {
  43699. mesh: mesh,
  43700. color: color,
  43701. // Lambda required for capture due to Observable this context
  43702. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  43703. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  43704. _this._defaultStencilReference(mesh);
  43705. }
  43706. else {
  43707. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  43708. }
  43709. }),
  43710. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  43711. glowEmissiveOnly: glowEmissiveOnly
  43712. };
  43713. mesh.onDisposeObservable.add(function () {
  43714. _this._disposeMesh(mesh);
  43715. });
  43716. }
  43717. this._shouldRender = true;
  43718. };
  43719. /**
  43720. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43721. * @param mesh The mesh to highlight
  43722. */
  43723. HighlightLayer.prototype.removeMesh = function (mesh) {
  43724. if (!this._meshes) {
  43725. return;
  43726. }
  43727. var meshHighlight = this._meshes[mesh.uniqueId];
  43728. if (meshHighlight) {
  43729. if (meshHighlight.observerHighlight) {
  43730. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43731. }
  43732. if (meshHighlight.observerDefault) {
  43733. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43734. }
  43735. delete this._meshes[mesh.uniqueId];
  43736. }
  43737. this._shouldRender = false;
  43738. for (var meshHighlightToCheck in this._meshes) {
  43739. if (this._meshes[meshHighlightToCheck]) {
  43740. this._shouldRender = true;
  43741. break;
  43742. }
  43743. }
  43744. };
  43745. /**
  43746. * Force the stencil to the normal expected value for none glowing parts
  43747. */
  43748. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  43749. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  43750. };
  43751. /**
  43752. * Free any resources and references associated to a mesh.
  43753. * Internal use
  43754. * @param mesh The mesh to free.
  43755. * @hidden
  43756. */
  43757. HighlightLayer.prototype._disposeMesh = function (mesh) {
  43758. this.removeMesh(mesh);
  43759. this.removeExcludedMesh(mesh);
  43760. };
  43761. /**
  43762. * Dispose the highlight layer and free resources.
  43763. */
  43764. HighlightLayer.prototype.dispose = function () {
  43765. if (this._meshes) {
  43766. // Clean mesh references
  43767. for (var id in this._meshes) {
  43768. var meshHighlight = this._meshes[id];
  43769. if (meshHighlight && meshHighlight.mesh) {
  43770. if (meshHighlight.observerHighlight) {
  43771. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43772. }
  43773. if (meshHighlight.observerDefault) {
  43774. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43775. }
  43776. }
  43777. }
  43778. this._meshes = null;
  43779. }
  43780. if (this._excludedMeshes) {
  43781. for (var id in this._excludedMeshes) {
  43782. var meshHighlight = this._excludedMeshes[id];
  43783. if (meshHighlight) {
  43784. if (meshHighlight.beforeBind) {
  43785. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  43786. }
  43787. if (meshHighlight.afterRender) {
  43788. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  43789. }
  43790. }
  43791. }
  43792. this._excludedMeshes = null;
  43793. }
  43794. _super.prototype.dispose.call(this);
  43795. };
  43796. /**
  43797. * Gets the class name of the effect layer
  43798. * @returns the string with the class name of the effect layer
  43799. */
  43800. HighlightLayer.prototype.getClassName = function () {
  43801. return "HighlightLayer";
  43802. };
  43803. /**
  43804. * Serializes this Highlight layer
  43805. * @returns a serialized Highlight layer object
  43806. */
  43807. HighlightLayer.prototype.serialize = function () {
  43808. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43809. serializationObject.customType = "BABYLON.HighlightLayer";
  43810. // Highlighted meshes
  43811. serializationObject.meshes = [];
  43812. if (this._meshes) {
  43813. for (var m in this._meshes) {
  43814. var mesh = this._meshes[m];
  43815. if (mesh) {
  43816. serializationObject.meshes.push({
  43817. glowEmissiveOnly: mesh.glowEmissiveOnly,
  43818. color: mesh.color.asArray(),
  43819. meshId: mesh.mesh.id
  43820. });
  43821. }
  43822. }
  43823. }
  43824. // Excluded meshes
  43825. serializationObject.excludedMeshes = [];
  43826. if (this._excludedMeshes) {
  43827. for (var e in this._excludedMeshes) {
  43828. var excludedMesh = this._excludedMeshes[e];
  43829. if (excludedMesh) {
  43830. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  43831. }
  43832. }
  43833. }
  43834. return serializationObject;
  43835. };
  43836. /**
  43837. * Creates a Highlight layer from parsed Highlight layer data
  43838. * @param parsedHightlightLayer defines the Highlight layer data
  43839. * @param scene defines the current scene
  43840. * @param rootUrl defines the root URL containing the Highlight layer information
  43841. * @returns a parsed Highlight layer
  43842. */
  43843. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  43844. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  43845. var index;
  43846. // Excluded meshes
  43847. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  43848. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  43849. if (mesh) {
  43850. hl.addExcludedMesh(mesh);
  43851. }
  43852. }
  43853. // Included meshes
  43854. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  43855. var highlightedMesh = parsedHightlightLayer.meshes[index];
  43856. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  43857. if (mesh) {
  43858. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  43859. }
  43860. }
  43861. return hl;
  43862. };
  43863. /**
  43864. * Effect Name of the highlight layer.
  43865. */
  43866. HighlightLayer.EffectName = "HighlightLayer";
  43867. /**
  43868. * The neutral color used during the preparation of the glow effect.
  43869. * This is black by default as the blend operation is a blend operation.
  43870. */
  43871. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  43872. /**
  43873. * Stencil value used for glowing meshes.
  43874. */
  43875. HighlightLayer.GlowingMeshStencilReference = 0x02;
  43876. /**
  43877. * Stencil value used for the other meshes in the scene.
  43878. */
  43879. HighlightLayer.NormalMeshStencilReference = 0x01;
  43880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43882. ], HighlightLayer.prototype, "innerGlow", void 0);
  43883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43885. ], HighlightLayer.prototype, "outerGlow", void 0);
  43886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43888. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  43889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43891. ], HighlightLayer.prototype, "blurVerticalSize", null);
  43892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43894. ], HighlightLayer.prototype, "_options", void 0);
  43895. return HighlightLayer;
  43896. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  43897. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  43898. /***/ }),
  43899. /***/ "./Layers/index.ts":
  43900. /*!*************************!*\
  43901. !*** ./Layers/index.ts ***!
  43902. \*************************/
  43903. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  43904. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43905. "use strict";
  43906. __webpack_require__.r(__webpack_exports__);
  43907. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43909. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  43910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  43911. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  43912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  43913. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  43914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  43915. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  43916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  43917. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  43919. /***/ }),
  43920. /***/ "./Layers/layer.ts":
  43921. /*!*************************!*\
  43922. !*** ./Layers/layer.ts ***!
  43923. \*************************/
  43924. /*! exports provided: Layer */
  43925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43926. "use strict";
  43927. __webpack_require__.r(__webpack_exports__);
  43928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  43929. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43930. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43931. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43932. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43933. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43934. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43935. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43936. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43937. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43938. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  43939. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  43940. /**
  43941. * This represents a full screen 2d layer.
  43942. * This can be useful to display a picture in the background of your scene for instance.
  43943. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43944. */
  43945. var Layer = /** @class */ (function () {
  43946. /**
  43947. * Instantiates a new layer.
  43948. * This represents a full screen 2d layer.
  43949. * This can be useful to display a picture in the background of your scene for instance.
  43950. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43951. * @param name Define the name of the layer in the scene
  43952. * @param imgUrl Define the url of the texture to display in the layer
  43953. * @param scene Define the scene the layer belongs to
  43954. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  43955. * @param color Defines a color for the layer
  43956. */
  43957. function Layer(
  43958. /**
  43959. * Define the name of the layer.
  43960. */
  43961. name, imgUrl, scene, isBackground, color) {
  43962. this.name = name;
  43963. /**
  43964. * Define the scale of the layer in order to zoom in out of the texture.
  43965. */
  43966. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  43967. /**
  43968. * Define an offset for the layer in order to shift the texture.
  43969. */
  43970. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  43971. /**
  43972. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  43973. */
  43974. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  43975. /**
  43976. * Define a mask to restrict the layer to only some of the scene cameras.
  43977. */
  43978. this.layerMask = 0x0FFFFFFF;
  43979. /**
  43980. * Define the list of render target the layer is visible into.
  43981. */
  43982. this.renderTargetTextures = [];
  43983. /**
  43984. * Define if the layer is only used in renderTarget or if it also
  43985. * renders in the main frame buffer of the canvas.
  43986. */
  43987. this.renderOnlyInRenderTargetTextures = false;
  43988. this._vertexBuffers = {};
  43989. /**
  43990. * An event triggered when the layer is disposed.
  43991. */
  43992. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43993. /**
  43994. * An event triggered before rendering the scene
  43995. */
  43996. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43997. /**
  43998. * An event triggered after rendering the scene
  43999. */
  44000. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  44001. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  44002. this.isBackground = isBackground === undefined ? true : isBackground;
  44003. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  44004. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  44005. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  44006. if (!layerComponent) {
  44007. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  44008. this._scene._addComponent(layerComponent);
  44009. }
  44010. this._scene.layers.push(this);
  44011. var engine = this._scene.getEngine();
  44012. // VBO
  44013. var vertices = [];
  44014. vertices.push(1, 1);
  44015. vertices.push(-1, 1);
  44016. vertices.push(-1, -1);
  44017. vertices.push(1, -1);
  44018. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  44019. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  44020. this._createIndexBuffer();
  44021. // Effects
  44022. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  44023. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  44024. }
  44025. Object.defineProperty(Layer.prototype, "onDispose", {
  44026. /**
  44027. * Back compatibility with callback before the onDisposeObservable existed.
  44028. * The set callback will be triggered when the layer has been disposed.
  44029. */
  44030. set: function (callback) {
  44031. if (this._onDisposeObserver) {
  44032. this.onDisposeObservable.remove(this._onDisposeObserver);
  44033. }
  44034. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  44035. },
  44036. enumerable: true,
  44037. configurable: true
  44038. });
  44039. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  44040. /**
  44041. * Back compatibility with callback before the onBeforeRenderObservable existed.
  44042. * The set callback will be triggered just before rendering the layer.
  44043. */
  44044. set: function (callback) {
  44045. if (this._onBeforeRenderObserver) {
  44046. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  44047. }
  44048. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  44049. },
  44050. enumerable: true,
  44051. configurable: true
  44052. });
  44053. Object.defineProperty(Layer.prototype, "onAfterRender", {
  44054. /**
  44055. * Back compatibility with callback before the onAfterRenderObservable existed.
  44056. * The set callback will be triggered just after rendering the layer.
  44057. */
  44058. set: function (callback) {
  44059. if (this._onAfterRenderObserver) {
  44060. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  44061. }
  44062. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  44063. },
  44064. enumerable: true,
  44065. configurable: true
  44066. });
  44067. Layer.prototype._createIndexBuffer = function () {
  44068. var engine = this._scene.getEngine();
  44069. // Indices
  44070. var indices = [];
  44071. indices.push(0);
  44072. indices.push(1);
  44073. indices.push(2);
  44074. indices.push(0);
  44075. indices.push(2);
  44076. indices.push(3);
  44077. this._indexBuffer = engine.createIndexBuffer(indices);
  44078. };
  44079. /** @hidden */
  44080. Layer.prototype._rebuild = function () {
  44081. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  44082. if (vb) {
  44083. vb._rebuild();
  44084. }
  44085. this._createIndexBuffer();
  44086. };
  44087. /**
  44088. * Renders the layer in the scene.
  44089. */
  44090. Layer.prototype.render = function () {
  44091. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  44092. // Check
  44093. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  44094. return;
  44095. }
  44096. var engine = this._scene.getEngine();
  44097. this.onBeforeRenderObservable.notifyObservers(this);
  44098. // Render
  44099. engine.enableEffect(currentEffect);
  44100. engine.setState(false);
  44101. // Texture
  44102. currentEffect.setTexture("textureSampler", this.texture);
  44103. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  44104. // Color
  44105. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  44106. // Scale / offset
  44107. currentEffect.setVector2("offset", this.offset);
  44108. currentEffect.setVector2("scale", this.scale);
  44109. // VBOs
  44110. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  44111. // Draw order
  44112. if (!this.alphaTest) {
  44113. engine.setAlphaMode(this.alphaBlendingMode);
  44114. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  44115. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44116. }
  44117. else {
  44118. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  44119. }
  44120. this.onAfterRenderObservable.notifyObservers(this);
  44121. };
  44122. /**
  44123. * Disposes and releases the associated ressources.
  44124. */
  44125. Layer.prototype.dispose = function () {
  44126. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  44127. if (vertexBuffer) {
  44128. vertexBuffer.dispose();
  44129. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  44130. }
  44131. if (this._indexBuffer) {
  44132. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44133. this._indexBuffer = null;
  44134. }
  44135. if (this.texture) {
  44136. this.texture.dispose();
  44137. this.texture = null;
  44138. }
  44139. // Clean RTT list
  44140. this.renderTargetTextures = [];
  44141. // Remove from scene
  44142. var index = this._scene.layers.indexOf(this);
  44143. this._scene.layers.splice(index, 1);
  44144. // Callback
  44145. this.onDisposeObservable.notifyObservers(this);
  44146. this.onDisposeObservable.clear();
  44147. this.onAfterRenderObservable.clear();
  44148. this.onBeforeRenderObservable.clear();
  44149. };
  44150. return Layer;
  44151. }());
  44152. /***/ }),
  44153. /***/ "./Layers/layerSceneComponent.ts":
  44154. /*!***************************************!*\
  44155. !*** ./Layers/layerSceneComponent.ts ***!
  44156. \***************************************/
  44157. /*! exports provided: LayerSceneComponent */
  44158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44159. "use strict";
  44160. __webpack_require__.r(__webpack_exports__);
  44161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  44162. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44163. /**
  44164. * Defines the layer scene component responsible to manage any layers
  44165. * in a given scene.
  44166. */
  44167. var LayerSceneComponent = /** @class */ (function () {
  44168. /**
  44169. * Creates a new instance of the component for the given scene
  44170. * @param scene Defines the scene to register the component in
  44171. */
  44172. function LayerSceneComponent(scene) {
  44173. /**
  44174. * The component name helpfull to identify the component in the list of scene components.
  44175. */
  44176. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  44177. this.scene = scene;
  44178. this._engine = scene.getEngine();
  44179. scene.layers = new Array();
  44180. }
  44181. /**
  44182. * Registers the component in a given scene
  44183. */
  44184. LayerSceneComponent.prototype.register = function () {
  44185. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  44186. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  44187. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  44188. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  44189. };
  44190. /**
  44191. * Rebuilds the elements related to this component in case of
  44192. * context lost for instance.
  44193. */
  44194. LayerSceneComponent.prototype.rebuild = function () {
  44195. var layers = this.scene.layers;
  44196. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  44197. var layer = layers_1[_i];
  44198. layer._rebuild();
  44199. }
  44200. };
  44201. /**
  44202. * Disposes the component and the associated ressources.
  44203. */
  44204. LayerSceneComponent.prototype.dispose = function () {
  44205. var layers = this.scene.layers;
  44206. while (layers.length) {
  44207. layers[0].dispose();
  44208. }
  44209. };
  44210. LayerSceneComponent.prototype._draw = function (predicate) {
  44211. var layers = this.scene.layers;
  44212. if (layers.length) {
  44213. this._engine.setDepthBuffer(false);
  44214. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  44215. var layer = layers_2[_i];
  44216. if (predicate(layer)) {
  44217. layer.render();
  44218. }
  44219. }
  44220. this._engine.setDepthBuffer(true);
  44221. }
  44222. };
  44223. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  44224. return !layer.renderOnlyInRenderTargetTextures &&
  44225. layer.isBackground === isBackground &&
  44226. ((layer.layerMask & cameraLayerMask) !== 0);
  44227. };
  44228. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  44229. var _this = this;
  44230. this._draw(function (layer) {
  44231. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  44232. });
  44233. };
  44234. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  44235. var _this = this;
  44236. this._draw(function (layer) {
  44237. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  44238. });
  44239. };
  44240. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  44241. return (layer.renderTargetTextures.length > 0) &&
  44242. layer.isBackground === isBackground &&
  44243. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  44244. ((layer.layerMask & cameraLayerMask) !== 0);
  44245. };
  44246. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  44247. var _this = this;
  44248. this._draw(function (layer) {
  44249. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  44250. });
  44251. };
  44252. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  44253. var _this = this;
  44254. this._draw(function (layer) {
  44255. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  44256. });
  44257. };
  44258. return LayerSceneComponent;
  44259. }());
  44260. /***/ }),
  44261. /***/ "./Legacy/legacy.ts":
  44262. /*!**************************!*\
  44263. !*** ./Legacy/legacy.ts ***!
  44264. \**************************/
  44265. /*! 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, _IAnimationState, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, 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, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, _KTXTextureLoader, MultiRenderTarget, 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, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  44266. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44267. "use strict";
  44268. __webpack_require__.r(__webpack_exports__);
  44269. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  44270. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  44271. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  44272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  44273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  44274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  44275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  44276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  44277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  44278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  44279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  44280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  44281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  44282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  44283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  44284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  44285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  44286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  44287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  44288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  44289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  44290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  44291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  44292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  44293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  44294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  44295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  44296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  44297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  44298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  44299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  44300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IAnimationState"]; });
  44301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  44302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  44303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  44304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  44305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  44306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  44307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  44308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  44309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  44310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  44311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  44312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  44313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  44314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  44315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  44316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  44317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  44318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  44319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  44320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  44321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  44322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  44323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  44324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  44325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  44326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  44327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  44328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  44329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  44330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  44331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  44332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  44333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  44334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  44335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  44336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  44337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  44338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  44339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  44340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  44341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  44342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  44343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  44344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  44345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  44346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  44347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  44348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  44349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  44350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  44351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  44352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  44353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  44354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  44355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  44356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  44357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  44358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  44359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  44360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  44361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  44362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  44363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  44364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  44365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  44366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  44367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  44368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  44369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  44370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  44371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  44372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  44373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  44374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  44375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  44376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  44377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  44378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  44379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  44380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  44381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  44382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  44383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  44384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  44385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  44386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  44387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  44388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  44389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  44390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  44391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  44392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  44393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  44394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  44395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  44396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  44397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  44398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  44399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  44400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  44401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  44402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  44403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  44404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  44405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  44406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  44407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  44408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  44409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  44410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  44411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  44412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  44413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  44414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  44415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  44416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  44417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  44418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  44419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  44420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  44421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  44422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  44423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  44424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  44425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  44427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  44428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  44429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  44430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  44431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  44432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  44433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  44434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  44435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  44436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  44437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  44438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  44439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  44440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  44441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  44442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  44443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  44444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  44445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  44446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  44447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  44448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  44449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  44450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  44451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  44452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  44453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  44454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  44455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTexture"]; });
  44456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  44457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  44458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  44459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  44460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  44461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  44462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  44463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  44464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  44465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  44466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  44467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  44468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  44469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  44470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  44471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  44472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  44473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  44474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  44475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  44476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  44477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  44478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  44479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  44480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  44481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  44482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  44483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  44484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  44485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  44486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  44487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  44488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  44489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  44490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  44491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  44492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  44493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  44494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  44495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  44496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  44497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  44498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  44499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  44500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  44501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  44502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  44503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  44504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  44505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  44506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  44507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  44508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  44509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  44510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  44511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  44512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  44513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  44514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  44515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  44516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  44517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  44518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  44519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  44520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  44521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  44522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  44523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  44524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  44525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  44526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  44527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  44528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  44529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  44530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  44531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  44532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  44533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  44534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  44535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  44536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  44537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  44538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  44539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  44540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  44541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  44542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEventOptions"]; });
  44543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEventOptions"]; });
  44544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEventOptions"]; });
  44545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  44546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  44547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  44548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  44549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  44550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  44551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  44552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  44553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  44554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  44555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  44556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  44557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  44558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  44559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  44560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  44561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  44562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  44563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  44564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  44565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  44566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  44567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  44568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  44569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  44570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  44571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  44572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  44573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  44574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  44575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  44576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  44577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  44578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  44579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  44580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  44581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  44582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  44583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  44584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  44585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  44586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRMultiviewToSingleviewPostProcess"]; });
  44587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  44588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  44589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  44590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  44591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  44592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  44593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  44594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  44595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  44596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  44597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  44598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  44599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  44600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  44601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  44602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  44603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  44604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  44605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  44606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  44607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  44608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  44609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  44610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  44611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  44612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  44613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  44614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  44615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  44616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  44617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTextureAssetTask"]; });
  44618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  44619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  44620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  44621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  44622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  44623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  44624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  44625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  44626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  44627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  44628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  44629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  44630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  44631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  44632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMatrix"]; });
  44633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  44634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  44635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  44636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  44637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshExploder"]; });
  44638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  44639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  44640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  44641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  44642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  44643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  44644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  44645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  44646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  44647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  44648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  44649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  44650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  44651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  44652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  44653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  44654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  44655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  44656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  44657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  44658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  44659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  44660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  44661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  44662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  44663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  44664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  44665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  44666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  44667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  44668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  44669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  44670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  44671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  44672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  44673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  44674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  44675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  44676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  44677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  44678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  44679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  44680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  44681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  44682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  44683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  44684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  44685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  44686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]; });
  44687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InspectableType"]; });
  44688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  44689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  44690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  44691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  44692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  44693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  44694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  44695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  44696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  44697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  44698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  44699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  44700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  44701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  44702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  44703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  44704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  44705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  44706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  44707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  44708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  44709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  44710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  44711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  44712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  44713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  44714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  44715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  44716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  44717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  44718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  44719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  44720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  44721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  44722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  44723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  44724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  44725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  44726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  44727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  44728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  44729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  44730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  44731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  44732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  44733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  44734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  44735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  44736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  44737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  44738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  44740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  44741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  44742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  44743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  44744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  44745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  44746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  44747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  44748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  44749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  44750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  44751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  44752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  44753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  44754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  44755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  44756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  44757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  44758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  44759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  44760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphereBuilder"]; });
  44761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  44762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  44763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  44764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  44765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  44766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  44767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  44768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  44769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  44770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  44771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  44772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  44773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  44774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  44775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  44776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  44777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  44778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  44779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  44780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  44781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  44782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  44783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  44784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  44785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  44786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  44787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  44788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  44789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  44790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  44791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  44792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  44793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  44794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  44795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  44796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  44797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  44798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  44799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  44800. /**
  44801. * Legacy support, defining window.BABYLON (global variable).
  44802. *
  44803. * This is the entry point for the UMD module.
  44804. * The entry point for a future ESM package should be index.ts
  44805. */
  44806. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  44807. if (typeof globalObject !== "undefined") {
  44808. globalObject.BABYLON = BABYLON;
  44809. globalObject.BABYLON = globalObject.BABYLON || {};
  44810. var BABYLON = globalObject.BABYLON;
  44811. BABYLON.Debug = BABYLON.Debug || {};
  44812. var keys = [];
  44813. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  44814. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  44815. keys.push(key);
  44816. }
  44817. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  44818. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  44819. }
  44820. }
  44821. var Debug = {
  44822. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  44823. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  44824. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  44825. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  44826. };
  44827. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  44828. /***/ }),
  44829. /***/ "./LensFlares/index.ts":
  44830. /*!*****************************!*\
  44831. !*** ./LensFlares/index.ts ***!
  44832. \*****************************/
  44833. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  44834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44835. "use strict";
  44836. __webpack_require__.r(__webpack_exports__);
  44837. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44839. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  44841. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  44842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  44843. /***/ }),
  44844. /***/ "./LensFlares/lensFlare.ts":
  44845. /*!*********************************!*\
  44846. !*** ./LensFlares/lensFlare.ts ***!
  44847. \*********************************/
  44848. /*! exports provided: LensFlare */
  44849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44850. "use strict";
  44851. __webpack_require__.r(__webpack_exports__);
  44852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  44853. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44854. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44855. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44856. /**
  44857. * This represents one of the lens effect in a `lensFlareSystem`.
  44858. * It controls one of the indiviual texture used in the effect.
  44859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44860. */
  44861. var LensFlare = /** @class */ (function () {
  44862. /**
  44863. * Instantiates a new Lens Flare.
  44864. * This represents one of the lens effect in a `lensFlareSystem`.
  44865. * It controls one of the indiviual texture used in the effect.
  44866. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44867. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44868. * @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.
  44869. * @param color Define the lens color
  44870. * @param imgUrl Define the lens texture url
  44871. * @param system Define the `lensFlareSystem` this flare is part of
  44872. */
  44873. function LensFlare(
  44874. /**
  44875. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44876. */
  44877. size,
  44878. /**
  44879. * 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.
  44880. */
  44881. position, color, imgUrl, system) {
  44882. this.size = size;
  44883. this.position = position;
  44884. /**
  44885. * Define the alpha mode to render this particular lens.
  44886. */
  44887. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  44888. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  44889. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  44890. this._system = system;
  44891. system.lensFlares.push(this);
  44892. }
  44893. /**
  44894. * Creates a new Lens Flare.
  44895. * This represents one of the lens effect in a `lensFlareSystem`.
  44896. * It controls one of the indiviual texture used in the effect.
  44897. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44898. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44899. * @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.
  44900. * @param color Define the lens color
  44901. * @param imgUrl Define the lens texture url
  44902. * @param system Define the `lensFlareSystem` this flare is part of
  44903. * @returns The newly created Lens Flare
  44904. */
  44905. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  44906. return new LensFlare(size, position, color, imgUrl, system);
  44907. };
  44908. /**
  44909. * Dispose and release the lens flare with its associated resources.
  44910. */
  44911. LensFlare.prototype.dispose = function () {
  44912. if (this.texture) {
  44913. this.texture.dispose();
  44914. }
  44915. // Remove from scene
  44916. var index = this._system.lensFlares.indexOf(this);
  44917. this._system.lensFlares.splice(index, 1);
  44918. };
  44919. return LensFlare;
  44920. }());
  44921. /***/ }),
  44922. /***/ "./LensFlares/lensFlareSystem.ts":
  44923. /*!***************************************!*\
  44924. !*** ./LensFlares/lensFlareSystem.ts ***!
  44925. \***************************************/
  44926. /*! exports provided: LensFlareSystem */
  44927. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44928. "use strict";
  44929. __webpack_require__.r(__webpack_exports__);
  44930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  44931. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44932. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44933. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  44934. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  44935. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44936. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  44937. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44938. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44939. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44940. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  44941. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  44942. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  44943. /**
  44944. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44945. * It is usually composed of several `lensFlare`.
  44946. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44947. */
  44948. var LensFlareSystem = /** @class */ (function () {
  44949. /**
  44950. * Instantiates a lens flare system.
  44951. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44952. * It is usually composed of several `lensFlare`.
  44953. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44954. * @param name Define the name of the lens flare system in the scene
  44955. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44956. * @param scene Define the scene the lens flare system belongs to
  44957. */
  44958. function LensFlareSystem(
  44959. /**
  44960. * Define the name of the lens flare system
  44961. */
  44962. name, emitter, scene) {
  44963. this.name = name;
  44964. /**
  44965. * List of lens flares used in this system.
  44966. */
  44967. this.lensFlares = new Array();
  44968. /**
  44969. * Define a limit from the border the lens flare can be visible.
  44970. */
  44971. this.borderLimit = 300;
  44972. /**
  44973. * Define a viewport border we do not want to see the lens flare in.
  44974. */
  44975. this.viewportBorder = 0;
  44976. /**
  44977. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44978. */
  44979. this.layerMask = 0x0FFFFFFF;
  44980. this._vertexBuffers = {};
  44981. this._isEnabled = true;
  44982. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  44983. LensFlareSystem._SceneComponentInitialization(this._scene);
  44984. this._emitter = emitter;
  44985. this.id = name;
  44986. scene.lensFlareSystems.push(this);
  44987. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  44988. var engine = scene.getEngine();
  44989. // VBO
  44990. var vertices = [];
  44991. vertices.push(1, 1);
  44992. vertices.push(-1, 1);
  44993. vertices.push(-1, -1);
  44994. vertices.push(1, -1);
  44995. 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);
  44996. // Indices
  44997. var indices = [];
  44998. indices.push(0);
  44999. indices.push(1);
  45000. indices.push(2);
  45001. indices.push(0);
  45002. indices.push(2);
  45003. indices.push(3);
  45004. this._indexBuffer = engine.createIndexBuffer(indices);
  45005. // Effects
  45006. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  45007. }
  45008. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  45009. /**
  45010. * Define if the lens flare system is enabled.
  45011. */
  45012. get: function () {
  45013. return this._isEnabled;
  45014. },
  45015. set: function (value) {
  45016. this._isEnabled = value;
  45017. },
  45018. enumerable: true,
  45019. configurable: true
  45020. });
  45021. /**
  45022. * Get the scene the effects belongs to.
  45023. * @returns the scene holding the lens flare system
  45024. */
  45025. LensFlareSystem.prototype.getScene = function () {
  45026. return this._scene;
  45027. };
  45028. /**
  45029. * Get the emitter of the lens flare system.
  45030. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45031. * @returns the emitter of the lens flare system
  45032. */
  45033. LensFlareSystem.prototype.getEmitter = function () {
  45034. return this._emitter;
  45035. };
  45036. /**
  45037. * Set the emitter of the lens flare system.
  45038. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45039. * @param newEmitter Define the new emitter of the system
  45040. */
  45041. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  45042. this._emitter = newEmitter;
  45043. };
  45044. /**
  45045. * Get the lens flare system emitter position.
  45046. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  45047. * @returns the position
  45048. */
  45049. LensFlareSystem.prototype.getEmitterPosition = function () {
  45050. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  45051. };
  45052. /**
  45053. * @hidden
  45054. */
  45055. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  45056. var position = this.getEmitterPosition();
  45057. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  45058. this._positionX = position.x;
  45059. this._positionY = position.y;
  45060. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  45061. if (this.viewportBorder > 0) {
  45062. globalViewport.x -= this.viewportBorder;
  45063. globalViewport.y -= this.viewportBorder;
  45064. globalViewport.width += this.viewportBorder * 2;
  45065. globalViewport.height += this.viewportBorder * 2;
  45066. position.x += this.viewportBorder;
  45067. position.y += this.viewportBorder;
  45068. this._positionX += this.viewportBorder;
  45069. this._positionY += this.viewportBorder;
  45070. }
  45071. if (position.z > 0) {
  45072. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  45073. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  45074. return true;
  45075. }
  45076. }
  45077. return true;
  45078. }
  45079. return false;
  45080. };
  45081. /** @hidden */
  45082. LensFlareSystem.prototype._isVisible = function () {
  45083. if (!this._isEnabled || !this._scene.activeCamera) {
  45084. return false;
  45085. }
  45086. var emitterPosition = this.getEmitterPosition();
  45087. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  45088. var distance = direction.length();
  45089. direction.normalize();
  45090. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  45091. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  45092. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  45093. };
  45094. /**
  45095. * @hidden
  45096. */
  45097. LensFlareSystem.prototype.render = function () {
  45098. if (!this._effect.isReady() || !this._scene.activeCamera) {
  45099. return false;
  45100. }
  45101. var engine = this._scene.getEngine();
  45102. var viewport = this._scene.activeCamera.viewport;
  45103. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  45104. // Position
  45105. if (!this.computeEffectivePosition(globalViewport)) {
  45106. return false;
  45107. }
  45108. // Visibility
  45109. if (!this._isVisible()) {
  45110. return false;
  45111. }
  45112. // Intensity
  45113. var awayX;
  45114. var awayY;
  45115. if (this._positionX < this.borderLimit + globalViewport.x) {
  45116. awayX = this.borderLimit + globalViewport.x - this._positionX;
  45117. }
  45118. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  45119. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  45120. }
  45121. else {
  45122. awayX = 0;
  45123. }
  45124. if (this._positionY < this.borderLimit + globalViewport.y) {
  45125. awayY = this.borderLimit + globalViewport.y - this._positionY;
  45126. }
  45127. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  45128. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  45129. }
  45130. else {
  45131. awayY = 0;
  45132. }
  45133. var away = (awayX > awayY) ? awayX : awayY;
  45134. away -= this.viewportBorder;
  45135. if (away > this.borderLimit) {
  45136. away = this.borderLimit;
  45137. }
  45138. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  45139. if (intensity < 0) {
  45140. return false;
  45141. }
  45142. if (intensity > 1.0) {
  45143. intensity = 1.0;
  45144. }
  45145. if (this.viewportBorder > 0) {
  45146. globalViewport.x += this.viewportBorder;
  45147. globalViewport.y += this.viewportBorder;
  45148. globalViewport.width -= this.viewportBorder * 2;
  45149. globalViewport.height -= this.viewportBorder * 2;
  45150. this._positionX -= this.viewportBorder;
  45151. this._positionY -= this.viewportBorder;
  45152. }
  45153. // Position
  45154. var centerX = globalViewport.x + globalViewport.width / 2;
  45155. var centerY = globalViewport.y + globalViewport.height / 2;
  45156. var distX = centerX - this._positionX;
  45157. var distY = centerY - this._positionY;
  45158. // Effects
  45159. engine.enableEffect(this._effect);
  45160. engine.setState(false);
  45161. engine.setDepthBuffer(false);
  45162. // VBOs
  45163. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  45164. // Flares
  45165. for (var index = 0; index < this.lensFlares.length; index++) {
  45166. var flare = this.lensFlares[index];
  45167. engine.setAlphaMode(flare.alphaMode);
  45168. var x = centerX - (distX * flare.position);
  45169. var y = centerY - (distY * flare.position);
  45170. var cw = flare.size;
  45171. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  45172. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  45173. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  45174. 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);
  45175. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  45176. // Texture
  45177. this._effect.setTexture("textureSampler", flare.texture);
  45178. // Color
  45179. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  45180. // Draw order
  45181. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  45182. }
  45183. engine.setDepthBuffer(true);
  45184. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  45185. return true;
  45186. };
  45187. /**
  45188. * Dispose and release the lens flare with its associated resources.
  45189. */
  45190. LensFlareSystem.prototype.dispose = function () {
  45191. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  45192. if (vertexBuffer) {
  45193. vertexBuffer.dispose();
  45194. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  45195. }
  45196. if (this._indexBuffer) {
  45197. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  45198. this._indexBuffer = null;
  45199. }
  45200. while (this.lensFlares.length) {
  45201. this.lensFlares[0].dispose();
  45202. }
  45203. // Remove from scene
  45204. var index = this._scene.lensFlareSystems.indexOf(this);
  45205. this._scene.lensFlareSystems.splice(index, 1);
  45206. };
  45207. /**
  45208. * Parse a lens flare system from a JSON repressentation
  45209. * @param parsedLensFlareSystem Define the JSON to parse
  45210. * @param scene Define the scene the parsed system should be instantiated in
  45211. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  45212. * @returns the parsed system
  45213. */
  45214. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  45215. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  45216. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  45217. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  45218. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  45219. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  45220. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  45221. var parsedFlare = parsedLensFlareSystem.flares[index];
  45222. _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);
  45223. }
  45224. return lensFlareSystem;
  45225. };
  45226. /**
  45227. * Serialize the current Lens Flare System into a JSON representation.
  45228. * @returns the serialized JSON
  45229. */
  45230. LensFlareSystem.prototype.serialize = function () {
  45231. var serializationObject = {};
  45232. serializationObject.id = this.id;
  45233. serializationObject.name = this.name;
  45234. serializationObject.emitterId = this.getEmitter().id;
  45235. serializationObject.borderLimit = this.borderLimit;
  45236. serializationObject.flares = [];
  45237. for (var index = 0; index < this.lensFlares.length; index++) {
  45238. var flare = this.lensFlares[index];
  45239. serializationObject.flares.push({
  45240. size: flare.size,
  45241. position: flare.position,
  45242. color: flare.color.asArray(),
  45243. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  45244. });
  45245. }
  45246. return serializationObject;
  45247. };
  45248. /** @hidden */
  45249. LensFlareSystem._SceneComponentInitialization = function (_) {
  45250. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  45251. };
  45252. return LensFlareSystem;
  45253. }());
  45254. /***/ }),
  45255. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  45256. /*!*****************************************************!*\
  45257. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  45258. \*****************************************************/
  45259. /*! exports provided: LensFlareSystemSceneComponent */
  45260. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45261. "use strict";
  45262. __webpack_require__.r(__webpack_exports__);
  45263. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  45264. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  45265. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  45266. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  45267. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  45268. // Adds the parser to the scene parsers.
  45269. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  45270. // Lens flares
  45271. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  45272. if (!container.lensFlareSystems) {
  45273. container.lensFlareSystems = new Array();
  45274. }
  45275. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  45276. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  45277. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  45278. container.lensFlareSystems.push(lf);
  45279. }
  45280. }
  45281. });
  45282. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  45283. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  45284. if (this.lensFlareSystems[index].name === name) {
  45285. return this.lensFlareSystems[index];
  45286. }
  45287. }
  45288. return null;
  45289. };
  45290. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  45291. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  45292. if (this.lensFlareSystems[index].id === id) {
  45293. return this.lensFlareSystems[index];
  45294. }
  45295. }
  45296. return null;
  45297. };
  45298. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  45299. var index = this.lensFlareSystems.indexOf(toRemove);
  45300. if (index !== -1) {
  45301. this.lensFlareSystems.splice(index, 1);
  45302. }
  45303. return index;
  45304. };
  45305. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  45306. this.lensFlareSystems.push(newLensFlareSystem);
  45307. };
  45308. /**
  45309. * Defines the lens flare scene component responsible to manage any lens flares
  45310. * in a given scene.
  45311. */
  45312. var LensFlareSystemSceneComponent = /** @class */ (function () {
  45313. /**
  45314. * Creates a new instance of the component for the given scene
  45315. * @param scene Defines the scene to register the component in
  45316. */
  45317. function LensFlareSystemSceneComponent(scene) {
  45318. /**
  45319. * The component name helpfull to identify the component in the list of scene components.
  45320. */
  45321. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  45322. this.scene = scene;
  45323. scene.lensFlareSystems = new Array();
  45324. }
  45325. /**
  45326. * Registers the component in a given scene
  45327. */
  45328. LensFlareSystemSceneComponent.prototype.register = function () {
  45329. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  45330. };
  45331. /**
  45332. * Rebuilds the elements related to this component in case of
  45333. * context lost for instance.
  45334. */
  45335. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  45336. // Nothing to do for lens flare
  45337. };
  45338. /**
  45339. * Adds all the element from the container to the scene
  45340. * @param container the container holding the elements
  45341. */
  45342. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  45343. var _this = this;
  45344. if (!container.lensFlareSystems) {
  45345. return;
  45346. }
  45347. container.lensFlareSystems.forEach(function (o) {
  45348. _this.scene.addLensFlareSystem(o);
  45349. });
  45350. };
  45351. /**
  45352. * Removes all the elements in the container from the scene
  45353. * @param container contains the elements to remove
  45354. * @param dispose if the removed element should be disposed (default: false)
  45355. */
  45356. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  45357. var _this = this;
  45358. if (!container.lensFlareSystems) {
  45359. return;
  45360. }
  45361. container.lensFlareSystems.forEach(function (o) {
  45362. _this.scene.removeLensFlareSystem(o);
  45363. if (dispose) {
  45364. o.dispose();
  45365. }
  45366. });
  45367. };
  45368. /**
  45369. * Serializes the component data to the specified json object
  45370. * @param serializationObject The object to serialize to
  45371. */
  45372. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  45373. // Lens flares
  45374. serializationObject.lensFlareSystems = [];
  45375. var lensFlareSystems = this.scene.lensFlareSystems;
  45376. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  45377. var lensFlareSystem = lensFlareSystems_1[_i];
  45378. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  45379. }
  45380. };
  45381. /**
  45382. * Disposes the component and the associated ressources.
  45383. */
  45384. LensFlareSystemSceneComponent.prototype.dispose = function () {
  45385. var lensFlareSystems = this.scene.lensFlareSystems;
  45386. while (lensFlareSystems.length) {
  45387. lensFlareSystems[0].dispose();
  45388. }
  45389. };
  45390. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  45391. // Lens flares
  45392. if (this.scene.lensFlaresEnabled) {
  45393. var lensFlareSystems = this.scene.lensFlareSystems;
  45394. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45395. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  45396. var lensFlareSystem = lensFlareSystems_2[_i];
  45397. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  45398. lensFlareSystem.render();
  45399. }
  45400. }
  45401. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45402. }
  45403. };
  45404. return LensFlareSystemSceneComponent;
  45405. }());
  45406. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  45407. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  45408. if (!component) {
  45409. component = new LensFlareSystemSceneComponent(scene);
  45410. scene._addComponent(component);
  45411. }
  45412. };
  45413. /***/ }),
  45414. /***/ "./Lights/Shadows/index.ts":
  45415. /*!*********************************!*\
  45416. !*** ./Lights/Shadows/index.ts ***!
  45417. \*********************************/
  45418. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  45419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45420. "use strict";
  45421. __webpack_require__.r(__webpack_exports__);
  45422. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  45424. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  45425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  45426. /***/ }),
  45427. /***/ "./Lights/Shadows/shadowGenerator.ts":
  45428. /*!*******************************************!*\
  45429. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  45430. \*******************************************/
  45431. /*! exports provided: ShadowGenerator */
  45432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45433. "use strict";
  45434. __webpack_require__.r(__webpack_exports__);
  45435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  45436. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45437. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  45438. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  45439. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  45440. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  45441. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  45442. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  45443. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  45444. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  45445. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  45446. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  45447. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  45448. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  45449. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  45450. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  45451. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  45452. /**
  45453. * Default implementation IShadowGenerator.
  45454. * This is the main object responsible of generating shadows in the framework.
  45455. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  45456. */
  45457. var ShadowGenerator = /** @class */ (function () {
  45458. /**
  45459. * Creates a ShadowGenerator object.
  45460. * A ShadowGenerator is the required tool to use the shadows.
  45461. * Each light casting shadows needs to use its own ShadowGenerator.
  45462. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  45463. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  45464. * @param light The light object generating the shadows.
  45465. * @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.
  45466. */
  45467. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  45468. /**
  45469. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  45470. */
  45471. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45472. /**
  45473. * Observable triggered before a mesh is rendered in the shadow map.
  45474. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  45475. */
  45476. this.onBeforeShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45477. this._bias = 0.00005;
  45478. this._normalBias = 0;
  45479. this._blurBoxOffset = 1;
  45480. this._blurScale = 2;
  45481. this._blurKernel = 1;
  45482. this._useKernelBlur = false;
  45483. this._filter = ShadowGenerator.FILTER_NONE;
  45484. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  45485. this._contactHardeningLightSizeUVRatio = 0.1;
  45486. this._darkness = 0;
  45487. this._transparencyShadow = false;
  45488. /**
  45489. * Controls the extent to which the shadows fade out at the edge of the frustum
  45490. * Used only by directionals and spots
  45491. */
  45492. this.frustumEdgeFalloff = 0;
  45493. /**
  45494. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  45495. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  45496. * It might on the other hand introduce peter panning.
  45497. */
  45498. this.forceBackFacesOnly = false;
  45499. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  45500. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45501. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45502. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45503. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45504. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45505. this._currentFaceIndex = 0;
  45506. this._currentFaceIndexCache = 0;
  45507. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  45508. this._mapSize = mapSize;
  45509. this._light = light;
  45510. this._scene = light.getScene();
  45511. light._shadowGenerator = this;
  45512. ShadowGenerator._SceneComponentInitialization(this._scene);
  45513. // Texture type fallback from float to int if not supported.
  45514. var caps = this._scene.getEngine().getCaps();
  45515. if (!usefulFloatFirst) {
  45516. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45517. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45518. }
  45519. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45520. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45521. }
  45522. else {
  45523. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45524. }
  45525. }
  45526. else {
  45527. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45528. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45529. }
  45530. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45531. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45532. }
  45533. else {
  45534. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45535. }
  45536. }
  45537. this._initializeGenerator();
  45538. this._applyFilterValues();
  45539. }
  45540. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  45541. /**
  45542. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  45543. */
  45544. get: function () {
  45545. return this._bias;
  45546. },
  45547. /**
  45548. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  45549. */
  45550. set: function (bias) {
  45551. this._bias = bias;
  45552. },
  45553. enumerable: true,
  45554. configurable: true
  45555. });
  45556. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  45557. /**
  45558. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45559. */
  45560. get: function () {
  45561. return this._normalBias;
  45562. },
  45563. /**
  45564. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45565. */
  45566. set: function (normalBias) {
  45567. this._normalBias = normalBias;
  45568. },
  45569. enumerable: true,
  45570. configurable: true
  45571. });
  45572. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  45573. /**
  45574. * Gets the blur box offset: offset applied during the blur pass.
  45575. * Only useful if useKernelBlur = false
  45576. */
  45577. get: function () {
  45578. return this._blurBoxOffset;
  45579. },
  45580. /**
  45581. * Sets the blur box offset: offset applied during the blur pass.
  45582. * Only useful if useKernelBlur = false
  45583. */
  45584. set: function (value) {
  45585. if (this._blurBoxOffset === value) {
  45586. return;
  45587. }
  45588. this._blurBoxOffset = value;
  45589. this._disposeBlurPostProcesses();
  45590. },
  45591. enumerable: true,
  45592. configurable: true
  45593. });
  45594. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  45595. /**
  45596. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  45597. * 2 means half of the size.
  45598. */
  45599. get: function () {
  45600. return this._blurScale;
  45601. },
  45602. /**
  45603. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  45604. * 2 means half of the size.
  45605. */
  45606. set: function (value) {
  45607. if (this._blurScale === value) {
  45608. return;
  45609. }
  45610. this._blurScale = value;
  45611. this._disposeBlurPostProcesses();
  45612. },
  45613. enumerable: true,
  45614. configurable: true
  45615. });
  45616. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  45617. /**
  45618. * Gets the blur kernel: kernel size of the blur pass.
  45619. * Only useful if useKernelBlur = true
  45620. */
  45621. get: function () {
  45622. return this._blurKernel;
  45623. },
  45624. /**
  45625. * Sets the blur kernel: kernel size of the blur pass.
  45626. * Only useful if useKernelBlur = true
  45627. */
  45628. set: function (value) {
  45629. if (this._blurKernel === value) {
  45630. return;
  45631. }
  45632. this._blurKernel = value;
  45633. this._disposeBlurPostProcesses();
  45634. },
  45635. enumerable: true,
  45636. configurable: true
  45637. });
  45638. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  45639. /**
  45640. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  45641. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45642. */
  45643. get: function () {
  45644. return this._useKernelBlur;
  45645. },
  45646. /**
  45647. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  45648. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45649. */
  45650. set: function (value) {
  45651. if (this._useKernelBlur === value) {
  45652. return;
  45653. }
  45654. this._useKernelBlur = value;
  45655. this._disposeBlurPostProcesses();
  45656. },
  45657. enumerable: true,
  45658. configurable: true
  45659. });
  45660. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  45661. /**
  45662. * Gets the depth scale used in ESM mode.
  45663. */
  45664. get: function () {
  45665. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  45666. },
  45667. /**
  45668. * Sets the depth scale used in ESM mode.
  45669. * This can override the scale stored on the light.
  45670. */
  45671. set: function (value) {
  45672. this._depthScale = value;
  45673. },
  45674. enumerable: true,
  45675. configurable: true
  45676. });
  45677. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  45678. /**
  45679. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  45680. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45681. */
  45682. get: function () {
  45683. return this._filter;
  45684. },
  45685. /**
  45686. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  45687. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45688. */
  45689. set: function (value) {
  45690. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  45691. if (this._light.needCube()) {
  45692. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45693. this.useExponentialShadowMap = true;
  45694. return;
  45695. }
  45696. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45697. this.useCloseExponentialShadowMap = true;
  45698. return;
  45699. }
  45700. // PCF on cubemap would also be expensive
  45701. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45702. this.usePoissonSampling = true;
  45703. return;
  45704. }
  45705. }
  45706. // Weblg1 fallback for PCF.
  45707. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45708. if (this._scene.getEngine().webGLVersion === 1) {
  45709. this.usePoissonSampling = true;
  45710. return;
  45711. }
  45712. }
  45713. if (this._filter === value) {
  45714. return;
  45715. }
  45716. this._filter = value;
  45717. this._disposeBlurPostProcesses();
  45718. this._applyFilterValues();
  45719. this._light._markMeshesAsLightDirty();
  45720. },
  45721. enumerable: true,
  45722. configurable: true
  45723. });
  45724. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  45725. /**
  45726. * Gets if the current filter is set to Poisson Sampling.
  45727. */
  45728. get: function () {
  45729. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  45730. },
  45731. /**
  45732. * Sets the current filter to Poisson Sampling.
  45733. */
  45734. set: function (value) {
  45735. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  45736. return;
  45737. }
  45738. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  45739. },
  45740. enumerable: true,
  45741. configurable: true
  45742. });
  45743. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  45744. /**
  45745. * Gets if the current filter is set to ESM.
  45746. */
  45747. get: function () {
  45748. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  45749. },
  45750. /**
  45751. * Sets the current filter is to ESM.
  45752. */
  45753. set: function (value) {
  45754. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  45755. return;
  45756. }
  45757. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45758. },
  45759. enumerable: true,
  45760. configurable: true
  45761. });
  45762. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  45763. /**
  45764. * Gets if the current filter is set to filtered ESM.
  45765. */
  45766. get: function () {
  45767. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  45768. },
  45769. /**
  45770. * Gets if the current filter is set to filtered ESM.
  45771. */
  45772. set: function (value) {
  45773. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45774. return;
  45775. }
  45776. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45777. },
  45778. enumerable: true,
  45779. configurable: true
  45780. });
  45781. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  45782. /**
  45783. * Gets if the current filter is set to "close ESM" (using the inverse of the
  45784. * exponential to prevent steep falloff artifacts).
  45785. */
  45786. get: function () {
  45787. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  45788. },
  45789. /**
  45790. * Sets the current filter to "close ESM" (using the inverse of the
  45791. * exponential to prevent steep falloff artifacts).
  45792. */
  45793. set: function (value) {
  45794. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  45795. return;
  45796. }
  45797. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45798. },
  45799. enumerable: true,
  45800. configurable: true
  45801. });
  45802. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  45803. /**
  45804. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  45805. * exponential to prevent steep falloff artifacts).
  45806. */
  45807. get: function () {
  45808. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  45809. },
  45810. /**
  45811. * Sets the current filter to filtered "close ESM" (using the inverse of the
  45812. * exponential to prevent steep falloff artifacts).
  45813. */
  45814. set: function (value) {
  45815. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45816. return;
  45817. }
  45818. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45819. },
  45820. enumerable: true,
  45821. configurable: true
  45822. });
  45823. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  45824. /**
  45825. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  45826. */
  45827. get: function () {
  45828. return this.filter === ShadowGenerator.FILTER_PCF;
  45829. },
  45830. /**
  45831. * Sets the current filter to "PCF" (percentage closer filtering).
  45832. */
  45833. set: function (value) {
  45834. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  45835. return;
  45836. }
  45837. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  45838. },
  45839. enumerable: true,
  45840. configurable: true
  45841. });
  45842. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  45843. /**
  45844. * Gets the PCF or PCSS Quality.
  45845. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45846. */
  45847. get: function () {
  45848. return this._filteringQuality;
  45849. },
  45850. /**
  45851. * Sets the PCF or PCSS Quality.
  45852. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45853. */
  45854. set: function (filteringQuality) {
  45855. this._filteringQuality = filteringQuality;
  45856. },
  45857. enumerable: true,
  45858. configurable: true
  45859. });
  45860. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  45861. /**
  45862. * Gets if the current filter is set to "PCSS" (contact hardening).
  45863. */
  45864. get: function () {
  45865. return this.filter === ShadowGenerator.FILTER_PCSS;
  45866. },
  45867. /**
  45868. * Sets the current filter to "PCSS" (contact hardening).
  45869. */
  45870. set: function (value) {
  45871. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  45872. return;
  45873. }
  45874. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  45875. },
  45876. enumerable: true,
  45877. configurable: true
  45878. });
  45879. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  45880. /**
  45881. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45882. * Using a ratio helps keeping shape stability independently of the map size.
  45883. *
  45884. * It does not account for the light projection as it was having too much
  45885. * instability during the light setup or during light position changes.
  45886. *
  45887. * Only valid if useContactHardeningShadow is true.
  45888. */
  45889. get: function () {
  45890. return this._contactHardeningLightSizeUVRatio;
  45891. },
  45892. /**
  45893. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45894. * Using a ratio helps keeping shape stability independently of the map size.
  45895. *
  45896. * It does not account for the light projection as it was having too much
  45897. * instability during the light setup or during light position changes.
  45898. *
  45899. * Only valid if useContactHardeningShadow is true.
  45900. */
  45901. set: function (contactHardeningLightSizeUVRatio) {
  45902. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  45903. },
  45904. enumerable: true,
  45905. configurable: true
  45906. });
  45907. /**
  45908. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  45909. * 0 means strongest and 1 would means no shadow.
  45910. * @returns the darkness.
  45911. */
  45912. ShadowGenerator.prototype.getDarkness = function () {
  45913. return this._darkness;
  45914. };
  45915. /**
  45916. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  45917. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  45918. * @returns the shadow generator allowing fluent coding.
  45919. */
  45920. ShadowGenerator.prototype.setDarkness = function (darkness) {
  45921. if (darkness >= 1.0) {
  45922. this._darkness = 1.0;
  45923. }
  45924. else if (darkness <= 0.0) {
  45925. this._darkness = 0.0;
  45926. }
  45927. else {
  45928. this._darkness = darkness;
  45929. }
  45930. return this;
  45931. };
  45932. /**
  45933. * Sets the ability to have transparent shadow (boolean).
  45934. * @param transparent True if transparent else False
  45935. * @returns the shadow generator allowing fluent coding
  45936. */
  45937. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  45938. this._transparencyShadow = transparent;
  45939. return this;
  45940. };
  45941. /**
  45942. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  45943. * @returns The render target texture if present otherwise, null
  45944. */
  45945. ShadowGenerator.prototype.getShadowMap = function () {
  45946. return this._shadowMap;
  45947. };
  45948. /**
  45949. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  45950. * @returns The render target texture if the shadow map is present otherwise, null
  45951. */
  45952. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  45953. if (this._shadowMap2) {
  45954. return this._shadowMap2;
  45955. }
  45956. return this._shadowMap;
  45957. };
  45958. /**
  45959. * Helper function to add a mesh and its descendants to the list of shadow casters.
  45960. * @param mesh Mesh to add
  45961. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  45962. * @returns the Shadow Generator itself
  45963. */
  45964. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  45965. if (includeDescendants === void 0) { includeDescendants = true; }
  45966. var _a;
  45967. if (!this._shadowMap) {
  45968. return this;
  45969. }
  45970. if (!this._shadowMap.renderList) {
  45971. this._shadowMap.renderList = [];
  45972. }
  45973. this._shadowMap.renderList.push(mesh);
  45974. if (includeDescendants) {
  45975. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  45976. }
  45977. return this;
  45978. };
  45979. /**
  45980. * Helper function to remove a mesh and its descendants from the list of shadow casters
  45981. * @param mesh Mesh to remove
  45982. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  45983. * @returns the Shadow Generator itself
  45984. */
  45985. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  45986. if (includeDescendants === void 0) { includeDescendants = true; }
  45987. if (!this._shadowMap || !this._shadowMap.renderList) {
  45988. return this;
  45989. }
  45990. var index = this._shadowMap.renderList.indexOf(mesh);
  45991. if (index !== -1) {
  45992. this._shadowMap.renderList.splice(index, 1);
  45993. }
  45994. if (includeDescendants) {
  45995. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  45996. var child = _a[_i];
  45997. this.removeShadowCaster(child);
  45998. }
  45999. }
  46000. return this;
  46001. };
  46002. /**
  46003. * Returns the associated light object.
  46004. * @returns the light generating the shadow
  46005. */
  46006. ShadowGenerator.prototype.getLight = function () {
  46007. return this._light;
  46008. };
  46009. ShadowGenerator.prototype._initializeGenerator = function () {
  46010. this._light._markMeshesAsLightDirty();
  46011. this._initializeShadowMap();
  46012. };
  46013. ShadowGenerator.prototype._initializeShadowMap = function () {
  46014. var _this = this;
  46015. // Render target
  46016. var engine = this._scene.getEngine();
  46017. if (engine.webGLVersion > 1) {
  46018. 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);
  46019. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  46020. }
  46021. else {
  46022. 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());
  46023. }
  46024. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46025. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46026. this._shadowMap.anisotropicFilteringLevel = 1;
  46027. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46028. this._shadowMap.renderParticles = false;
  46029. this._shadowMap.ignoreCameraViewport = true;
  46030. // Record Face Index before render.
  46031. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  46032. _this._currentFaceIndex = faceIndex;
  46033. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46034. engine.setColorWrite(false);
  46035. }
  46036. });
  46037. // Custom render function.
  46038. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  46039. // Blur if required afer render.
  46040. this._shadowMap.onAfterUnbindObservable.add(function () {
  46041. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46042. engine.setColorWrite(true);
  46043. }
  46044. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  46045. return;
  46046. }
  46047. var shadowMap = _this.getShadowMapForRendering();
  46048. if (shadowMap) {
  46049. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  46050. }
  46051. });
  46052. // Clear according to the chosen filter.
  46053. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  46054. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  46055. this._shadowMap.onClearObservable.add(function (engine) {
  46056. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46057. engine.clear(clearOne, false, true, false);
  46058. }
  46059. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  46060. engine.clear(clearZero, true, true, false);
  46061. }
  46062. else {
  46063. engine.clear(clearOne, true, true, false);
  46064. }
  46065. });
  46066. };
  46067. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  46068. var _this = this;
  46069. var engine = this._scene.getEngine();
  46070. var targetSize = this._mapSize / this.blurScale;
  46071. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  46072. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  46073. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46074. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46075. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46076. }
  46077. if (this.useKernelBlur) {
  46078. 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);
  46079. this._kernelBlurXPostprocess.width = targetSize;
  46080. this._kernelBlurXPostprocess.height = targetSize;
  46081. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  46082. effect.setTexture("textureSampler", _this._shadowMap);
  46083. });
  46084. 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);
  46085. this._kernelBlurXPostprocess.autoClear = false;
  46086. this._kernelBlurYPostprocess.autoClear = false;
  46087. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  46088. this._kernelBlurXPostprocess.packedFloat = true;
  46089. this._kernelBlurYPostprocess.packedFloat = true;
  46090. }
  46091. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  46092. }
  46093. else {
  46094. 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);
  46095. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  46096. effect.setFloat2("screenSize", targetSize, targetSize);
  46097. effect.setTexture("textureSampler", _this._shadowMap);
  46098. });
  46099. this._boxBlurPostprocess.autoClear = false;
  46100. this._blurPostProcesses = [this._boxBlurPostprocess];
  46101. }
  46102. };
  46103. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  46104. var index;
  46105. var engine = this._scene.getEngine();
  46106. if (depthOnlySubMeshes.length) {
  46107. engine.setColorWrite(false);
  46108. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  46109. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  46110. }
  46111. engine.setColorWrite(true);
  46112. }
  46113. for (index = 0; index < opaqueSubMeshes.length; index++) {
  46114. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  46115. }
  46116. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  46117. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  46118. }
  46119. if (this._transparencyShadow) {
  46120. for (index = 0; index < transparentSubMeshes.length; index++) {
  46121. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  46122. }
  46123. }
  46124. };
  46125. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  46126. var _this = this;
  46127. var mesh = subMesh.getRenderingMesh();
  46128. var scene = this._scene;
  46129. var engine = scene.getEngine();
  46130. var material = subMesh.getMaterial();
  46131. if (!material || subMesh.verticesCount === 0) {
  46132. return;
  46133. }
  46134. // Culling
  46135. engine.setState(material.backFaceCulling);
  46136. // Managing instances
  46137. var batch = mesh._getInstancesRenderList(subMesh._id);
  46138. if (batch.mustReturn) {
  46139. return;
  46140. }
  46141. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  46142. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  46143. engine.enableEffect(this._effect);
  46144. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  46145. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  46146. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  46147. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  46148. this._effect.setVector3("lightData", this._cachedDirection);
  46149. }
  46150. else {
  46151. this._effect.setVector3("lightData", this._cachedPosition);
  46152. }
  46153. if (scene.activeCamera) {
  46154. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  46155. }
  46156. // Alpha test
  46157. if (material && material.needAlphaTesting()) {
  46158. var alphaTexture = material.getAlphaTestTexture();
  46159. if (alphaTexture) {
  46160. this._effect.setTexture("diffuseSampler", alphaTexture);
  46161. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  46162. }
  46163. }
  46164. // Bones
  46165. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  46166. var skeleton = mesh.skeleton;
  46167. if (skeleton.isUsingTextureForMatrices) {
  46168. var boneTexture = skeleton.getTransformMatrixTexture();
  46169. if (!boneTexture) {
  46170. return;
  46171. }
  46172. this._effect.setTexture("boneSampler", boneTexture);
  46173. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  46174. }
  46175. else {
  46176. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  46177. }
  46178. }
  46179. // Morph targets
  46180. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  46181. if (this.forceBackFacesOnly) {
  46182. engine.setState(true, 0, false, true);
  46183. }
  46184. // Observables
  46185. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(mesh);
  46186. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  46187. // Draw
  46188. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  46189. if (this.forceBackFacesOnly) {
  46190. engine.setState(true, 0, false, false);
  46191. }
  46192. }
  46193. else {
  46194. // Need to reset refresh rate of the shadowMap
  46195. if (this._shadowMap) {
  46196. this._shadowMap.resetRefreshCounter();
  46197. }
  46198. }
  46199. };
  46200. ShadowGenerator.prototype._applyFilterValues = function () {
  46201. if (!this._shadowMap) {
  46202. return;
  46203. }
  46204. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  46205. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  46206. }
  46207. else {
  46208. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46209. }
  46210. };
  46211. /**
  46212. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  46213. * @param onCompiled Callback triggered at the and of the effects compilation
  46214. * @param options Sets of optional options forcing the compilation with different modes
  46215. */
  46216. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  46217. var _this = this;
  46218. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  46219. var shadowMap = this.getShadowMap();
  46220. if (!shadowMap) {
  46221. if (onCompiled) {
  46222. onCompiled(this);
  46223. }
  46224. return;
  46225. }
  46226. var renderList = shadowMap.renderList;
  46227. if (!renderList) {
  46228. if (onCompiled) {
  46229. onCompiled(this);
  46230. }
  46231. return;
  46232. }
  46233. var subMeshes = new Array();
  46234. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  46235. var mesh = renderList_1[_i];
  46236. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  46237. }
  46238. if (subMeshes.length === 0) {
  46239. if (onCompiled) {
  46240. onCompiled(this);
  46241. }
  46242. return;
  46243. }
  46244. var currentIndex = 0;
  46245. var checkReady = function () {
  46246. if (!_this._scene || !_this._scene.getEngine()) {
  46247. return;
  46248. }
  46249. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  46250. currentIndex++;
  46251. if (currentIndex >= subMeshes.length) {
  46252. if (onCompiled) {
  46253. onCompiled(_this);
  46254. }
  46255. return;
  46256. }
  46257. }
  46258. setTimeout(checkReady, 16);
  46259. };
  46260. checkReady();
  46261. };
  46262. /**
  46263. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  46264. * @param options Sets of optional options forcing the compilation with different modes
  46265. * @returns A promise that resolves when the compilation completes
  46266. */
  46267. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  46268. var _this = this;
  46269. return new Promise(function (resolve) {
  46270. _this.forceCompilation(function () {
  46271. resolve();
  46272. }, options);
  46273. });
  46274. };
  46275. /**
  46276. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  46277. * @param subMesh The submesh we want to render in the shadow map
  46278. * @param useInstances Defines wether will draw in the map using instances
  46279. * @returns true if ready otherwise, false
  46280. */
  46281. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  46282. var defines = [];
  46283. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  46284. defines.push("#define FLOAT");
  46285. }
  46286. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  46287. defines.push("#define ESM");
  46288. }
  46289. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  46290. defines.push("#define DEPTHTEXTURE");
  46291. }
  46292. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  46293. var mesh = subMesh.getMesh();
  46294. var material = subMesh.getMaterial();
  46295. // Normal bias.
  46296. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  46297. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  46298. defines.push("#define NORMAL");
  46299. if (mesh.nonUniformScaling) {
  46300. defines.push("#define NONUNIFORMSCALING");
  46301. }
  46302. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  46303. defines.push("#define DIRECTIONINLIGHTDATA");
  46304. }
  46305. }
  46306. // Alpha test
  46307. if (material && material.needAlphaTesting()) {
  46308. var alphaTexture = material.getAlphaTestTexture();
  46309. if (alphaTexture) {
  46310. defines.push("#define ALPHATEST");
  46311. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  46312. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  46313. defines.push("#define UV1");
  46314. }
  46315. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  46316. if (alphaTexture.coordinatesIndex === 1) {
  46317. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  46318. defines.push("#define UV2");
  46319. }
  46320. }
  46321. }
  46322. }
  46323. // Bones
  46324. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  46325. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  46326. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  46327. if (mesh.numBoneInfluencers > 4) {
  46328. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  46329. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  46330. }
  46331. var skeleton = mesh.skeleton;
  46332. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  46333. if (skeleton.isUsingTextureForMatrices) {
  46334. defines.push("#define BONETEXTURE");
  46335. }
  46336. else {
  46337. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  46338. }
  46339. }
  46340. else {
  46341. defines.push("#define NUM_BONE_INFLUENCERS 0");
  46342. }
  46343. // Morph targets
  46344. var manager = mesh.morphTargetManager;
  46345. var morphInfluencers = 0;
  46346. if (manager) {
  46347. if (manager.numInfluencers > 0) {
  46348. defines.push("#define MORPHTARGETS");
  46349. morphInfluencers = manager.numInfluencers;
  46350. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  46351. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  46352. }
  46353. }
  46354. // Instances
  46355. if (useInstances) {
  46356. defines.push("#define INSTANCES");
  46357. attribs.push("world0");
  46358. attribs.push("world1");
  46359. attribs.push("world2");
  46360. attribs.push("world3");
  46361. }
  46362. if (this.customShaderOptions) {
  46363. if (this.customShaderOptions.defines) {
  46364. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  46365. var define = _a[_i];
  46366. if (defines.indexOf(define) === -1) {
  46367. defines.push(define);
  46368. }
  46369. }
  46370. }
  46371. }
  46372. // Get correct effect
  46373. var join = defines.join("\n");
  46374. if (this._cachedDefines !== join) {
  46375. this._cachedDefines = join;
  46376. var shaderName = "shadowMap";
  46377. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  46378. var samplers = ["diffuseSampler", "boneSampler"];
  46379. // Custom shader?
  46380. if (this.customShaderOptions) {
  46381. shaderName = this.customShaderOptions.shaderName;
  46382. if (this.customShaderOptions.attributes) {
  46383. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  46384. var attrib = _c[_b];
  46385. if (attribs.indexOf(attrib) === -1) {
  46386. attribs.push(attrib);
  46387. }
  46388. }
  46389. }
  46390. if (this.customShaderOptions.uniforms) {
  46391. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  46392. var uniform = _e[_d];
  46393. if (uniforms.indexOf(uniform) === -1) {
  46394. uniforms.push(uniform);
  46395. }
  46396. }
  46397. }
  46398. if (this.customShaderOptions.samplers) {
  46399. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  46400. var sampler = _g[_f];
  46401. if (samplers.indexOf(sampler) === -1) {
  46402. samplers.push(sampler);
  46403. }
  46404. }
  46405. }
  46406. }
  46407. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  46408. }
  46409. if (!this._effect.isReady()) {
  46410. return false;
  46411. }
  46412. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46413. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  46414. this._initializeBlurRTTAndPostProcesses();
  46415. }
  46416. }
  46417. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  46418. return false;
  46419. }
  46420. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  46421. return false;
  46422. }
  46423. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  46424. return false;
  46425. }
  46426. return true;
  46427. };
  46428. /**
  46429. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  46430. * @param defines Defines of the material we want to update
  46431. * @param lightIndex Index of the light in the enabled light list of the material
  46432. */
  46433. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  46434. var scene = this._scene;
  46435. var light = this._light;
  46436. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46437. return;
  46438. }
  46439. defines["SHADOW" + lightIndex] = true;
  46440. if (this.useContactHardeningShadow) {
  46441. defines["SHADOWPCSS" + lightIndex] = true;
  46442. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46443. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46444. }
  46445. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46446. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46447. }
  46448. // else default to high.
  46449. }
  46450. if (this.usePercentageCloserFiltering) {
  46451. defines["SHADOWPCF" + lightIndex] = true;
  46452. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46453. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46454. }
  46455. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46456. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46457. }
  46458. // else default to high.
  46459. }
  46460. else if (this.usePoissonSampling) {
  46461. defines["SHADOWPOISSON" + lightIndex] = true;
  46462. }
  46463. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  46464. defines["SHADOWESM" + lightIndex] = true;
  46465. }
  46466. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46467. defines["SHADOWCLOSEESM" + lightIndex] = true;
  46468. }
  46469. if (light.needCube()) {
  46470. defines["SHADOWCUBE" + lightIndex] = true;
  46471. }
  46472. };
  46473. /**
  46474. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  46475. * defined in the generator but impacting the effect).
  46476. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  46477. * @param effect The effect we are binfing the information for
  46478. */
  46479. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  46480. var light = this._light;
  46481. var scene = this._scene;
  46482. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46483. return;
  46484. }
  46485. var camera = scene.activeCamera;
  46486. if (!camera) {
  46487. return;
  46488. }
  46489. var shadowMap = this.getShadowMap();
  46490. if (!shadowMap) {
  46491. return;
  46492. }
  46493. if (!light.needCube()) {
  46494. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  46495. }
  46496. // Only PCF uses depth stencil texture.
  46497. if (this._filter === ShadowGenerator.FILTER_PCF) {
  46498. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46499. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46500. }
  46501. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  46502. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46503. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  46504. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46505. }
  46506. else {
  46507. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46508. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  46509. }
  46510. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  46511. };
  46512. /**
  46513. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  46514. * (eq to shadow prjection matrix * light transform matrix)
  46515. * @returns The transform matrix used to create the shadow map
  46516. */
  46517. ShadowGenerator.prototype.getTransformMatrix = function () {
  46518. var scene = this._scene;
  46519. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  46520. return this._transformMatrix;
  46521. }
  46522. this._currentRenderID = scene.getRenderId();
  46523. this._currentFaceIndexCache = this._currentFaceIndex;
  46524. var lightPosition = this._light.position;
  46525. if (this._light.computeTransformedInformation()) {
  46526. lightPosition = this._light.transformedPosition;
  46527. }
  46528. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  46529. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  46530. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  46531. }
  46532. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  46533. this._cachedPosition.copyFrom(lightPosition);
  46534. this._cachedDirection.copyFrom(this._lightDirection);
  46535. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  46536. var shadowMap = this.getShadowMap();
  46537. if (shadowMap) {
  46538. var renderList = shadowMap.renderList;
  46539. if (renderList) {
  46540. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  46541. }
  46542. }
  46543. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  46544. }
  46545. return this._transformMatrix;
  46546. };
  46547. /**
  46548. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  46549. * Cube and 2D textures for instance.
  46550. */
  46551. ShadowGenerator.prototype.recreateShadowMap = function () {
  46552. var shadowMap = this._shadowMap;
  46553. if (!shadowMap) {
  46554. return;
  46555. }
  46556. // Track render list.
  46557. var renderList = shadowMap.renderList;
  46558. // Clean up existing data.
  46559. this._disposeRTTandPostProcesses();
  46560. // Reinitializes.
  46561. this._initializeGenerator();
  46562. // Reaffect the filter to ensure a correct fallback if necessary.
  46563. this.filter = this.filter;
  46564. // Reaffect the filter.
  46565. this._applyFilterValues();
  46566. // Reaffect Render List.
  46567. this._shadowMap.renderList = renderList;
  46568. };
  46569. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  46570. if (this._shadowMap2) {
  46571. this._shadowMap2.dispose();
  46572. this._shadowMap2 = null;
  46573. }
  46574. if (this._boxBlurPostprocess) {
  46575. this._boxBlurPostprocess.dispose();
  46576. this._boxBlurPostprocess = null;
  46577. }
  46578. if (this._kernelBlurXPostprocess) {
  46579. this._kernelBlurXPostprocess.dispose();
  46580. this._kernelBlurXPostprocess = null;
  46581. }
  46582. if (this._kernelBlurYPostprocess) {
  46583. this._kernelBlurYPostprocess.dispose();
  46584. this._kernelBlurYPostprocess = null;
  46585. }
  46586. this._blurPostProcesses = [];
  46587. };
  46588. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  46589. if (this._shadowMap) {
  46590. this._shadowMap.dispose();
  46591. this._shadowMap = null;
  46592. }
  46593. this._disposeBlurPostProcesses();
  46594. };
  46595. /**
  46596. * Disposes the ShadowGenerator.
  46597. * Returns nothing.
  46598. */
  46599. ShadowGenerator.prototype.dispose = function () {
  46600. this._disposeRTTandPostProcesses();
  46601. if (this._light) {
  46602. this._light._shadowGenerator = null;
  46603. this._light._markMeshesAsLightDirty();
  46604. }
  46605. };
  46606. /**
  46607. * Serializes the shadow generator setup to a json object.
  46608. * @returns The serialized JSON object
  46609. */
  46610. ShadowGenerator.prototype.serialize = function () {
  46611. var serializationObject = {};
  46612. var shadowMap = this.getShadowMap();
  46613. if (!shadowMap) {
  46614. return serializationObject;
  46615. }
  46616. serializationObject.lightId = this._light.id;
  46617. serializationObject.mapSize = shadowMap.getRenderSize();
  46618. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  46619. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  46620. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46621. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46622. serializationObject.usePoissonSampling = this.usePoissonSampling;
  46623. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  46624. serializationObject.depthScale = this.depthScale;
  46625. serializationObject.darkness = this.getDarkness();
  46626. serializationObject.blurBoxOffset = this.blurBoxOffset;
  46627. serializationObject.blurKernel = this.blurKernel;
  46628. serializationObject.blurScale = this.blurScale;
  46629. serializationObject.useKernelBlur = this.useKernelBlur;
  46630. serializationObject.transparencyShadow = this._transparencyShadow;
  46631. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  46632. serializationObject.bias = this.bias;
  46633. serializationObject.normalBias = this.normalBias;
  46634. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  46635. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  46636. serializationObject.filteringQuality = this.filteringQuality;
  46637. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  46638. serializationObject.renderList = [];
  46639. if (shadowMap.renderList) {
  46640. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  46641. var mesh = shadowMap.renderList[meshIndex];
  46642. serializationObject.renderList.push(mesh.id);
  46643. }
  46644. }
  46645. return serializationObject;
  46646. };
  46647. /**
  46648. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  46649. * @param parsedShadowGenerator The JSON object to parse
  46650. * @param scene The scene to create the shadow map for
  46651. * @returns The parsed shadow generator
  46652. */
  46653. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  46654. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  46655. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  46656. var shadowMap = shadowGenerator.getShadowMap();
  46657. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  46658. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  46659. meshes.forEach(function (mesh) {
  46660. if (!shadowMap) {
  46661. return;
  46662. }
  46663. if (!shadowMap.renderList) {
  46664. shadowMap.renderList = [];
  46665. }
  46666. shadowMap.renderList.push(mesh);
  46667. });
  46668. }
  46669. if (parsedShadowGenerator.usePoissonSampling) {
  46670. shadowGenerator.usePoissonSampling = true;
  46671. }
  46672. else if (parsedShadowGenerator.useExponentialShadowMap) {
  46673. shadowGenerator.useExponentialShadowMap = true;
  46674. }
  46675. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  46676. shadowGenerator.useBlurExponentialShadowMap = true;
  46677. }
  46678. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  46679. shadowGenerator.useCloseExponentialShadowMap = true;
  46680. }
  46681. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  46682. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  46683. }
  46684. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  46685. shadowGenerator.usePercentageCloserFiltering = true;
  46686. }
  46687. else if (parsedShadowGenerator.useContactHardeningShadow) {
  46688. shadowGenerator.useContactHardeningShadow = true;
  46689. }
  46690. if (parsedShadowGenerator.filteringQuality) {
  46691. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  46692. }
  46693. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  46694. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  46695. }
  46696. // Backward compat
  46697. else if (parsedShadowGenerator.useVarianceShadowMap) {
  46698. shadowGenerator.useExponentialShadowMap = true;
  46699. }
  46700. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  46701. shadowGenerator.useBlurExponentialShadowMap = true;
  46702. }
  46703. if (parsedShadowGenerator.depthScale) {
  46704. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  46705. }
  46706. if (parsedShadowGenerator.blurScale) {
  46707. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  46708. }
  46709. if (parsedShadowGenerator.blurBoxOffset) {
  46710. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  46711. }
  46712. if (parsedShadowGenerator.useKernelBlur) {
  46713. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  46714. }
  46715. if (parsedShadowGenerator.blurKernel) {
  46716. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  46717. }
  46718. if (parsedShadowGenerator.bias !== undefined) {
  46719. shadowGenerator.bias = parsedShadowGenerator.bias;
  46720. }
  46721. if (parsedShadowGenerator.normalBias !== undefined) {
  46722. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  46723. }
  46724. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  46725. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  46726. }
  46727. if (parsedShadowGenerator.darkness) {
  46728. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  46729. }
  46730. if (parsedShadowGenerator.transparencyShadow) {
  46731. shadowGenerator.setTransparencyShadow(true);
  46732. }
  46733. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  46734. return shadowGenerator;
  46735. };
  46736. /**
  46737. * Shadow generator mode None: no filtering applied.
  46738. */
  46739. ShadowGenerator.FILTER_NONE = 0;
  46740. /**
  46741. * Shadow generator mode ESM: Exponential Shadow Mapping.
  46742. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46743. */
  46744. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  46745. /**
  46746. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  46747. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  46748. */
  46749. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  46750. /**
  46751. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  46752. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46753. */
  46754. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  46755. /**
  46756. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  46757. * edge artifacts on steep falloff.
  46758. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46759. */
  46760. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  46761. /**
  46762. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  46763. * edge artifacts on steep falloff.
  46764. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46765. */
  46766. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  46767. /**
  46768. * Shadow generator mode PCF: Percentage Closer Filtering
  46769. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46770. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  46771. */
  46772. ShadowGenerator.FILTER_PCF = 6;
  46773. /**
  46774. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  46775. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46776. * Contact Hardening
  46777. */
  46778. ShadowGenerator.FILTER_PCSS = 7;
  46779. /**
  46780. * Reserved for PCF and PCSS
  46781. * Highest Quality.
  46782. *
  46783. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  46784. *
  46785. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  46786. */
  46787. ShadowGenerator.QUALITY_HIGH = 0;
  46788. /**
  46789. * Reserved for PCF and PCSS
  46790. * Good tradeoff for quality/perf cross devices
  46791. *
  46792. * Execute PCF on a 3*3 kernel.
  46793. *
  46794. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  46795. */
  46796. ShadowGenerator.QUALITY_MEDIUM = 1;
  46797. /**
  46798. * Reserved for PCF and PCSS
  46799. * The lowest quality but the fastest.
  46800. *
  46801. * Execute PCF on a 1*1 kernel.
  46802. *
  46803. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  46804. */
  46805. ShadowGenerator.QUALITY_LOW = 2;
  46806. /** @hidden */
  46807. ShadowGenerator._SceneComponentInitialization = function (_) {
  46808. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  46809. };
  46810. return ShadowGenerator;
  46811. }());
  46812. /***/ }),
  46813. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  46814. /*!*********************************************************!*\
  46815. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  46816. \*********************************************************/
  46817. /*! exports provided: ShadowGeneratorSceneComponent */
  46818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46819. "use strict";
  46820. __webpack_require__.r(__webpack_exports__);
  46821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  46822. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  46823. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46824. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46825. // Adds the parser to the scene parsers.
  46826. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  46827. // Shadows
  46828. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  46829. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  46830. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  46831. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  46832. // SG would be available on their associated lights
  46833. }
  46834. }
  46835. });
  46836. /**
  46837. * Defines the shadow generator component responsible to manage any shadow generators
  46838. * in a given scene.
  46839. */
  46840. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  46841. /**
  46842. * Creates a new instance of the component for the given scene
  46843. * @param scene Defines the scene to register the component in
  46844. */
  46845. function ShadowGeneratorSceneComponent(scene) {
  46846. /**
  46847. * The component name helpfull to identify the component in the list of scene components.
  46848. */
  46849. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  46850. this.scene = scene;
  46851. }
  46852. /**
  46853. * Registers the component in a given scene
  46854. */
  46855. ShadowGeneratorSceneComponent.prototype.register = function () {
  46856. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  46857. };
  46858. /**
  46859. * Rebuilds the elements related to this component in case of
  46860. * context lost for instance.
  46861. */
  46862. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  46863. // Nothing To Do Here.
  46864. };
  46865. /**
  46866. * Serializes the component data to the specified json object
  46867. * @param serializationObject The object to serialize to
  46868. */
  46869. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  46870. // Shadows
  46871. serializationObject.shadowGenerators = [];
  46872. var lights = this.scene.lights;
  46873. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  46874. var light = lights_1[_i];
  46875. var shadowGenerator = light.getShadowGenerator();
  46876. if (shadowGenerator) {
  46877. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  46878. }
  46879. }
  46880. };
  46881. /**
  46882. * Adds all the element from the container to the scene
  46883. * @param container the container holding the elements
  46884. */
  46885. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  46886. // Nothing To Do Here. (directly attached to a light)
  46887. };
  46888. /**
  46889. * Removes all the elements in the container from the scene
  46890. * @param container contains the elements to remove
  46891. * @param dispose if the removed element should be disposed (default: false)
  46892. */
  46893. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  46894. // Nothing To Do Here. (directly attached to a light)
  46895. };
  46896. /**
  46897. * Rebuilds the elements related to this component in case of
  46898. * context lost for instance.
  46899. */
  46900. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  46901. // Nothing To Do Here.
  46902. };
  46903. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  46904. // Shadows
  46905. var scene = this.scene;
  46906. if (this.scene.shadowsEnabled) {
  46907. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  46908. var light = scene.lights[lightIndex];
  46909. var shadowGenerator = light.getShadowGenerator();
  46910. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  46911. var shadowMap = (shadowGenerator.getShadowMap());
  46912. if (scene.textures.indexOf(shadowMap) !== -1) {
  46913. renderTargets.push(shadowMap);
  46914. }
  46915. }
  46916. }
  46917. }
  46918. };
  46919. return ShadowGeneratorSceneComponent;
  46920. }());
  46921. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  46922. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  46923. if (!component) {
  46924. component = new ShadowGeneratorSceneComponent(scene);
  46925. scene._addComponent(component);
  46926. }
  46927. };
  46928. /***/ }),
  46929. /***/ "./Lights/directionalLight.ts":
  46930. /*!************************************!*\
  46931. !*** ./Lights/directionalLight.ts ***!
  46932. \************************************/
  46933. /*! exports provided: DirectionalLight */
  46934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46935. "use strict";
  46936. __webpack_require__.r(__webpack_exports__);
  46937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  46938. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46939. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46941. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46942. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46943. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46944. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  46945. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46946. });
  46947. /**
  46948. * A directional light is defined by a direction (what a surprise!).
  46949. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46950. * 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.
  46951. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46952. */
  46953. var DirectionalLight = /** @class */ (function (_super) {
  46954. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  46955. /**
  46956. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46957. * The directional light is emitted from everywhere in the given direction.
  46958. * It can cast shadows.
  46959. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46960. * @param name The friendly name of the light
  46961. * @param direction The direction of the light
  46962. * @param scene The scene the light belongs to
  46963. */
  46964. function DirectionalLight(name, direction, scene) {
  46965. var _this = _super.call(this, name, scene) || this;
  46966. _this._shadowFrustumSize = 0;
  46967. _this._shadowOrthoScale = 0.1;
  46968. /**
  46969. * Automatically compute the projection matrix to best fit (including all the casters)
  46970. * on each frame.
  46971. */
  46972. _this.autoUpdateExtends = true;
  46973. // Cache
  46974. _this._orthoLeft = Number.MAX_VALUE;
  46975. _this._orthoRight = Number.MIN_VALUE;
  46976. _this._orthoTop = Number.MIN_VALUE;
  46977. _this._orthoBottom = Number.MAX_VALUE;
  46978. _this.position = direction.scale(-1.0);
  46979. _this.direction = direction;
  46980. return _this;
  46981. }
  46982. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  46983. /**
  46984. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46985. */
  46986. get: function () {
  46987. return this._shadowFrustumSize;
  46988. },
  46989. /**
  46990. * Specifies a fix frustum size for the shadow generation.
  46991. */
  46992. set: function (value) {
  46993. this._shadowFrustumSize = value;
  46994. this.forceProjectionMatrixCompute();
  46995. },
  46996. enumerable: true,
  46997. configurable: true
  46998. });
  46999. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  47000. /**
  47001. * Gets the shadow projection scale against the optimal computed one.
  47002. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47003. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47004. */
  47005. get: function () {
  47006. return this._shadowOrthoScale;
  47007. },
  47008. /**
  47009. * Sets the shadow projection scale against the optimal computed one.
  47010. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47011. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47012. */
  47013. set: function (value) {
  47014. this._shadowOrthoScale = value;
  47015. this.forceProjectionMatrixCompute();
  47016. },
  47017. enumerable: true,
  47018. configurable: true
  47019. });
  47020. /**
  47021. * Returns the string "DirectionalLight".
  47022. * @return The class name
  47023. */
  47024. DirectionalLight.prototype.getClassName = function () {
  47025. return "DirectionalLight";
  47026. };
  47027. /**
  47028. * Returns the integer 1.
  47029. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47030. */
  47031. DirectionalLight.prototype.getTypeID = function () {
  47032. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  47033. };
  47034. /**
  47035. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47036. * Returns the DirectionalLight Shadow projection matrix.
  47037. */
  47038. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47039. if (this.shadowFrustumSize > 0) {
  47040. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  47041. }
  47042. else {
  47043. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47044. }
  47045. };
  47046. /**
  47047. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47048. * Returns the DirectionalLight Shadow projection matrix.
  47049. */
  47050. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  47051. var activeCamera = this.getScene().activeCamera;
  47052. if (!activeCamera) {
  47053. return;
  47054. }
  47055. _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);
  47056. };
  47057. /**
  47058. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47059. * Returns the DirectionalLight Shadow projection matrix.
  47060. */
  47061. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47062. var activeCamera = this.getScene().activeCamera;
  47063. if (!activeCamera) {
  47064. return;
  47065. }
  47066. // Check extends
  47067. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  47068. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47069. this._orthoLeft = Number.MAX_VALUE;
  47070. this._orthoRight = Number.MIN_VALUE;
  47071. this._orthoTop = Number.MIN_VALUE;
  47072. this._orthoBottom = Number.MAX_VALUE;
  47073. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  47074. var mesh = renderList[meshIndex];
  47075. if (!mesh) {
  47076. continue;
  47077. }
  47078. var boundingInfo = mesh.getBoundingInfo();
  47079. var boundingBox = boundingInfo.boundingBox;
  47080. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  47081. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  47082. if (tempVector3.x < this._orthoLeft) {
  47083. this._orthoLeft = tempVector3.x;
  47084. }
  47085. if (tempVector3.y < this._orthoBottom) {
  47086. this._orthoBottom = tempVector3.y;
  47087. }
  47088. if (tempVector3.x > this._orthoRight) {
  47089. this._orthoRight = tempVector3.x;
  47090. }
  47091. if (tempVector3.y > this._orthoTop) {
  47092. this._orthoTop = tempVector3.y;
  47093. }
  47094. }
  47095. }
  47096. }
  47097. var xOffset = this._orthoRight - this._orthoLeft;
  47098. var yOffset = this._orthoTop - this._orthoBottom;
  47099. _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);
  47100. };
  47101. DirectionalLight.prototype._buildUniformLayout = function () {
  47102. this._uniformBuffer.addUniform("vLightData", 4);
  47103. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47104. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47105. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47106. this._uniformBuffer.addUniform("depthValues", 2);
  47107. this._uniformBuffer.create();
  47108. };
  47109. /**
  47110. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47111. * @param effect The effect to update
  47112. * @param lightIndex The index of the light in the effect to update
  47113. * @returns The directional light
  47114. */
  47115. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  47116. if (this.computeTransformedInformation()) {
  47117. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  47118. return this;
  47119. }
  47120. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  47121. return this;
  47122. };
  47123. /**
  47124. * Gets the minZ used for shadow according to both the scene and the light.
  47125. *
  47126. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47127. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47128. * @param activeCamera The camera we are returning the min for
  47129. * @returns the depth min z
  47130. */
  47131. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  47132. return 1;
  47133. };
  47134. /**
  47135. * Gets the maxZ used for shadow according to both the scene and the light.
  47136. *
  47137. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47138. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47139. * @param activeCamera The camera we are returning the max for
  47140. * @returns the depth max z
  47141. */
  47142. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  47143. return 1;
  47144. };
  47145. /**
  47146. * Prepares the list of defines specific to the light type.
  47147. * @param defines the list of defines
  47148. * @param lightIndex defines the index of the light for the effect
  47149. */
  47150. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47151. defines["DIRLIGHT" + lightIndex] = true;
  47152. };
  47153. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47154. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47155. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  47156. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47157. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47158. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  47159. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47160. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47161. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  47162. return DirectionalLight;
  47163. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47164. /***/ }),
  47165. /***/ "./Lights/hemisphericLight.ts":
  47166. /*!************************************!*\
  47167. !*** ./Lights/hemisphericLight.ts ***!
  47168. \************************************/
  47169. /*! exports provided: HemisphericLight */
  47170. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47171. "use strict";
  47172. __webpack_require__.r(__webpack_exports__);
  47173. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  47174. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47175. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47176. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47177. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47178. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47179. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  47180. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  47181. });
  47182. /**
  47183. * The HemisphericLight simulates the ambient environment light,
  47184. * so the passed direction is the light reflection direction, not the incoming direction.
  47185. */
  47186. var HemisphericLight = /** @class */ (function (_super) {
  47187. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  47188. /**
  47189. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  47190. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  47191. * The HemisphericLight can't cast shadows.
  47192. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47193. * @param name The friendly name of the light
  47194. * @param direction The direction of the light reflection
  47195. * @param scene The scene the light belongs to
  47196. */
  47197. function HemisphericLight(name, direction, scene) {
  47198. var _this = _super.call(this, name, scene) || this;
  47199. /**
  47200. * The groundColor is the light in the opposite direction to the one specified during creation.
  47201. * 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.
  47202. */
  47203. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  47204. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47205. return _this;
  47206. }
  47207. HemisphericLight.prototype._buildUniformLayout = function () {
  47208. this._uniformBuffer.addUniform("vLightData", 4);
  47209. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47210. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47211. this._uniformBuffer.addUniform("vLightGround", 3);
  47212. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47213. this._uniformBuffer.addUniform("depthValues", 2);
  47214. this._uniformBuffer.create();
  47215. };
  47216. /**
  47217. * Returns the string "HemisphericLight".
  47218. * @return The class name
  47219. */
  47220. HemisphericLight.prototype.getClassName = function () {
  47221. return "HemisphericLight";
  47222. };
  47223. /**
  47224. * Sets the HemisphericLight direction towards the passed target (Vector3).
  47225. * Returns the updated direction.
  47226. * @param target The target the direction should point to
  47227. * @return The computed direction
  47228. */
  47229. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  47230. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  47231. return this.direction;
  47232. };
  47233. /**
  47234. * Returns the shadow generator associated to the light.
  47235. * @returns Always null for hemispheric lights because it does not support shadows.
  47236. */
  47237. HemisphericLight.prototype.getShadowGenerator = function () {
  47238. return null;
  47239. };
  47240. /**
  47241. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  47242. * @param effect The effect to update
  47243. * @param lightIndex The index of the light in the effect to update
  47244. * @returns The hemispheric light
  47245. */
  47246. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  47247. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47248. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  47249. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  47250. return this;
  47251. };
  47252. /**
  47253. * Computes the world matrix of the node
  47254. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47255. * @param useWasUpdatedFlag defines a reserved property
  47256. * @returns the world matrix
  47257. */
  47258. HemisphericLight.prototype.computeWorldMatrix = function () {
  47259. if (!this._worldMatrix) {
  47260. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47261. }
  47262. return this._worldMatrix;
  47263. };
  47264. /**
  47265. * Returns the integer 3.
  47266. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47267. */
  47268. HemisphericLight.prototype.getTypeID = function () {
  47269. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  47270. };
  47271. /**
  47272. * Prepares the list of defines specific to the light type.
  47273. * @param defines the list of defines
  47274. * @param lightIndex defines the index of the light for the effect
  47275. */
  47276. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47277. defines["HEMILIGHT" + lightIndex] = true;
  47278. };
  47279. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47281. ], HemisphericLight.prototype, "groundColor", void 0);
  47282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47284. ], HemisphericLight.prototype, "direction", void 0);
  47285. return HemisphericLight;
  47286. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  47287. /***/ }),
  47288. /***/ "./Lights/index.ts":
  47289. /*!*************************!*\
  47290. !*** ./Lights/index.ts ***!
  47291. \*************************/
  47292. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  47293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47294. "use strict";
  47295. __webpack_require__.r(__webpack_exports__);
  47296. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  47298. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  47300. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  47301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  47302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  47303. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  47304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  47305. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  47306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  47307. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  47308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  47309. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  47310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  47311. /***/ }),
  47312. /***/ "./Lights/light.ts":
  47313. /*!*************************!*\
  47314. !*** ./Lights/light.ts ***!
  47315. \*************************/
  47316. /*! exports provided: Light */
  47317. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47318. "use strict";
  47319. __webpack_require__.r(__webpack_exports__);
  47320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  47321. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47322. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47323. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47324. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47325. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  47326. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  47327. /**
  47328. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  47329. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  47330. * 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.
  47331. */
  47332. var Light = /** @class */ (function (_super) {
  47333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  47334. /**
  47335. * Creates a Light object in the scene.
  47336. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47337. * @param name The firendly name of the light
  47338. * @param scene The scene the light belongs too
  47339. */
  47340. function Light(name, scene) {
  47341. var _this = _super.call(this, name, scene) || this;
  47342. /**
  47343. * Diffuse gives the basic color to an object.
  47344. */
  47345. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47346. /**
  47347. * Specular produces a highlight color on an object.
  47348. * Note: This is note affecting PBR materials.
  47349. */
  47350. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47351. /**
  47352. * Defines the falloff type for this light. This lets overrriding how punctual light are
  47353. * falling off base on range or angle.
  47354. * This can be set to any values in Light.FALLOFF_x.
  47355. *
  47356. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  47357. * other types of materials.
  47358. */
  47359. _this.falloffType = Light.FALLOFF_DEFAULT;
  47360. /**
  47361. * Strength of the light.
  47362. * Note: By default it is define in the framework own unit.
  47363. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  47364. */
  47365. _this.intensity = 1.0;
  47366. _this._range = Number.MAX_VALUE;
  47367. _this._inverseSquaredRange = 0;
  47368. /**
  47369. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  47370. * of light.
  47371. */
  47372. _this._photometricScale = 1.0;
  47373. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  47374. _this._radius = 0.00001;
  47375. /**
  47376. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  47377. * exceeding the number allowed of the materials.
  47378. */
  47379. _this.renderPriority = 0;
  47380. _this._shadowEnabled = true;
  47381. _this._excludeWithLayerMask = 0;
  47382. _this._includeOnlyWithLayerMask = 0;
  47383. _this._lightmapMode = 0;
  47384. /**
  47385. * @hidden Internal use only.
  47386. */
  47387. _this._excludedMeshesIds = new Array();
  47388. /**
  47389. * @hidden Internal use only.
  47390. */
  47391. _this._includedOnlyMeshesIds = new Array();
  47392. /** @hidden */
  47393. _this._isLight = true;
  47394. _this.getScene().addLight(_this);
  47395. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  47396. _this._buildUniformLayout();
  47397. _this.includedOnlyMeshes = new Array();
  47398. _this.excludedMeshes = new Array();
  47399. _this._resyncMeshes();
  47400. return _this;
  47401. }
  47402. Object.defineProperty(Light.prototype, "range", {
  47403. /**
  47404. * Defines how far from the source the light is impacting in scene units.
  47405. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47406. */
  47407. get: function () {
  47408. return this._range;
  47409. },
  47410. /**
  47411. * Defines how far from the source the light is impacting in scene units.
  47412. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47413. */
  47414. set: function (value) {
  47415. this._range = value;
  47416. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  47417. },
  47418. enumerable: true,
  47419. configurable: true
  47420. });
  47421. Object.defineProperty(Light.prototype, "intensityMode", {
  47422. /**
  47423. * Gets the photometric scale used to interpret the intensity.
  47424. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47425. */
  47426. get: function () {
  47427. return this._intensityMode;
  47428. },
  47429. /**
  47430. * Sets the photometric scale used to interpret the intensity.
  47431. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47432. */
  47433. set: function (value) {
  47434. this._intensityMode = value;
  47435. this._computePhotometricScale();
  47436. },
  47437. enumerable: true,
  47438. configurable: true
  47439. });
  47440. Object.defineProperty(Light.prototype, "radius", {
  47441. /**
  47442. * Gets the light radius used by PBR Materials to simulate soft area lights.
  47443. */
  47444. get: function () {
  47445. return this._radius;
  47446. },
  47447. /**
  47448. * sets the light radius used by PBR Materials to simulate soft area lights.
  47449. */
  47450. set: function (value) {
  47451. this._radius = value;
  47452. this._computePhotometricScale();
  47453. },
  47454. enumerable: true,
  47455. configurable: true
  47456. });
  47457. Object.defineProperty(Light.prototype, "shadowEnabled", {
  47458. /**
  47459. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47460. * the current shadow generator.
  47461. */
  47462. get: function () {
  47463. return this._shadowEnabled;
  47464. },
  47465. /**
  47466. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47467. * the current shadow generator.
  47468. */
  47469. set: function (value) {
  47470. if (this._shadowEnabled === value) {
  47471. return;
  47472. }
  47473. this._shadowEnabled = value;
  47474. this._markMeshesAsLightDirty();
  47475. },
  47476. enumerable: true,
  47477. configurable: true
  47478. });
  47479. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  47480. /**
  47481. * Gets the only meshes impacted by this light.
  47482. */
  47483. get: function () {
  47484. return this._includedOnlyMeshes;
  47485. },
  47486. /**
  47487. * Sets the only meshes impacted by this light.
  47488. */
  47489. set: function (value) {
  47490. this._includedOnlyMeshes = value;
  47491. this._hookArrayForIncludedOnly(value);
  47492. },
  47493. enumerable: true,
  47494. configurable: true
  47495. });
  47496. Object.defineProperty(Light.prototype, "excludedMeshes", {
  47497. /**
  47498. * Gets the meshes not impacted by this light.
  47499. */
  47500. get: function () {
  47501. return this._excludedMeshes;
  47502. },
  47503. /**
  47504. * Sets the meshes not impacted by this light.
  47505. */
  47506. set: function (value) {
  47507. this._excludedMeshes = value;
  47508. this._hookArrayForExcluded(value);
  47509. },
  47510. enumerable: true,
  47511. configurable: true
  47512. });
  47513. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  47514. /**
  47515. * Gets the layer id use to find what meshes are not impacted by the light.
  47516. * Inactive if 0
  47517. */
  47518. get: function () {
  47519. return this._excludeWithLayerMask;
  47520. },
  47521. /**
  47522. * Sets the layer id use to find what meshes are not impacted by the light.
  47523. * Inactive if 0
  47524. */
  47525. set: function (value) {
  47526. this._excludeWithLayerMask = value;
  47527. this._resyncMeshes();
  47528. },
  47529. enumerable: true,
  47530. configurable: true
  47531. });
  47532. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  47533. /**
  47534. * Gets the layer id use to find what meshes are impacted by the light.
  47535. * Inactive if 0
  47536. */
  47537. get: function () {
  47538. return this._includeOnlyWithLayerMask;
  47539. },
  47540. /**
  47541. * Sets the layer id use to find what meshes are impacted by the light.
  47542. * Inactive if 0
  47543. */
  47544. set: function (value) {
  47545. this._includeOnlyWithLayerMask = value;
  47546. this._resyncMeshes();
  47547. },
  47548. enumerable: true,
  47549. configurable: true
  47550. });
  47551. Object.defineProperty(Light.prototype, "lightmapMode", {
  47552. /**
  47553. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47554. */
  47555. get: function () {
  47556. return this._lightmapMode;
  47557. },
  47558. /**
  47559. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47560. */
  47561. set: function (value) {
  47562. if (this._lightmapMode === value) {
  47563. return;
  47564. }
  47565. this._lightmapMode = value;
  47566. this._markMeshesAsLightDirty();
  47567. },
  47568. enumerable: true,
  47569. configurable: true
  47570. });
  47571. /**
  47572. * Returns the string "Light".
  47573. * @returns the class name
  47574. */
  47575. Light.prototype.getClassName = function () {
  47576. return "Light";
  47577. };
  47578. /**
  47579. * Converts the light information to a readable string for debug purpose.
  47580. * @param fullDetails Supports for multiple levels of logging within scene loading
  47581. * @returns the human readable light info
  47582. */
  47583. Light.prototype.toString = function (fullDetails) {
  47584. var ret = "Name: " + this.name;
  47585. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  47586. if (this.animations) {
  47587. for (var i = 0; i < this.animations.length; i++) {
  47588. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  47589. }
  47590. }
  47591. if (fullDetails) {
  47592. }
  47593. return ret;
  47594. };
  47595. /** @hidden */
  47596. Light.prototype._syncParentEnabledState = function () {
  47597. _super.prototype._syncParentEnabledState.call(this);
  47598. this._resyncMeshes();
  47599. };
  47600. /**
  47601. * Set the enabled state of this node.
  47602. * @param value - the new enabled state
  47603. */
  47604. Light.prototype.setEnabled = function (value) {
  47605. _super.prototype.setEnabled.call(this, value);
  47606. this._resyncMeshes();
  47607. };
  47608. /**
  47609. * Returns the Light associated shadow generator if any.
  47610. * @return the associated shadow generator.
  47611. */
  47612. Light.prototype.getShadowGenerator = function () {
  47613. return this._shadowGenerator;
  47614. };
  47615. /**
  47616. * Returns a Vector3, the absolute light position in the World.
  47617. * @returns the world space position of the light
  47618. */
  47619. Light.prototype.getAbsolutePosition = function () {
  47620. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47621. };
  47622. /**
  47623. * Specifies if the light will affect the passed mesh.
  47624. * @param mesh The mesh to test against the light
  47625. * @return true the mesh is affected otherwise, false.
  47626. */
  47627. Light.prototype.canAffectMesh = function (mesh) {
  47628. if (!mesh) {
  47629. return true;
  47630. }
  47631. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  47632. return false;
  47633. }
  47634. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  47635. return false;
  47636. }
  47637. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  47638. return false;
  47639. }
  47640. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  47641. return false;
  47642. }
  47643. return true;
  47644. };
  47645. /**
  47646. * Sort function to order lights for rendering.
  47647. * @param a First Light object to compare to second.
  47648. * @param b Second Light object to compare first.
  47649. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  47650. */
  47651. Light.CompareLightsPriority = function (a, b) {
  47652. //shadow-casting lights have priority over non-shadow-casting lights
  47653. //the renderPrioirty is a secondary sort criterion
  47654. if (a.shadowEnabled !== b.shadowEnabled) {
  47655. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  47656. }
  47657. return b.renderPriority - a.renderPriority;
  47658. };
  47659. /**
  47660. * Releases resources associated with this node.
  47661. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47662. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47663. */
  47664. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  47665. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  47666. if (this._shadowGenerator) {
  47667. this._shadowGenerator.dispose();
  47668. this._shadowGenerator = null;
  47669. }
  47670. // Animations
  47671. this.getScene().stopAnimation(this);
  47672. // Remove from meshes
  47673. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47674. var mesh = _a[_i];
  47675. mesh._removeLightSource(this);
  47676. }
  47677. this._uniformBuffer.dispose();
  47678. // Remove from scene
  47679. this.getScene().removeLight(this);
  47680. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  47681. };
  47682. /**
  47683. * Returns the light type ID (integer).
  47684. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47685. */
  47686. Light.prototype.getTypeID = function () {
  47687. return 0;
  47688. };
  47689. /**
  47690. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  47691. * @returns the scaled intensity in intensity mode unit
  47692. */
  47693. Light.prototype.getScaledIntensity = function () {
  47694. return this._photometricScale * this.intensity;
  47695. };
  47696. /**
  47697. * Returns a new Light object, named "name", from the current one.
  47698. * @param name The name of the cloned light
  47699. * @returns the new created light
  47700. */
  47701. Light.prototype.clone = function (name) {
  47702. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  47703. if (!constructor) {
  47704. return null;
  47705. }
  47706. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  47707. };
  47708. /**
  47709. * Serializes the current light into a Serialization object.
  47710. * @returns the serialized object.
  47711. */
  47712. Light.prototype.serialize = function () {
  47713. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  47714. // Type
  47715. serializationObject.type = this.getTypeID();
  47716. // Parent
  47717. if (this.parent) {
  47718. serializationObject.parentId = this.parent.id;
  47719. }
  47720. // Inclusion / exclusions
  47721. if (this.excludedMeshes.length > 0) {
  47722. serializationObject.excludedMeshesIds = [];
  47723. this.excludedMeshes.forEach(function (mesh) {
  47724. serializationObject.excludedMeshesIds.push(mesh.id);
  47725. });
  47726. }
  47727. if (this.includedOnlyMeshes.length > 0) {
  47728. serializationObject.includedOnlyMeshesIds = [];
  47729. this.includedOnlyMeshes.forEach(function (mesh) {
  47730. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  47731. });
  47732. }
  47733. // Animations
  47734. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  47735. serializationObject.ranges = this.serializeAnimationRanges();
  47736. return serializationObject;
  47737. };
  47738. /**
  47739. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  47740. * This new light is named "name" and added to the passed scene.
  47741. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  47742. * @param name The friendly name of the light
  47743. * @param scene The scene the new light will belong to
  47744. * @returns the constructor function
  47745. */
  47746. Light.GetConstructorFromName = function (type, name, scene) {
  47747. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  47748. if (constructorFunc) {
  47749. return constructorFunc;
  47750. }
  47751. // Default to no light for none present once.
  47752. return null;
  47753. };
  47754. /**
  47755. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  47756. * @param parsedLight The JSON representation of the light
  47757. * @param scene The scene to create the parsed light in
  47758. * @returns the created light after parsing
  47759. */
  47760. Light.Parse = function (parsedLight, scene) {
  47761. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  47762. if (!constructor) {
  47763. return null;
  47764. }
  47765. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  47766. // Inclusion / exclusions
  47767. if (parsedLight.excludedMeshesIds) {
  47768. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  47769. }
  47770. if (parsedLight.includedOnlyMeshesIds) {
  47771. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  47772. }
  47773. // Parent
  47774. if (parsedLight.parentId) {
  47775. light._waitingParentId = parsedLight.parentId;
  47776. }
  47777. // Animations
  47778. if (parsedLight.animations) {
  47779. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  47780. var parsedAnimation = parsedLight.animations[animationIndex];
  47781. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  47782. if (internalClass) {
  47783. light.animations.push(internalClass.Parse(parsedAnimation));
  47784. }
  47785. }
  47786. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  47787. }
  47788. if (parsedLight.autoAnimate) {
  47789. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  47790. }
  47791. return light;
  47792. };
  47793. Light.prototype._hookArrayForExcluded = 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. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  47803. var item = items_1[_a];
  47804. item._resyncLighSource(_this);
  47805. }
  47806. return result;
  47807. };
  47808. var oldSplice = array.splice;
  47809. array.splice = function (index, deleteCount) {
  47810. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47811. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  47812. var item = deleted_1[_i];
  47813. item._resyncLighSource(_this);
  47814. }
  47815. return deleted;
  47816. };
  47817. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  47818. var item = array_1[_i];
  47819. item._resyncLighSource(this);
  47820. }
  47821. };
  47822. Light.prototype._hookArrayForIncludedOnly = function (array) {
  47823. var _this = this;
  47824. var oldPush = array.push;
  47825. array.push = function () {
  47826. var items = [];
  47827. for (var _i = 0; _i < arguments.length; _i++) {
  47828. items[_i] = arguments[_i];
  47829. }
  47830. var result = oldPush.apply(array, items);
  47831. _this._resyncMeshes();
  47832. return result;
  47833. };
  47834. var oldSplice = array.splice;
  47835. array.splice = function (index, deleteCount) {
  47836. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47837. _this._resyncMeshes();
  47838. return deleted;
  47839. };
  47840. this._resyncMeshes();
  47841. };
  47842. Light.prototype._resyncMeshes = function () {
  47843. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47844. var mesh = _a[_i];
  47845. mesh._resyncLighSource(this);
  47846. }
  47847. };
  47848. /**
  47849. * Forces the meshes to update their light related information in their rendering used effects
  47850. * @hidden Internal Use Only
  47851. */
  47852. Light.prototype._markMeshesAsLightDirty = function () {
  47853. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47854. var mesh = _a[_i];
  47855. if (mesh._lightSources.indexOf(this) !== -1) {
  47856. mesh._markSubMeshesAsLightDirty();
  47857. }
  47858. }
  47859. };
  47860. /**
  47861. * Recomputes the cached photometric scale if needed.
  47862. */
  47863. Light.prototype._computePhotometricScale = function () {
  47864. this._photometricScale = this._getPhotometricScale();
  47865. this.getScene().resetCachedMaterial();
  47866. };
  47867. /**
  47868. * Returns the Photometric Scale according to the light type and intensity mode.
  47869. */
  47870. Light.prototype._getPhotometricScale = function () {
  47871. var photometricScale = 0.0;
  47872. var lightTypeID = this.getTypeID();
  47873. //get photometric mode
  47874. var photometricMode = this.intensityMode;
  47875. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  47876. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  47877. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  47878. }
  47879. else {
  47880. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  47881. }
  47882. }
  47883. //compute photometric scale
  47884. switch (lightTypeID) {
  47885. case Light.LIGHTTYPEID_POINTLIGHT:
  47886. case Light.LIGHTTYPEID_SPOTLIGHT:
  47887. switch (photometricMode) {
  47888. case Light.INTENSITYMODE_LUMINOUSPOWER:
  47889. photometricScale = 1.0 / (4.0 * Math.PI);
  47890. break;
  47891. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  47892. photometricScale = 1.0;
  47893. break;
  47894. case Light.INTENSITYMODE_LUMINANCE:
  47895. photometricScale = this.radius * this.radius;
  47896. break;
  47897. }
  47898. break;
  47899. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  47900. switch (photometricMode) {
  47901. case Light.INTENSITYMODE_ILLUMINANCE:
  47902. photometricScale = 1.0;
  47903. break;
  47904. case Light.INTENSITYMODE_LUMINANCE:
  47905. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  47906. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  47907. var apexAngleRadians = this.radius;
  47908. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  47909. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  47910. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  47911. photometricScale = solidAngle;
  47912. break;
  47913. }
  47914. break;
  47915. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  47916. // No fall off in hemisperic light.
  47917. photometricScale = 1.0;
  47918. break;
  47919. }
  47920. return photometricScale;
  47921. };
  47922. /**
  47923. * Reorder the light in the scene according to their defined priority.
  47924. * @hidden Internal Use Only
  47925. */
  47926. Light.prototype._reorderLightsInScene = function () {
  47927. var scene = this.getScene();
  47928. if (this._renderPriority != 0) {
  47929. scene.requireLightSorting = true;
  47930. }
  47931. this.getScene().sortLightsByPriority();
  47932. };
  47933. /**
  47934. * Falloff Default: light is falling off following the material specification:
  47935. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  47936. */
  47937. Light.FALLOFF_DEFAULT = 0;
  47938. /**
  47939. * Falloff Physical: light is falling off following the inverse squared distance law.
  47940. */
  47941. Light.FALLOFF_PHYSICAL = 1;
  47942. /**
  47943. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  47944. * to enhance interoperability with other engines.
  47945. */
  47946. Light.FALLOFF_GLTF = 2;
  47947. /**
  47948. * Falloff Standard: light is falling off like in the standard material
  47949. * to enhance interoperability with other materials.
  47950. */
  47951. Light.FALLOFF_STANDARD = 3;
  47952. //lightmapMode Consts
  47953. /**
  47954. * If every light affecting the material is in this lightmapMode,
  47955. * material.lightmapTexture adds or multiplies
  47956. * (depends on material.useLightmapAsShadowmap)
  47957. * after every other light calculations.
  47958. */
  47959. Light.LIGHTMAP_DEFAULT = 0;
  47960. /**
  47961. * material.lightmapTexture as only diffuse lighting from this light
  47962. * adds only specular lighting from this light
  47963. * adds dynamic shadows
  47964. */
  47965. Light.LIGHTMAP_SPECULAR = 1;
  47966. /**
  47967. * material.lightmapTexture as only lighting
  47968. * no light calculation from this light
  47969. * only adds dynamic shadows from this light
  47970. */
  47971. Light.LIGHTMAP_SHADOWSONLY = 2;
  47972. // Intensity Mode Consts
  47973. /**
  47974. * Each light type uses the default quantity according to its type:
  47975. * point/spot lights use luminous intensity
  47976. * directional lights use illuminance
  47977. */
  47978. Light.INTENSITYMODE_AUTOMATIC = 0;
  47979. /**
  47980. * lumen (lm)
  47981. */
  47982. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  47983. /**
  47984. * candela (lm/sr)
  47985. */
  47986. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  47987. /**
  47988. * lux (lm/m^2)
  47989. */
  47990. Light.INTENSITYMODE_ILLUMINANCE = 3;
  47991. /**
  47992. * nit (cd/m^2)
  47993. */
  47994. Light.INTENSITYMODE_LUMINANCE = 4;
  47995. // Light types ids const.
  47996. /**
  47997. * Light type const id of the point light.
  47998. */
  47999. Light.LIGHTTYPEID_POINTLIGHT = 0;
  48000. /**
  48001. * Light type const id of the directional light.
  48002. */
  48003. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  48004. /**
  48005. * Light type const id of the spot light.
  48006. */
  48007. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  48008. /**
  48009. * Light type const id of the hemispheric light.
  48010. */
  48011. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  48012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  48014. ], Light.prototype, "diffuse", void 0);
  48015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  48017. ], Light.prototype, "specular", void 0);
  48018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48020. ], Light.prototype, "falloffType", void 0);
  48021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48023. ], Light.prototype, "intensity", void 0);
  48024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48026. ], Light.prototype, "range", null);
  48027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48029. ], Light.prototype, "intensityMode", null);
  48030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48032. ], Light.prototype, "radius", null);
  48033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48035. ], Light.prototype, "_renderPriority", void 0);
  48036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  48038. ], Light.prototype, "renderPriority", void 0);
  48039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  48041. ], Light.prototype, "_shadowEnabled", void 0);
  48042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  48044. ], Light.prototype, "_excludeWithLayerMask", void 0);
  48045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  48047. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  48048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  48050. ], Light.prototype, "_lightmapMode", void 0);
  48051. return Light;
  48052. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  48053. /***/ }),
  48054. /***/ "./Lights/pointLight.ts":
  48055. /*!******************************!*\
  48056. !*** ./Lights/pointLight.ts ***!
  48057. \******************************/
  48058. /*! exports provided: PointLight */
  48059. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48060. "use strict";
  48061. __webpack_require__.r(__webpack_exports__);
  48062. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  48063. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48064. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48065. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48066. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48067. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48068. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48069. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  48070. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  48071. });
  48072. /**
  48073. * A point light is a light defined by an unique point in world space.
  48074. * The light is emitted in every direction from this point.
  48075. * A good example of a point light is a standard light bulb.
  48076. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48077. */
  48078. var PointLight = /** @class */ (function (_super) {
  48079. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  48080. /**
  48081. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48082. * A PointLight emits the light in every direction.
  48083. * It can cast shadows.
  48084. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48085. * ```javascript
  48086. * var pointLight = new PointLight("pl", camera.position, scene);
  48087. * ```
  48088. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48089. * @param name The light friendly name
  48090. * @param position The position of the point light in the scene
  48091. * @param scene The scene the lights belongs to
  48092. */
  48093. function PointLight(name, position, scene) {
  48094. var _this = _super.call(this, name, scene) || this;
  48095. _this._shadowAngle = Math.PI / 2;
  48096. _this.position = position;
  48097. return _this;
  48098. }
  48099. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  48100. /**
  48101. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48102. * This specifies what angle the shadow will use to be created.
  48103. *
  48104. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48105. */
  48106. get: function () {
  48107. return this._shadowAngle;
  48108. },
  48109. /**
  48110. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48111. * This specifies what angle the shadow will use to be created.
  48112. *
  48113. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48114. */
  48115. set: function (value) {
  48116. this._shadowAngle = value;
  48117. this.forceProjectionMatrixCompute();
  48118. },
  48119. enumerable: true,
  48120. configurable: true
  48121. });
  48122. Object.defineProperty(PointLight.prototype, "direction", {
  48123. /**
  48124. * Gets the direction if it has been set.
  48125. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48126. */
  48127. get: function () {
  48128. return this._direction;
  48129. },
  48130. /**
  48131. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48132. */
  48133. set: function (value) {
  48134. var previousNeedCube = this.needCube();
  48135. this._direction = value;
  48136. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  48137. this._shadowGenerator.recreateShadowMap();
  48138. }
  48139. },
  48140. enumerable: true,
  48141. configurable: true
  48142. });
  48143. /**
  48144. * Returns the string "PointLight"
  48145. * @returns the class name
  48146. */
  48147. PointLight.prototype.getClassName = function () {
  48148. return "PointLight";
  48149. };
  48150. /**
  48151. * Returns the integer 0.
  48152. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48153. */
  48154. PointLight.prototype.getTypeID = function () {
  48155. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  48156. };
  48157. /**
  48158. * Specifies wether or not the shadowmap should be a cube texture.
  48159. * @returns true if the shadowmap needs to be a cube texture.
  48160. */
  48161. PointLight.prototype.needCube = function () {
  48162. return !this.direction;
  48163. };
  48164. /**
  48165. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48166. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48167. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48168. */
  48169. PointLight.prototype.getShadowDirection = function (faceIndex) {
  48170. if (this.direction) {
  48171. return _super.prototype.getShadowDirection.call(this, faceIndex);
  48172. }
  48173. else {
  48174. switch (faceIndex) {
  48175. case 0:
  48176. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  48177. case 1:
  48178. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  48179. case 2:
  48180. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  48181. case 3:
  48182. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  48183. case 4:
  48184. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  48185. case 5:
  48186. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  48187. }
  48188. }
  48189. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48190. };
  48191. /**
  48192. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48193. * - fov = PI / 2
  48194. * - aspect ratio : 1.0
  48195. * - z-near and far equal to the active camera minZ and maxZ.
  48196. * Returns the PointLight.
  48197. */
  48198. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48199. var activeCamera = this.getScene().activeCamera;
  48200. if (!activeCamera) {
  48201. return;
  48202. }
  48203. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48204. };
  48205. PointLight.prototype._buildUniformLayout = function () {
  48206. this._uniformBuffer.addUniform("vLightData", 4);
  48207. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48208. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48209. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48210. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48211. this._uniformBuffer.addUniform("depthValues", 2);
  48212. this._uniformBuffer.create();
  48213. };
  48214. /**
  48215. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48216. * @param effect The effect to update
  48217. * @param lightIndex The index of the light in the effect to update
  48218. * @returns The point light
  48219. */
  48220. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  48221. if (this.computeTransformedInformation()) {
  48222. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  48223. }
  48224. else {
  48225. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  48226. }
  48227. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  48228. return this;
  48229. };
  48230. /**
  48231. * Prepares the list of defines specific to the light type.
  48232. * @param defines the list of defines
  48233. * @param lightIndex defines the index of the light for the effect
  48234. */
  48235. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48236. defines["POINTLIGHT" + lightIndex] = true;
  48237. };
  48238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48240. ], PointLight.prototype, "shadowAngle", null);
  48241. return PointLight;
  48242. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48243. /***/ }),
  48244. /***/ "./Lights/shadowLight.ts":
  48245. /*!*******************************!*\
  48246. !*** ./Lights/shadowLight.ts ***!
  48247. \*******************************/
  48248. /*! exports provided: ShadowLight */
  48249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48250. "use strict";
  48251. __webpack_require__.r(__webpack_exports__);
  48252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  48253. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48254. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48255. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48256. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48257. /**
  48258. * Base implementation IShadowLight
  48259. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  48260. */
  48261. var ShadowLight = /** @class */ (function (_super) {
  48262. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  48263. function ShadowLight() {
  48264. var _this = _super !== null && _super.apply(this, arguments) || this;
  48265. _this._needProjectionMatrixCompute = true;
  48266. return _this;
  48267. }
  48268. ShadowLight.prototype._setPosition = function (value) {
  48269. this._position = value;
  48270. };
  48271. Object.defineProperty(ShadowLight.prototype, "position", {
  48272. /**
  48273. * Sets the position the shadow will be casted from. Also use as the light position for both
  48274. * point and spot lights.
  48275. */
  48276. get: function () {
  48277. return this._position;
  48278. },
  48279. /**
  48280. * Sets the position the shadow will be casted from. Also use as the light position for both
  48281. * point and spot lights.
  48282. */
  48283. set: function (value) {
  48284. this._setPosition(value);
  48285. },
  48286. enumerable: true,
  48287. configurable: true
  48288. });
  48289. ShadowLight.prototype._setDirection = function (value) {
  48290. this._direction = value;
  48291. };
  48292. Object.defineProperty(ShadowLight.prototype, "direction", {
  48293. /**
  48294. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  48295. * Also use as the light direction on spot and directional lights.
  48296. */
  48297. get: function () {
  48298. return this._direction;
  48299. },
  48300. /**
  48301. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  48302. * Also use as the light direction on spot and directional lights.
  48303. */
  48304. set: function (value) {
  48305. this._setDirection(value);
  48306. },
  48307. enumerable: true,
  48308. configurable: true
  48309. });
  48310. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  48311. /**
  48312. * Gets the shadow projection clipping minimum z value.
  48313. */
  48314. get: function () {
  48315. return this._shadowMinZ;
  48316. },
  48317. /**
  48318. * Sets the shadow projection clipping minimum z value.
  48319. */
  48320. set: function (value) {
  48321. this._shadowMinZ = value;
  48322. this.forceProjectionMatrixCompute();
  48323. },
  48324. enumerable: true,
  48325. configurable: true
  48326. });
  48327. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  48328. /**
  48329. * Sets the shadow projection clipping maximum z value.
  48330. */
  48331. get: function () {
  48332. return this._shadowMaxZ;
  48333. },
  48334. /**
  48335. * Gets the shadow projection clipping maximum z value.
  48336. */
  48337. set: function (value) {
  48338. this._shadowMaxZ = value;
  48339. this.forceProjectionMatrixCompute();
  48340. },
  48341. enumerable: true,
  48342. configurable: true
  48343. });
  48344. /**
  48345. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  48346. * @returns true if the information has been computed, false if it does not need to (no parenting)
  48347. */
  48348. ShadowLight.prototype.computeTransformedInformation = function () {
  48349. if (this.parent && this.parent.getWorldMatrix) {
  48350. if (!this.transformedPosition) {
  48351. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48352. }
  48353. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  48354. // In case the direction is present.
  48355. if (this.direction) {
  48356. if (!this.transformedDirection) {
  48357. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48358. }
  48359. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  48360. }
  48361. return true;
  48362. }
  48363. return false;
  48364. };
  48365. /**
  48366. * Return the depth scale used for the shadow map.
  48367. * @returns the depth scale.
  48368. */
  48369. ShadowLight.prototype.getDepthScale = function () {
  48370. return 50.0;
  48371. };
  48372. /**
  48373. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  48374. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48375. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48376. */
  48377. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  48378. return this.transformedDirection ? this.transformedDirection : this.direction;
  48379. };
  48380. /**
  48381. * Returns the ShadowLight absolute position in the World.
  48382. * @returns the position vector in world space
  48383. */
  48384. ShadowLight.prototype.getAbsolutePosition = function () {
  48385. return this.transformedPosition ? this.transformedPosition : this.position;
  48386. };
  48387. /**
  48388. * Sets the ShadowLight direction toward the passed target.
  48389. * @param target The point to target in local space
  48390. * @returns the updated ShadowLight direction
  48391. */
  48392. ShadowLight.prototype.setDirectionToTarget = function (target) {
  48393. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  48394. return this.direction;
  48395. };
  48396. /**
  48397. * Returns the light rotation in euler definition.
  48398. * @returns the x y z rotation in local space.
  48399. */
  48400. ShadowLight.prototype.getRotation = function () {
  48401. this.direction.normalize();
  48402. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  48403. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  48404. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  48405. };
  48406. /**
  48407. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  48408. * @returns true if a cube texture needs to be use
  48409. */
  48410. ShadowLight.prototype.needCube = function () {
  48411. return false;
  48412. };
  48413. /**
  48414. * Detects if the projection matrix requires to be recomputed this frame.
  48415. * @returns true if it requires to be recomputed otherwise, false.
  48416. */
  48417. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  48418. return this._needProjectionMatrixCompute;
  48419. };
  48420. /**
  48421. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  48422. */
  48423. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  48424. this._needProjectionMatrixCompute = true;
  48425. };
  48426. /** @hidden */
  48427. ShadowLight.prototype._initCache = function () {
  48428. _super.prototype._initCache.call(this);
  48429. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48430. };
  48431. /** @hidden */
  48432. ShadowLight.prototype._isSynchronized = function () {
  48433. if (!this._cache.position.equals(this.position)) {
  48434. return false;
  48435. }
  48436. return true;
  48437. };
  48438. /**
  48439. * Computes the world matrix of the node
  48440. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  48441. * @returns the world matrix
  48442. */
  48443. ShadowLight.prototype.computeWorldMatrix = function (force) {
  48444. if (!force && this.isSynchronized()) {
  48445. this._currentRenderId = this.getScene().getRenderId();
  48446. return this._worldMatrix;
  48447. }
  48448. this._updateCache();
  48449. this._cache.position.copyFrom(this.position);
  48450. if (!this._worldMatrix) {
  48451. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  48452. }
  48453. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  48454. if (this.parent && this.parent.getWorldMatrix) {
  48455. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  48456. this._markSyncedWithParent();
  48457. }
  48458. // Cache the determinant
  48459. this._worldMatrixDeterminantIsDirty = true;
  48460. return this._worldMatrix;
  48461. };
  48462. /**
  48463. * Gets the minZ used for shadow according to both the scene and the light.
  48464. * @param activeCamera The camera we are returning the min for
  48465. * @returns the depth min z
  48466. */
  48467. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  48468. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  48469. };
  48470. /**
  48471. * Gets the maxZ used for shadow according to both the scene and the light.
  48472. * @param activeCamera The camera we are returning the max for
  48473. * @returns the depth max z
  48474. */
  48475. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  48476. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  48477. };
  48478. /**
  48479. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  48480. * @param matrix The materix to updated with the projection information
  48481. * @param viewMatrix The transform matrix of the light
  48482. * @param renderList The list of mesh to render in the map
  48483. * @returns The current light
  48484. */
  48485. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48486. if (this.customProjectionMatrixBuilder) {
  48487. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  48488. }
  48489. else {
  48490. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  48491. }
  48492. return this;
  48493. };
  48494. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48495. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48496. ], ShadowLight.prototype, "position", null);
  48497. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48498. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48499. ], ShadowLight.prototype, "direction", null);
  48500. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48501. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48502. ], ShadowLight.prototype, "shadowMinZ", null);
  48503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48505. ], ShadowLight.prototype, "shadowMaxZ", null);
  48506. return ShadowLight;
  48507. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  48508. /***/ }),
  48509. /***/ "./Lights/spotLight.ts":
  48510. /*!*****************************!*\
  48511. !*** ./Lights/spotLight.ts ***!
  48512. \*****************************/
  48513. /*! exports provided: SpotLight */
  48514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48515. "use strict";
  48516. __webpack_require__.r(__webpack_exports__);
  48517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  48518. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48519. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48520. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48521. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48522. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48523. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48524. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  48525. 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); };
  48526. });
  48527. /**
  48528. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48529. * These values define a cone of light starting from the position, emitting toward the direction.
  48530. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48531. * and the exponent defines the speed of the decay of the light with distance (reach).
  48532. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48533. */
  48534. var SpotLight = /** @class */ (function (_super) {
  48535. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  48536. /**
  48537. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48538. * It can cast shadows.
  48539. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48540. * @param name The light friendly name
  48541. * @param position The position of the spot light in the scene
  48542. * @param direction The direction of the light in the scene
  48543. * @param angle The cone angle of the light in Radians
  48544. * @param exponent The light decay speed with the distance from the emission spot
  48545. * @param scene The scene the lights belongs to
  48546. */
  48547. function SpotLight(name, position, direction, angle, exponent, scene) {
  48548. var _this = _super.call(this, name, scene) || this;
  48549. _this._innerAngle = 0;
  48550. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48551. _this._projectionTextureLightNear = 1e-6;
  48552. _this._projectionTextureLightFar = 1000.0;
  48553. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  48554. _this._projectionTextureViewLightDirty = true;
  48555. _this._projectionTextureProjectionLightDirty = true;
  48556. _this._projectionTextureDirty = true;
  48557. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48558. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48559. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48560. _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);
  48561. _this.position = position;
  48562. _this.direction = direction;
  48563. _this.angle = angle;
  48564. _this.exponent = exponent;
  48565. return _this;
  48566. }
  48567. Object.defineProperty(SpotLight.prototype, "angle", {
  48568. /**
  48569. * Gets the cone angle of the spot light in Radians.
  48570. */
  48571. get: function () {
  48572. return this._angle;
  48573. },
  48574. /**
  48575. * Sets the cone angle of the spot light in Radians.
  48576. */
  48577. set: function (value) {
  48578. this._angle = value;
  48579. this._cosHalfAngle = Math.cos(value * 0.5);
  48580. this._projectionTextureProjectionLightDirty = true;
  48581. this.forceProjectionMatrixCompute();
  48582. this._computeAngleValues();
  48583. },
  48584. enumerable: true,
  48585. configurable: true
  48586. });
  48587. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  48588. /**
  48589. * Only used in gltf falloff mode, this defines the angle where
  48590. * the directional falloff will start before cutting at angle which could be seen
  48591. * as outer angle.
  48592. */
  48593. get: function () {
  48594. return this._innerAngle;
  48595. },
  48596. /**
  48597. * Only used in gltf falloff mode, this defines the angle where
  48598. * the directional falloff will start before cutting at angle which could be seen
  48599. * as outer angle.
  48600. */
  48601. set: function (value) {
  48602. this._innerAngle = value;
  48603. this._computeAngleValues();
  48604. },
  48605. enumerable: true,
  48606. configurable: true
  48607. });
  48608. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  48609. /**
  48610. * Allows scaling the angle of the light for shadow generation only.
  48611. */
  48612. get: function () {
  48613. return this._shadowAngleScale;
  48614. },
  48615. /**
  48616. * Allows scaling the angle of the light for shadow generation only.
  48617. */
  48618. set: function (value) {
  48619. this._shadowAngleScale = value;
  48620. this.forceProjectionMatrixCompute();
  48621. },
  48622. enumerable: true,
  48623. configurable: true
  48624. });
  48625. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  48626. /**
  48627. * Allows reading the projecton texture
  48628. */
  48629. get: function () {
  48630. return this._projectionTextureMatrix;
  48631. },
  48632. enumerable: true,
  48633. configurable: true
  48634. });
  48635. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  48636. /**
  48637. * Gets the near clip of the Spotlight for texture projection.
  48638. */
  48639. get: function () {
  48640. return this._projectionTextureLightNear;
  48641. },
  48642. /**
  48643. * Sets the near clip of the Spotlight for texture projection.
  48644. */
  48645. set: function (value) {
  48646. this._projectionTextureLightNear = value;
  48647. this._projectionTextureProjectionLightDirty = true;
  48648. },
  48649. enumerable: true,
  48650. configurable: true
  48651. });
  48652. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  48653. /**
  48654. * Gets the far clip of the Spotlight for texture projection.
  48655. */
  48656. get: function () {
  48657. return this._projectionTextureLightFar;
  48658. },
  48659. /**
  48660. * Sets the far clip of the Spotlight for texture projection.
  48661. */
  48662. set: function (value) {
  48663. this._projectionTextureLightFar = value;
  48664. this._projectionTextureProjectionLightDirty = true;
  48665. },
  48666. enumerable: true,
  48667. configurable: true
  48668. });
  48669. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  48670. /**
  48671. * Gets the Up vector of the Spotlight for texture projection.
  48672. */
  48673. get: function () {
  48674. return this._projectionTextureUpDirection;
  48675. },
  48676. /**
  48677. * Sets the Up vector of the Spotlight for texture projection.
  48678. */
  48679. set: function (value) {
  48680. this._projectionTextureUpDirection = value;
  48681. this._projectionTextureProjectionLightDirty = true;
  48682. },
  48683. enumerable: true,
  48684. configurable: true
  48685. });
  48686. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  48687. /**
  48688. * Gets the projection texture of the light.
  48689. */
  48690. get: function () {
  48691. return this._projectionTexture;
  48692. },
  48693. /**
  48694. * Sets the projection texture of the light.
  48695. */
  48696. set: function (value) {
  48697. this._projectionTexture = value;
  48698. this._projectionTextureDirty = true;
  48699. },
  48700. enumerable: true,
  48701. configurable: true
  48702. });
  48703. /**
  48704. * Returns the string "SpotLight".
  48705. * @returns the class name
  48706. */
  48707. SpotLight.prototype.getClassName = function () {
  48708. return "SpotLight";
  48709. };
  48710. /**
  48711. * Returns the integer 2.
  48712. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48713. */
  48714. SpotLight.prototype.getTypeID = function () {
  48715. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  48716. };
  48717. /**
  48718. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48719. */
  48720. SpotLight.prototype._setDirection = function (value) {
  48721. _super.prototype._setDirection.call(this, value);
  48722. this._projectionTextureViewLightDirty = true;
  48723. };
  48724. /**
  48725. * Overrides the position setter to recompute the projection texture view light Matrix.
  48726. */
  48727. SpotLight.prototype._setPosition = function (value) {
  48728. _super.prototype._setPosition.call(this, value);
  48729. this._projectionTextureViewLightDirty = true;
  48730. };
  48731. /**
  48732. * 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.
  48733. * Returns the SpotLight.
  48734. */
  48735. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48736. var activeCamera = this.getScene().activeCamera;
  48737. if (!activeCamera) {
  48738. return;
  48739. }
  48740. this._shadowAngleScale = this._shadowAngleScale || 1;
  48741. var angle = this._shadowAngleScale * this._angle;
  48742. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48743. };
  48744. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  48745. this._projectionTextureViewLightDirty = false;
  48746. this._projectionTextureDirty = true;
  48747. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  48748. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  48749. };
  48750. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  48751. this._projectionTextureProjectionLightDirty = false;
  48752. this._projectionTextureDirty = true;
  48753. var light_far = this.projectionTextureLightFar;
  48754. var light_near = this.projectionTextureLightNear;
  48755. var P = light_far / (light_far - light_near);
  48756. var Q = -P * light_near;
  48757. var S = 1.0 / Math.tan(this._angle / 2.0);
  48758. var A = 1.0;
  48759. _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);
  48760. };
  48761. /**
  48762. * Main function for light texture projection matrix computing.
  48763. */
  48764. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  48765. this._projectionTextureDirty = false;
  48766. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  48767. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  48768. };
  48769. SpotLight.prototype._buildUniformLayout = function () {
  48770. this._uniformBuffer.addUniform("vLightData", 4);
  48771. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48772. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48773. this._uniformBuffer.addUniform("vLightDirection", 3);
  48774. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48775. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48776. this._uniformBuffer.addUniform("depthValues", 2);
  48777. this._uniformBuffer.create();
  48778. };
  48779. SpotLight.prototype._computeAngleValues = function () {
  48780. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  48781. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  48782. };
  48783. /**
  48784. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48785. * @param effect The effect to update
  48786. * @param lightIndex The index of the light in the effect to update
  48787. * @returns The spot light
  48788. */
  48789. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  48790. var normalizeDirection;
  48791. if (this.computeTransformedInformation()) {
  48792. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  48793. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  48794. }
  48795. else {
  48796. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  48797. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  48798. }
  48799. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  48800. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  48801. if (this.projectionTexture && this.projectionTexture.isReady()) {
  48802. if (this._projectionTextureViewLightDirty) {
  48803. this._computeProjectionTextureViewLightMatrix();
  48804. }
  48805. if (this._projectionTextureProjectionLightDirty) {
  48806. this._computeProjectionTextureProjectionLightMatrix();
  48807. }
  48808. if (this._projectionTextureDirty) {
  48809. this._computeProjectionTextureMatrix();
  48810. }
  48811. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  48812. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  48813. }
  48814. return this;
  48815. };
  48816. /**
  48817. * Disposes the light and the associated resources.
  48818. */
  48819. SpotLight.prototype.dispose = function () {
  48820. _super.prototype.dispose.call(this);
  48821. if (this._projectionTexture) {
  48822. this._projectionTexture.dispose();
  48823. }
  48824. };
  48825. /**
  48826. * Prepares the list of defines specific to the light type.
  48827. * @param defines the list of defines
  48828. * @param lightIndex defines the index of the light for the effect
  48829. */
  48830. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48831. defines["SPOTLIGHT" + lightIndex] = true;
  48832. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  48833. };
  48834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48836. ], SpotLight.prototype, "angle", null);
  48837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48839. ], SpotLight.prototype, "innerAngle", null);
  48840. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48842. ], SpotLight.prototype, "shadowAngleScale", null);
  48843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48845. ], SpotLight.prototype, "exponent", void 0);
  48846. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48847. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48848. ], SpotLight.prototype, "projectionTextureLightNear", null);
  48849. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48851. ], SpotLight.prototype, "projectionTextureLightFar", null);
  48852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48854. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  48855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  48857. ], SpotLight.prototype, "_projectionTexture", void 0);
  48858. return SpotLight;
  48859. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48860. /***/ }),
  48861. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  48862. /*!**********************************************!*\
  48863. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  48864. \**********************************************/
  48865. /*! exports provided: _BabylonLoaderRegistered */
  48866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48867. "use strict";
  48868. __webpack_require__.r(__webpack_exports__);
  48869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  48870. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48871. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  48872. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48873. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  48874. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  48875. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  48876. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  48877. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  48878. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  48879. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  48880. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  48881. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  48882. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  48883. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  48884. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  48885. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  48886. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  48887. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  48888. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  48889. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  48890. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  48891. /* harmony import */ var _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Physics/Plugins/ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  48892. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  48893. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48894. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  48895. /** @hidden */
  48896. var _BabylonLoaderRegistered = true;
  48897. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  48898. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48899. var parsedMaterial = parsedData.materials[index];
  48900. if (parsedMaterial.id === id) {
  48901. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48902. }
  48903. }
  48904. return null;
  48905. };
  48906. var isDescendantOf = function (mesh, names, hierarchyIds) {
  48907. for (var i in names) {
  48908. if (mesh.name === names[i]) {
  48909. hierarchyIds.push(mesh.id);
  48910. return true;
  48911. }
  48912. }
  48913. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  48914. hierarchyIds.push(mesh.id);
  48915. return true;
  48916. }
  48917. return false;
  48918. };
  48919. var logOperation = function (operation, producer) {
  48920. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  48921. };
  48922. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  48923. if (addToScene === void 0) { addToScene = false; }
  48924. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  48925. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48926. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48927. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48928. // and avoid problems with multiple concurrent .babylon loads.
  48929. var log = "importScene has failed JSON parse";
  48930. try {
  48931. var parsedData = JSON.parse(data);
  48932. log = "";
  48933. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48934. var index;
  48935. var cache;
  48936. // Environment texture
  48937. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48938. // PBR needed for both HDR texture (gamma space) & a sky box
  48939. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48940. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48941. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48942. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48943. if (parsedData.environmentTextureRotationY) {
  48944. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48945. }
  48946. scene.environmentTexture = hdrTexture;
  48947. }
  48948. else {
  48949. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  48950. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  48951. if (parsedData.environmentTextureRotationY) {
  48952. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  48953. }
  48954. scene.environmentTexture = compressedTexture;
  48955. }
  48956. else {
  48957. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  48958. if (parsedData.environmentTextureRotationY) {
  48959. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48960. }
  48961. scene.environmentTexture = cubeTexture;
  48962. }
  48963. }
  48964. if (parsedData.createDefaultSkybox === true) {
  48965. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48966. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48967. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48968. }
  48969. container.environmentTexture = scene.environmentTexture;
  48970. }
  48971. // Lights
  48972. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  48973. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  48974. var parsedLight = parsedData.lights[index];
  48975. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  48976. if (light) {
  48977. container.lights.push(light);
  48978. log += (index === 0 ? "\n\tLights:" : "");
  48979. log += "\n\t\t" + light.toString(fullDetails);
  48980. }
  48981. }
  48982. }
  48983. // Reflection probes
  48984. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  48985. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  48986. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  48987. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  48988. if (reflectionProbe) {
  48989. container.reflectionProbes.push(reflectionProbe);
  48990. log += (index === 0 ? "\n\tReflection Probes:" : "");
  48991. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  48992. }
  48993. }
  48994. }
  48995. // Animations
  48996. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  48997. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  48998. var parsedAnimation = parsedData.animations[index];
  48999. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__["_TypeStore"].GetClass("BABYLON.Animation");
  49000. if (internalClass) {
  49001. var animation = internalClass.Parse(parsedAnimation);
  49002. scene.animations.push(animation);
  49003. container.animations.push(animation);
  49004. log += (index === 0 ? "\n\tAnimations:" : "");
  49005. log += "\n\t\t" + animation.toString(fullDetails);
  49006. }
  49007. }
  49008. }
  49009. // Materials
  49010. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  49011. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  49012. var parsedMaterial = parsedData.materials[index];
  49013. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  49014. if (mat) {
  49015. container.materials.push(mat);
  49016. log += (index === 0 ? "\n\tMaterials:" : "");
  49017. log += "\n\t\t" + mat.toString(fullDetails);
  49018. // Textures
  49019. var textures = mat.getActiveTextures();
  49020. textures.forEach(function (t) {
  49021. if (container.textures.indexOf(t) == -1) {
  49022. container.textures.push(t);
  49023. }
  49024. });
  49025. }
  49026. }
  49027. }
  49028. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  49029. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  49030. var parsedMultiMaterial = parsedData.multiMaterials[index];
  49031. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  49032. container.multiMaterials.push(mmat);
  49033. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  49034. log += "\n\t\t" + mmat.toString(fullDetails);
  49035. // Textures
  49036. var textures = mmat.getActiveTextures();
  49037. textures.forEach(function (t) {
  49038. if (container.textures.indexOf(t) == -1) {
  49039. container.textures.push(t);
  49040. }
  49041. });
  49042. }
  49043. }
  49044. // Morph targets
  49045. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  49046. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  49047. var managerData = _a[_i];
  49048. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  49049. }
  49050. }
  49051. // Skeletons
  49052. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  49053. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  49054. var parsedSkeleton = parsedData.skeletons[index];
  49055. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  49056. container.skeletons.push(skeleton);
  49057. log += (index === 0 ? "\n\tSkeletons:" : "");
  49058. log += "\n\t\t" + skeleton.toString(fullDetails);
  49059. }
  49060. }
  49061. // Geometries
  49062. var geometries = parsedData.geometries;
  49063. if (geometries !== undefined && geometries !== null) {
  49064. var addedGeometry = new Array();
  49065. // VertexData
  49066. var vertexData = geometries.vertexData;
  49067. if (vertexData !== undefined && vertexData !== null) {
  49068. for (index = 0, cache = vertexData.length; index < cache; index++) {
  49069. var parsedVertexData = vertexData[index];
  49070. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  49071. }
  49072. }
  49073. addedGeometry.forEach(function (g) {
  49074. if (g) {
  49075. container.geometries.push(g);
  49076. }
  49077. });
  49078. }
  49079. // Transform nodes
  49080. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  49081. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  49082. var parsedTransformNode = parsedData.transformNodes[index];
  49083. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  49084. container.transformNodes.push(node);
  49085. }
  49086. }
  49087. // Meshes
  49088. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  49089. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  49090. var parsedMesh = parsedData.meshes[index];
  49091. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  49092. container.meshes.push(mesh);
  49093. log += (index === 0 ? "\n\tMeshes:" : "");
  49094. log += "\n\t\t" + mesh.toString(fullDetails);
  49095. }
  49096. }
  49097. // Cameras
  49098. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  49099. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  49100. var parsedCamera = parsedData.cameras[index];
  49101. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  49102. container.cameras.push(camera);
  49103. log += (index === 0 ? "\n\tCameras:" : "");
  49104. log += "\n\t\t" + camera.toString(fullDetails);
  49105. }
  49106. }
  49107. // Animation Groups
  49108. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  49109. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  49110. var parsedAnimationGroup = parsedData.animationGroups[index];
  49111. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  49112. container.animationGroups.push(animationGroup);
  49113. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  49114. log += "\n\t\t" + animationGroup.toString(fullDetails);
  49115. }
  49116. }
  49117. // Browsing all the graph to connect the dots
  49118. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  49119. var camera = scene.cameras[index];
  49120. if (camera._waitingParentId) {
  49121. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  49122. camera._waitingParentId = null;
  49123. }
  49124. }
  49125. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  49126. var light_1 = scene.lights[index];
  49127. if (light_1 && light_1._waitingParentId) {
  49128. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  49129. light_1._waitingParentId = null;
  49130. }
  49131. }
  49132. // Connect parents & children and parse actions
  49133. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  49134. var transformNode = scene.transformNodes[index];
  49135. if (transformNode._waitingParentId) {
  49136. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  49137. transformNode._waitingParentId = null;
  49138. }
  49139. }
  49140. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49141. var mesh = scene.meshes[index];
  49142. if (mesh._waitingParentId) {
  49143. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  49144. mesh._waitingParentId = null;
  49145. }
  49146. }
  49147. // freeze world matrix application
  49148. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49149. var currentMesh = scene.meshes[index];
  49150. if (currentMesh._waitingFreezeWorldMatrix) {
  49151. currentMesh.freezeWorldMatrix();
  49152. currentMesh._waitingFreezeWorldMatrix = null;
  49153. }
  49154. else {
  49155. currentMesh.computeWorldMatrix(true);
  49156. }
  49157. }
  49158. // Lights exclusions / inclusions
  49159. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  49160. var light_2 = scene.lights[index];
  49161. // Excluded check
  49162. if (light_2._excludedMeshesIds.length > 0) {
  49163. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  49164. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  49165. if (excludedMesh) {
  49166. light_2.excludedMeshes.push(excludedMesh);
  49167. }
  49168. }
  49169. light_2._excludedMeshesIds = [];
  49170. }
  49171. // Included check
  49172. if (light_2._includedOnlyMeshesIds.length > 0) {
  49173. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  49174. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  49175. if (includedOnlyMesh) {
  49176. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  49177. }
  49178. }
  49179. light_2._includedOnlyMeshesIds = [];
  49180. }
  49181. }
  49182. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  49183. // Actions (scene) Done last as it can access other objects.
  49184. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49185. var mesh = scene.meshes[index];
  49186. if (mesh._waitingActions) {
  49187. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  49188. mesh._waitingActions = null;
  49189. }
  49190. }
  49191. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  49192. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  49193. }
  49194. if (!addToScene) {
  49195. container.removeAllFromScene();
  49196. }
  49197. }
  49198. catch (err) {
  49199. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  49200. if (onError) {
  49201. onError(msg, err);
  49202. }
  49203. else {
  49204. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49205. throw err;
  49206. }
  49207. }
  49208. finally {
  49209. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49210. _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 : ""));
  49211. }
  49212. }
  49213. return container;
  49214. };
  49215. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  49216. name: "babylon.js",
  49217. extensions: ".babylon",
  49218. canDirectLoad: function (data) {
  49219. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  49220. return true;
  49221. }
  49222. return false;
  49223. },
  49224. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  49225. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49226. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49227. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49228. // and avoid problems with multiple concurrent .babylon loads.
  49229. var log = "importMesh has failed JSON parse";
  49230. try {
  49231. var parsedData = JSON.parse(data);
  49232. log = "";
  49233. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  49234. if (!meshesNames) {
  49235. meshesNames = null;
  49236. }
  49237. else if (!Array.isArray(meshesNames)) {
  49238. meshesNames = [meshesNames];
  49239. }
  49240. var hierarchyIds = new Array();
  49241. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  49242. var loadedSkeletonsIds = [];
  49243. var loadedMaterialsIds = [];
  49244. var index;
  49245. var cache;
  49246. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  49247. var parsedMesh = parsedData.meshes[index];
  49248. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  49249. if (meshesNames !== null) {
  49250. // Remove found mesh name from list.
  49251. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  49252. }
  49253. //Geometry?
  49254. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  49255. //does the file contain geometries?
  49256. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  49257. //find the correct geometry and add it to the scene
  49258. var found = false;
  49259. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  49260. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  49261. return;
  49262. }
  49263. else {
  49264. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  49265. if (parsedGeometryData.id === parsedMesh.geometryId) {
  49266. switch (geometryType) {
  49267. case "vertexData":
  49268. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  49269. break;
  49270. }
  49271. found = true;
  49272. }
  49273. });
  49274. }
  49275. });
  49276. if (found === false) {
  49277. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  49278. }
  49279. }
  49280. }
  49281. // Material ?
  49282. if (parsedMesh.materialId) {
  49283. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  49284. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  49285. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  49286. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  49287. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  49288. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  49289. var subMatId = parsedMultiMaterial.materials[matIndex];
  49290. loadedMaterialsIds.push(subMatId);
  49291. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  49292. if (mat) {
  49293. log += "\n\tMaterial " + mat.toString(fullDetails);
  49294. }
  49295. }
  49296. loadedMaterialsIds.push(parsedMultiMaterial.id);
  49297. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  49298. if (mmat) {
  49299. materialFound = true;
  49300. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  49301. }
  49302. break;
  49303. }
  49304. }
  49305. }
  49306. if (materialFound === false) {
  49307. loadedMaterialsIds.push(parsedMesh.materialId);
  49308. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  49309. if (!mat) {
  49310. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  49311. }
  49312. else {
  49313. log += "\n\tMaterial " + mat.toString(fullDetails);
  49314. }
  49315. }
  49316. }
  49317. // Skeleton ?
  49318. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  49319. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  49320. if (skeletonAlreadyLoaded === false) {
  49321. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  49322. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  49323. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  49324. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  49325. skeletons.push(skeleton);
  49326. loadedSkeletonsIds.push(parsedSkeleton.id);
  49327. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  49328. }
  49329. }
  49330. }
  49331. }
  49332. // Morph targets ?
  49333. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  49334. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  49335. var managerData = _a[_i];
  49336. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  49337. }
  49338. }
  49339. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  49340. meshes.push(mesh);
  49341. log += "\n\tMesh " + mesh.toString(fullDetails);
  49342. }
  49343. }
  49344. // Connecting parents
  49345. var currentMesh;
  49346. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49347. currentMesh = scene.meshes[index];
  49348. if (currentMesh._waitingParentId) {
  49349. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  49350. currentMesh._waitingParentId = null;
  49351. }
  49352. }
  49353. // freeze and compute world matrix application
  49354. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49355. currentMesh = scene.meshes[index];
  49356. if (currentMesh._waitingFreezeWorldMatrix) {
  49357. currentMesh.freezeWorldMatrix();
  49358. currentMesh._waitingFreezeWorldMatrix = null;
  49359. }
  49360. else {
  49361. currentMesh.computeWorldMatrix(true);
  49362. }
  49363. }
  49364. }
  49365. // Particles
  49366. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  49367. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  49368. if (parser) {
  49369. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  49370. var parsedParticleSystem = parsedData.particleSystems[index];
  49371. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  49372. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  49373. }
  49374. }
  49375. }
  49376. }
  49377. return true;
  49378. }
  49379. catch (err) {
  49380. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  49381. if (onError) {
  49382. onError(msg, err);
  49383. }
  49384. else {
  49385. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49386. throw err;
  49387. }
  49388. }
  49389. finally {
  49390. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49391. _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 : ""));
  49392. }
  49393. }
  49394. return false;
  49395. },
  49396. load: function (scene, data, rootUrl, onError) {
  49397. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49398. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49399. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49400. // and avoid problems with multiple concurrent .babylon loads.
  49401. var log = "importScene has failed JSON parse";
  49402. try {
  49403. var parsedData = JSON.parse(data);
  49404. log = "";
  49405. // Scene
  49406. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  49407. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  49408. }
  49409. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  49410. scene.autoClear = parsedData.autoClear;
  49411. }
  49412. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  49413. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  49414. }
  49415. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  49416. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  49417. }
  49418. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  49419. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  49420. }
  49421. // Fog
  49422. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  49423. scene.fogMode = parsedData.fogMode;
  49424. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  49425. scene.fogStart = parsedData.fogStart;
  49426. scene.fogEnd = parsedData.fogEnd;
  49427. scene.fogDensity = parsedData.fogDensity;
  49428. log += "\tFog mode for scene: ";
  49429. switch (scene.fogMode) {
  49430. // getters not compiling, so using hardcoded
  49431. case 1:
  49432. log += "exp\n";
  49433. break;
  49434. case 2:
  49435. log += "exp2\n";
  49436. break;
  49437. case 3:
  49438. log += "linear\n";
  49439. break;
  49440. }
  49441. }
  49442. //Physics
  49443. if (parsedData.physicsEnabled) {
  49444. var physicsPlugin;
  49445. if (parsedData.physicsEngine === "cannon") {
  49446. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  49447. }
  49448. else if (parsedData.physicsEngine === "oimo") {
  49449. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  49450. }
  49451. else if (parsedData.physicsEngine === "ammo") {
  49452. physicsPlugin = new _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__["AmmoJSPlugin"]();
  49453. }
  49454. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  49455. //else - default engine, which is currently oimo
  49456. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  49457. scene.enablePhysics(physicsGravity, physicsPlugin);
  49458. }
  49459. // Metadata
  49460. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  49461. scene.metadata = parsedData.metadata;
  49462. }
  49463. //collisions, if defined. otherwise, default is true
  49464. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  49465. scene.collisionsEnabled = parsedData.collisionsEnabled;
  49466. }
  49467. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  49468. if (!container) {
  49469. return false;
  49470. }
  49471. if (parsedData.autoAnimate) {
  49472. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  49473. }
  49474. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  49475. scene.setActiveCameraByID(parsedData.activeCameraID);
  49476. }
  49477. // Environment texture
  49478. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  49479. // PBR needed for both HDR texture (gamma space) & a sky box
  49480. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  49481. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  49482. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  49483. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  49484. if (parsedData.environmentTextureRotationY) {
  49485. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  49486. }
  49487. scene.environmentTexture = hdrTexture;
  49488. }
  49489. else {
  49490. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  49491. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](rootUrl + parsedData.environmentTexture, scene);
  49492. if (parsedData.environmentTextureRotationY) {
  49493. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  49494. }
  49495. scene.environmentTexture = compressedTexture;
  49496. }
  49497. else {
  49498. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  49499. if (parsedData.environmentTextureRotationY) {
  49500. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  49501. }
  49502. scene.environmentTexture = cubeTexture;
  49503. }
  49504. }
  49505. if (parsedData.createDefaultSkybox === true) {
  49506. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  49507. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  49508. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  49509. }
  49510. }
  49511. // Finish
  49512. return true;
  49513. }
  49514. catch (err) {
  49515. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  49516. if (onError) {
  49517. onError(msg, err);
  49518. }
  49519. else {
  49520. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49521. throw err;
  49522. }
  49523. }
  49524. finally {
  49525. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49526. _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 : ""));
  49527. }
  49528. }
  49529. return false;
  49530. },
  49531. loadAssetContainer: function (scene, data, rootUrl, onError) {
  49532. var container = loadAssetContainer(scene, data, rootUrl, onError);
  49533. return container;
  49534. }
  49535. });
  49536. /***/ }),
  49537. /***/ "./Loading/Plugins/index.ts":
  49538. /*!**********************************!*\
  49539. !*** ./Loading/Plugins/index.ts ***!
  49540. \**********************************/
  49541. /*! exports provided: _BabylonLoaderRegistered */
  49542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49543. "use strict";
  49544. __webpack_require__.r(__webpack_exports__);
  49545. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  49546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  49547. /***/ }),
  49548. /***/ "./Loading/index.ts":
  49549. /*!**************************!*\
  49550. !*** ./Loading/index.ts ***!
  49551. \**************************/
  49552. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  49553. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49554. "use strict";
  49555. __webpack_require__.r(__webpack_exports__);
  49556. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  49557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  49558. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  49559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  49560. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  49561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  49562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  49563. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  49565. /***/ }),
  49566. /***/ "./Loading/loadingScreen.ts":
  49567. /*!**********************************!*\
  49568. !*** ./Loading/loadingScreen.ts ***!
  49569. \**********************************/
  49570. /*! exports provided: DefaultLoadingScreen */
  49571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49572. "use strict";
  49573. __webpack_require__.r(__webpack_exports__);
  49574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  49575. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49576. /**
  49577. * Class used for the default loading screen
  49578. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  49579. */
  49580. var DefaultLoadingScreen = /** @class */ (function () {
  49581. /**
  49582. * Creates a new default loading screen
  49583. * @param _renderingCanvas defines the canvas used to render the scene
  49584. * @param _loadingText defines the default text to display
  49585. * @param _loadingDivBackgroundColor defines the default background color
  49586. */
  49587. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  49588. if (_loadingText === void 0) { _loadingText = ""; }
  49589. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  49590. var _this = this;
  49591. this._renderingCanvas = _renderingCanvas;
  49592. this._loadingText = _loadingText;
  49593. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  49594. // Resize
  49595. this._resizeLoadingUI = function () {
  49596. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  49597. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  49598. if (!_this._loadingDiv) {
  49599. return;
  49600. }
  49601. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  49602. _this._loadingDiv.style.left = canvasRect.left + "px";
  49603. _this._loadingDiv.style.top = canvasRect.top + "px";
  49604. _this._loadingDiv.style.width = canvasRect.width + "px";
  49605. _this._loadingDiv.style.height = canvasRect.height + "px";
  49606. };
  49607. }
  49608. /**
  49609. * Function called to display the loading screen
  49610. */
  49611. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  49612. if (this._loadingDiv) {
  49613. // Do not add a loading screen if there is already one
  49614. return;
  49615. }
  49616. this._loadingDiv = document.createElement("div");
  49617. this._loadingDiv.id = "babylonjsLoadingDiv";
  49618. this._loadingDiv.style.opacity = "0";
  49619. this._loadingDiv.style.transition = "opacity 1.5s ease";
  49620. this._loadingDiv.style.pointerEvents = "none";
  49621. // Loading text
  49622. this._loadingTextDiv = document.createElement("div");
  49623. this._loadingTextDiv.style.position = "absolute";
  49624. this._loadingTextDiv.style.left = "0";
  49625. this._loadingTextDiv.style.top = "50%";
  49626. this._loadingTextDiv.style.marginTop = "80px";
  49627. this._loadingTextDiv.style.width = "100%";
  49628. this._loadingTextDiv.style.height = "20px";
  49629. this._loadingTextDiv.style.fontFamily = "Arial";
  49630. this._loadingTextDiv.style.fontSize = "14px";
  49631. this._loadingTextDiv.style.color = "white";
  49632. this._loadingTextDiv.style.textAlign = "center";
  49633. this._loadingTextDiv.innerHTML = "Loading";
  49634. this._loadingDiv.appendChild(this._loadingTextDiv);
  49635. //set the predefined text
  49636. this._loadingTextDiv.innerHTML = this._loadingText;
  49637. // Generating keyframes
  49638. var style = document.createElement('style');
  49639. style.type = 'text/css';
  49640. 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 }";
  49641. style.innerHTML = keyFrames;
  49642. document.getElementsByTagName('head')[0].appendChild(style);
  49643. // Loading img
  49644. var imgBack = new Image();
  49645. 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";
  49646. imgBack.style.position = "absolute";
  49647. imgBack.style.left = "50%";
  49648. imgBack.style.top = "50%";
  49649. imgBack.style.marginLeft = "-60px";
  49650. imgBack.style.marginTop = "-60px";
  49651. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  49652. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  49653. imgBack.style.transformOrigin = "50% 50%";
  49654. imgBack.style.webkitTransformOrigin = "50% 50%";
  49655. this._loadingDiv.appendChild(imgBack);
  49656. this._resizeLoadingUI();
  49657. window.addEventListener("resize", this._resizeLoadingUI);
  49658. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49659. document.body.appendChild(this._loadingDiv);
  49660. this._loadingDiv.style.opacity = "1";
  49661. };
  49662. /**
  49663. * Function called to hide the loading screen
  49664. */
  49665. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  49666. var _this = this;
  49667. if (!this._loadingDiv) {
  49668. return;
  49669. }
  49670. var onTransitionEnd = function () {
  49671. if (!_this._loadingDiv) {
  49672. return;
  49673. }
  49674. if (_this._loadingDiv.parentElement) {
  49675. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  49676. }
  49677. window.removeEventListener("resize", _this._resizeLoadingUI);
  49678. _this._loadingDiv = null;
  49679. };
  49680. this._loadingDiv.style.opacity = "0";
  49681. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  49682. };
  49683. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  49684. get: function () {
  49685. return this._loadingText;
  49686. },
  49687. /**
  49688. * Gets or sets the text to display while loading
  49689. */
  49690. set: function (text) {
  49691. this._loadingText = text;
  49692. if (this._loadingTextDiv) {
  49693. this._loadingTextDiv.innerHTML = this._loadingText;
  49694. }
  49695. },
  49696. enumerable: true,
  49697. configurable: true
  49698. });
  49699. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  49700. /**
  49701. * Gets or sets the color to use for the background
  49702. */
  49703. get: function () {
  49704. return this._loadingDivBackgroundColor;
  49705. },
  49706. set: function (color) {
  49707. this._loadingDivBackgroundColor = color;
  49708. if (!this._loadingDiv) {
  49709. return;
  49710. }
  49711. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49712. },
  49713. enumerable: true,
  49714. configurable: true
  49715. });
  49716. return DefaultLoadingScreen;
  49717. }());
  49718. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  49719. /***/ }),
  49720. /***/ "./Loading/sceneLoader.ts":
  49721. /*!********************************!*\
  49722. !*** ./Loading/sceneLoader.ts ***!
  49723. \********************************/
  49724. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  49725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49726. "use strict";
  49727. __webpack_require__.r(__webpack_exports__);
  49728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  49729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  49730. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  49731. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  49732. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  49733. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  49734. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49735. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  49736. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  49737. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49738. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49739. /**
  49740. * Class used to represent data loading progression
  49741. */
  49742. var SceneLoaderProgressEvent = /** @class */ (function () {
  49743. /**
  49744. * Create a new progress event
  49745. * @param lengthComputable defines if data length to load can be evaluated
  49746. * @param loaded defines the loaded data length
  49747. * @param total defines the data length to load
  49748. */
  49749. function SceneLoaderProgressEvent(
  49750. /** defines if data length to load can be evaluated */
  49751. lengthComputable,
  49752. /** defines the loaded data length */
  49753. loaded,
  49754. /** defines the data length to load */
  49755. total) {
  49756. this.lengthComputable = lengthComputable;
  49757. this.loaded = loaded;
  49758. this.total = total;
  49759. }
  49760. /**
  49761. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  49762. * @param event defines the source event
  49763. * @returns a new SceneLoaderProgressEvent
  49764. */
  49765. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  49766. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  49767. };
  49768. return SceneLoaderProgressEvent;
  49769. }());
  49770. /**
  49771. * Class used to load scene from various file formats using registered plugins
  49772. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  49773. */
  49774. var SceneLoader = /** @class */ (function () {
  49775. function SceneLoader() {
  49776. }
  49777. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  49778. /**
  49779. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49780. */
  49781. get: function () {
  49782. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  49783. },
  49784. set: function (value) {
  49785. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  49786. },
  49787. enumerable: true,
  49788. configurable: true
  49789. });
  49790. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  49791. /**
  49792. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49793. */
  49794. get: function () {
  49795. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  49796. },
  49797. set: function (value) {
  49798. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  49799. },
  49800. enumerable: true,
  49801. configurable: true
  49802. });
  49803. Object.defineProperty(SceneLoader, "loggingLevel", {
  49804. /**
  49805. * Defines the current logging level (while loading the scene)
  49806. * @ignorenaming
  49807. */
  49808. get: function () {
  49809. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  49810. },
  49811. set: function (value) {
  49812. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  49813. },
  49814. enumerable: true,
  49815. configurable: true
  49816. });
  49817. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  49818. /**
  49819. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49820. */
  49821. get: function () {
  49822. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  49823. },
  49824. set: function (value) {
  49825. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  49826. },
  49827. enumerable: true,
  49828. configurable: true
  49829. });
  49830. SceneLoader._getDefaultPlugin = function () {
  49831. return SceneLoader._registeredPlugins[".babylon"];
  49832. };
  49833. SceneLoader._getPluginForExtension = function (extension) {
  49834. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  49835. if (registeredPlugin) {
  49836. return registeredPlugin;
  49837. }
  49838. _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");
  49839. return SceneLoader._getDefaultPlugin();
  49840. };
  49841. SceneLoader._getPluginForDirectLoad = function (data) {
  49842. for (var extension in SceneLoader._registeredPlugins) {
  49843. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  49844. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  49845. return SceneLoader._registeredPlugins[extension];
  49846. }
  49847. }
  49848. return SceneLoader._getDefaultPlugin();
  49849. };
  49850. SceneLoader._getPluginForFilename = function (sceneFilename) {
  49851. var queryStringPosition = sceneFilename.indexOf("?");
  49852. if (queryStringPosition !== -1) {
  49853. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  49854. }
  49855. var dotPosition = sceneFilename.lastIndexOf(".");
  49856. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  49857. return SceneLoader._getPluginForExtension(extension);
  49858. };
  49859. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  49860. SceneLoader._getDirectLoad = function (sceneFilename) {
  49861. if (sceneFilename.substr(0, 5) === "data:") {
  49862. return sceneFilename.substr(5);
  49863. }
  49864. return null;
  49865. };
  49866. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  49867. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  49868. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  49869. var plugin;
  49870. if (registeredPlugin.plugin.createPlugin) {
  49871. plugin = registeredPlugin.plugin.createPlugin();
  49872. }
  49873. else {
  49874. plugin = registeredPlugin.plugin;
  49875. }
  49876. if (!plugin) {
  49877. 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.";
  49878. }
  49879. var useArrayBuffer = registeredPlugin.isBinary;
  49880. var offlineProvider;
  49881. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  49882. var dataCallback = function (data, responseURL) {
  49883. if (scene.isDisposed) {
  49884. onError("Scene has been disposed");
  49885. return;
  49886. }
  49887. scene.offlineProvider = offlineProvider;
  49888. onSuccess(plugin, data, responseURL);
  49889. };
  49890. var request = null;
  49891. var pluginDisposed = false;
  49892. var onDisposeObservable = plugin.onDisposeObservable;
  49893. if (onDisposeObservable) {
  49894. onDisposeObservable.add(function () {
  49895. pluginDisposed = true;
  49896. if (request) {
  49897. request.abort();
  49898. request = null;
  49899. }
  49900. onDispose();
  49901. });
  49902. }
  49903. var manifestChecked = function () {
  49904. if (pluginDisposed) {
  49905. return;
  49906. }
  49907. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  49908. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  49909. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  49910. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  49911. });
  49912. };
  49913. if (directLoad) {
  49914. dataCallback(directLoad);
  49915. return plugin;
  49916. }
  49917. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  49918. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  49919. var engine = scene.getEngine();
  49920. var canUseOfflineSupport = engine.enableOfflineSupport;
  49921. if (canUseOfflineSupport) {
  49922. // Also check for exceptions
  49923. var exceptionFound = false;
  49924. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  49925. var regex = _a[_i];
  49926. if (regex.test(fileInfo.url)) {
  49927. exceptionFound = true;
  49928. break;
  49929. }
  49930. }
  49931. canUseOfflineSupport = !exceptionFound;
  49932. }
  49933. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  49934. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  49935. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  49936. }
  49937. else {
  49938. manifestChecked();
  49939. }
  49940. }
  49941. // Loading file from disk via input file or drag'n'drop
  49942. else {
  49943. if (file) {
  49944. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  49945. }
  49946. else {
  49947. onError("Unable to find file named " + fileInfo.name);
  49948. }
  49949. }
  49950. return plugin;
  49951. };
  49952. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  49953. var url;
  49954. var name;
  49955. var file = null;
  49956. if (!sceneFilename) {
  49957. url = rootUrl;
  49958. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  49959. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  49960. }
  49961. else if (sceneFilename.name) {
  49962. var sceneFile = sceneFilename;
  49963. url = rootUrl + sceneFile.name;
  49964. name = sceneFile.name;
  49965. file = sceneFile;
  49966. }
  49967. else {
  49968. var filename = sceneFilename;
  49969. if (filename.substr(0, 1) === "/") {
  49970. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  49971. return null;
  49972. }
  49973. url = rootUrl + filename;
  49974. name = filename;
  49975. }
  49976. return {
  49977. url: url,
  49978. rootUrl: rootUrl,
  49979. name: name,
  49980. file: file
  49981. };
  49982. };
  49983. // Public functions
  49984. /**
  49985. * Gets a plugin that can load the given extension
  49986. * @param extension defines the extension to load
  49987. * @returns a plugin or null if none works
  49988. */
  49989. SceneLoader.GetPluginForExtension = function (extension) {
  49990. return SceneLoader._getPluginForExtension(extension).plugin;
  49991. };
  49992. /**
  49993. * Gets a boolean indicating that the given extension can be loaded
  49994. * @param extension defines the extension to load
  49995. * @returns true if the extension is supported
  49996. */
  49997. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  49998. return !!SceneLoader._registeredPlugins[extension];
  49999. };
  50000. /**
  50001. * Adds a new plugin to the list of registered plugins
  50002. * @param plugin defines the plugin to add
  50003. */
  50004. SceneLoader.RegisterPlugin = function (plugin) {
  50005. if (typeof plugin.extensions === "string") {
  50006. var extension = plugin.extensions;
  50007. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  50008. plugin: plugin,
  50009. isBinary: false
  50010. };
  50011. }
  50012. else {
  50013. var extensions = plugin.extensions;
  50014. Object.keys(extensions).forEach(function (extension) {
  50015. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  50016. plugin: plugin,
  50017. isBinary: extensions[extension].isBinary
  50018. };
  50019. });
  50020. }
  50021. };
  50022. /**
  50023. * Import meshes into a scene
  50024. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50025. * @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)
  50026. * @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)
  50027. * @param scene the instance of BABYLON.Scene to append to
  50028. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  50029. * @param onProgress a callback with a progress event for each file being loaded
  50030. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50031. * @param pluginExtension the extension used to determine the plugin
  50032. * @returns The loaded plugin
  50033. */
  50034. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50035. if (sceneFilename === void 0) { sceneFilename = ""; }
  50036. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50037. if (onSuccess === void 0) { onSuccess = null; }
  50038. if (onProgress === void 0) { onProgress = null; }
  50039. if (onError === void 0) { onError = null; }
  50040. if (pluginExtension === void 0) { pluginExtension = null; }
  50041. if (!scene) {
  50042. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  50043. return null;
  50044. }
  50045. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50046. if (!fileInfo) {
  50047. return null;
  50048. }
  50049. var loadingToken = {};
  50050. scene._addPendingData(loadingToken);
  50051. var disposeHandler = function () {
  50052. scene._removePendingData(loadingToken);
  50053. };
  50054. var errorHandler = function (message, exception) {
  50055. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  50056. if (onError) {
  50057. onError(scene, errorMessage, exception);
  50058. }
  50059. else {
  50060. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50061. // should the exception be thrown?
  50062. }
  50063. disposeHandler();
  50064. };
  50065. var progressHandler = onProgress ? function (event) {
  50066. try {
  50067. onProgress(event);
  50068. }
  50069. catch (e) {
  50070. errorHandler("Error in onProgress callback", e);
  50071. }
  50072. } : undefined;
  50073. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  50074. scene.importedMeshesFiles.push(fileInfo.url);
  50075. if (onSuccess) {
  50076. try {
  50077. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  50078. }
  50079. catch (e) {
  50080. errorHandler("Error in onSuccess callback", e);
  50081. }
  50082. }
  50083. scene._removePendingData(loadingToken);
  50084. };
  50085. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  50086. if (plugin.rewriteRootURL) {
  50087. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  50088. }
  50089. if (plugin.importMesh) {
  50090. var syncedPlugin = plugin;
  50091. var meshes = new Array();
  50092. var particleSystems = new Array();
  50093. var skeletons = new Array();
  50094. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  50095. return;
  50096. }
  50097. scene.loadingPluginName = plugin.name;
  50098. successHandler(meshes, particleSystems, skeletons, []);
  50099. }
  50100. else {
  50101. var asyncedPlugin = plugin;
  50102. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  50103. scene.loadingPluginName = plugin.name;
  50104. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  50105. }).catch(function (error) {
  50106. errorHandler(error.message, error);
  50107. });
  50108. }
  50109. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50110. };
  50111. /**
  50112. * Import meshes into a scene
  50113. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50114. * @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)
  50115. * @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)
  50116. * @param scene the instance of BABYLON.Scene to append to
  50117. * @param onProgress a callback with a progress event for each file being loaded
  50118. * @param pluginExtension the extension used to determine the plugin
  50119. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50120. */
  50121. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50122. if (sceneFilename === void 0) { sceneFilename = ""; }
  50123. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50124. if (onProgress === void 0) { onProgress = null; }
  50125. if (pluginExtension === void 0) { pluginExtension = null; }
  50126. return new Promise(function (resolve, reject) {
  50127. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  50128. resolve({
  50129. meshes: meshes,
  50130. particleSystems: particleSystems,
  50131. skeletons: skeletons,
  50132. animationGroups: animationGroups
  50133. });
  50134. }, onProgress, function (scene, message, exception) {
  50135. reject(exception || new Error(message));
  50136. }, pluginExtension);
  50137. });
  50138. };
  50139. /**
  50140. * Load a scene
  50141. * @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)
  50142. * @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)
  50143. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50144. * @param onSuccess a callback with the scene when import succeeds
  50145. * @param onProgress a callback with a progress event for each file being loaded
  50146. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50147. * @param pluginExtension the extension used to determine the plugin
  50148. * @returns The loaded plugin
  50149. */
  50150. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  50151. if (sceneFilename === void 0) { sceneFilename = ""; }
  50152. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  50153. if (onSuccess === void 0) { onSuccess = null; }
  50154. if (onProgress === void 0) { onProgress = null; }
  50155. if (onError === void 0) { onError = null; }
  50156. if (pluginExtension === void 0) { pluginExtension = null; }
  50157. if (!engine) {
  50158. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  50159. return null;
  50160. }
  50161. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  50162. };
  50163. /**
  50164. * Load a scene
  50165. * @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)
  50166. * @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)
  50167. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50168. * @param onProgress a callback with a progress event for each file being loaded
  50169. * @param pluginExtension the extension used to determine the plugin
  50170. * @returns The loaded scene
  50171. */
  50172. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  50173. if (sceneFilename === void 0) { sceneFilename = ""; }
  50174. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  50175. if (onProgress === void 0) { onProgress = null; }
  50176. if (pluginExtension === void 0) { pluginExtension = null; }
  50177. return new Promise(function (resolve, reject) {
  50178. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  50179. resolve(scene);
  50180. }, onProgress, function (scene, message, exception) {
  50181. reject(exception || new Error(message));
  50182. }, pluginExtension);
  50183. });
  50184. };
  50185. /**
  50186. * Append a scene
  50187. * @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)
  50188. * @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)
  50189. * @param scene is the instance of BABYLON.Scene to append to
  50190. * @param onSuccess a callback with the scene when import succeeds
  50191. * @param onProgress a callback with a progress event for each file being loaded
  50192. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50193. * @param pluginExtension the extension used to determine the plugin
  50194. * @returns The loaded plugin
  50195. */
  50196. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50197. if (sceneFilename === void 0) { sceneFilename = ""; }
  50198. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50199. if (onSuccess === void 0) { onSuccess = null; }
  50200. if (onProgress === void 0) { onProgress = null; }
  50201. if (onError === void 0) { onError = null; }
  50202. if (pluginExtension === void 0) { pluginExtension = null; }
  50203. if (!scene) {
  50204. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  50205. return null;
  50206. }
  50207. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50208. if (!fileInfo) {
  50209. return null;
  50210. }
  50211. if (SceneLoader.ShowLoadingScreen) {
  50212. scene.getEngine().displayLoadingUI();
  50213. }
  50214. var loadingToken = {};
  50215. scene._addPendingData(loadingToken);
  50216. var disposeHandler = function () {
  50217. scene._removePendingData(loadingToken);
  50218. scene.getEngine().hideLoadingUI();
  50219. };
  50220. var errorHandler = function (message, exception) {
  50221. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  50222. if (onError) {
  50223. onError(scene, errorMessage, exception);
  50224. }
  50225. else {
  50226. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50227. // should the exception be thrown?
  50228. }
  50229. disposeHandler();
  50230. };
  50231. var progressHandler = onProgress ? function (event) {
  50232. try {
  50233. onProgress(event);
  50234. }
  50235. catch (e) {
  50236. errorHandler("Error in onProgress callback", e);
  50237. }
  50238. } : undefined;
  50239. var successHandler = function () {
  50240. if (onSuccess) {
  50241. try {
  50242. onSuccess(scene);
  50243. }
  50244. catch (e) {
  50245. errorHandler("Error in onSuccess callback", e);
  50246. }
  50247. }
  50248. scene._removePendingData(loadingToken);
  50249. };
  50250. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  50251. if (plugin.load) {
  50252. var syncedPlugin = plugin;
  50253. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  50254. return;
  50255. }
  50256. scene.loadingPluginName = plugin.name;
  50257. successHandler();
  50258. }
  50259. else {
  50260. var asyncedPlugin = plugin;
  50261. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  50262. scene.loadingPluginName = plugin.name;
  50263. successHandler();
  50264. }).catch(function (error) {
  50265. errorHandler(error.message, error);
  50266. });
  50267. }
  50268. if (SceneLoader.ShowLoadingScreen) {
  50269. scene.executeWhenReady(function () {
  50270. scene.getEngine().hideLoadingUI();
  50271. });
  50272. }
  50273. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50274. };
  50275. /**
  50276. * Append a scene
  50277. * @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)
  50278. * @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)
  50279. * @param scene is the instance of BABYLON.Scene to append to
  50280. * @param onProgress a callback with a progress event for each file being loaded
  50281. * @param pluginExtension the extension used to determine the plugin
  50282. * @returns The given scene
  50283. */
  50284. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50285. if (sceneFilename === void 0) { sceneFilename = ""; }
  50286. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50287. if (onProgress === void 0) { onProgress = null; }
  50288. if (pluginExtension === void 0) { pluginExtension = null; }
  50289. return new Promise(function (resolve, reject) {
  50290. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  50291. resolve(scene);
  50292. }, onProgress, function (scene, message, exception) {
  50293. reject(exception || new Error(message));
  50294. }, pluginExtension);
  50295. });
  50296. };
  50297. /**
  50298. * Load a scene into an asset container
  50299. * @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)
  50300. * @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)
  50301. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50302. * @param onSuccess a callback with the scene when import succeeds
  50303. * @param onProgress a callback with a progress event for each file being loaded
  50304. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50305. * @param pluginExtension the extension used to determine the plugin
  50306. * @returns The loaded plugin
  50307. */
  50308. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50309. if (sceneFilename === void 0) { sceneFilename = ""; }
  50310. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50311. if (onSuccess === void 0) { onSuccess = null; }
  50312. if (onProgress === void 0) { onProgress = null; }
  50313. if (onError === void 0) { onError = null; }
  50314. if (pluginExtension === void 0) { pluginExtension = null; }
  50315. if (!scene) {
  50316. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  50317. return null;
  50318. }
  50319. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50320. if (!fileInfo) {
  50321. return null;
  50322. }
  50323. var loadingToken = {};
  50324. scene._addPendingData(loadingToken);
  50325. var disposeHandler = function () {
  50326. scene._removePendingData(loadingToken);
  50327. };
  50328. var errorHandler = function (message, exception) {
  50329. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  50330. if (onError) {
  50331. onError(scene, errorMessage, exception);
  50332. }
  50333. else {
  50334. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50335. // should the exception be thrown?
  50336. }
  50337. disposeHandler();
  50338. };
  50339. var progressHandler = onProgress ? function (event) {
  50340. try {
  50341. onProgress(event);
  50342. }
  50343. catch (e) {
  50344. errorHandler("Error in onProgress callback", e);
  50345. }
  50346. } : undefined;
  50347. var successHandler = function (assets) {
  50348. if (onSuccess) {
  50349. try {
  50350. onSuccess(assets);
  50351. }
  50352. catch (e) {
  50353. errorHandler("Error in onSuccess callback", e);
  50354. }
  50355. }
  50356. scene._removePendingData(loadingToken);
  50357. };
  50358. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  50359. if (plugin.loadAssetContainer) {
  50360. var syncedPlugin = plugin;
  50361. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  50362. if (!assetContainer) {
  50363. return;
  50364. }
  50365. scene.loadingPluginName = plugin.name;
  50366. successHandler(assetContainer);
  50367. }
  50368. else if (plugin.loadAssetContainerAsync) {
  50369. var asyncedPlugin = plugin;
  50370. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  50371. scene.loadingPluginName = plugin.name;
  50372. successHandler(assetContainer);
  50373. }).catch(function (error) {
  50374. errorHandler(error.message, error);
  50375. });
  50376. }
  50377. else {
  50378. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  50379. }
  50380. if (SceneLoader.ShowLoadingScreen) {
  50381. scene.executeWhenReady(function () {
  50382. scene.getEngine().hideLoadingUI();
  50383. });
  50384. }
  50385. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50386. };
  50387. /**
  50388. * Load a scene into an asset container
  50389. * @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)
  50390. * @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)
  50391. * @param scene is the instance of Scene to append to
  50392. * @param onProgress a callback with a progress event for each file being loaded
  50393. * @param pluginExtension the extension used to determine the plugin
  50394. * @returns The loaded asset container
  50395. */
  50396. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50397. if (sceneFilename === void 0) { sceneFilename = ""; }
  50398. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50399. if (onProgress === void 0) { onProgress = null; }
  50400. if (pluginExtension === void 0) { pluginExtension = null; }
  50401. return new Promise(function (resolve, reject) {
  50402. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  50403. resolve(assetContainer);
  50404. }, onProgress, function (scene, message, exception) {
  50405. reject(exception || new Error(message));
  50406. }, pluginExtension);
  50407. });
  50408. };
  50409. /**
  50410. * No logging while loading
  50411. */
  50412. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  50413. /**
  50414. * Minimal logging while loading
  50415. */
  50416. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  50417. /**
  50418. * Summary logging while loading
  50419. */
  50420. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  50421. /**
  50422. * Detailled logging while loading
  50423. */
  50424. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  50425. // Members
  50426. /**
  50427. * Event raised when a plugin is used to load a scene
  50428. */
  50429. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  50430. SceneLoader._registeredPlugins = {};
  50431. return SceneLoader;
  50432. }());
  50433. /***/ }),
  50434. /***/ "./Loading/sceneLoaderFlags.ts":
  50435. /*!*************************************!*\
  50436. !*** ./Loading/sceneLoaderFlags.ts ***!
  50437. \*************************************/
  50438. /*! exports provided: SceneLoaderFlags */
  50439. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50440. "use strict";
  50441. __webpack_require__.r(__webpack_exports__);
  50442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  50443. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  50444. /**
  50445. * Class used to represent data loading progression
  50446. */
  50447. var SceneLoaderFlags = /** @class */ (function () {
  50448. function SceneLoaderFlags() {
  50449. }
  50450. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  50451. /**
  50452. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50453. */
  50454. get: function () {
  50455. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  50456. },
  50457. set: function (value) {
  50458. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  50459. },
  50460. enumerable: true,
  50461. configurable: true
  50462. });
  50463. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  50464. /**
  50465. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50466. */
  50467. get: function () {
  50468. return SceneLoaderFlags._ShowLoadingScreen;
  50469. },
  50470. set: function (value) {
  50471. SceneLoaderFlags._ShowLoadingScreen = value;
  50472. },
  50473. enumerable: true,
  50474. configurable: true
  50475. });
  50476. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  50477. /**
  50478. * Defines the current logging level (while loading the scene)
  50479. * @ignorenaming
  50480. */
  50481. get: function () {
  50482. return SceneLoaderFlags._loggingLevel;
  50483. },
  50484. set: function (value) {
  50485. SceneLoaderFlags._loggingLevel = value;
  50486. },
  50487. enumerable: true,
  50488. configurable: true
  50489. });
  50490. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  50491. /**
  50492. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50493. */
  50494. get: function () {
  50495. return SceneLoaderFlags._CleanBoneMatrixWeights;
  50496. },
  50497. set: function (value) {
  50498. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  50499. },
  50500. enumerable: true,
  50501. configurable: true
  50502. });
  50503. // Flags
  50504. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  50505. SceneLoaderFlags._ShowLoadingScreen = true;
  50506. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  50507. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  50508. return SceneLoaderFlags;
  50509. }());
  50510. /***/ }),
  50511. /***/ "./Materials/Background/backgroundMaterial.ts":
  50512. /*!****************************************************!*\
  50513. !*** ./Materials/Background/backgroundMaterial.ts ***!
  50514. \****************************************************/
  50515. /*! exports provided: BackgroundMaterial */
  50516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50517. "use strict";
  50518. __webpack_require__.r(__webpack_exports__);
  50519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  50520. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50521. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50522. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50523. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50524. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50525. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50526. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50527. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50528. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50529. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50530. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50531. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50532. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50533. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  50534. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50535. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  50536. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  50537. /**
  50538. * Background material defines definition.
  50539. * @hidden Mainly internal Use
  50540. */
  50541. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  50542. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  50543. /**
  50544. * Constructor of the defines.
  50545. */
  50546. function BackgroundMaterialDefines() {
  50547. var _this = _super.call(this) || this;
  50548. /**
  50549. * True if the diffuse texture is in use.
  50550. */
  50551. _this.DIFFUSE = false;
  50552. /**
  50553. * The direct UV channel to use.
  50554. */
  50555. _this.DIFFUSEDIRECTUV = 0;
  50556. /**
  50557. * True if the diffuse texture is in gamma space.
  50558. */
  50559. _this.GAMMADIFFUSE = false;
  50560. /**
  50561. * True if the diffuse texture has opacity in the alpha channel.
  50562. */
  50563. _this.DIFFUSEHASALPHA = false;
  50564. /**
  50565. * True if you want the material to fade to transparent at grazing angle.
  50566. */
  50567. _this.OPACITYFRESNEL = false;
  50568. /**
  50569. * True if an extra blur needs to be added in the reflection.
  50570. */
  50571. _this.REFLECTIONBLUR = false;
  50572. /**
  50573. * True if you want the material to fade to reflection at grazing angle.
  50574. */
  50575. _this.REFLECTIONFRESNEL = false;
  50576. /**
  50577. * True if you want the material to falloff as far as you move away from the scene center.
  50578. */
  50579. _this.REFLECTIONFALLOFF = false;
  50580. /**
  50581. * False if the current Webgl implementation does not support the texture lod extension.
  50582. */
  50583. _this.TEXTURELODSUPPORT = false;
  50584. /**
  50585. * True to ensure the data are premultiplied.
  50586. */
  50587. _this.PREMULTIPLYALPHA = false;
  50588. /**
  50589. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  50590. */
  50591. _this.USERGBCOLOR = false;
  50592. /**
  50593. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  50594. * stays aligned with the desired configuration.
  50595. */
  50596. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  50597. /**
  50598. * True to add noise in order to reduce the banding effect.
  50599. */
  50600. _this.NOISE = false;
  50601. /**
  50602. * is the reflection texture in BGR color scheme?
  50603. * Mainly used to solve a bug in ios10 video tag
  50604. */
  50605. _this.REFLECTIONBGR = false;
  50606. _this.IMAGEPROCESSING = false;
  50607. _this.VIGNETTE = false;
  50608. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50609. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50610. _this.TONEMAPPING = false;
  50611. _this.TONEMAPPING_ACES = false;
  50612. _this.CONTRAST = false;
  50613. _this.COLORCURVES = false;
  50614. _this.COLORGRADING = false;
  50615. _this.COLORGRADING3D = false;
  50616. _this.SAMPLER3DGREENDEPTH = false;
  50617. _this.SAMPLER3DBGRMAP = false;
  50618. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50619. _this.EXPOSURE = false;
  50620. _this.MULTIVIEW = false;
  50621. // Reflection.
  50622. _this.REFLECTION = false;
  50623. _this.REFLECTIONMAP_3D = false;
  50624. _this.REFLECTIONMAP_SPHERICAL = false;
  50625. _this.REFLECTIONMAP_PLANAR = false;
  50626. _this.REFLECTIONMAP_CUBIC = false;
  50627. _this.REFLECTIONMAP_PROJECTION = false;
  50628. _this.REFLECTIONMAP_SKYBOX = false;
  50629. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50630. _this.REFLECTIONMAP_EXPLICIT = false;
  50631. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50632. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50633. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50634. _this.INVERTCUBICMAP = false;
  50635. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50636. _this.LODINREFLECTIONALPHA = false;
  50637. _this.GAMMAREFLECTION = false;
  50638. _this.RGBDREFLECTION = false;
  50639. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  50640. // Default BJS.
  50641. _this.MAINUV1 = false;
  50642. _this.MAINUV2 = false;
  50643. _this.UV1 = false;
  50644. _this.UV2 = false;
  50645. _this.CLIPPLANE = false;
  50646. _this.CLIPPLANE2 = false;
  50647. _this.CLIPPLANE3 = false;
  50648. _this.CLIPPLANE4 = false;
  50649. _this.POINTSIZE = false;
  50650. _this.FOG = false;
  50651. _this.NORMAL = false;
  50652. _this.NUM_BONE_INFLUENCERS = 0;
  50653. _this.BonesPerMesh = 0;
  50654. _this.INSTANCES = false;
  50655. _this.SHADOWFLOAT = false;
  50656. _this.rebuild();
  50657. return _this;
  50658. }
  50659. return BackgroundMaterialDefines;
  50660. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  50661. /**
  50662. * Background material used to create an efficient environement around your scene.
  50663. */
  50664. var BackgroundMaterial = /** @class */ (function (_super) {
  50665. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  50666. /**
  50667. * Instantiates a Background Material in the given scene
  50668. * @param name The friendly name of the material
  50669. * @param scene The scene to add the material to
  50670. */
  50671. function BackgroundMaterial(name, scene) {
  50672. var _this = _super.call(this, name, scene) || this;
  50673. /**
  50674. * Key light Color (multiply against the environement texture)
  50675. */
  50676. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50677. _this._primaryColorShadowLevel = 0;
  50678. _this._primaryColorHighlightLevel = 0;
  50679. /**
  50680. * Reflection Texture used in the material.
  50681. * Should be author in a specific way for the best result (refer to the documentation).
  50682. */
  50683. _this.reflectionTexture = null;
  50684. /**
  50685. * Reflection Texture level of blur.
  50686. *
  50687. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50688. * texture twice.
  50689. */
  50690. _this.reflectionBlur = 0;
  50691. /**
  50692. * Diffuse Texture used in the material.
  50693. * Should be author in a specific way for the best result (refer to the documentation).
  50694. */
  50695. _this.diffuseTexture = null;
  50696. _this._shadowLights = null;
  50697. /**
  50698. * Specify the list of lights casting shadow on the material.
  50699. * All scene shadow lights will be included if null.
  50700. */
  50701. _this.shadowLights = null;
  50702. /**
  50703. * Helps adjusting the shadow to a softer level if required.
  50704. * 0 means black shadows and 1 means no shadows.
  50705. */
  50706. _this.shadowLevel = 0;
  50707. /**
  50708. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50709. * It is usually zero but might be interesting to modify according to your setup.
  50710. */
  50711. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  50712. /**
  50713. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50714. * This helps ensuring a nice transition when the camera goes under the ground.
  50715. */
  50716. _this.opacityFresnel = true;
  50717. /**
  50718. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50719. * This helps adding a mirror texture on the ground.
  50720. */
  50721. _this.reflectionFresnel = false;
  50722. /**
  50723. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50724. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50725. */
  50726. _this.reflectionFalloffDistance = 0.0;
  50727. /**
  50728. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50729. */
  50730. _this.reflectionAmount = 1.0;
  50731. /**
  50732. * This specifies the weight of the reflection at grazing angle.
  50733. */
  50734. _this.reflectionReflectance0 = 0.05;
  50735. /**
  50736. * This specifies the weight of the reflection at a perpendicular point of view.
  50737. */
  50738. _this.reflectionReflectance90 = 0.5;
  50739. /**
  50740. * Helps to directly use the maps channels instead of their level.
  50741. */
  50742. _this.useRGBColor = true;
  50743. /**
  50744. * This helps reducing the banding effect that could occur on the background.
  50745. */
  50746. _this.enableNoise = false;
  50747. _this._fovMultiplier = 1.0;
  50748. /**
  50749. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50750. */
  50751. _this.useEquirectangularFOV = false;
  50752. _this._maxSimultaneousLights = 4;
  50753. /**
  50754. * Number of Simultaneous lights allowed on the material.
  50755. */
  50756. _this.maxSimultaneousLights = 4;
  50757. /**
  50758. * Keep track of the image processing observer to allow dispose and replace.
  50759. */
  50760. _this._imageProcessingObserver = null;
  50761. /**
  50762. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50763. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50764. */
  50765. _this.switchToBGR = false;
  50766. // Temp values kept as cache in the material.
  50767. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  50768. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  50769. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50770. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50771. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50772. // Setup the default processing configuration to the scene.
  50773. _this._attachImageProcessingConfiguration(null);
  50774. _this.getRenderTargetTextures = function () {
  50775. _this._renderTargets.reset();
  50776. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  50777. _this._renderTargets.push(_this._diffuseTexture);
  50778. }
  50779. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50780. _this._renderTargets.push(_this._reflectionTexture);
  50781. }
  50782. return _this._renderTargets;
  50783. };
  50784. return _this;
  50785. }
  50786. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  50787. /**
  50788. * Experimental Internal Use Only.
  50789. *
  50790. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50791. * This acts as a helper to set the primary color to a more "human friendly" value.
  50792. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50793. * output color as close as possible from the chosen value.
  50794. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50795. * part of lighting setup.)
  50796. */
  50797. get: function () {
  50798. return this.__perceptualColor;
  50799. },
  50800. set: function (value) {
  50801. this.__perceptualColor = value;
  50802. this._computePrimaryColorFromPerceptualColor();
  50803. this._markAllSubMeshesAsLightsDirty();
  50804. },
  50805. enumerable: true,
  50806. configurable: true
  50807. });
  50808. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  50809. /**
  50810. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50811. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50812. */
  50813. get: function () {
  50814. return this._primaryColorShadowLevel;
  50815. },
  50816. set: function (value) {
  50817. this._primaryColorShadowLevel = value;
  50818. this._computePrimaryColors();
  50819. this._markAllSubMeshesAsLightsDirty();
  50820. },
  50821. enumerable: true,
  50822. configurable: true
  50823. });
  50824. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  50825. /**
  50826. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50827. * The primary color is used at the level chosen to define what the white area would look.
  50828. */
  50829. get: function () {
  50830. return this._primaryColorHighlightLevel;
  50831. },
  50832. set: function (value) {
  50833. this._primaryColorHighlightLevel = value;
  50834. this._computePrimaryColors();
  50835. this._markAllSubMeshesAsLightsDirty();
  50836. },
  50837. enumerable: true,
  50838. configurable: true
  50839. });
  50840. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  50841. /**
  50842. * Sets the reflection reflectance fresnel values according to the default standard
  50843. * empirically know to work well :-)
  50844. */
  50845. set: function (value) {
  50846. var reflectionWeight = value;
  50847. if (reflectionWeight < 0.5) {
  50848. reflectionWeight = reflectionWeight * 2.0;
  50849. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  50850. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  50851. }
  50852. else {
  50853. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  50854. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  50855. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  50856. }
  50857. },
  50858. enumerable: true,
  50859. configurable: true
  50860. });
  50861. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  50862. /**
  50863. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50864. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50865. * Recommended to be keep at 1.0 except for special cases.
  50866. */
  50867. get: function () {
  50868. return this._fovMultiplier;
  50869. },
  50870. set: function (value) {
  50871. if (isNaN(value)) {
  50872. value = 1.0;
  50873. }
  50874. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  50875. },
  50876. enumerable: true,
  50877. configurable: true
  50878. });
  50879. /**
  50880. * Attaches a new image processing configuration to the PBR Material.
  50881. * @param configuration (if null the scene configuration will be use)
  50882. */
  50883. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50884. var _this = this;
  50885. if (configuration === this._imageProcessingConfiguration) {
  50886. return;
  50887. }
  50888. // Detaches observer.
  50889. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50890. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50891. }
  50892. // Pick the scene configuration if needed.
  50893. if (!configuration) {
  50894. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50895. }
  50896. else {
  50897. this._imageProcessingConfiguration = configuration;
  50898. }
  50899. // Attaches observer.
  50900. if (this._imageProcessingConfiguration) {
  50901. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50902. _this._computePrimaryColorFromPerceptualColor();
  50903. _this._markAllSubMeshesAsImageProcessingDirty();
  50904. });
  50905. }
  50906. };
  50907. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  50908. /**
  50909. * Gets the image processing configuration used either in this material.
  50910. */
  50911. get: function () {
  50912. return this._imageProcessingConfiguration;
  50913. },
  50914. /**
  50915. * Sets the Default image processing configuration used either in the this material.
  50916. *
  50917. * If sets to null, the scene one is in use.
  50918. */
  50919. set: function (value) {
  50920. this._attachImageProcessingConfiguration(value);
  50921. // Ensure the effect will be rebuilt.
  50922. this._markAllSubMeshesAsTexturesDirty();
  50923. },
  50924. enumerable: true,
  50925. configurable: true
  50926. });
  50927. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  50928. /**
  50929. * Gets wether the color curves effect is enabled.
  50930. */
  50931. get: function () {
  50932. return this.imageProcessingConfiguration.colorCurvesEnabled;
  50933. },
  50934. /**
  50935. * Sets wether the color curves effect is enabled.
  50936. */
  50937. set: function (value) {
  50938. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  50939. },
  50940. enumerable: true,
  50941. configurable: true
  50942. });
  50943. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  50944. /**
  50945. * Gets wether the color grading effect is enabled.
  50946. */
  50947. get: function () {
  50948. return this.imageProcessingConfiguration.colorGradingEnabled;
  50949. },
  50950. /**
  50951. * Gets wether the color grading effect is enabled.
  50952. */
  50953. set: function (value) {
  50954. this.imageProcessingConfiguration.colorGradingEnabled = value;
  50955. },
  50956. enumerable: true,
  50957. configurable: true
  50958. });
  50959. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  50960. /**
  50961. * Gets wether tonemapping is enabled or not.
  50962. */
  50963. get: function () {
  50964. return this._imageProcessingConfiguration.toneMappingEnabled;
  50965. },
  50966. /**
  50967. * Sets wether tonemapping is enabled or not
  50968. */
  50969. set: function (value) {
  50970. this._imageProcessingConfiguration.toneMappingEnabled = value;
  50971. },
  50972. enumerable: true,
  50973. configurable: true
  50974. });
  50975. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  50976. /**
  50977. * The camera exposure used on this material.
  50978. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50979. * This corresponds to a photographic exposure.
  50980. */
  50981. get: function () {
  50982. return this._imageProcessingConfiguration.exposure;
  50983. },
  50984. /**
  50985. * The camera exposure used on this material.
  50986. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50987. * This corresponds to a photographic exposure.
  50988. */
  50989. set: function (value) {
  50990. this._imageProcessingConfiguration.exposure = value;
  50991. },
  50992. enumerable: true,
  50993. configurable: true
  50994. });
  50995. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  50996. /**
  50997. * Gets The camera contrast used on this material.
  50998. */
  50999. get: function () {
  51000. return this._imageProcessingConfiguration.contrast;
  51001. },
  51002. /**
  51003. * Sets The camera contrast used on this material.
  51004. */
  51005. set: function (value) {
  51006. this._imageProcessingConfiguration.contrast = value;
  51007. },
  51008. enumerable: true,
  51009. configurable: true
  51010. });
  51011. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  51012. /**
  51013. * Gets the Color Grading 2D Lookup Texture.
  51014. */
  51015. get: function () {
  51016. return this._imageProcessingConfiguration.colorGradingTexture;
  51017. },
  51018. /**
  51019. * Sets the Color Grading 2D Lookup Texture.
  51020. */
  51021. set: function (value) {
  51022. this.imageProcessingConfiguration.colorGradingTexture = value;
  51023. },
  51024. enumerable: true,
  51025. configurable: true
  51026. });
  51027. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  51028. /**
  51029. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51030. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51031. * 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;
  51032. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51033. */
  51034. get: function () {
  51035. return this.imageProcessingConfiguration.colorCurves;
  51036. },
  51037. /**
  51038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51040. * 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;
  51041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51042. */
  51043. set: function (value) {
  51044. this.imageProcessingConfiguration.colorCurves = value;
  51045. },
  51046. enumerable: true,
  51047. configurable: true
  51048. });
  51049. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  51050. /**
  51051. * Gets a boolean indicating that current material needs to register RTT
  51052. */
  51053. get: function () {
  51054. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  51055. return true;
  51056. }
  51057. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51058. return true;
  51059. }
  51060. return false;
  51061. },
  51062. enumerable: true,
  51063. configurable: true
  51064. });
  51065. /**
  51066. * The entire material has been created in order to prevent overdraw.
  51067. * @returns false
  51068. */
  51069. BackgroundMaterial.prototype.needAlphaTesting = function () {
  51070. return true;
  51071. };
  51072. /**
  51073. * The entire material has been created in order to prevent overdraw.
  51074. * @returns true if blending is enable
  51075. */
  51076. BackgroundMaterial.prototype.needAlphaBlending = function () {
  51077. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  51078. };
  51079. /**
  51080. * Checks wether the material is ready to be rendered for a given mesh.
  51081. * @param mesh The mesh to render
  51082. * @param subMesh The submesh to check against
  51083. * @param useInstances Specify wether or not the material is used with instances
  51084. * @returns true if all the dependencies are ready (Textures, Effects...)
  51085. */
  51086. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  51087. var _this = this;
  51088. if (useInstances === void 0) { useInstances = false; }
  51089. if (subMesh.effect && this.isFrozen) {
  51090. if (this._wasPreviouslyReady) {
  51091. return true;
  51092. }
  51093. }
  51094. if (!subMesh._materialDefines) {
  51095. subMesh._materialDefines = new BackgroundMaterialDefines();
  51096. }
  51097. var scene = this.getScene();
  51098. var defines = subMesh._materialDefines;
  51099. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  51100. if (defines._renderId === scene.getRenderId()) {
  51101. return true;
  51102. }
  51103. }
  51104. var engine = scene.getEngine();
  51105. // Lights
  51106. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  51107. defines._needNormals = true;
  51108. // Multiview
  51109. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  51110. // Textures
  51111. if (defines._areTexturesDirty) {
  51112. defines._needUVs = false;
  51113. if (scene.texturesEnabled) {
  51114. if (scene.getEngine().getCaps().textureLOD) {
  51115. defines.TEXTURELODSUPPORT = true;
  51116. }
  51117. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51118. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  51119. return false;
  51120. }
  51121. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  51122. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  51123. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  51124. defines.OPACITYFRESNEL = this._opacityFresnel;
  51125. }
  51126. else {
  51127. defines.DIFFUSE = false;
  51128. defines.DIFFUSEHASALPHA = false;
  51129. defines.GAMMADIFFUSE = false;
  51130. defines.OPACITYFRESNEL = false;
  51131. }
  51132. var reflectionTexture = this._reflectionTexture;
  51133. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51134. if (!reflectionTexture.isReadyOrNotBlocking()) {
  51135. return false;
  51136. }
  51137. defines.REFLECTION = true;
  51138. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51139. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51140. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  51141. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51142. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51143. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  51144. defines.REFLECTIONBGR = this.switchToBGR;
  51145. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  51146. defines.INVERTCUBICMAP = true;
  51147. }
  51148. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51149. switch (reflectionTexture.coordinatesMode) {
  51150. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  51151. defines.REFLECTIONMAP_EXPLICIT = true;
  51152. break;
  51153. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  51154. defines.REFLECTIONMAP_PLANAR = true;
  51155. break;
  51156. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  51157. defines.REFLECTIONMAP_PROJECTION = true;
  51158. break;
  51159. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  51160. defines.REFLECTIONMAP_SKYBOX = true;
  51161. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51162. break;
  51163. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  51164. defines.REFLECTIONMAP_SPHERICAL = true;
  51165. break;
  51166. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  51167. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51168. break;
  51169. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51170. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51171. break;
  51172. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51173. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51174. break;
  51175. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  51176. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  51177. default:
  51178. defines.REFLECTIONMAP_CUBIC = true;
  51179. break;
  51180. }
  51181. if (this.reflectionFresnel) {
  51182. defines.REFLECTIONFRESNEL = true;
  51183. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  51184. this._reflectionControls.x = this.reflectionAmount;
  51185. this._reflectionControls.y = this.reflectionReflectance0;
  51186. this._reflectionControls.z = this.reflectionReflectance90;
  51187. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  51188. }
  51189. else {
  51190. defines.REFLECTIONFRESNEL = false;
  51191. defines.REFLECTIONFALLOFF = false;
  51192. }
  51193. }
  51194. else {
  51195. defines.REFLECTION = false;
  51196. defines.REFLECTIONFRESNEL = false;
  51197. defines.REFLECTIONFALLOFF = false;
  51198. defines.REFLECTIONBLUR = false;
  51199. defines.REFLECTIONMAP_3D = false;
  51200. defines.REFLECTIONMAP_SPHERICAL = false;
  51201. defines.REFLECTIONMAP_PLANAR = false;
  51202. defines.REFLECTIONMAP_CUBIC = false;
  51203. defines.REFLECTIONMAP_PROJECTION = false;
  51204. defines.REFLECTIONMAP_SKYBOX = false;
  51205. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51206. defines.REFLECTIONMAP_EXPLICIT = false;
  51207. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51208. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51209. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51210. defines.INVERTCUBICMAP = false;
  51211. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51212. defines.LODINREFLECTIONALPHA = false;
  51213. defines.GAMMAREFLECTION = false;
  51214. defines.RGBDREFLECTION = false;
  51215. }
  51216. }
  51217. 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);
  51218. defines.USERGBCOLOR = this._useRGBColor;
  51219. defines.NOISE = this._enableNoise;
  51220. }
  51221. if (defines._areLightsDirty) {
  51222. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  51223. }
  51224. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51225. if (!this._imageProcessingConfiguration.isReady()) {
  51226. return false;
  51227. }
  51228. this._imageProcessingConfiguration.prepareDefines(defines);
  51229. }
  51230. // Misc.
  51231. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  51232. // Values that need to be evaluated on every frame
  51233. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  51234. // Attribs
  51235. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  51236. if (mesh) {
  51237. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  51238. mesh.createNormals(true);
  51239. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  51240. }
  51241. }
  51242. }
  51243. // Get correct effect
  51244. if (defines.isDirty) {
  51245. defines.markAsProcessed();
  51246. scene.resetCachedMaterial();
  51247. // Fallbacks
  51248. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  51249. if (defines.FOG) {
  51250. fallbacks.addFallback(0, "FOG");
  51251. }
  51252. if (defines.POINTSIZE) {
  51253. fallbacks.addFallback(1, "POINTSIZE");
  51254. }
  51255. if (defines.MULTIVIEW) {
  51256. fallbacks.addFallback(0, "MULTIVIEW");
  51257. }
  51258. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  51259. if (defines.NUM_BONE_INFLUENCERS > 0) {
  51260. fallbacks.addCPUSkinningFallback(0, mesh);
  51261. }
  51262. //Attributes
  51263. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  51264. if (defines.NORMAL) {
  51265. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  51266. }
  51267. if (defines.UV1) {
  51268. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  51269. }
  51270. if (defines.UV2) {
  51271. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  51272. }
  51273. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  51274. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  51275. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  51276. "vFogInfos", "vFogColor", "pointSize",
  51277. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  51278. "vPrimaryColor", "vPrimaryColorShadow",
  51279. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  51280. "shadowLevel", "alpha",
  51281. "vBackgroundCenter", "vReflectionControl",
  51282. "vDiffuseInfos", "diffuseMatrix",
  51283. ];
  51284. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  51285. var uniformBuffers = ["Material", "Scene"];
  51286. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  51287. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  51288. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  51289. }
  51290. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  51291. uniformsNames: uniforms,
  51292. uniformBuffersNames: uniformBuffers,
  51293. samplers: samplers,
  51294. defines: defines,
  51295. maxSimultaneousLights: this._maxSimultaneousLights
  51296. });
  51297. var onCompiled = function (effect) {
  51298. if (_this.onCompiled) {
  51299. _this.onCompiled(effect);
  51300. }
  51301. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  51302. };
  51303. var join = defines.toString();
  51304. subMesh.setEffect(scene.getEngine().createEffect("background", {
  51305. attributes: attribs,
  51306. uniformsNames: uniforms,
  51307. uniformBuffersNames: uniformBuffers,
  51308. samplers: samplers,
  51309. defines: join,
  51310. fallbacks: fallbacks,
  51311. onCompiled: onCompiled,
  51312. onError: this.onError,
  51313. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  51314. }, engine), defines);
  51315. this.buildUniformLayout();
  51316. }
  51317. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51318. return false;
  51319. }
  51320. defines._renderId = scene.getRenderId();
  51321. this._wasPreviouslyReady = true;
  51322. return true;
  51323. };
  51324. /**
  51325. * Compute the primary color according to the chosen perceptual color.
  51326. */
  51327. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  51328. if (!this.__perceptualColor) {
  51329. return;
  51330. }
  51331. this._primaryColor.copyFrom(this.__perceptualColor);
  51332. // Revert gamma space.
  51333. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  51334. // Revert image processing configuration.
  51335. if (this._imageProcessingConfiguration) {
  51336. // Revert Exposure.
  51337. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  51338. }
  51339. this._computePrimaryColors();
  51340. };
  51341. /**
  51342. * Compute the highlights and shadow colors according to their chosen levels.
  51343. */
  51344. BackgroundMaterial.prototype._computePrimaryColors = function () {
  51345. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  51346. return;
  51347. }
  51348. // Find the highlight color based on the configuration.
  51349. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  51350. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  51351. // Find the shadow color based on the configuration.
  51352. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  51353. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  51354. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  51355. };
  51356. /**
  51357. * Build the uniform buffer used in the material.
  51358. */
  51359. BackgroundMaterial.prototype.buildUniformLayout = function () {
  51360. // Order is important !
  51361. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  51362. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  51363. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  51364. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51365. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  51366. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51367. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51368. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  51369. this._uniformBuffer.addUniform("pointSize", 1);
  51370. this._uniformBuffer.addUniform("shadowLevel", 1);
  51371. this._uniformBuffer.addUniform("alpha", 1);
  51372. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  51373. this._uniformBuffer.addUniform("vReflectionControl", 4);
  51374. this._uniformBuffer.create();
  51375. };
  51376. /**
  51377. * Unbind the material.
  51378. */
  51379. BackgroundMaterial.prototype.unbind = function () {
  51380. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  51381. this._uniformBuffer.setTexture("diffuseSampler", null);
  51382. }
  51383. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51384. this._uniformBuffer.setTexture("reflectionSampler", null);
  51385. }
  51386. _super.prototype.unbind.call(this);
  51387. };
  51388. /**
  51389. * Bind only the world matrix to the material.
  51390. * @param world The world matrix to bind.
  51391. */
  51392. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  51393. this._activeEffect.setMatrix("world", world);
  51394. };
  51395. /**
  51396. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51397. * @param world The world matrix to bind.
  51398. * @param subMesh The submesh to bind for.
  51399. */
  51400. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51401. var scene = this.getScene();
  51402. var defines = subMesh._materialDefines;
  51403. if (!defines) {
  51404. return;
  51405. }
  51406. var effect = subMesh.effect;
  51407. if (!effect) {
  51408. return;
  51409. }
  51410. this._activeEffect = effect;
  51411. // Matrices
  51412. this.bindOnlyWorldMatrix(world);
  51413. // Bones
  51414. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51415. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51416. if (mustRebind) {
  51417. this._uniformBuffer.bindToEffect(effect, "Material");
  51418. this.bindViewProjection(effect);
  51419. var reflectionTexture = this._reflectionTexture;
  51420. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51421. // Texture uniforms
  51422. if (scene.texturesEnabled) {
  51423. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51424. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  51425. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  51426. }
  51427. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51428. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51429. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  51430. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51431. }
  51432. }
  51433. if (this.shadowLevel > 0) {
  51434. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  51435. }
  51436. this._uniformBuffer.updateFloat("alpha", this.alpha);
  51437. // Point size
  51438. if (this.pointsCloud) {
  51439. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51440. }
  51441. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  51442. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  51443. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  51444. }
  51445. else {
  51446. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  51447. }
  51448. }
  51449. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  51450. // Textures
  51451. if (scene.texturesEnabled) {
  51452. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51453. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  51454. }
  51455. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51456. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  51457. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51458. }
  51459. else if (!defines.REFLECTIONBLUR) {
  51460. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51461. }
  51462. else {
  51463. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51464. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51465. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51466. }
  51467. if (defines.REFLECTIONFRESNEL) {
  51468. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  51469. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  51470. }
  51471. }
  51472. }
  51473. // Clip plane
  51474. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51475. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  51476. }
  51477. if (mustRebind || !this.isFrozen) {
  51478. if (scene.lightsEnabled) {
  51479. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  51480. }
  51481. // View
  51482. this.bindView(effect);
  51483. // Fog
  51484. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51485. // image processing
  51486. if (this._imageProcessingConfiguration) {
  51487. this._imageProcessingConfiguration.bind(this._activeEffect);
  51488. }
  51489. }
  51490. this._uniformBuffer.update();
  51491. this._afterBind(mesh, this._activeEffect);
  51492. };
  51493. /**
  51494. * Dispose the material.
  51495. * @param forceDisposeEffect Force disposal of the associated effect.
  51496. * @param forceDisposeTextures Force disposal of the associated textures.
  51497. */
  51498. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51499. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  51500. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  51501. if (forceDisposeTextures) {
  51502. if (this.diffuseTexture) {
  51503. this.diffuseTexture.dispose();
  51504. }
  51505. if (this.reflectionTexture) {
  51506. this.reflectionTexture.dispose();
  51507. }
  51508. }
  51509. this._renderTargets.dispose();
  51510. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51511. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51512. }
  51513. _super.prototype.dispose.call(this, forceDisposeEffect);
  51514. };
  51515. /**
  51516. * Clones the material.
  51517. * @param name The cloned name.
  51518. * @returns The cloned material.
  51519. */
  51520. BackgroundMaterial.prototype.clone = function (name) {
  51521. var _this = this;
  51522. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  51523. };
  51524. /**
  51525. * Serializes the current material to its JSON representation.
  51526. * @returns The JSON representation.
  51527. */
  51528. BackgroundMaterial.prototype.serialize = function () {
  51529. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51530. serializationObject.customType = "BABYLON.BackgroundMaterial";
  51531. return serializationObject;
  51532. };
  51533. /**
  51534. * Gets the class name of the material
  51535. * @returns "BackgroundMaterial"
  51536. */
  51537. BackgroundMaterial.prototype.getClassName = function () {
  51538. return "BackgroundMaterial";
  51539. };
  51540. /**
  51541. * Parse a JSON input to create back a background material.
  51542. * @param source The JSON data to parse
  51543. * @param scene The scene to create the parsed material in
  51544. * @param rootUrl The root url of the assets the material depends upon
  51545. * @returns the instantiated BackgroundMaterial.
  51546. */
  51547. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  51548. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  51549. };
  51550. /**
  51551. * Standard reflectance value at parallel view angle.
  51552. */
  51553. BackgroundMaterial.StandardReflectance0 = 0.05;
  51554. /**
  51555. * Standard reflectance value at grazing angle.
  51556. */
  51557. BackgroundMaterial.StandardReflectance90 = 0.5;
  51558. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51559. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51560. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  51561. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51562. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51563. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  51564. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51565. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51566. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  51567. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51568. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51569. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  51570. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51571. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51572. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  51573. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51574. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51575. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  51576. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51577. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51578. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  51579. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51580. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51581. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  51582. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51583. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51584. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  51585. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51586. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51587. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  51588. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51589. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51590. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  51591. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51592. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51593. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  51594. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51595. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51596. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  51597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51598. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51599. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  51600. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51601. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51602. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  51603. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51604. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  51605. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  51606. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51607. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51608. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  51609. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51610. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51611. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  51612. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51613. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51614. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  51615. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51616. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51617. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  51618. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51619. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51620. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  51621. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51622. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51623. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  51624. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51625. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51626. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  51627. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51628. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51629. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  51630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51632. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  51633. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51635. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  51636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51638. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  51639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51641. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  51642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51644. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  51645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51647. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  51648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51650. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  51651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51653. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  51654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51656. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  51657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51659. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  51660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51662. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  51663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51665. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51666. return BackgroundMaterial;
  51667. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  51668. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  51669. /***/ }),
  51670. /***/ "./Materials/Background/index.ts":
  51671. /*!***************************************!*\
  51672. !*** ./Materials/Background/index.ts ***!
  51673. \***************************************/
  51674. /*! exports provided: BackgroundMaterial */
  51675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51676. "use strict";
  51677. __webpack_require__.r(__webpack_exports__);
  51678. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  51679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  51680. /***/ }),
  51681. /***/ "./Materials/PBR/index.ts":
  51682. /*!********************************!*\
  51683. !*** ./Materials/PBR/index.ts ***!
  51684. \********************************/
  51685. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  51686. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51687. "use strict";
  51688. __webpack_require__.r(__webpack_exports__);
  51689. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  51691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  51692. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  51693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  51694. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  51695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  51696. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  51697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  51698. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  51699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  51700. /***/ }),
  51701. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  51702. /*!******************************************************!*\
  51703. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  51704. \******************************************************/
  51705. /*! exports provided: PBRAnisotropicConfiguration */
  51706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51707. "use strict";
  51708. __webpack_require__.r(__webpack_exports__);
  51709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  51710. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51711. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51712. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51713. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51714. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  51715. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51716. /**
  51717. * Define the code related to the anisotropic parameters of the pbr material.
  51718. */
  51719. var PBRAnisotropicConfiguration = /** @class */ (function () {
  51720. /**
  51721. * Instantiate a new istance of anisotropy configuration.
  51722. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51723. */
  51724. function PBRAnisotropicConfiguration(markAllSubMeshesAsTexturesDirty) {
  51725. this._isEnabled = false;
  51726. /**
  51727. * Defines if the anisotropy is enabled in the material.
  51728. */
  51729. this.isEnabled = false;
  51730. /**
  51731. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51732. */
  51733. this.intensity = 1;
  51734. /**
  51735. * Defines if the effect is along the tangents, bitangents or in between.
  51736. * By default, the effect is "strectching" the highlights along the tangents.
  51737. */
  51738. this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0);
  51739. this._texture = null;
  51740. /**
  51741. * Stores the anisotropy values in a texture.
  51742. * rg is direction (like normal from -1 to 1)
  51743. * b is a intensity
  51744. */
  51745. this.texture = null;
  51746. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  51747. }
  51748. /** @hidden */
  51749. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  51750. this._internalMarkAllSubMeshesAsTexturesDirty();
  51751. };
  51752. /**
  51753. * Specifies that the submesh is ready to be used.
  51754. * @param defines the list of "defines" to update.
  51755. * @param scene defines the scene the material belongs to.
  51756. * @returns - boolean indicating that the submesh is ready or not.
  51757. */
  51758. PBRAnisotropicConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  51759. if (defines._areTexturesDirty) {
  51760. if (scene.texturesEnabled) {
  51761. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51762. if (!this._texture.isReadyOrNotBlocking()) {
  51763. return false;
  51764. }
  51765. }
  51766. }
  51767. }
  51768. return true;
  51769. };
  51770. /**
  51771. * Checks to see if a texture is used in the material.
  51772. * @param defines the list of "defines" to update.
  51773. * @param mesh the mesh we are preparing the defines for.
  51774. * @param scene defines the scene the material belongs to.
  51775. */
  51776. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh, scene) {
  51777. if (this._isEnabled) {
  51778. defines.ANISOTROPIC = this._isEnabled;
  51779. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  51780. defines._needUVs = true;
  51781. defines.MAINUV1 = true;
  51782. }
  51783. if (defines._areTexturesDirty) {
  51784. if (scene.texturesEnabled) {
  51785. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51786. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "ANISOTROPIC_TEXTURE");
  51787. }
  51788. else {
  51789. defines.ANISOTROPIC_TEXTURE = false;
  51790. }
  51791. }
  51792. }
  51793. }
  51794. else {
  51795. defines.ANISOTROPIC = false;
  51796. defines.ANISOTROPIC_TEXTURE = false;
  51797. }
  51798. };
  51799. /**
  51800. * Binds the material data.
  51801. * @param uniformBuffer defines the Uniform buffer to fill in.
  51802. * @param scene defines the scene the material belongs to.
  51803. * @param isFrozen defines wether the material is frozen or not.
  51804. */
  51805. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  51806. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  51807. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51808. uniformBuffer.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level);
  51809. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "anisotropy");
  51810. }
  51811. // Anisotropy
  51812. uniformBuffer.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity);
  51813. }
  51814. // Textures
  51815. if (scene.texturesEnabled) {
  51816. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51817. uniformBuffer.setTexture("anisotropySampler", this._texture);
  51818. }
  51819. }
  51820. };
  51821. /**
  51822. * Checks to see if a texture is used in the material.
  51823. * @param texture - Base texture to use.
  51824. * @returns - Boolean specifying if a texture is used in the material.
  51825. */
  51826. PBRAnisotropicConfiguration.prototype.hasTexture = function (texture) {
  51827. if (this._texture === texture) {
  51828. return true;
  51829. }
  51830. return false;
  51831. };
  51832. /**
  51833. * Returns an array of the actively used textures.
  51834. * @param activeTextures Array of BaseTextures
  51835. */
  51836. PBRAnisotropicConfiguration.prototype.getActiveTextures = function (activeTextures) {
  51837. if (this._texture) {
  51838. activeTextures.push(this._texture);
  51839. }
  51840. };
  51841. /**
  51842. * Returns the animatable textures.
  51843. * @param animatables Array of animatable textures.
  51844. */
  51845. PBRAnisotropicConfiguration.prototype.getAnimatables = function (animatables) {
  51846. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  51847. animatables.push(this._texture);
  51848. }
  51849. };
  51850. /**
  51851. * Disposes the resources of the material.
  51852. * @param forceDisposeTextures - Forces the disposal of all textures.
  51853. */
  51854. PBRAnisotropicConfiguration.prototype.dispose = function (forceDisposeTextures) {
  51855. if (forceDisposeTextures) {
  51856. if (this._texture) {
  51857. this._texture.dispose();
  51858. }
  51859. }
  51860. };
  51861. /**
  51862. * Get the current class name of the texture useful for serialization or dynamic coding.
  51863. * @returns "PBRAnisotropicConfiguration"
  51864. */
  51865. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  51866. return "PBRAnisotropicConfiguration";
  51867. };
  51868. /**
  51869. * Add fallbacks to the effect fallbacks list.
  51870. * @param defines defines the Base texture to use.
  51871. * @param fallbacks defines the current fallback list.
  51872. * @param currentRank defines the current fallback rank.
  51873. * @returns the new fallback rank.
  51874. */
  51875. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  51876. if (defines.ANISOTROPIC) {
  51877. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  51878. }
  51879. return currentRank;
  51880. };
  51881. /**
  51882. * Add the required uniforms to the current list.
  51883. * @param uniforms defines the current uniform list.
  51884. */
  51885. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  51886. uniforms.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
  51887. };
  51888. /**
  51889. * Add the required uniforms to the current buffer.
  51890. * @param uniformBuffer defines the current uniform buffer.
  51891. */
  51892. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  51893. uniformBuffer.addUniform("vAnisotropy", 3);
  51894. uniformBuffer.addUniform("vAnisotropyInfos", 2);
  51895. uniformBuffer.addUniform("anisotropyMatrix", 16);
  51896. };
  51897. /**
  51898. * Add the required samplers to the current list.
  51899. * @param samplers defines the current sampler list.
  51900. */
  51901. PBRAnisotropicConfiguration.AddSamplers = function (samplers) {
  51902. samplers.push("anisotropySampler");
  51903. };
  51904. /**
  51905. * Makes a duplicate of the current configuration into another one.
  51906. * @param anisotropicConfiguration define the config where to copy the info
  51907. */
  51908. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  51909. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  51910. };
  51911. /**
  51912. * Serializes this anisotropy configuration.
  51913. * @returns - An object with the serialized config.
  51914. */
  51915. PBRAnisotropicConfiguration.prototype.serialize = function () {
  51916. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51917. };
  51918. /**
  51919. * Parses a anisotropy Configuration from a serialized object.
  51920. * @param source - Serialized object.
  51921. */
  51922. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  51923. var _this = this;
  51924. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51925. };
  51926. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51927. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51928. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  51929. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51931. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  51932. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51933. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51934. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  51935. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51936. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
  51937. ], PBRAnisotropicConfiguration.prototype, "direction", void 0);
  51938. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51939. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51940. ], PBRAnisotropicConfiguration.prototype, "_texture", void 0);
  51941. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51943. ], PBRAnisotropicConfiguration.prototype, "texture", void 0);
  51944. return PBRAnisotropicConfiguration;
  51945. }());
  51946. /***/ }),
  51947. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  51948. /*!***********************************************!*\
  51949. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  51950. \***********************************************/
  51951. /*! exports provided: PBRBRDFConfiguration */
  51952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51953. "use strict";
  51954. __webpack_require__.r(__webpack_exports__);
  51955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  51956. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51957. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51958. /**
  51959. * Define the code related to the BRDF parameters of the pbr material.
  51960. */
  51961. var PBRBRDFConfiguration = /** @class */ (function () {
  51962. /**
  51963. * Instantiate a new istance of clear coat configuration.
  51964. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51965. */
  51966. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  51967. this._useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51968. /**
  51969. * Defines if the material uses energy conservation.
  51970. */
  51971. this.useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51972. this._useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51973. /**
  51974. * LEGACY Mode set to false
  51975. * Defines if the material uses height smith correlated visibility term.
  51976. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51977. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51978. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51979. * Not relying on height correlated will also disable energy conservation.
  51980. */
  51981. this.useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51982. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  51983. }
  51984. /** @hidden */
  51985. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  51986. this._internalMarkAllSubMeshesAsMiscDirty();
  51987. };
  51988. /**
  51989. * Checks to see if a texture is used in the material.
  51990. * @param defines the list of "defines" to update.
  51991. */
  51992. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  51993. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  51994. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  51995. };
  51996. /**
  51997. * Get the current class name of the texture useful for serialization or dynamic coding.
  51998. * @returns "PBRClearCoatConfiguration"
  51999. */
  52000. PBRBRDFConfiguration.prototype.getClassName = function () {
  52001. return "PBRClearCoatConfiguration";
  52002. };
  52003. /**
  52004. * Makes a duplicate of the current configuration into another one.
  52005. * @param brdfConfiguration define the config where to copy the info
  52006. */
  52007. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  52008. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  52009. };
  52010. /**
  52011. * Serializes this BRDF configuration.
  52012. * @returns - An object with the serialized config.
  52013. */
  52014. PBRBRDFConfiguration.prototype.serialize = function () {
  52015. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52016. };
  52017. /**
  52018. * Parses a BRDF Configuration from a serialized object.
  52019. * @param source - Serialized object.
  52020. */
  52021. PBRBRDFConfiguration.prototype.parse = function (source) {
  52022. var _this = this;
  52023. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  52024. };
  52025. /**
  52026. * Default value used for the energy conservation.
  52027. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52028. */
  52029. PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION = true;
  52030. /**
  52031. * Default value used for the Smith Visibility Height Correlated mode.
  52032. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52033. */
  52034. PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = true;
  52035. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52037. ], PBRBRDFConfiguration.prototype, "_useEnergyConservation", void 0);
  52038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52040. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  52041. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52043. ], PBRBRDFConfiguration.prototype, "_useSmithVisibilityHeightCorrelated", void 0);
  52044. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52045. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52046. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  52047. return PBRBRDFConfiguration;
  52048. }());
  52049. /***/ }),
  52050. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  52051. /*!******************************************!*\
  52052. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  52053. \******************************************/
  52054. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial */
  52055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52056. "use strict";
  52057. __webpack_require__.r(__webpack_exports__);
  52058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return PBRMaterialDefines; });
  52059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  52060. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52061. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52062. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  52063. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  52064. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  52065. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  52066. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52067. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  52068. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  52069. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  52070. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  52071. /* harmony import */ var _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./pbrSheenConfiguration */ "./Materials/PBR/pbrSheenConfiguration.ts");
  52072. /* harmony import */ var _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./pbrSubSurfaceConfiguration */ "./Materials/PBR/pbrSubSurfaceConfiguration.ts");
  52073. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  52074. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  52075. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  52076. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  52077. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  52078. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  52079. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  52080. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  52081. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  52082. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  52083. /**
  52084. * Manages the defines for the PBR Material.
  52085. * @hidden
  52086. */
  52087. var PBRMaterialDefines = /** @class */ (function (_super) {
  52088. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  52089. /**
  52090. * Initializes the PBR Material defines.
  52091. */
  52092. function PBRMaterialDefines() {
  52093. var _this = _super.call(this) || this;
  52094. _this.PBR = true;
  52095. _this.MAINUV1 = false;
  52096. _this.MAINUV2 = false;
  52097. _this.UV1 = false;
  52098. _this.UV2 = false;
  52099. _this.ALBEDO = false;
  52100. _this.ALBEDODIRECTUV = 0;
  52101. _this.VERTEXCOLOR = false;
  52102. _this.AMBIENT = false;
  52103. _this.AMBIENTDIRECTUV = 0;
  52104. _this.AMBIENTINGRAYSCALE = false;
  52105. _this.OPACITY = false;
  52106. _this.VERTEXALPHA = false;
  52107. _this.OPACITYDIRECTUV = 0;
  52108. _this.OPACITYRGB = false;
  52109. _this.ALPHATEST = false;
  52110. _this.DEPTHPREPASS = false;
  52111. _this.ALPHABLEND = false;
  52112. _this.ALPHAFROMALBEDO = false;
  52113. _this.ALPHATESTVALUE = "0.5";
  52114. _this.SPECULAROVERALPHA = false;
  52115. _this.RADIANCEOVERALPHA = false;
  52116. _this.ALPHAFRESNEL = false;
  52117. _this.LINEARALPHAFRESNEL = false;
  52118. _this.PREMULTIPLYALPHA = false;
  52119. _this.EMISSIVE = false;
  52120. _this.EMISSIVEDIRECTUV = 0;
  52121. _this.REFLECTIVITY = false;
  52122. _this.REFLECTIVITYDIRECTUV = 0;
  52123. _this.SPECULARTERM = false;
  52124. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  52125. _this.MICROSURFACEAUTOMATIC = false;
  52126. _this.LODBASEDMICROSFURACE = false;
  52127. _this.MICROSURFACEMAP = false;
  52128. _this.MICROSURFACEMAPDIRECTUV = 0;
  52129. _this.METALLICWORKFLOW = false;
  52130. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  52131. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  52132. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  52133. _this.AOSTOREINMETALMAPRED = false;
  52134. _this.ENVIRONMENTBRDF = false;
  52135. _this.ENVIRONMENTBRDF_RGBD = false;
  52136. _this.NORMAL = false;
  52137. _this.TANGENT = false;
  52138. _this.BUMP = false;
  52139. _this.BUMPDIRECTUV = 0;
  52140. _this.OBJECTSPACE_NORMALMAP = false;
  52141. _this.PARALLAX = false;
  52142. _this.PARALLAXOCCLUSION = false;
  52143. _this.NORMALXYSCALE = true;
  52144. _this.LIGHTMAP = false;
  52145. _this.LIGHTMAPDIRECTUV = 0;
  52146. _this.USELIGHTMAPASSHADOWMAP = false;
  52147. _this.GAMMALIGHTMAP = false;
  52148. _this.REFLECTION = false;
  52149. _this.REFLECTIONMAP_3D = false;
  52150. _this.REFLECTIONMAP_SPHERICAL = false;
  52151. _this.REFLECTIONMAP_PLANAR = false;
  52152. _this.REFLECTIONMAP_CUBIC = false;
  52153. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  52154. _this.REFLECTIONMAP_PROJECTION = false;
  52155. _this.REFLECTIONMAP_SKYBOX = false;
  52156. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52157. _this.REFLECTIONMAP_EXPLICIT = false;
  52158. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52159. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52160. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52161. _this.INVERTCUBICMAP = false;
  52162. _this.USESPHERICALFROMREFLECTIONMAP = false;
  52163. _this.USESPHERICALINVERTEX = false;
  52164. _this.REFLECTIONMAP_OPPOSITEZ = false;
  52165. _this.LODINREFLECTIONALPHA = false;
  52166. _this.GAMMAREFLECTION = false;
  52167. _this.RGBDREFLECTION = false;
  52168. _this.RADIANCEOCCLUSION = false;
  52169. _this.HORIZONOCCLUSION = false;
  52170. _this.INSTANCES = false;
  52171. _this.NUM_BONE_INFLUENCERS = 0;
  52172. _this.BonesPerMesh = 0;
  52173. _this.BONETEXTURE = false;
  52174. _this.NONUNIFORMSCALING = false;
  52175. _this.MORPHTARGETS = false;
  52176. _this.MORPHTARGETS_NORMAL = false;
  52177. _this.MORPHTARGETS_TANGENT = false;
  52178. _this.NUM_MORPH_INFLUENCERS = 0;
  52179. _this.IMAGEPROCESSING = false;
  52180. _this.VIGNETTE = false;
  52181. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  52182. _this.VIGNETTEBLENDMODEOPAQUE = false;
  52183. _this.TONEMAPPING = false;
  52184. _this.TONEMAPPING_ACES = false;
  52185. _this.CONTRAST = false;
  52186. _this.COLORCURVES = false;
  52187. _this.COLORGRADING = false;
  52188. _this.COLORGRADING3D = false;
  52189. _this.SAMPLER3DGREENDEPTH = false;
  52190. _this.SAMPLER3DBGRMAP = false;
  52191. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  52192. _this.EXPOSURE = false;
  52193. _this.MULTIVIEW = false;
  52194. _this.USEPHYSICALLIGHTFALLOFF = false;
  52195. _this.USEGLTFLIGHTFALLOFF = false;
  52196. _this.TWOSIDEDLIGHTING = false;
  52197. _this.SHADOWFLOAT = false;
  52198. _this.CLIPPLANE = false;
  52199. _this.CLIPPLANE2 = false;
  52200. _this.CLIPPLANE3 = false;
  52201. _this.CLIPPLANE4 = false;
  52202. _this.POINTSIZE = false;
  52203. _this.FOG = false;
  52204. _this.LOGARITHMICDEPTH = false;
  52205. _this.FORCENORMALFORWARD = false;
  52206. _this.SPECULARAA = false;
  52207. _this.CLEARCOAT = false;
  52208. _this.CLEARCOAT_DEFAULTIOR = false;
  52209. _this.CLEARCOAT_TEXTURE = false;
  52210. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  52211. _this.CLEARCOAT_BUMP = false;
  52212. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  52213. _this.CLEARCOAT_TINT = false;
  52214. _this.CLEARCOAT_TINT_TEXTURE = false;
  52215. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  52216. _this.ANISOTROPIC = false;
  52217. _this.ANISOTROPIC_TEXTURE = false;
  52218. _this.ANISOTROPIC_TEXTUREDIRECTUV = 0;
  52219. _this.BRDF_V_HEIGHT_CORRELATED = false;
  52220. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  52221. _this.SHEEN = false;
  52222. _this.SHEEN_TEXTURE = false;
  52223. _this.SHEEN_TEXTUREDIRECTUV = 0;
  52224. _this.SHEEN_LINKWITHALBEDO = false;
  52225. _this.SUBSURFACE = false;
  52226. _this.SS_REFRACTION = false;
  52227. _this.SS_TRANSLUCENCY = false;
  52228. _this.SS_SCATERRING = false;
  52229. _this.SS_THICKNESSANDMASK_TEXTURE = false;
  52230. _this.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0;
  52231. _this.SS_REFRACTIONMAP_3D = false;
  52232. _this.SS_REFRACTIONMAP_OPPOSITEZ = false;
  52233. _this.SS_LODINREFRACTIONALPHA = false;
  52234. _this.SS_GAMMAREFRACTION = false;
  52235. _this.SS_RGBDREFRACTION = false;
  52236. _this.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  52237. _this.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  52238. _this.UNLIT = false;
  52239. _this.DEBUGMODE = 0;
  52240. _this.rebuild();
  52241. return _this;
  52242. }
  52243. /**
  52244. * Resets the PBR Material defines.
  52245. */
  52246. PBRMaterialDefines.prototype.reset = function () {
  52247. _super.prototype.reset.call(this);
  52248. this.ALPHATESTVALUE = "0.5";
  52249. this.PBR = true;
  52250. };
  52251. return PBRMaterialDefines;
  52252. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_15__["MaterialDefines"]));
  52253. /**
  52254. * The Physically based material base class of BJS.
  52255. *
  52256. * This offers the main features of a standard PBR material.
  52257. * For more information, please refer to the documentation :
  52258. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  52259. */
  52260. var PBRBaseMaterial = /** @class */ (function (_super) {
  52261. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  52262. /**
  52263. * Instantiates a new PBRMaterial instance.
  52264. *
  52265. * @param name The material name
  52266. * @param scene The scene the material will be use in.
  52267. */
  52268. function PBRBaseMaterial(name, scene) {
  52269. var _this = _super.call(this, name, scene) || this;
  52270. /**
  52271. * Intensity of the direct lights e.g. the four lights available in your scene.
  52272. * This impacts both the direct diffuse and specular highlights.
  52273. */
  52274. _this._directIntensity = 1.0;
  52275. /**
  52276. * Intensity of the emissive part of the material.
  52277. * This helps controlling the emissive effect without modifying the emissive color.
  52278. */
  52279. _this._emissiveIntensity = 1.0;
  52280. /**
  52281. * Intensity of the environment e.g. how much the environment will light the object
  52282. * either through harmonics for rough material or through the refelction for shiny ones.
  52283. */
  52284. _this._environmentIntensity = 1.0;
  52285. /**
  52286. * This is a special control allowing the reduction of the specular highlights coming from the
  52287. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52288. */
  52289. _this._specularIntensity = 1.0;
  52290. /**
  52291. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52292. */
  52293. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  52294. /**
  52295. * Debug Control allowing disabling the bump map on this material.
  52296. */
  52297. _this._disableBumpMap = false;
  52298. /**
  52299. * AKA Diffuse Texture in standard nomenclature.
  52300. */
  52301. _this._albedoTexture = null;
  52302. /**
  52303. * AKA Occlusion Texture in other nomenclature.
  52304. */
  52305. _this._ambientTexture = null;
  52306. /**
  52307. * AKA Occlusion Texture Intensity in other nomenclature.
  52308. */
  52309. _this._ambientTextureStrength = 1.0;
  52310. /**
  52311. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52312. * 1 means it completely occludes it
  52313. * 0 mean it has no impact
  52314. */
  52315. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52316. /**
  52317. * Stores the alpha values in a texture.
  52318. */
  52319. _this._opacityTexture = null;
  52320. /**
  52321. * Stores the reflection values in a texture.
  52322. */
  52323. _this._reflectionTexture = null;
  52324. /**
  52325. * Stores the emissive values in a texture.
  52326. */
  52327. _this._emissiveTexture = null;
  52328. /**
  52329. * AKA Specular texture in other nomenclature.
  52330. */
  52331. _this._reflectivityTexture = null;
  52332. /**
  52333. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52334. */
  52335. _this._metallicTexture = null;
  52336. /**
  52337. * Specifies the metallic scalar of the metallic/roughness workflow.
  52338. * Can also be used to scale the metalness values of the metallic texture.
  52339. */
  52340. _this._metallic = null;
  52341. /**
  52342. * Specifies the roughness scalar of the metallic/roughness workflow.
  52343. * Can also be used to scale the roughness values of the metallic texture.
  52344. */
  52345. _this._roughness = null;
  52346. /**
  52347. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52348. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52349. */
  52350. _this._microSurfaceTexture = null;
  52351. /**
  52352. * Stores surface normal data used to displace a mesh in a texture.
  52353. */
  52354. _this._bumpTexture = null;
  52355. /**
  52356. * Stores the pre-calculated light information of a mesh in a texture.
  52357. */
  52358. _this._lightmapTexture = null;
  52359. /**
  52360. * The color of a material in ambient lighting.
  52361. */
  52362. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52363. /**
  52364. * AKA Diffuse Color in other nomenclature.
  52365. */
  52366. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52367. /**
  52368. * AKA Specular Color in other nomenclature.
  52369. */
  52370. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52371. /**
  52372. * The color applied when light is reflected from a material.
  52373. */
  52374. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52375. /**
  52376. * The color applied when light is emitted from a material.
  52377. */
  52378. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52379. /**
  52380. * AKA Glossiness in other nomenclature.
  52381. */
  52382. _this._microSurface = 0.9;
  52383. /**
  52384. * Specifies that the material will use the light map as a show map.
  52385. */
  52386. _this._useLightmapAsShadowmap = false;
  52387. /**
  52388. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52389. * makes the reflect vector face the model (under horizon).
  52390. */
  52391. _this._useHorizonOcclusion = true;
  52392. /**
  52393. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52394. * too much the area relying on ambient texture to define their ambient occlusion.
  52395. */
  52396. _this._useRadianceOcclusion = true;
  52397. /**
  52398. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52399. */
  52400. _this._useAlphaFromAlbedoTexture = false;
  52401. /**
  52402. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52403. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52404. */
  52405. _this._useSpecularOverAlpha = true;
  52406. /**
  52407. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52408. */
  52409. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  52410. /**
  52411. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52412. */
  52413. _this._useRoughnessFromMetallicTextureAlpha = true;
  52414. /**
  52415. * Specifies if the metallic texture contains the roughness information in its green channel.
  52416. */
  52417. _this._useRoughnessFromMetallicTextureGreen = false;
  52418. /**
  52419. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52420. */
  52421. _this._useMetallnessFromMetallicTextureBlue = false;
  52422. /**
  52423. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52424. */
  52425. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  52426. /**
  52427. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52428. */
  52429. _this._useAmbientInGrayScale = false;
  52430. /**
  52431. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52432. * The material will try to infer what glossiness each pixel should be.
  52433. */
  52434. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  52435. /**
  52436. * Defines the falloff type used in this material.
  52437. * It by default is Physical.
  52438. */
  52439. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  52440. /**
  52441. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52442. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52443. */
  52444. _this._useRadianceOverAlpha = true;
  52445. /**
  52446. * Allows using an object space normal map (instead of tangent space).
  52447. */
  52448. _this._useObjectSpaceNormalMap = false;
  52449. /**
  52450. * Allows using the bump map in parallax mode.
  52451. */
  52452. _this._useParallax = false;
  52453. /**
  52454. * Allows using the bump map in parallax occlusion mode.
  52455. */
  52456. _this._useParallaxOcclusion = false;
  52457. /**
  52458. * Controls the scale bias of the parallax mode.
  52459. */
  52460. _this._parallaxScaleBias = 0.05;
  52461. /**
  52462. * If sets to true, disables all the lights affecting the material.
  52463. */
  52464. _this._disableLighting = false;
  52465. /**
  52466. * Number of Simultaneous lights allowed on the material.
  52467. */
  52468. _this._maxSimultaneousLights = 4;
  52469. /**
  52470. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52471. */
  52472. _this._invertNormalMapX = false;
  52473. /**
  52474. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52475. */
  52476. _this._invertNormalMapY = false;
  52477. /**
  52478. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52479. */
  52480. _this._twoSidedLighting = false;
  52481. /**
  52482. * Defines the alpha limits in alpha test mode.
  52483. */
  52484. _this._alphaCutOff = 0.4;
  52485. /**
  52486. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52487. */
  52488. _this._forceAlphaTest = false;
  52489. /**
  52490. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52491. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52492. */
  52493. _this._useAlphaFresnel = false;
  52494. /**
  52495. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52496. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52497. */
  52498. _this._useLinearAlphaFresnel = false;
  52499. /**
  52500. * The transparency mode of the material.
  52501. */
  52502. _this._transparencyMode = null;
  52503. /**
  52504. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52505. * from cos thetav and roughness:
  52506. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52507. */
  52508. _this._environmentBRDFTexture = null;
  52509. /**
  52510. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52511. */
  52512. _this._forceIrradianceInFragment = false;
  52513. /**
  52514. * Force normal to face away from face.
  52515. */
  52516. _this._forceNormalForward = false;
  52517. /**
  52518. * Enables specular anti aliasing in the PBR shader.
  52519. * It will both interacts on the Geometry for analytical and IBL lighting.
  52520. * It also prefilter the roughness map based on the bump values.
  52521. */
  52522. _this._enableSpecularAntiAliasing = false;
  52523. /**
  52524. * Keep track of the image processing observer to allow dispose and replace.
  52525. */
  52526. _this._imageProcessingObserver = null;
  52527. /**
  52528. * Stores the available render targets.
  52529. */
  52530. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  52531. /**
  52532. * Sets the global ambient color for the material used in lighting calculations.
  52533. */
  52534. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52535. /**
  52536. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52537. */
  52538. _this._useLogarithmicDepth = false;
  52539. /**
  52540. * If set to true, no lighting calculations will be applied.
  52541. */
  52542. _this._unlit = false;
  52543. _this._debugMode = 0;
  52544. /**
  52545. * @hidden
  52546. * This is reserved for the inspector.
  52547. * Defines the material debug mode.
  52548. * It helps seeing only some components of the material while troubleshooting.
  52549. */
  52550. _this.debugMode = 0;
  52551. /**
  52552. * @hidden
  52553. * This is reserved for the inspector.
  52554. * Specify from where on screen the debug mode should start.
  52555. * The value goes from -1 (full screen) to 1 (not visible)
  52556. * It helps with side by side comparison against the final render
  52557. * This defaults to -1
  52558. */
  52559. _this.debugLimit = -1;
  52560. /**
  52561. * @hidden
  52562. * This is reserved for the inspector.
  52563. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52564. * You can use the factor to better multiply the final value.
  52565. */
  52566. _this.debugFactor = 1;
  52567. /**
  52568. * Defines the clear coat layer parameters for the material.
  52569. */
  52570. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52571. /**
  52572. * Defines the anisotropic parameters for the material.
  52573. */
  52574. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52575. /**
  52576. * Defines the BRDF parameters for the material.
  52577. */
  52578. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  52579. /**
  52580. * Defines the Sheen parameters for the material.
  52581. */
  52582. _this.sheen = new _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52583. /**
  52584. * Defines the SubSurface parameters for the material.
  52585. */
  52586. _this.subSurface = new _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52587. // Setup the default processing configuration to the scene.
  52588. _this._attachImageProcessingConfiguration(null);
  52589. _this.getRenderTargetTextures = function () {
  52590. _this._renderTargets.reset();
  52591. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  52592. _this._renderTargets.push(_this._reflectionTexture);
  52593. }
  52594. _this.subSurface.fillRenderTargetTextures(_this._renderTargets);
  52595. return _this._renderTargets;
  52596. };
  52597. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  52598. return _this;
  52599. }
  52600. /**
  52601. * Attaches a new image processing configuration to the PBR Material.
  52602. * @param configuration
  52603. */
  52604. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  52605. var _this = this;
  52606. if (configuration === this._imageProcessingConfiguration) {
  52607. return;
  52608. }
  52609. // Detaches observer.
  52610. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  52611. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  52612. }
  52613. // Pick the scene configuration if needed.
  52614. if (!configuration) {
  52615. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  52616. }
  52617. else {
  52618. this._imageProcessingConfiguration = configuration;
  52619. }
  52620. // Attaches observer.
  52621. if (this._imageProcessingConfiguration) {
  52622. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  52623. _this._markAllSubMeshesAsImageProcessingDirty();
  52624. });
  52625. }
  52626. };
  52627. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  52628. /**
  52629. * Gets a boolean indicating that current material needs to register RTT
  52630. */
  52631. get: function () {
  52632. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52633. return true;
  52634. }
  52635. return this.subSurface.hasRenderTargetTextures();
  52636. },
  52637. enumerable: true,
  52638. configurable: true
  52639. });
  52640. /**
  52641. * Gets the name of the material class.
  52642. */
  52643. PBRBaseMaterial.prototype.getClassName = function () {
  52644. return "PBRBaseMaterial";
  52645. };
  52646. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  52647. /**
  52648. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52649. */
  52650. get: function () {
  52651. return this._useLogarithmicDepth;
  52652. },
  52653. /**
  52654. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52655. */
  52656. set: function (value) {
  52657. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  52658. },
  52659. enumerable: true,
  52660. configurable: true
  52661. });
  52662. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  52663. /**
  52664. * Gets the current transparency mode.
  52665. */
  52666. get: function () {
  52667. return this._transparencyMode;
  52668. },
  52669. /**
  52670. * Sets the transparency mode of the material.
  52671. *
  52672. * | Value | Type | Description |
  52673. * | ----- | ----------------------------------- | ----------- |
  52674. * | 0 | OPAQUE | |
  52675. * | 1 | ALPHATEST | |
  52676. * | 2 | ALPHABLEND | |
  52677. * | 3 | ALPHATESTANDBLEND | |
  52678. *
  52679. */
  52680. set: function (value) {
  52681. if (this._transparencyMode === value) {
  52682. return;
  52683. }
  52684. this._transparencyMode = value;
  52685. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  52686. this._markAllSubMeshesAsTexturesAndMiscDirty();
  52687. },
  52688. enumerable: true,
  52689. configurable: true
  52690. });
  52691. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  52692. /**
  52693. * Returns true if alpha blending should be disabled.
  52694. */
  52695. get: function () {
  52696. return (this.subSurface.disableAlphaBlending ||
  52697. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  52698. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52699. },
  52700. enumerable: true,
  52701. configurable: true
  52702. });
  52703. /**
  52704. * Specifies whether or not this material should be rendered in alpha blend mode.
  52705. */
  52706. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  52707. if (this._disableAlphaBlending) {
  52708. return false;
  52709. }
  52710. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  52711. };
  52712. /**
  52713. * Specifies if the mesh will require alpha blending.
  52714. * @param mesh - BJS mesh.
  52715. */
  52716. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  52717. if (this._disableAlphaBlending && mesh.visibility >= 1.0) {
  52718. return false;
  52719. }
  52720. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  52721. };
  52722. /**
  52723. * Specifies whether or not this material should be rendered in alpha test mode.
  52724. */
  52725. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  52726. if (this._forceAlphaTest) {
  52727. return true;
  52728. }
  52729. if (this.subSurface.disableAlphaBlending) {
  52730. return false;
  52731. }
  52732. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52733. };
  52734. /**
  52735. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52736. */
  52737. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  52738. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  52739. };
  52740. /**
  52741. * Gets the texture used for the alpha test.
  52742. */
  52743. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  52744. return this._albedoTexture;
  52745. };
  52746. /**
  52747. * Specifies that the submesh is ready to be used.
  52748. * @param mesh - BJS mesh.
  52749. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52750. * @param useInstances - Specifies that instances should be used.
  52751. * @returns - boolean indicating that the submesh is ready or not.
  52752. */
  52753. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  52754. if (subMesh.effect && this.isFrozen) {
  52755. if (this._wasPreviouslyReady) {
  52756. return true;
  52757. }
  52758. }
  52759. if (!subMesh._materialDefines) {
  52760. subMesh._materialDefines = new PBRMaterialDefines();
  52761. }
  52762. var defines = subMesh._materialDefines;
  52763. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  52764. if (defines._renderId === this.getScene().getRenderId()) {
  52765. return true;
  52766. }
  52767. }
  52768. var scene = this.getScene();
  52769. var engine = scene.getEngine();
  52770. if (defines._areTexturesDirty) {
  52771. if (scene.texturesEnabled) {
  52772. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  52773. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  52774. return false;
  52775. }
  52776. }
  52777. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  52778. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  52779. return false;
  52780. }
  52781. }
  52782. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  52783. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  52784. return false;
  52785. }
  52786. }
  52787. var reflectionTexture = this._getReflectionTexture();
  52788. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  52789. if (!reflectionTexture.isReadyOrNotBlocking()) {
  52790. return false;
  52791. }
  52792. }
  52793. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  52794. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  52795. return false;
  52796. }
  52797. }
  52798. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  52799. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  52800. return false;
  52801. }
  52802. }
  52803. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  52804. if (this._metallicTexture) {
  52805. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  52806. return false;
  52807. }
  52808. }
  52809. else if (this._reflectivityTexture) {
  52810. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  52811. return false;
  52812. }
  52813. }
  52814. if (this._microSurfaceTexture) {
  52815. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  52816. return false;
  52817. }
  52818. }
  52819. }
  52820. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52821. // Bump texture cannot be not blocking.
  52822. if (!this._bumpTexture.isReady()) {
  52823. return false;
  52824. }
  52825. }
  52826. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  52827. // This is blocking.
  52828. if (!this._environmentBRDFTexture.isReady()) {
  52829. return false;
  52830. }
  52831. }
  52832. }
  52833. }
  52834. if (!this.subSurface.isReadyForSubMesh(defines, scene) ||
  52835. !this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap) ||
  52836. !this.sheen.isReadyForSubMesh(defines, scene) ||
  52837. !this.anisotropy.isReadyForSubMesh(defines, scene)) {
  52838. return false;
  52839. }
  52840. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52841. if (!this._imageProcessingConfiguration.isReady()) {
  52842. return false;
  52843. }
  52844. }
  52845. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  52846. mesh.createNormals(true);
  52847. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  52848. }
  52849. var previousEffect = subMesh.effect;
  52850. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  52851. if (effect) {
  52852. // Use previous effect while new one is compiling
  52853. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  52854. effect = previousEffect;
  52855. defines.markAsUnprocessed();
  52856. }
  52857. else {
  52858. scene.resetCachedMaterial();
  52859. subMesh.setEffect(effect, defines);
  52860. this.buildUniformLayout();
  52861. }
  52862. }
  52863. if (!subMesh.effect || !subMesh.effect.isReady()) {
  52864. return false;
  52865. }
  52866. defines._renderId = scene.getRenderId();
  52867. this._wasPreviouslyReady = true;
  52868. return true;
  52869. };
  52870. /**
  52871. * Specifies if the material uses metallic roughness workflow.
  52872. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52873. */
  52874. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  52875. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  52876. return true;
  52877. }
  52878. return false;
  52879. };
  52880. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  52881. if (onCompiled === void 0) { onCompiled = null; }
  52882. if (onError === void 0) { onError = null; }
  52883. if (useInstances === void 0) { useInstances = null; }
  52884. if (useClipPlane === void 0) { useClipPlane = null; }
  52885. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  52886. if (!defines.isDirty) {
  52887. return null;
  52888. }
  52889. defines.markAsProcessed();
  52890. var scene = this.getScene();
  52891. var engine = scene.getEngine();
  52892. // Fallbacks
  52893. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_14__["EffectFallbacks"]();
  52894. var fallbackRank = 0;
  52895. if (defines.USESPHERICALINVERTEX) {
  52896. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  52897. }
  52898. if (defines.FOG) {
  52899. fallbacks.addFallback(fallbackRank, "FOG");
  52900. }
  52901. if (defines.SPECULARAA) {
  52902. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  52903. }
  52904. if (defines.POINTSIZE) {
  52905. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  52906. }
  52907. if (defines.LOGARITHMICDEPTH) {
  52908. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  52909. }
  52910. if (defines.PARALLAX) {
  52911. fallbacks.addFallback(fallbackRank, "PARALLAX");
  52912. }
  52913. if (defines.PARALLAXOCCLUSION) {
  52914. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  52915. }
  52916. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52917. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52918. fallbackRank = _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52919. fallbackRank = _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52920. if (defines.ENVIRONMENTBRDF) {
  52921. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  52922. }
  52923. if (defines.TANGENT) {
  52924. fallbacks.addFallback(fallbackRank++, "TANGENT");
  52925. }
  52926. if (defines.BUMP) {
  52927. fallbacks.addFallback(fallbackRank++, "BUMP");
  52928. }
  52929. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  52930. if (defines.SPECULARTERM) {
  52931. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  52932. }
  52933. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  52934. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  52935. }
  52936. if (defines.LIGHTMAP) {
  52937. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  52938. }
  52939. if (defines.NORMAL) {
  52940. fallbacks.addFallback(fallbackRank++, "NORMAL");
  52941. }
  52942. if (defines.AMBIENT) {
  52943. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  52944. }
  52945. if (defines.EMISSIVE) {
  52946. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  52947. }
  52948. if (defines.VERTEXCOLOR) {
  52949. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  52950. }
  52951. if (defines.NUM_BONE_INFLUENCERS > 0) {
  52952. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  52953. }
  52954. if (defines.MORPHTARGETS) {
  52955. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  52956. }
  52957. if (defines.MULTIVIEW) {
  52958. fallbacks.addFallback(0, "MULTIVIEW");
  52959. }
  52960. //Attributes
  52961. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  52962. if (defines.NORMAL) {
  52963. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  52964. }
  52965. if (defines.TANGENT) {
  52966. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  52967. }
  52968. if (defines.UV1) {
  52969. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  52970. }
  52971. if (defines.UV2) {
  52972. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  52973. }
  52974. if (defines.VERTEXCOLOR) {
  52975. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  52976. }
  52977. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  52978. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  52979. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  52980. var shaderName = "pbr";
  52981. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "visibility", "vReflectionColor",
  52982. "vFogInfos", "vFogColor", "pointSize",
  52983. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  52984. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos",
  52985. "mBones",
  52986. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix",
  52987. "vLightingIntensity",
  52988. "logarithmicDepthConstant",
  52989. "vSphericalX", "vSphericalY", "vSphericalZ",
  52990. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  52991. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  52992. "vReflectionMicrosurfaceInfos",
  52993. "vTangentSpaceParams", "boneTextureWidth",
  52994. "vDebugMode"
  52995. ];
  52996. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  52997. "bumpSampler", "lightmapSampler", "opacitySampler",
  52998. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  52999. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  53000. var uniformBuffers = ["Material", "Scene"];
  53001. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddUniforms(uniforms);
  53002. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddSamplers(samplers);
  53003. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  53004. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  53005. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  53006. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddSamplers(samplers);
  53007. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddUniforms(uniforms);
  53008. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddSamplers(samplers);
  53009. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"]) {
  53010. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  53011. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  53012. }
  53013. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareUniformsAndSamplersList({
  53014. uniformsNames: uniforms,
  53015. uniformBuffersNames: uniformBuffers,
  53016. samplers: samplers,
  53017. defines: defines,
  53018. maxSimultaneousLights: this._maxSimultaneousLights
  53019. });
  53020. if (this.customShaderNameResolve) {
  53021. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  53022. }
  53023. var join = defines.toString();
  53024. return engine.createEffect(shaderName, {
  53025. attributes: attribs,
  53026. uniformsNames: uniforms,
  53027. uniformBuffersNames: uniformBuffers,
  53028. samplers: samplers,
  53029. defines: join,
  53030. fallbacks: fallbacks,
  53031. onCompiled: onCompiled,
  53032. onError: onError,
  53033. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  53034. }, engine);
  53035. };
  53036. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  53037. if (useInstances === void 0) { useInstances = null; }
  53038. if (useClipPlane === void 0) { useClipPlane = null; }
  53039. var scene = this.getScene();
  53040. var engine = scene.getEngine();
  53041. // Lights
  53042. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  53043. defines._needNormals = true;
  53044. // Multiview
  53045. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  53046. // Textures
  53047. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  53048. if (defines._areTexturesDirty) {
  53049. defines._needUVs = false;
  53050. if (scene.texturesEnabled) {
  53051. if (scene.getEngine().getCaps().textureLOD) {
  53052. defines.LODBASEDMICROSFURACE = true;
  53053. }
  53054. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53055. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  53056. }
  53057. else {
  53058. defines.ALBEDO = false;
  53059. }
  53060. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  53061. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  53062. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  53063. }
  53064. else {
  53065. defines.AMBIENT = false;
  53066. }
  53067. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  53068. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  53069. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  53070. }
  53071. else {
  53072. defines.OPACITY = false;
  53073. }
  53074. var reflectionTexture = this._getReflectionTexture();
  53075. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53076. defines.REFLECTION = true;
  53077. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  53078. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  53079. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  53080. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  53081. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].INVCUBIC_MODE) {
  53082. defines.INVERTCUBICMAP = true;
  53083. }
  53084. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  53085. defines.REFLECTIONMAP_CUBIC = false;
  53086. defines.REFLECTIONMAP_EXPLICIT = false;
  53087. defines.REFLECTIONMAP_PLANAR = false;
  53088. defines.REFLECTIONMAP_PROJECTION = false;
  53089. defines.REFLECTIONMAP_SKYBOX = false;
  53090. defines.REFLECTIONMAP_SPHERICAL = false;
  53091. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  53092. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  53093. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  53094. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  53095. switch (reflectionTexture.coordinatesMode) {
  53096. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].EXPLICIT_MODE:
  53097. defines.REFLECTIONMAP_EXPLICIT = true;
  53098. break;
  53099. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].PLANAR_MODE:
  53100. defines.REFLECTIONMAP_PLANAR = true;
  53101. break;
  53102. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].PROJECTION_MODE:
  53103. defines.REFLECTIONMAP_PROJECTION = true;
  53104. break;
  53105. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SKYBOX_MODE:
  53106. defines.REFLECTIONMAP_SKYBOX = true;
  53107. break;
  53108. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SPHERICAL_MODE:
  53109. defines.REFLECTIONMAP_SPHERICAL = true;
  53110. break;
  53111. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].EQUIRECTANGULAR_MODE:
  53112. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  53113. break;
  53114. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  53115. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  53116. break;
  53117. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  53118. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  53119. break;
  53120. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].CUBIC_MODE:
  53121. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].INVCUBIC_MODE:
  53122. default:
  53123. defines.REFLECTIONMAP_CUBIC = true;
  53124. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  53125. break;
  53126. }
  53127. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SKYBOX_MODE) {
  53128. if (reflectionTexture.sphericalPolynomial) {
  53129. defines.USESPHERICALFROMREFLECTIONMAP = true;
  53130. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  53131. defines.USESPHERICALINVERTEX = false;
  53132. }
  53133. else {
  53134. defines.USESPHERICALINVERTEX = true;
  53135. }
  53136. }
  53137. }
  53138. else {
  53139. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  53140. }
  53141. }
  53142. else {
  53143. defines.REFLECTION = false;
  53144. defines.REFLECTIONMAP_3D = false;
  53145. defines.REFLECTIONMAP_SPHERICAL = false;
  53146. defines.REFLECTIONMAP_PLANAR = false;
  53147. defines.REFLECTIONMAP_CUBIC = false;
  53148. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  53149. defines.REFLECTIONMAP_PROJECTION = false;
  53150. defines.REFLECTIONMAP_SKYBOX = false;
  53151. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  53152. defines.REFLECTIONMAP_EXPLICIT = false;
  53153. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  53154. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  53155. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  53156. defines.INVERTCUBICMAP = false;
  53157. defines.USESPHERICALFROMREFLECTIONMAP = false;
  53158. defines.USESPHERICALINVERTEX = false;
  53159. defines.REFLECTIONMAP_OPPOSITEZ = false;
  53160. defines.LODINREFLECTIONALPHA = false;
  53161. defines.GAMMAREFLECTION = false;
  53162. defines.RGBDREFLECTION = false;
  53163. }
  53164. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53165. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  53166. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  53167. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  53168. }
  53169. else {
  53170. defines.LIGHTMAP = false;
  53171. }
  53172. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53173. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  53174. }
  53175. else {
  53176. defines.EMISSIVE = false;
  53177. }
  53178. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53179. if (this._metallicTexture) {
  53180. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  53181. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  53182. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  53183. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  53184. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  53185. }
  53186. else if (this._reflectivityTexture) {
  53187. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  53188. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  53189. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  53190. }
  53191. else {
  53192. defines.REFLECTIVITY = false;
  53193. }
  53194. if (this._microSurfaceTexture) {
  53195. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  53196. }
  53197. else {
  53198. defines.MICROSURFACEMAP = false;
  53199. }
  53200. }
  53201. else {
  53202. defines.REFLECTIVITY = false;
  53203. defines.MICROSURFACEMAP = false;
  53204. }
  53205. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53206. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  53207. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53208. defines.PARALLAX = true;
  53209. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  53210. }
  53211. else {
  53212. defines.PARALLAX = false;
  53213. }
  53214. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  53215. }
  53216. else {
  53217. defines.BUMP = false;
  53218. }
  53219. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53220. defines.ENVIRONMENTBRDF = true;
  53221. // Not actual true RGBD, only the B chanel is encoded as RGBD for sheen.
  53222. defines.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD;
  53223. }
  53224. else {
  53225. defines.ENVIRONMENTBRDF = false;
  53226. defines.ENVIRONMENTBRDF_RGBD = false;
  53227. }
  53228. if (this._shouldUseAlphaFromAlbedoTexture()) {
  53229. defines.ALPHAFROMALBEDO = true;
  53230. }
  53231. else {
  53232. defines.ALPHAFROMALBEDO = false;
  53233. }
  53234. }
  53235. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  53236. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  53237. defines.USEPHYSICALLIGHTFALLOFF = false;
  53238. defines.USEGLTFLIGHTFALLOFF = false;
  53239. }
  53240. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  53241. defines.USEPHYSICALLIGHTFALLOFF = false;
  53242. defines.USEGLTFLIGHTFALLOFF = true;
  53243. }
  53244. else {
  53245. defines.USEPHYSICALLIGHTFALLOFF = true;
  53246. defines.USEGLTFLIGHTFALLOFF = false;
  53247. }
  53248. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  53249. if (!this.backFaceCulling && this._twoSidedLighting) {
  53250. defines.TWOSIDEDLIGHTING = true;
  53251. }
  53252. else {
  53253. defines.TWOSIDEDLIGHTING = false;
  53254. }
  53255. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  53256. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  53257. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  53258. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  53259. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  53260. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  53261. }
  53262. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  53263. this._imageProcessingConfiguration.prepareDefines(defines);
  53264. }
  53265. defines.FORCENORMALFORWARD = this._forceNormalForward;
  53266. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  53267. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  53268. // Misc.
  53269. if (defines._areMiscDirty) {
  53270. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  53271. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  53272. defines.DEBUGMODE = this._debugMode;
  53273. }
  53274. // External config
  53275. this.subSurface.prepareDefines(defines, scene);
  53276. this.clearCoat.prepareDefines(defines, scene);
  53277. this.anisotropy.prepareDefines(defines, mesh, scene);
  53278. this.brdf.prepareDefines(defines);
  53279. this.sheen.prepareDefines(defines, scene);
  53280. // Values that need to be evaluated on every frame
  53281. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  53282. // Attribs
  53283. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  53284. };
  53285. /**
  53286. * Force shader compilation
  53287. */
  53288. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  53289. var _this = this;
  53290. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  53291. var defines = new PBRMaterialDefines();
  53292. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  53293. if (effect.isReady()) {
  53294. if (onCompiled) {
  53295. onCompiled(this);
  53296. }
  53297. }
  53298. else {
  53299. effect.onCompileObservable.add(function () {
  53300. if (onCompiled) {
  53301. onCompiled(_this);
  53302. }
  53303. });
  53304. }
  53305. };
  53306. /**
  53307. * Initializes the uniform buffer layout for the shader.
  53308. */
  53309. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  53310. // Order is important !
  53311. var ubo = this._uniformBuffer;
  53312. ubo.addUniform("vAlbedoInfos", 2);
  53313. ubo.addUniform("vAmbientInfos", 4);
  53314. ubo.addUniform("vOpacityInfos", 2);
  53315. ubo.addUniform("vEmissiveInfos", 2);
  53316. ubo.addUniform("vLightmapInfos", 2);
  53317. ubo.addUniform("vReflectivityInfos", 3);
  53318. ubo.addUniform("vMicroSurfaceSamplerInfos", 2);
  53319. ubo.addUniform("vReflectionInfos", 2);
  53320. ubo.addUniform("vReflectionPosition", 3);
  53321. ubo.addUniform("vReflectionSize", 3);
  53322. ubo.addUniform("vBumpInfos", 3);
  53323. ubo.addUniform("albedoMatrix", 16);
  53324. ubo.addUniform("ambientMatrix", 16);
  53325. ubo.addUniform("opacityMatrix", 16);
  53326. ubo.addUniform("emissiveMatrix", 16);
  53327. ubo.addUniform("lightmapMatrix", 16);
  53328. ubo.addUniform("reflectivityMatrix", 16);
  53329. ubo.addUniform("microSurfaceSamplerMatrix", 16);
  53330. ubo.addUniform("bumpMatrix", 16);
  53331. ubo.addUniform("vTangentSpaceParams", 2);
  53332. ubo.addUniform("reflectionMatrix", 16);
  53333. ubo.addUniform("vReflectionColor", 3);
  53334. ubo.addUniform("vAlbedoColor", 4);
  53335. ubo.addUniform("vLightingIntensity", 4);
  53336. ubo.addUniform("vReflectionMicrosurfaceInfos", 3);
  53337. ubo.addUniform("pointSize", 1);
  53338. ubo.addUniform("vReflectivityColor", 4);
  53339. ubo.addUniform("vEmissiveColor", 3);
  53340. ubo.addUniform("visibility", 1);
  53341. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(ubo);
  53342. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(ubo);
  53343. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].PrepareUniformBuffer(ubo);
  53344. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].PrepareUniformBuffer(ubo);
  53345. ubo.create();
  53346. };
  53347. /**
  53348. * Unbinds the material from the mesh
  53349. */
  53350. PBRBaseMaterial.prototype.unbind = function () {
  53351. if (this._activeEffect) {
  53352. var needFlag = false;
  53353. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  53354. this._activeEffect.setTexture("reflection2DSampler", null);
  53355. needFlag = true;
  53356. }
  53357. if (this.subSurface.unbind(this._activeEffect)) {
  53358. needFlag = true;
  53359. }
  53360. if (needFlag) {
  53361. this._markAllSubMeshesAsTexturesDirty();
  53362. }
  53363. }
  53364. _super.prototype.unbind.call(this);
  53365. };
  53366. /**
  53367. * Binds the submesh data.
  53368. * @param world - The world matrix.
  53369. * @param mesh - The BJS mesh.
  53370. * @param subMesh - A submesh of the BJS mesh.
  53371. */
  53372. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  53373. var scene = this.getScene();
  53374. var defines = subMesh._materialDefines;
  53375. if (!defines) {
  53376. return;
  53377. }
  53378. var effect = subMesh.effect;
  53379. if (!effect) {
  53380. return;
  53381. }
  53382. this._activeEffect = effect;
  53383. // Matrices
  53384. if (!defines.INSTANCES) {
  53385. this.bindOnlyWorldMatrix(world);
  53386. }
  53387. // Normal Matrix
  53388. if (defines.OBJECTSPACE_NORMALMAP) {
  53389. world.toNormalMatrix(this._normalMatrix);
  53390. this.bindOnlyNormalMatrix(this._normalMatrix);
  53391. }
  53392. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  53393. // Bones
  53394. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  53395. var reflectionTexture = null;
  53396. var ubo = this._uniformBuffer;
  53397. if (mustRebind) {
  53398. var engine = scene.getEngine();
  53399. ubo.bindToEffect(effect, "Material");
  53400. this.bindViewProjection(effect);
  53401. reflectionTexture = this._getReflectionTexture();
  53402. if (!ubo.useUbo || !this.isFrozen || !ubo.isSync) {
  53403. // Texture uniforms
  53404. if (scene.texturesEnabled) {
  53405. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53406. ubo.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  53407. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, ubo, "albedo");
  53408. }
  53409. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  53410. ubo.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  53411. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, ubo, "ambient");
  53412. }
  53413. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  53414. ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  53415. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, ubo, "opacity");
  53416. }
  53417. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53418. ubo.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  53419. ubo.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  53420. if (reflectionTexture.boundingBoxSize) {
  53421. var cubeTexture = reflectionTexture;
  53422. ubo.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  53423. ubo.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  53424. }
  53425. var polynomials = reflectionTexture.sphericalPolynomial;
  53426. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  53427. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  53428. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  53429. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  53430. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  53431. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  53432. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  53433. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  53434. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  53435. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  53436. }
  53437. ubo.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  53438. }
  53439. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53440. ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  53441. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
  53442. }
  53443. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53444. ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  53445. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
  53446. }
  53447. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53448. if (this._metallicTexture) {
  53449. ubo.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  53450. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, ubo, "reflectivity");
  53451. }
  53452. else if (this._reflectivityTexture) {
  53453. ubo.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  53454. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, ubo, "reflectivity");
  53455. }
  53456. if (this._microSurfaceTexture) {
  53457. ubo.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  53458. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, ubo, "microSurfaceSampler");
  53459. }
  53460. }
  53461. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53462. ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  53463. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, ubo, "bump");
  53464. if (scene._mirroredCameraPosition) {
  53465. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  53466. }
  53467. else {
  53468. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  53469. }
  53470. }
  53471. }
  53472. // Point size
  53473. if (this.pointsCloud) {
  53474. ubo.updateFloat("pointSize", this.pointSize);
  53475. }
  53476. // Colors
  53477. if (defines.METALLICWORKFLOW) {
  53478. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  53479. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  53480. ubo.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  53481. }
  53482. else {
  53483. ubo.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  53484. }
  53485. ubo.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  53486. ubo.updateColor3("vReflectionColor", this._reflectionColor);
  53487. ubo.updateColor4("vAlbedoColor", this._albedoColor, this.alpha);
  53488. // Visibility
  53489. ubo.updateFloat("visibility", mesh.visibility);
  53490. // Misc
  53491. this._lightingInfos.x = this._directIntensity;
  53492. this._lightingInfos.y = this._emissiveIntensity;
  53493. this._lightingInfos.z = this._environmentIntensity;
  53494. this._lightingInfos.w = this._specularIntensity;
  53495. ubo.updateVector4("vLightingIntensity", this._lightingInfos);
  53496. }
  53497. // Textures
  53498. if (scene.texturesEnabled) {
  53499. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53500. ubo.setTexture("albedoSampler", this._albedoTexture);
  53501. }
  53502. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  53503. ubo.setTexture("ambientSampler", this._ambientTexture);
  53504. }
  53505. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  53506. ubo.setTexture("opacitySampler", this._opacityTexture);
  53507. }
  53508. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53509. if (defines.LODBASEDMICROSFURACE) {
  53510. ubo.setTexture("reflectionSampler", reflectionTexture);
  53511. }
  53512. else {
  53513. ubo.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  53514. ubo.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  53515. ubo.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  53516. }
  53517. }
  53518. if (defines.ENVIRONMENTBRDF) {
  53519. ubo.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  53520. }
  53521. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53522. ubo.setTexture("emissiveSampler", this._emissiveTexture);
  53523. }
  53524. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53525. ubo.setTexture("lightmapSampler", this._lightmapTexture);
  53526. }
  53527. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53528. if (this._metallicTexture) {
  53529. ubo.setTexture("reflectivitySampler", this._metallicTexture);
  53530. }
  53531. else if (this._reflectivityTexture) {
  53532. ubo.setTexture("reflectivitySampler", this._reflectivityTexture);
  53533. }
  53534. if (this._microSurfaceTexture) {
  53535. ubo.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  53536. }
  53537. }
  53538. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53539. ubo.setTexture("bumpSampler", this._bumpTexture);
  53540. }
  53541. }
  53542. this.subSurface.bindForSubMesh(ubo, scene, engine, this.isFrozen, defines.LODBASEDMICROSFURACE);
  53543. this.clearCoat.bindForSubMesh(ubo, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  53544. this.anisotropy.bindForSubMesh(ubo, scene, this.isFrozen);
  53545. this.sheen.bindForSubMesh(ubo, scene, this.isFrozen);
  53546. // Clip plane
  53547. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  53548. // Colors
  53549. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  53550. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  53551. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  53552. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  53553. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  53554. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  53555. }
  53556. if (mustRebind || !this.isFrozen) {
  53557. // Lights
  53558. if (scene.lightsEnabled && !this._disableLighting) {
  53559. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  53560. }
  53561. // View
  53562. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  53563. this.bindView(effect);
  53564. }
  53565. // Fog
  53566. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  53567. // Morph targets
  53568. if (defines.NUM_MORPH_INFLUENCERS) {
  53569. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  53570. }
  53571. // image processing
  53572. this._imageProcessingConfiguration.bind(this._activeEffect);
  53573. // Log. depth
  53574. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  53575. }
  53576. ubo.update();
  53577. this._afterBind(mesh, this._activeEffect);
  53578. };
  53579. /**
  53580. * Returns the animatable textures.
  53581. * @returns - Array of animatable textures.
  53582. */
  53583. PBRBaseMaterial.prototype.getAnimatables = function () {
  53584. var results = [];
  53585. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  53586. results.push(this._albedoTexture);
  53587. }
  53588. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  53589. results.push(this._ambientTexture);
  53590. }
  53591. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  53592. results.push(this._opacityTexture);
  53593. }
  53594. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  53595. results.push(this._reflectionTexture);
  53596. }
  53597. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  53598. results.push(this._emissiveTexture);
  53599. }
  53600. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  53601. results.push(this._metallicTexture);
  53602. }
  53603. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  53604. results.push(this._reflectivityTexture);
  53605. }
  53606. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53607. results.push(this._bumpTexture);
  53608. }
  53609. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  53610. results.push(this._lightmapTexture);
  53611. }
  53612. this.subSurface.getAnimatables(results);
  53613. this.clearCoat.getAnimatables(results);
  53614. this.sheen.getAnimatables(results);
  53615. this.anisotropy.getAnimatables(results);
  53616. return results;
  53617. };
  53618. /**
  53619. * Returns the texture used for reflections.
  53620. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53621. */
  53622. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  53623. if (this._reflectionTexture) {
  53624. return this._reflectionTexture;
  53625. }
  53626. return this.getScene().environmentTexture;
  53627. };
  53628. /**
  53629. * Returns an array of the actively used textures.
  53630. * @returns - Array of BaseTextures
  53631. */
  53632. PBRBaseMaterial.prototype.getActiveTextures = function () {
  53633. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53634. if (this._albedoTexture) {
  53635. activeTextures.push(this._albedoTexture);
  53636. }
  53637. if (this._ambientTexture) {
  53638. activeTextures.push(this._ambientTexture);
  53639. }
  53640. if (this._opacityTexture) {
  53641. activeTextures.push(this._opacityTexture);
  53642. }
  53643. if (this._reflectionTexture) {
  53644. activeTextures.push(this._reflectionTexture);
  53645. }
  53646. if (this._emissiveTexture) {
  53647. activeTextures.push(this._emissiveTexture);
  53648. }
  53649. if (this._reflectivityTexture) {
  53650. activeTextures.push(this._reflectivityTexture);
  53651. }
  53652. if (this._metallicTexture) {
  53653. activeTextures.push(this._metallicTexture);
  53654. }
  53655. if (this._microSurfaceTexture) {
  53656. activeTextures.push(this._microSurfaceTexture);
  53657. }
  53658. if (this._bumpTexture) {
  53659. activeTextures.push(this._bumpTexture);
  53660. }
  53661. if (this._lightmapTexture) {
  53662. activeTextures.push(this._lightmapTexture);
  53663. }
  53664. this.subSurface.getActiveTextures(activeTextures);
  53665. this.clearCoat.getActiveTextures(activeTextures);
  53666. this.sheen.getActiveTextures(activeTextures);
  53667. this.anisotropy.getActiveTextures(activeTextures);
  53668. return activeTextures;
  53669. };
  53670. /**
  53671. * Checks to see if a texture is used in the material.
  53672. * @param texture - Base texture to use.
  53673. * @returns - Boolean specifying if a texture is used in the material.
  53674. */
  53675. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  53676. if (_super.prototype.hasTexture.call(this, texture)) {
  53677. return true;
  53678. }
  53679. if (this._albedoTexture === texture) {
  53680. return true;
  53681. }
  53682. if (this._ambientTexture === texture) {
  53683. return true;
  53684. }
  53685. if (this._opacityTexture === texture) {
  53686. return true;
  53687. }
  53688. if (this._reflectionTexture === texture) {
  53689. return true;
  53690. }
  53691. if (this._reflectivityTexture === texture) {
  53692. return true;
  53693. }
  53694. if (this._metallicTexture === texture) {
  53695. return true;
  53696. }
  53697. if (this._microSurfaceTexture === texture) {
  53698. return true;
  53699. }
  53700. if (this._bumpTexture === texture) {
  53701. return true;
  53702. }
  53703. if (this._lightmapTexture === texture) {
  53704. return true;
  53705. }
  53706. return this.subSurface.hasTexture(texture) ||
  53707. this.clearCoat.hasTexture(texture) ||
  53708. this.sheen.hasTexture(texture) ||
  53709. this.anisotropy.hasTexture(texture);
  53710. };
  53711. /**
  53712. * Disposes the resources of the material.
  53713. * @param forceDisposeEffect - Forces the disposal of effects.
  53714. * @param forceDisposeTextures - Forces the disposal of all textures.
  53715. */
  53716. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  53717. if (forceDisposeTextures) {
  53718. if (this._albedoTexture) {
  53719. this._albedoTexture.dispose();
  53720. }
  53721. if (this._ambientTexture) {
  53722. this._ambientTexture.dispose();
  53723. }
  53724. if (this._opacityTexture) {
  53725. this._opacityTexture.dispose();
  53726. }
  53727. if (this._reflectionTexture) {
  53728. this._reflectionTexture.dispose();
  53729. }
  53730. if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
  53731. this._environmentBRDFTexture.dispose();
  53732. }
  53733. if (this._emissiveTexture) {
  53734. this._emissiveTexture.dispose();
  53735. }
  53736. if (this._metallicTexture) {
  53737. this._metallicTexture.dispose();
  53738. }
  53739. if (this._reflectivityTexture) {
  53740. this._reflectivityTexture.dispose();
  53741. }
  53742. if (this._bumpTexture) {
  53743. this._bumpTexture.dispose();
  53744. }
  53745. if (this._lightmapTexture) {
  53746. this._lightmapTexture.dispose();
  53747. }
  53748. }
  53749. this.subSurface.dispose(forceDisposeTextures);
  53750. this.clearCoat.dispose(forceDisposeTextures);
  53751. this.sheen.dispose(forceDisposeTextures);
  53752. this.anisotropy.dispose(forceDisposeTextures);
  53753. this._renderTargets.dispose();
  53754. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  53755. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  53756. }
  53757. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  53758. };
  53759. /**
  53760. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53761. */
  53762. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  53763. /**
  53764. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53765. */
  53766. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  53767. /**
  53768. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53769. */
  53770. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  53771. /**
  53772. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53773. * They are also discarded below the alpha cutoff threshold to improve performances.
  53774. */
  53775. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  53776. /**
  53777. * Defines the default value of how much AO map is occluding the analytical lights
  53778. * (point spot...).
  53779. */
  53780. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  53781. /**
  53782. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53783. */
  53784. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  53785. /**
  53786. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53787. * to enhance interoperability with other engines.
  53788. */
  53789. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  53790. /**
  53791. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53792. * to enhance interoperability with other materials.
  53793. */
  53794. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  53795. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53796. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  53797. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  53798. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53799. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53800. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  53801. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53802. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53803. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  53804. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53806. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  53807. return PBRBaseMaterial;
  53808. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_16__["PushMaterial"]));
  53809. /***/ }),
  53810. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  53811. /*!************************************************!*\
  53812. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  53813. \************************************************/
  53814. /*! exports provided: PBRBaseSimpleMaterial */
  53815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53816. "use strict";
  53817. __webpack_require__.r(__webpack_exports__);
  53818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  53819. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53820. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53821. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53822. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53823. /**
  53824. * The Physically based simple base material of BJS.
  53825. *
  53826. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53827. * It is used as the base class for both the specGloss and metalRough conventions.
  53828. */
  53829. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  53830. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  53831. /**
  53832. * Instantiates a new PBRMaterial instance.
  53833. *
  53834. * @param name The material name
  53835. * @param scene The scene the material will be use in.
  53836. */
  53837. function PBRBaseSimpleMaterial(name, scene) {
  53838. var _this = _super.call(this, name, scene) || this;
  53839. /**
  53840. * Number of Simultaneous lights allowed on the material.
  53841. */
  53842. _this.maxSimultaneousLights = 4;
  53843. /**
  53844. * If sets to true, disables all the lights affecting the material.
  53845. */
  53846. _this.disableLighting = false;
  53847. /**
  53848. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53849. */
  53850. _this.invertNormalMapX = false;
  53851. /**
  53852. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53853. */
  53854. _this.invertNormalMapY = false;
  53855. /**
  53856. * Emissivie color used to self-illuminate the model.
  53857. */
  53858. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  53859. /**
  53860. * Occlusion Channel Strenght.
  53861. */
  53862. _this.occlusionStrength = 1.0;
  53863. /**
  53864. * If true, the light map contains occlusion information instead of lighting info.
  53865. */
  53866. _this.useLightmapAsShadowmap = false;
  53867. _this._useAlphaFromAlbedoTexture = true;
  53868. _this._useAmbientInGrayScale = true;
  53869. return _this;
  53870. }
  53871. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  53872. /**
  53873. * Gets the current double sided mode.
  53874. */
  53875. get: function () {
  53876. return this._twoSidedLighting;
  53877. },
  53878. /**
  53879. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53880. */
  53881. set: function (value) {
  53882. if (this._twoSidedLighting === value) {
  53883. return;
  53884. }
  53885. this._twoSidedLighting = value;
  53886. this.backFaceCulling = !value;
  53887. this._markAllSubMeshesAsTexturesDirty();
  53888. },
  53889. enumerable: true,
  53890. configurable: true
  53891. });
  53892. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  53893. return "PBRBaseSimpleMaterial";
  53894. };
  53895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53898. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  53899. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53900. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53902. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  53903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  53906. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  53907. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53908. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53910. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  53911. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53912. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53914. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  53915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53917. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  53918. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  53919. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53920. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  53921. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53922. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  53923. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53924. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53925. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53926. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  53927. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53928. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53929. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  53930. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  53931. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53932. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53933. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  53934. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  53935. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53936. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53937. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  53938. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  53939. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53940. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53941. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  53942. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53943. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  53945. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  53946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53948. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53949. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  53950. return PBRBaseSimpleMaterial;
  53951. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  53952. /***/ }),
  53953. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  53954. /*!****************************************************!*\
  53955. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  53956. \****************************************************/
  53957. /*! exports provided: PBRClearCoatConfiguration */
  53958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53959. "use strict";
  53960. __webpack_require__.r(__webpack_exports__);
  53961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  53962. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53963. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53964. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53965. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53966. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53967. /**
  53968. * Define the code related to the clear coat parameters of the pbr material.
  53969. */
  53970. var PBRClearCoatConfiguration = /** @class */ (function () {
  53971. /**
  53972. * Instantiate a new istance of clear coat configuration.
  53973. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53974. */
  53975. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  53976. this._isEnabled = false;
  53977. /**
  53978. * Defines if the clear coat is enabled in the material.
  53979. */
  53980. this.isEnabled = false;
  53981. /**
  53982. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53983. */
  53984. this.intensity = 1;
  53985. /**
  53986. * Defines the clear coat layer roughness.
  53987. */
  53988. this.roughness = 0;
  53989. this._indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53990. /**
  53991. * Defines the indice of refraction of the clear coat.
  53992. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53993. * The default fits with a polyurethane material.
  53994. * Changing the default value is more performance intensive.
  53995. */
  53996. this.indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53997. this._texture = null;
  53998. /**
  53999. * Stores the clear coat values in a texture.
  54000. */
  54001. this.texture = null;
  54002. this._bumpTexture = null;
  54003. /**
  54004. * Define the clear coat specific bump texture.
  54005. */
  54006. this.bumpTexture = null;
  54007. this._isTintEnabled = false;
  54008. /**
  54009. * Defines if the clear coat tint is enabled in the material.
  54010. */
  54011. this.isTintEnabled = false;
  54012. /**
  54013. * Defines the clear coat tint of the material.
  54014. * This is only use if tint is enabled
  54015. */
  54016. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  54017. /**
  54018. * Defines the distance at which the tint color should be found in the
  54019. * clear coat media.
  54020. * This is only use if tint is enabled
  54021. */
  54022. this.tintColorAtDistance = 1;
  54023. /**
  54024. * Defines the clear coat layer thickness.
  54025. * This is only use if tint is enabled
  54026. */
  54027. this.tintThickness = 1;
  54028. this._tintTexture = null;
  54029. /**
  54030. * Stores the clear tint values in a texture.
  54031. * rgb is tint
  54032. * a is a thickness factor
  54033. */
  54034. this.tintTexture = null;
  54035. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  54036. }
  54037. /** @hidden */
  54038. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  54039. this._internalMarkAllSubMeshesAsTexturesDirty();
  54040. };
  54041. /**
  54042. * Gets wehter the submesh is ready to be used or not.
  54043. * @param defines the list of "defines" to update.
  54044. * @param scene defines the scene the material belongs to.
  54045. * @param engine defines the engine the material belongs to.
  54046. * @param disableBumpMap defines wether the material disables bump or not.
  54047. * @returns - boolean indicating that the submesh is ready or not.
  54048. */
  54049. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  54050. if (defines._areTexturesDirty) {
  54051. if (scene.texturesEnabled) {
  54052. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54053. if (!this._texture.isReadyOrNotBlocking()) {
  54054. return false;
  54055. }
  54056. }
  54057. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  54058. // Bump texture cannot be not blocking.
  54059. if (!this._bumpTexture.isReady()) {
  54060. return false;
  54061. }
  54062. }
  54063. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54064. if (!this._tintTexture.isReadyOrNotBlocking()) {
  54065. return false;
  54066. }
  54067. }
  54068. }
  54069. }
  54070. return true;
  54071. };
  54072. /**
  54073. * Checks to see if a texture is used in the material.
  54074. * @param defines the list of "defines" to update.
  54075. * @param scene defines the scene to the material belongs to.
  54076. */
  54077. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  54078. if (this._isEnabled) {
  54079. defines.CLEARCOAT = true;
  54080. if (defines._areTexturesDirty) {
  54081. if (scene.texturesEnabled) {
  54082. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54083. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  54084. }
  54085. else {
  54086. defines.CLEARCOAT_TEXTURE = false;
  54087. }
  54088. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  54089. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  54090. }
  54091. else {
  54092. defines.CLEARCOAT_BUMP = false;
  54093. }
  54094. defines.CLEARCOAT_DEFAULTIOR = this._indiceOfRefraction === PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  54095. if (this._isTintEnabled) {
  54096. defines.CLEARCOAT_TINT = true;
  54097. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54098. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  54099. }
  54100. else {
  54101. defines.CLEARCOAT_TINT_TEXTURE = false;
  54102. }
  54103. }
  54104. else {
  54105. defines.CLEARCOAT_TINT = false;
  54106. defines.CLEARCOAT_TINT_TEXTURE = false;
  54107. }
  54108. }
  54109. }
  54110. }
  54111. else {
  54112. defines.CLEARCOAT = false;
  54113. defines.CLEARCOAT_TEXTURE = false;
  54114. defines.CLEARCOAT_BUMP = false;
  54115. defines.CLEARCOAT_TINT = false;
  54116. defines.CLEARCOAT_TINT_TEXTURE = false;
  54117. }
  54118. };
  54119. /**
  54120. * Binds the material data.
  54121. * @param uniformBuffer defines the Uniform buffer to fill in.
  54122. * @param scene defines the scene the material belongs to.
  54123. * @param engine defines the engine the material belongs to.
  54124. * @param disableBumpMap defines wether the material disables bump or not.
  54125. * @param isFrozen defines wether the material is frozen or not.
  54126. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54127. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54128. */
  54129. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  54130. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  54131. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54132. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  54133. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  54134. }
  54135. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  54136. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  54137. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  54138. if (scene._mirroredCameraPosition) {
  54139. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  54140. }
  54141. else {
  54142. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  54143. }
  54144. }
  54145. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54146. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  54147. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  54148. }
  54149. // Clear Coat General params
  54150. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  54151. // Clear Coat Refraction params
  54152. var a = 1 - this._indiceOfRefraction;
  54153. var b = 1 + this._indiceOfRefraction;
  54154. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  54155. var eta = 1 / this._indiceOfRefraction;
  54156. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  54157. if (this._isTintEnabled) {
  54158. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  54159. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  54160. }
  54161. }
  54162. // Textures
  54163. if (scene.texturesEnabled) {
  54164. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54165. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  54166. }
  54167. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  54168. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  54169. }
  54170. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54171. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  54172. }
  54173. }
  54174. };
  54175. /**
  54176. * Checks to see if a texture is used in the material.
  54177. * @param texture - Base texture to use.
  54178. * @returns - Boolean specifying if a texture is used in the material.
  54179. */
  54180. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  54181. if (this._texture === texture) {
  54182. return true;
  54183. }
  54184. if (this._bumpTexture === texture) {
  54185. return true;
  54186. }
  54187. if (this._tintTexture === texture) {
  54188. return true;
  54189. }
  54190. return false;
  54191. };
  54192. /**
  54193. * Returns an array of the actively used textures.
  54194. * @param activeTextures Array of BaseTextures
  54195. */
  54196. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  54197. if (this._texture) {
  54198. activeTextures.push(this._texture);
  54199. }
  54200. if (this._bumpTexture) {
  54201. activeTextures.push(this._bumpTexture);
  54202. }
  54203. if (this._tintTexture) {
  54204. activeTextures.push(this._tintTexture);
  54205. }
  54206. };
  54207. /**
  54208. * Returns the animatable textures.
  54209. * @param animatables Array of animatable textures.
  54210. */
  54211. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  54212. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  54213. animatables.push(this._texture);
  54214. }
  54215. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  54216. animatables.push(this._bumpTexture);
  54217. }
  54218. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  54219. animatables.push(this._tintTexture);
  54220. }
  54221. };
  54222. /**
  54223. * Disposes the resources of the material.
  54224. * @param forceDisposeTextures - Forces the disposal of all textures.
  54225. */
  54226. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  54227. if (forceDisposeTextures) {
  54228. if (this._texture) {
  54229. this._texture.dispose();
  54230. }
  54231. if (this._bumpTexture) {
  54232. this._bumpTexture.dispose();
  54233. }
  54234. if (this._tintTexture) {
  54235. this._tintTexture.dispose();
  54236. }
  54237. }
  54238. };
  54239. /**
  54240. * Get the current class name of the texture useful for serialization or dynamic coding.
  54241. * @returns "PBRClearCoatConfiguration"
  54242. */
  54243. PBRClearCoatConfiguration.prototype.getClassName = function () {
  54244. return "PBRClearCoatConfiguration";
  54245. };
  54246. /**
  54247. * Add fallbacks to the effect fallbacks list.
  54248. * @param defines defines the Base texture to use.
  54249. * @param fallbacks defines the current fallback list.
  54250. * @param currentRank defines the current fallback rank.
  54251. * @returns the new fallback rank.
  54252. */
  54253. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  54254. if (defines.CLEARCOAT_BUMP) {
  54255. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  54256. }
  54257. if (defines.CLEARCOAT_TINT) {
  54258. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  54259. }
  54260. if (defines.CLEARCOAT) {
  54261. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  54262. }
  54263. return currentRank;
  54264. };
  54265. /**
  54266. * Add the required uniforms to the current list.
  54267. * @param uniforms defines the current uniform list.
  54268. */
  54269. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  54270. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  54271. };
  54272. /**
  54273. * Add the required samplers to the current list.
  54274. * @param samplers defines the current sampler list.
  54275. */
  54276. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  54277. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  54278. };
  54279. /**
  54280. * Add the required uniforms to the current buffer.
  54281. * @param uniformBuffer defines the current uniform buffer.
  54282. */
  54283. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  54284. uniformBuffer.addUniform("vClearCoatParams", 2);
  54285. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  54286. uniformBuffer.addUniform("vClearCoatInfos", 2);
  54287. uniformBuffer.addUniform("clearCoatMatrix", 16);
  54288. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  54289. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  54290. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  54291. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  54292. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  54293. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  54294. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  54295. };
  54296. /**
  54297. * Makes a duplicate of the current configuration into another one.
  54298. * @param clearCoatConfiguration define the config where to copy the info
  54299. */
  54300. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  54301. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  54302. };
  54303. /**
  54304. * Serializes this clear coat configuration.
  54305. * @returns - An object with the serialized config.
  54306. */
  54307. PBRClearCoatConfiguration.prototype.serialize = function () {
  54308. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54309. };
  54310. /**
  54311. * Parses a Clear Coat Configuration from a serialized object.
  54312. * @param source - Serialized object.
  54313. */
  54314. PBRClearCoatConfiguration.prototype.parse = function (source) {
  54315. var _this = this;
  54316. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  54317. };
  54318. /**
  54319. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54320. * The default fits with a polyurethane material.
  54321. */
  54322. PBRClearCoatConfiguration._DefaultIndiceOfRefraction = 1.5;
  54323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54325. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  54326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54328. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  54329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54331. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  54332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54334. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  54335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54337. ], PBRClearCoatConfiguration.prototype, "_indiceOfRefraction", void 0);
  54338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54340. ], PBRClearCoatConfiguration.prototype, "indiceOfRefraction", void 0);
  54341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54343. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  54344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54346. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  54347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54349. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  54350. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54352. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  54353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54355. ], PBRClearCoatConfiguration.prototype, "_isTintEnabled", void 0);
  54356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54358. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  54359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  54361. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  54362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54364. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  54365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54367. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  54368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54370. ], PBRClearCoatConfiguration.prototype, "_tintTexture", void 0);
  54371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54373. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  54374. return PBRClearCoatConfiguration;
  54375. }());
  54376. /***/ }),
  54377. /***/ "./Materials/PBR/pbrMaterial.ts":
  54378. /*!**************************************!*\
  54379. !*** ./Materials/PBR/pbrMaterial.ts ***!
  54380. \**************************************/
  54381. /*! exports provided: PBRMaterial */
  54382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54383. "use strict";
  54384. __webpack_require__.r(__webpack_exports__);
  54385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  54386. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54387. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54388. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  54389. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54390. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  54391. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54392. /**
  54393. * The Physically based material of BJS.
  54394. *
  54395. * This offers the main features of a standard PBR material.
  54396. * For more information, please refer to the documentation :
  54397. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  54398. */
  54399. var PBRMaterial = /** @class */ (function (_super) {
  54400. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  54401. /**
  54402. * Instantiates a new PBRMaterial instance.
  54403. *
  54404. * @param name The material name
  54405. * @param scene The scene the material will be use in.
  54406. */
  54407. function PBRMaterial(name, scene) {
  54408. var _this = _super.call(this, name, scene) || this;
  54409. /**
  54410. * Intensity of the direct lights e.g. the four lights available in your scene.
  54411. * This impacts both the direct diffuse and specular highlights.
  54412. */
  54413. _this.directIntensity = 1.0;
  54414. /**
  54415. * Intensity of the emissive part of the material.
  54416. * This helps controlling the emissive effect without modifying the emissive color.
  54417. */
  54418. _this.emissiveIntensity = 1.0;
  54419. /**
  54420. * Intensity of the environment e.g. how much the environment will light the object
  54421. * either through harmonics for rough material or through the refelction for shiny ones.
  54422. */
  54423. _this.environmentIntensity = 1.0;
  54424. /**
  54425. * This is a special control allowing the reduction of the specular highlights coming from the
  54426. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54427. */
  54428. _this.specularIntensity = 1.0;
  54429. /**
  54430. * Debug Control allowing disabling the bump map on this material.
  54431. */
  54432. _this.disableBumpMap = false;
  54433. /**
  54434. * AKA Occlusion Texture Intensity in other nomenclature.
  54435. */
  54436. _this.ambientTextureStrength = 1.0;
  54437. /**
  54438. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54439. * 1 means it completely occludes it
  54440. * 0 mean it has no impact
  54441. */
  54442. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54443. /**
  54444. * The color of a material in ambient lighting.
  54445. */
  54446. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54447. /**
  54448. * AKA Diffuse Color in other nomenclature.
  54449. */
  54450. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54451. /**
  54452. * AKA Specular Color in other nomenclature.
  54453. */
  54454. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54455. /**
  54456. * The color reflected from the material.
  54457. */
  54458. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  54459. /**
  54460. * The color emitted from the material.
  54461. */
  54462. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54463. /**
  54464. * AKA Glossiness in other nomenclature.
  54465. */
  54466. _this.microSurface = 1.0;
  54467. /**
  54468. * If true, the light map contains occlusion information instead of lighting info.
  54469. */
  54470. _this.useLightmapAsShadowmap = false;
  54471. /**
  54472. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54473. */
  54474. _this.useAlphaFromAlbedoTexture = false;
  54475. /**
  54476. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54477. */
  54478. _this.forceAlphaTest = false;
  54479. /**
  54480. * Defines the alpha limits in alpha test mode.
  54481. */
  54482. _this.alphaCutOff = 0.4;
  54483. /**
  54484. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54485. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54486. */
  54487. _this.useSpecularOverAlpha = true;
  54488. /**
  54489. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54490. */
  54491. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  54492. /**
  54493. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54494. */
  54495. _this.useRoughnessFromMetallicTextureAlpha = true;
  54496. /**
  54497. * Specifies if the metallic texture contains the roughness information in its green channel.
  54498. */
  54499. _this.useRoughnessFromMetallicTextureGreen = false;
  54500. /**
  54501. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54502. */
  54503. _this.useMetallnessFromMetallicTextureBlue = false;
  54504. /**
  54505. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54506. */
  54507. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  54508. /**
  54509. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54510. */
  54511. _this.useAmbientInGrayScale = false;
  54512. /**
  54513. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54514. * The material will try to infer what glossiness each pixel should be.
  54515. */
  54516. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  54517. /**
  54518. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54519. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54520. */
  54521. _this.useRadianceOverAlpha = true;
  54522. /**
  54523. * Allows using an object space normal map (instead of tangent space).
  54524. */
  54525. _this.useObjectSpaceNormalMap = false;
  54526. /**
  54527. * Allows using the bump map in parallax mode.
  54528. */
  54529. _this.useParallax = false;
  54530. /**
  54531. * Allows using the bump map in parallax occlusion mode.
  54532. */
  54533. _this.useParallaxOcclusion = false;
  54534. /**
  54535. * Controls the scale bias of the parallax mode.
  54536. */
  54537. _this.parallaxScaleBias = 0.05;
  54538. /**
  54539. * If sets to true, disables all the lights affecting the material.
  54540. */
  54541. _this.disableLighting = false;
  54542. /**
  54543. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54544. */
  54545. _this.forceIrradianceInFragment = false;
  54546. /**
  54547. * Number of Simultaneous lights allowed on the material.
  54548. */
  54549. _this.maxSimultaneousLights = 4;
  54550. /**
  54551. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54552. */
  54553. _this.invertNormalMapX = false;
  54554. /**
  54555. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54556. */
  54557. _this.invertNormalMapY = false;
  54558. /**
  54559. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54560. */
  54561. _this.twoSidedLighting = false;
  54562. /**
  54563. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54564. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54565. */
  54566. _this.useAlphaFresnel = false;
  54567. /**
  54568. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54569. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54570. */
  54571. _this.useLinearAlphaFresnel = false;
  54572. /**
  54573. * Let user defines the brdf lookup texture used for IBL.
  54574. * A default 8bit version is embedded but you could point at :
  54575. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  54576. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54577. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54578. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54579. */
  54580. _this.environmentBRDFTexture = null;
  54581. /**
  54582. * Force normal to face away from face.
  54583. */
  54584. _this.forceNormalForward = false;
  54585. /**
  54586. * Enables specular anti aliasing in the PBR shader.
  54587. * It will both interacts on the Geometry for analytical and IBL lighting.
  54588. * It also prefilter the roughness map based on the bump values.
  54589. */
  54590. _this.enableSpecularAntiAliasing = false;
  54591. /**
  54592. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54593. * makes the reflect vector face the model (under horizon).
  54594. */
  54595. _this.useHorizonOcclusion = true;
  54596. /**
  54597. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54598. * too much the area relying on ambient texture to define their ambient occlusion.
  54599. */
  54600. _this.useRadianceOcclusion = true;
  54601. /**
  54602. * If set to true, no lighting calculations will be applied.
  54603. */
  54604. _this.unlit = false;
  54605. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  54606. return _this;
  54607. }
  54608. Object.defineProperty(PBRMaterial.prototype, "refractionTexture", {
  54609. /**
  54610. * Stores the refracted light information in a texture.
  54611. */
  54612. get: function () {
  54613. return this.subSurface.refractionTexture;
  54614. },
  54615. set: function (value) {
  54616. this.subSurface.refractionTexture = value;
  54617. if (value) {
  54618. this.subSurface.isRefractionEnabled = true;
  54619. }
  54620. else if (!this.subSurface.linkRefractionWithTransparency) {
  54621. this.subSurface.isRefractionEnabled = false;
  54622. }
  54623. },
  54624. enumerable: true,
  54625. configurable: true
  54626. });
  54627. Object.defineProperty(PBRMaterial.prototype, "indexOfRefraction", {
  54628. /**
  54629. * source material index of refraction (IOR)' / 'destination material IOR.
  54630. */
  54631. get: function () {
  54632. return 1 / this.subSurface.indexOfRefraction;
  54633. },
  54634. set: function (value) {
  54635. this.subSurface.indexOfRefraction = 1 / value;
  54636. },
  54637. enumerable: true,
  54638. configurable: true
  54639. });
  54640. Object.defineProperty(PBRMaterial.prototype, "invertRefractionY", {
  54641. /**
  54642. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54643. */
  54644. get: function () {
  54645. return this.subSurface.invertRefractionY;
  54646. },
  54647. set: function (value) {
  54648. this.subSurface.invertRefractionY = value;
  54649. },
  54650. enumerable: true,
  54651. configurable: true
  54652. });
  54653. Object.defineProperty(PBRMaterial.prototype, "linkRefractionWithTransparency", {
  54654. /**
  54655. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54656. * Materials half opaque for instance using refraction could benefit from this control.
  54657. */
  54658. get: function () {
  54659. return this.subSurface.linkRefractionWithTransparency;
  54660. },
  54661. set: function (value) {
  54662. this.subSurface.linkRefractionWithTransparency = value;
  54663. if (value) {
  54664. this.subSurface.isRefractionEnabled = true;
  54665. }
  54666. },
  54667. enumerable: true,
  54668. configurable: true
  54669. });
  54670. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  54671. /**
  54672. * BJS is using an harcoded light falloff based on a manually sets up range.
  54673. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54674. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54675. */
  54676. get: function () {
  54677. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54678. },
  54679. /**
  54680. * BJS is using an harcoded light falloff based on a manually sets up range.
  54681. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54682. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54683. */
  54684. set: function (value) {
  54685. if (value !== this.usePhysicalLightFalloff) {
  54686. // Ensure the effect will be rebuilt.
  54687. this._markAllSubMeshesAsTexturesDirty();
  54688. if (value) {
  54689. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54690. }
  54691. else {
  54692. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54693. }
  54694. }
  54695. },
  54696. enumerable: true,
  54697. configurable: true
  54698. });
  54699. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  54700. /**
  54701. * In order to support the falloff compatibility with gltf, a special mode has been added
  54702. * to reproduce the gltf light falloff.
  54703. */
  54704. get: function () {
  54705. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54706. },
  54707. /**
  54708. * In order to support the falloff compatibility with gltf, a special mode has been added
  54709. * to reproduce the gltf light falloff.
  54710. */
  54711. set: function (value) {
  54712. if (value !== this.useGLTFLightFalloff) {
  54713. // Ensure the effect will be rebuilt.
  54714. this._markAllSubMeshesAsTexturesDirty();
  54715. if (value) {
  54716. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54717. }
  54718. else {
  54719. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54720. }
  54721. }
  54722. },
  54723. enumerable: true,
  54724. configurable: true
  54725. });
  54726. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  54727. /**
  54728. * Gets the image processing configuration used either in this material.
  54729. */
  54730. get: function () {
  54731. return this._imageProcessingConfiguration;
  54732. },
  54733. /**
  54734. * Sets the Default image processing configuration used either in the this material.
  54735. *
  54736. * If sets to null, the scene one is in use.
  54737. */
  54738. set: function (value) {
  54739. this._attachImageProcessingConfiguration(value);
  54740. // Ensure the effect will be rebuilt.
  54741. this._markAllSubMeshesAsTexturesDirty();
  54742. },
  54743. enumerable: true,
  54744. configurable: true
  54745. });
  54746. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  54747. /**
  54748. * Gets wether the color curves effect is enabled.
  54749. */
  54750. get: function () {
  54751. return this.imageProcessingConfiguration.colorCurvesEnabled;
  54752. },
  54753. /**
  54754. * Sets wether the color curves effect is enabled.
  54755. */
  54756. set: function (value) {
  54757. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  54758. },
  54759. enumerable: true,
  54760. configurable: true
  54761. });
  54762. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  54763. /**
  54764. * Gets wether the color grading effect is enabled.
  54765. */
  54766. get: function () {
  54767. return this.imageProcessingConfiguration.colorGradingEnabled;
  54768. },
  54769. /**
  54770. * Gets wether the color grading effect is enabled.
  54771. */
  54772. set: function (value) {
  54773. this.imageProcessingConfiguration.colorGradingEnabled = value;
  54774. },
  54775. enumerable: true,
  54776. configurable: true
  54777. });
  54778. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  54779. /**
  54780. * Gets wether tonemapping is enabled or not.
  54781. */
  54782. get: function () {
  54783. return this._imageProcessingConfiguration.toneMappingEnabled;
  54784. },
  54785. /**
  54786. * Sets wether tonemapping is enabled or not
  54787. */
  54788. set: function (value) {
  54789. this._imageProcessingConfiguration.toneMappingEnabled = value;
  54790. },
  54791. enumerable: true,
  54792. configurable: true
  54793. });
  54794. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  54795. /**
  54796. * The camera exposure used on this material.
  54797. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54798. * This corresponds to a photographic exposure.
  54799. */
  54800. get: function () {
  54801. return this._imageProcessingConfiguration.exposure;
  54802. },
  54803. /**
  54804. * The camera exposure used on this material.
  54805. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54806. * This corresponds to a photographic exposure.
  54807. */
  54808. set: function (value) {
  54809. this._imageProcessingConfiguration.exposure = value;
  54810. },
  54811. enumerable: true,
  54812. configurable: true
  54813. });
  54814. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  54815. /**
  54816. * Gets The camera contrast used on this material.
  54817. */
  54818. get: function () {
  54819. return this._imageProcessingConfiguration.contrast;
  54820. },
  54821. /**
  54822. * Sets The camera contrast used on this material.
  54823. */
  54824. set: function (value) {
  54825. this._imageProcessingConfiguration.contrast = value;
  54826. },
  54827. enumerable: true,
  54828. configurable: true
  54829. });
  54830. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  54831. /**
  54832. * Gets the Color Grading 2D Lookup Texture.
  54833. */
  54834. get: function () {
  54835. return this._imageProcessingConfiguration.colorGradingTexture;
  54836. },
  54837. /**
  54838. * Sets the Color Grading 2D Lookup Texture.
  54839. */
  54840. set: function (value) {
  54841. this._imageProcessingConfiguration.colorGradingTexture = value;
  54842. },
  54843. enumerable: true,
  54844. configurable: true
  54845. });
  54846. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  54847. /**
  54848. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54849. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54850. * 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;
  54851. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54852. */
  54853. get: function () {
  54854. return this._imageProcessingConfiguration.colorCurves;
  54855. },
  54856. /**
  54857. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54858. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54859. * 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;
  54860. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54861. */
  54862. set: function (value) {
  54863. this._imageProcessingConfiguration.colorCurves = value;
  54864. },
  54865. enumerable: true,
  54866. configurable: true
  54867. });
  54868. /**
  54869. * Returns the name of this material class.
  54870. */
  54871. PBRMaterial.prototype.getClassName = function () {
  54872. return "PBRMaterial";
  54873. };
  54874. /**
  54875. * Makes a duplicate of the current material.
  54876. * @param name - name to use for the new material.
  54877. */
  54878. PBRMaterial.prototype.clone = function (name) {
  54879. var _this = this;
  54880. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  54881. clone.id = name;
  54882. clone.name = name;
  54883. this.clearCoat.copyTo(clone.clearCoat);
  54884. this.anisotropy.copyTo(clone.anisotropy);
  54885. this.brdf.copyTo(clone.brdf);
  54886. this.sheen.copyTo(clone.sheen);
  54887. return clone;
  54888. };
  54889. /**
  54890. * Serializes this PBR Material.
  54891. * @returns - An object with the serialized material.
  54892. */
  54893. PBRMaterial.prototype.serialize = function () {
  54894. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54895. serializationObject.customType = "BABYLON.PBRMaterial";
  54896. serializationObject.clearCoat = this.clearCoat.serialize();
  54897. serializationObject.anisotropy = this.anisotropy.serialize();
  54898. serializationObject.brdf = this.brdf.serialize();
  54899. serializationObject.sheen = this.sheen.serialize();
  54900. return serializationObject;
  54901. };
  54902. // Statics
  54903. /**
  54904. * Parses a PBR Material from a serialized object.
  54905. * @param source - Serialized object.
  54906. * @param scene - BJS scene instance.
  54907. * @param rootUrl - url for the scene object
  54908. * @returns - PBRMaterial
  54909. */
  54910. PBRMaterial.Parse = function (source, scene, rootUrl) {
  54911. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  54912. if (source.clearCoat) {
  54913. material.clearCoat.parse(source.clearCoat);
  54914. }
  54915. if (source.anisotropy) {
  54916. material.anisotropy.parse(source.anisotropy);
  54917. }
  54918. if (source.brdf) {
  54919. material.brdf.parse(source.brdf);
  54920. }
  54921. if (source.sheen) {
  54922. material.sheen.parse(source.brdf);
  54923. }
  54924. return material;
  54925. };
  54926. /**
  54927. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54928. */
  54929. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  54930. /**
  54931. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54932. */
  54933. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  54934. /**
  54935. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54936. */
  54937. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  54938. /**
  54939. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54940. * They are also discarded below the alpha cutoff threshold to improve performances.
  54941. */
  54942. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  54943. /**
  54944. * Defines the default value of how much AO map is occluding the analytical lights
  54945. * (point spot...).
  54946. */
  54947. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54948. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54949. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54951. ], PBRMaterial.prototype, "directIntensity", void 0);
  54952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54954. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54955. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  54956. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54957. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54959. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  54960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54963. ], PBRMaterial.prototype, "specularIntensity", void 0);
  54964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54967. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  54968. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54969. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54971. ], PBRMaterial.prototype, "albedoTexture", void 0);
  54972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54975. ], PBRMaterial.prototype, "ambientTexture", void 0);
  54976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54978. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54979. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  54980. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54981. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54983. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  54984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54987. ], PBRMaterial.prototype, "opacityTexture", void 0);
  54988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54991. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  54992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54995. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  54996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54999. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  55000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55003. ], PBRMaterial.prototype, "metallicTexture", void 0);
  55004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55007. ], PBRMaterial.prototype, "metallic", void 0);
  55008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55011. ], PBRMaterial.prototype, "roughness", void 0);
  55012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55015. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  55016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55018. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55019. ], PBRMaterial.prototype, "bumpTexture", void 0);
  55020. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55021. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  55023. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  55024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  55026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55027. ], PBRMaterial.prototype, "ambientColor", void 0);
  55028. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55029. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  55030. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55031. ], PBRMaterial.prototype, "albedoColor", void 0);
  55032. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55033. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  55034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55035. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  55036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  55038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55039. ], PBRMaterial.prototype, "reflectionColor", void 0);
  55040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  55042. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55043. ], PBRMaterial.prototype, "emissiveColor", 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"])("_markAllSubMeshesAsTexturesDirty")
  55047. ], PBRMaterial.prototype, "microSurface", 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, "useLightmapAsShadowmap", 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"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  55055. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", 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"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  55059. ], PBRMaterial.prototype, "forceAlphaTest", 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"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  55063. ], PBRMaterial.prototype, "alphaCutOff", 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, "useSpecularOverAlpha", 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, "useMicroSurfaceFromReflectivityMapAlpha", 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, "useRoughnessFromMetallicTextureAlpha", void 0);
  55076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55078. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55079. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", 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, "useMetallnessFromMetallicTextureBlue", 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, "useAmbientOcclusionFromMetallicTextureRed", 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, "useAmbientInGrayScale", 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, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  55096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55098. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  55099. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55101. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  55102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55104. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55105. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  55106. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55107. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55109. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  55110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55113. ], PBRMaterial.prototype, "useParallax", void 0);
  55114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55117. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  55118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55121. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  55122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55125. ], PBRMaterial.prototype, "disableLighting", void 0);
  55126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55129. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  55130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55133. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  55134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55137. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  55138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55140. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55141. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  55142. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55143. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55144. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55145. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  55146. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55147. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55149. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  55150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55152. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55153. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  55154. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55155. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55157. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  55158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55160. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55161. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  55162. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55163. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55164. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55165. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  55166. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55167. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55169. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  55170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55172. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55173. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  55174. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55175. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55176. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  55177. ], PBRMaterial.prototype, "unlit", void 0);
  55178. return PBRMaterial;
  55179. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  55180. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  55181. /***/ }),
  55182. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  55183. /*!*******************************************************!*\
  55184. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  55185. \*******************************************************/
  55186. /*! exports provided: PBRMetallicRoughnessMaterial */
  55187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55188. "use strict";
  55189. __webpack_require__.r(__webpack_exports__);
  55190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  55191. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55192. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55193. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  55194. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55195. /**
  55196. * The PBR material of BJS following the metal roughness convention.
  55197. *
  55198. * This fits to the PBR convention in the GLTF definition:
  55199. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55200. */
  55201. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  55202. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  55203. /**
  55204. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55205. *
  55206. * @param name The material name
  55207. * @param scene The scene the material will be use in.
  55208. */
  55209. function PBRMetallicRoughnessMaterial(name, scene) {
  55210. var _this = _super.call(this, name, scene) || this;
  55211. _this._useRoughnessFromMetallicTextureAlpha = false;
  55212. _this._useRoughnessFromMetallicTextureGreen = true;
  55213. _this._useMetallnessFromMetallicTextureBlue = true;
  55214. _this.metallic = 1.0;
  55215. _this.roughness = 1.0;
  55216. return _this;
  55217. }
  55218. /**
  55219. * Return the currrent class name of the material.
  55220. */
  55221. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  55222. return "PBRMetallicRoughnessMaterial";
  55223. };
  55224. /**
  55225. * Makes a duplicate of the current material.
  55226. * @param name - name to use for the new material.
  55227. */
  55228. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  55229. var _this = this;
  55230. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  55231. clone.id = name;
  55232. clone.name = name;
  55233. this.clearCoat.copyTo(clone.clearCoat);
  55234. this.anisotropy.copyTo(clone.anisotropy);
  55235. this.brdf.copyTo(clone.brdf);
  55236. this.sheen.copyTo(clone.sheen);
  55237. return clone;
  55238. };
  55239. /**
  55240. * Serialize the material to a parsable JSON object.
  55241. */
  55242. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  55243. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55244. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  55245. serializationObject.clearCoat = this.clearCoat.serialize();
  55246. serializationObject.anisotropy = this.anisotropy.serialize();
  55247. serializationObject.brdf = this.brdf.serialize();
  55248. serializationObject.sheen = this.sheen.serialize();
  55249. return serializationObject;
  55250. };
  55251. /**
  55252. * Parses a JSON object correponding to the serialize function.
  55253. */
  55254. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  55255. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  55256. if (source.clearCoat) {
  55257. material.clearCoat.parse(source.clearCoat);
  55258. }
  55259. if (source.anisotropy) {
  55260. material.anisotropy.parse(source.anisotropy);
  55261. }
  55262. if (source.brdf) {
  55263. material.brdf.parse(source.brdf);
  55264. }
  55265. if (source.sheen) {
  55266. material.sheen.parse(source.brdf);
  55267. }
  55268. return material;
  55269. };
  55270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  55272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55273. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  55274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55277. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  55278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55281. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  55282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55285. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  55286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  55289. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  55290. return PBRMetallicRoughnessMaterial;
  55291. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55292. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  55293. /***/ }),
  55294. /***/ "./Materials/PBR/pbrSheenConfiguration.ts":
  55295. /*!************************************************!*\
  55296. !*** ./Materials/PBR/pbrSheenConfiguration.ts ***!
  55297. \************************************************/
  55298. /*! exports provided: PBRSheenConfiguration */
  55299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55300. "use strict";
  55301. __webpack_require__.r(__webpack_exports__);
  55302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSheenConfiguration", function() { return PBRSheenConfiguration; });
  55303. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55304. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55305. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55306. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  55307. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  55308. /**
  55309. * Define the code related to the Sheen parameters of the pbr material.
  55310. */
  55311. var PBRSheenConfiguration = /** @class */ (function () {
  55312. /**
  55313. * Instantiate a new istance of clear coat configuration.
  55314. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55315. */
  55316. function PBRSheenConfiguration(markAllSubMeshesAsTexturesDirty) {
  55317. this._isEnabled = false;
  55318. /**
  55319. * Defines if the material uses sheen.
  55320. */
  55321. this.isEnabled = false;
  55322. this._linkSheenWithAlbedo = false;
  55323. /**
  55324. * Defines if the sheen is linked to the sheen color.
  55325. */
  55326. this.linkSheenWithAlbedo = false;
  55327. /**
  55328. * Defines the sheen intensity.
  55329. */
  55330. this.intensity = 1;
  55331. /**
  55332. * Defines the sheen color.
  55333. */
  55334. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55335. this._texture = null;
  55336. /**
  55337. * Stores the sheen tint values in a texture.
  55338. * rgb is tint
  55339. * a is a intensity
  55340. */
  55341. this.texture = null;
  55342. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  55343. }
  55344. /** @hidden */
  55345. PBRSheenConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  55346. this._internalMarkAllSubMeshesAsTexturesDirty();
  55347. };
  55348. /**
  55349. * Specifies that the submesh is ready to be used.
  55350. * @param defines the list of "defines" to update.
  55351. * @param scene defines the scene the material belongs to.
  55352. * @returns - boolean indicating that the submesh is ready or not.
  55353. */
  55354. PBRSheenConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  55355. if (defines._areTexturesDirty) {
  55356. if (scene.texturesEnabled) {
  55357. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55358. if (!this._texture.isReadyOrNotBlocking()) {
  55359. return false;
  55360. }
  55361. }
  55362. }
  55363. }
  55364. return true;
  55365. };
  55366. /**
  55367. * Checks to see if a texture is used in the material.
  55368. * @param defines the list of "defines" to update.
  55369. * @param scene defines the scene the material belongs to.
  55370. */
  55371. PBRSheenConfiguration.prototype.prepareDefines = function (defines, scene) {
  55372. if (this._isEnabled) {
  55373. defines.SHEEN = this._isEnabled;
  55374. defines.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo;
  55375. if (defines._areTexturesDirty) {
  55376. if (scene.texturesEnabled) {
  55377. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55378. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "SHEEN_TEXTURE");
  55379. }
  55380. else {
  55381. defines.SHEEN_TEXTURE = false;
  55382. }
  55383. }
  55384. }
  55385. }
  55386. else {
  55387. defines.SHEEN = false;
  55388. defines.SHEEN_TEXTURE = false;
  55389. defines.SHEEN_LINKWITHALBEDO = false;
  55390. }
  55391. };
  55392. /**
  55393. * Binds the material data.
  55394. * @param uniformBuffer defines the Uniform buffer to fill in.
  55395. * @param scene defines the scene the material belongs to.
  55396. * @param isFrozen defines wether the material is frozen or not.
  55397. */
  55398. PBRSheenConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  55399. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  55400. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55401. uniformBuffer.updateFloat2("vSheenInfos", this._texture.coordinatesIndex, this._texture.level);
  55402. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "sheen");
  55403. }
  55404. // Sheen
  55405. uniformBuffer.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity);
  55406. }
  55407. // Textures
  55408. if (scene.texturesEnabled) {
  55409. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55410. uniformBuffer.setTexture("sheenSampler", this._texture);
  55411. }
  55412. }
  55413. };
  55414. /**
  55415. * Checks to see if a texture is used in the material.
  55416. * @param texture - Base texture to use.
  55417. * @returns - Boolean specifying if a texture is used in the material.
  55418. */
  55419. PBRSheenConfiguration.prototype.hasTexture = function (texture) {
  55420. if (this._texture === texture) {
  55421. return true;
  55422. }
  55423. return false;
  55424. };
  55425. /**
  55426. * Returns an array of the actively used textures.
  55427. * @param activeTextures Array of BaseTextures
  55428. */
  55429. PBRSheenConfiguration.prototype.getActiveTextures = function (activeTextures) {
  55430. if (this._texture) {
  55431. activeTextures.push(this._texture);
  55432. }
  55433. };
  55434. /**
  55435. * Returns the animatable textures.
  55436. * @param animatables Array of animatable textures.
  55437. */
  55438. PBRSheenConfiguration.prototype.getAnimatables = function (animatables) {
  55439. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  55440. animatables.push(this._texture);
  55441. }
  55442. };
  55443. /**
  55444. * Disposes the resources of the material.
  55445. * @param forceDisposeTextures - Forces the disposal of all textures.
  55446. */
  55447. PBRSheenConfiguration.prototype.dispose = function (forceDisposeTextures) {
  55448. if (forceDisposeTextures) {
  55449. if (this._texture) {
  55450. this._texture.dispose();
  55451. }
  55452. }
  55453. };
  55454. /**
  55455. * Get the current class name of the texture useful for serialization or dynamic coding.
  55456. * @returns "PBRSheenConfiguration"
  55457. */
  55458. PBRSheenConfiguration.prototype.getClassName = function () {
  55459. return "PBRSheenConfiguration";
  55460. };
  55461. /**
  55462. * Add fallbacks to the effect fallbacks list.
  55463. * @param defines defines the Base texture to use.
  55464. * @param fallbacks defines the current fallback list.
  55465. * @param currentRank defines the current fallback rank.
  55466. * @returns the new fallback rank.
  55467. */
  55468. PBRSheenConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  55469. if (defines.SHEEN) {
  55470. fallbacks.addFallback(currentRank++, "SHEEN");
  55471. }
  55472. return currentRank;
  55473. };
  55474. /**
  55475. * Add the required uniforms to the current list.
  55476. * @param uniforms defines the current uniform list.
  55477. */
  55478. PBRSheenConfiguration.AddUniforms = function (uniforms) {
  55479. uniforms.push("vSheenColor", "vSheenInfos", "sheenMatrix");
  55480. };
  55481. /**
  55482. * Add the required uniforms to the current buffer.
  55483. * @param uniformBuffer defines the current uniform buffer.
  55484. */
  55485. PBRSheenConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  55486. uniformBuffer.addUniform("vSheenColor", 4);
  55487. uniformBuffer.addUniform("vSheenInfos", 2);
  55488. uniformBuffer.addUniform("sheenMatrix", 16);
  55489. };
  55490. /**
  55491. * Add the required samplers to the current list.
  55492. * @param samplers defines the current sampler list.
  55493. */
  55494. PBRSheenConfiguration.AddSamplers = function (samplers) {
  55495. samplers.push("sheenSampler");
  55496. };
  55497. /**
  55498. * Makes a duplicate of the current configuration into another one.
  55499. * @param sheenConfiguration define the config where to copy the info
  55500. */
  55501. PBRSheenConfiguration.prototype.copyTo = function (sheenConfiguration) {
  55502. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return sheenConfiguration; }, this);
  55503. };
  55504. /**
  55505. * Serializes this BRDF configuration.
  55506. * @returns - An object with the serialized config.
  55507. */
  55508. PBRSheenConfiguration.prototype.serialize = function () {
  55509. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55510. };
  55511. /**
  55512. * Parses a Sheen Configuration from a serialized object.
  55513. * @param source - Serialized object.
  55514. */
  55515. PBRSheenConfiguration.prototype.parse = function (source) {
  55516. var _this = this;
  55517. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  55518. };
  55519. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55520. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55521. ], PBRSheenConfiguration.prototype, "_isEnabled", void 0);
  55522. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55523. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55524. ], PBRSheenConfiguration.prototype, "isEnabled", void 0);
  55525. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55526. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55527. ], PBRSheenConfiguration.prototype, "_linkSheenWithAlbedo", void 0);
  55528. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55529. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55530. ], PBRSheenConfiguration.prototype, "linkSheenWithAlbedo", void 0);
  55531. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55532. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55533. ], PBRSheenConfiguration.prototype, "intensity", void 0);
  55534. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55535. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  55536. ], PBRSheenConfiguration.prototype, "color", void 0);
  55537. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55538. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  55539. ], PBRSheenConfiguration.prototype, "_texture", void 0);
  55540. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55542. ], PBRSheenConfiguration.prototype, "texture", void 0);
  55543. return PBRSheenConfiguration;
  55544. }());
  55545. /***/ }),
  55546. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  55547. /*!********************************************************!*\
  55548. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  55549. \********************************************************/
  55550. /*! exports provided: PBRSpecularGlossinessMaterial */
  55551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55552. "use strict";
  55553. __webpack_require__.r(__webpack_exports__);
  55554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  55555. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55556. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55557. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  55558. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55559. /**
  55560. * The PBR material of BJS following the specular glossiness convention.
  55561. *
  55562. * This fits to the PBR convention in the GLTF definition:
  55563. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55564. */
  55565. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  55566. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  55567. /**
  55568. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55569. *
  55570. * @param name The material name
  55571. * @param scene The scene the material will be use in.
  55572. */
  55573. function PBRSpecularGlossinessMaterial(name, scene) {
  55574. var _this = _super.call(this, name, scene) || this;
  55575. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  55576. return _this;
  55577. }
  55578. /**
  55579. * Return the currrent class name of the material.
  55580. */
  55581. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  55582. return "PBRSpecularGlossinessMaterial";
  55583. };
  55584. /**
  55585. * Makes a duplicate of the current material.
  55586. * @param name - name to use for the new material.
  55587. */
  55588. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  55589. var _this = this;
  55590. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  55591. clone.id = name;
  55592. clone.name = name;
  55593. this.clearCoat.copyTo(clone.clearCoat);
  55594. this.anisotropy.copyTo(clone.anisotropy);
  55595. this.brdf.copyTo(clone.brdf);
  55596. this.sheen.copyTo(clone.sheen);
  55597. return clone;
  55598. };
  55599. /**
  55600. * Serialize the material to a parsable JSON object.
  55601. */
  55602. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  55603. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55604. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  55605. serializationObject.clearCoat = this.clearCoat.serialize();
  55606. serializationObject.anisotropy = this.anisotropy.serialize();
  55607. serializationObject.brdf = this.brdf.serialize();
  55608. serializationObject.sheen = this.sheen.serialize();
  55609. return serializationObject;
  55610. };
  55611. /**
  55612. * Parses a JSON object correponding to the serialize function.
  55613. */
  55614. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  55615. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  55616. if (source.clearCoat) {
  55617. material.clearCoat.parse(source.clearCoat);
  55618. }
  55619. if (source.anisotropy) {
  55620. material.anisotropy.parse(source.anisotropy);
  55621. }
  55622. if (source.brdf) {
  55623. material.brdf.parse(source.brdf);
  55624. }
  55625. if (source.sheen) {
  55626. material.sheen.parse(source.brdf);
  55627. }
  55628. return material;
  55629. };
  55630. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55631. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  55632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55633. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  55634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55637. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  55638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  55640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  55641. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  55642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  55645. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  55646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  55649. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  55650. return PBRSpecularGlossinessMaterial;
  55651. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55652. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  55653. /***/ }),
  55654. /***/ "./Materials/PBR/pbrSubSurfaceConfiguration.ts":
  55655. /*!*****************************************************!*\
  55656. !*** ./Materials/PBR/pbrSubSurfaceConfiguration.ts ***!
  55657. \*****************************************************/
  55658. /*! exports provided: PBRSubSurfaceConfiguration */
  55659. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55660. "use strict";
  55661. __webpack_require__.r(__webpack_exports__);
  55662. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSubSurfaceConfiguration", function() { return PBRSubSurfaceConfiguration; });
  55663. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55664. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55665. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55666. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  55667. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  55668. /**
  55669. * Define the code related to the sub surface parameters of the pbr material.
  55670. */
  55671. var PBRSubSurfaceConfiguration = /** @class */ (function () {
  55672. /**
  55673. * Instantiate a new istance of sub surface configuration.
  55674. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55675. */
  55676. function PBRSubSurfaceConfiguration(markAllSubMeshesAsTexturesDirty) {
  55677. this._isRefractionEnabled = false;
  55678. /**
  55679. * Defines if the refraction is enabled in the material.
  55680. */
  55681. this.isRefractionEnabled = false;
  55682. this._isTranslucencyEnabled = false;
  55683. /**
  55684. * Defines if the translucency is enabled in the material.
  55685. */
  55686. this.isTranslucencyEnabled = false;
  55687. this._isScatteringEnabled = false;
  55688. // /**
  55689. // * Defines if the sub surface scattering is enabled in the material.
  55690. // */
  55691. // @expandToProperty("_markAllSubMeshesAsTexturesDirty")
  55692. // public isScatteringEnabled = false;
  55693. /**
  55694. * Defines the refraction intensity of the material.
  55695. * The refraction when enabled replaces the Diffuse part of the material.
  55696. * The intensity helps transitionning between diffuse and refraction.
  55697. */
  55698. this.refractionIntensity = 1;
  55699. /**
  55700. * Defines the translucency intensity of the material.
  55701. * When translucency has been enabled, this defines how much of the "translucency"
  55702. * is addded to the diffuse part of the material.
  55703. */
  55704. this.translucencyIntensity = 1;
  55705. /**
  55706. * Defines the scattering intensity of the material.
  55707. * When scattering has been enabled, this defines how much of the "scattered light"
  55708. * is addded to the diffuse part of the material.
  55709. */
  55710. this.scatteringIntensity = 1;
  55711. this._thicknessTexture = null;
  55712. /**
  55713. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55714. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55715. * 0 would mean minimumThickness
  55716. * 1 would mean maximumThickness
  55717. * The other channels might be use as a mask to vary the different effects intensity.
  55718. */
  55719. this.thicknessTexture = null;
  55720. this._refractionTexture = null;
  55721. /**
  55722. * Defines the texture to use for refraction.
  55723. */
  55724. this.refractionTexture = null;
  55725. this._indexOfRefraction = 1;
  55726. /**
  55727. * Defines the indice of refraction used in the material.
  55728. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55729. */
  55730. this.indexOfRefraction = 1;
  55731. this._invertRefractionY = false;
  55732. /**
  55733. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55734. */
  55735. this.invertRefractionY = false;
  55736. this._linkRefractionWithTransparency = false;
  55737. /**
  55738. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55739. * Materials half opaque for instance using refraction could benefit from this control.
  55740. */
  55741. this.linkRefractionWithTransparency = false;
  55742. /**
  55743. * Defines the minimum thickness stored in the thickness map.
  55744. * If no thickness map is defined, this value will be used to simulate thickness.
  55745. */
  55746. this.minimumThickness = 0;
  55747. /**
  55748. * Defines the maximum thickness stored in the thickness map.
  55749. */
  55750. this.maximumThickness = 1;
  55751. /**
  55752. * Defines the volume tint of the material.
  55753. * This is used for both translucency and scattering.
  55754. */
  55755. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55756. /**
  55757. * Defines the distance at which the tint color should be found in the media.
  55758. * This is used for refraction only.
  55759. */
  55760. this.tintColorAtDistance = 1;
  55761. /**
  55762. * Defines how far each channel transmit through the media.
  55763. * It is defined as a color to simplify it selection.
  55764. */
  55765. this.diffusionDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55766. this._useMaskFromThicknessTexture = false;
  55767. /**
  55768. * Stores the intensity of the different subsurface effects in the thickness texture.
  55769. * * the green channel is the translucency intensity.
  55770. * * the blue channel is the scattering intensity.
  55771. * * the alpha channel is the refraction intensity.
  55772. */
  55773. this.useMaskFromThicknessTexture = false;
  55774. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  55775. }
  55776. /** @hidden */
  55777. PBRSubSurfaceConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  55778. this._internalMarkAllSubMeshesAsTexturesDirty();
  55779. };
  55780. /**
  55781. * Gets wehter the submesh is ready to be used or not.
  55782. * @param defines the list of "defines" to update.
  55783. * @param scene defines the scene the material belongs to.
  55784. * @returns - boolean indicating that the submesh is ready or not.
  55785. */
  55786. PBRSubSurfaceConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  55787. if (defines._areTexturesDirty) {
  55788. if (scene.texturesEnabled) {
  55789. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55790. if (!this._thicknessTexture.isReadyOrNotBlocking()) {
  55791. return false;
  55792. }
  55793. }
  55794. var refractionTexture = this._getRefractionTexture(scene);
  55795. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55796. if (!refractionTexture.isReadyOrNotBlocking()) {
  55797. return false;
  55798. }
  55799. }
  55800. }
  55801. }
  55802. return true;
  55803. };
  55804. /**
  55805. * Checks to see if a texture is used in the material.
  55806. * @param defines the list of "defines" to update.
  55807. * @param scene defines the scene to the material belongs to.
  55808. */
  55809. PBRSubSurfaceConfiguration.prototype.prepareDefines = function (defines, scene) {
  55810. if (defines._areTexturesDirty) {
  55811. defines.SUBSURFACE = false;
  55812. defines.SS_TRANSLUCENCY = this._isTranslucencyEnabled;
  55813. defines.SS_SCATERRING = this._isScatteringEnabled;
  55814. defines.SS_THICKNESSANDMASK_TEXTURE = false;
  55815. defines.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  55816. defines.SS_REFRACTION = false;
  55817. defines.SS_REFRACTIONMAP_3D = false;
  55818. defines.SS_GAMMAREFRACTION = false;
  55819. defines.SS_RGBDREFRACTION = false;
  55820. defines.SS_REFRACTIONMAP_OPPOSITEZ = false;
  55821. defines.SS_LODINREFRACTIONALPHA = false;
  55822. defines.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  55823. if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
  55824. defines.SUBSURFACE = true;
  55825. if (defines._areTexturesDirty) {
  55826. if (scene.texturesEnabled) {
  55827. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55828. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._thicknessTexture, defines, "SS_THICKNESSANDMASK_TEXTURE");
  55829. }
  55830. }
  55831. }
  55832. defines.SS_MASK_FROM_THICKNESS_TEXTURE = this._useMaskFromThicknessTexture;
  55833. }
  55834. if (this._isRefractionEnabled) {
  55835. if (scene.texturesEnabled) {
  55836. var refractionTexture = this._getRefractionTexture(scene);
  55837. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55838. defines.SS_REFRACTION = true;
  55839. defines.SS_REFRACTIONMAP_3D = refractionTexture.isCube;
  55840. defines.SS_GAMMAREFRACTION = refractionTexture.gammaSpace;
  55841. defines.SS_RGBDREFRACTION = refractionTexture.isRGBD;
  55842. defines.SS_REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  55843. defines.SS_LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  55844. defines.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency;
  55845. }
  55846. }
  55847. }
  55848. }
  55849. };
  55850. /**
  55851. * Binds the material data.
  55852. * @param uniformBuffer defines the Uniform buffer to fill in.
  55853. * @param scene defines the scene the material belongs to.
  55854. * @param engine defines the engine the material belongs to.
  55855. * @param isFrozen defines wether the material is frozen or not.
  55856. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  55857. */
  55858. PBRSubSurfaceConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, isFrozen, lodBasedMicrosurface) {
  55859. var refractionTexture = this._getRefractionTexture(scene);
  55860. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  55861. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55862. uniformBuffer.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level);
  55863. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._thicknessTexture, uniformBuffer, "thickness");
  55864. }
  55865. uniformBuffer.updateFloat2("vThicknessParam", this.minimumThickness, this.maximumThickness - this.minimumThickness);
  55866. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55867. uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  55868. var depth = 1.0;
  55869. if (!refractionTexture.isCube) {
  55870. if (refractionTexture.depth) {
  55871. depth = refractionTexture.depth;
  55872. }
  55873. }
  55874. uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, 1 / this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  55875. uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  55876. }
  55877. uniformBuffer.updateColor3("vDiffusionDistance", this.diffusionDistance);
  55878. uniformBuffer.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, this.tintColorAtDistance);
  55879. uniformBuffer.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, this.scatteringIntensity);
  55880. }
  55881. // Textures
  55882. if (scene.texturesEnabled) {
  55883. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55884. uniformBuffer.setTexture("thicknessSampler", this._thicknessTexture);
  55885. }
  55886. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55887. if (lodBasedMicrosurface) {
  55888. uniformBuffer.setTexture("refractionSampler", refractionTexture);
  55889. }
  55890. else {
  55891. uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  55892. uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  55893. uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  55894. }
  55895. }
  55896. }
  55897. };
  55898. /**
  55899. * Unbinds the material from the mesh.
  55900. * @param activeEffect defines the effect that should be unbound from.
  55901. * @returns true if unbound, otherwise false
  55902. */
  55903. PBRSubSurfaceConfiguration.prototype.unbind = function (activeEffect) {
  55904. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  55905. activeEffect.setTexture("refractionSampler", null);
  55906. return true;
  55907. }
  55908. return false;
  55909. };
  55910. /**
  55911. * Returns the texture used for refraction or null if none is used.
  55912. * @param scene defines the scene the material belongs to.
  55913. * @returns - Refraction texture if present. If no refraction texture and refraction
  55914. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55915. */
  55916. PBRSubSurfaceConfiguration.prototype._getRefractionTexture = function (scene) {
  55917. if (this._refractionTexture) {
  55918. return this._refractionTexture;
  55919. }
  55920. if (this._isRefractionEnabled) {
  55921. return scene.environmentTexture;
  55922. }
  55923. return null;
  55924. };
  55925. Object.defineProperty(PBRSubSurfaceConfiguration.prototype, "disableAlphaBlending", {
  55926. /**
  55927. * Returns true if alpha blending should be disabled.
  55928. */
  55929. get: function () {
  55930. return this.isRefractionEnabled && this._linkRefractionWithTransparency;
  55931. },
  55932. enumerable: true,
  55933. configurable: true
  55934. });
  55935. /**
  55936. * Fills the list of render target textures.
  55937. * @param renderTargets the list of render targets to update
  55938. */
  55939. PBRSubSurfaceConfiguration.prototype.fillRenderTargetTextures = function (renderTargets) {
  55940. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  55941. renderTargets.push(this._refractionTexture);
  55942. }
  55943. };
  55944. /**
  55945. * Checks to see if a texture is used in the material.
  55946. * @param texture - Base texture to use.
  55947. * @returns - Boolean specifying if a texture is used in the material.
  55948. */
  55949. PBRSubSurfaceConfiguration.prototype.hasTexture = function (texture) {
  55950. if (this._thicknessTexture === texture) {
  55951. return true;
  55952. }
  55953. if (this._refractionTexture === texture) {
  55954. return true;
  55955. }
  55956. return false;
  55957. };
  55958. /**
  55959. * Gets a boolean indicating that current material needs to register RTT
  55960. * @returns true if this uses a render target otherwise false.
  55961. */
  55962. PBRSubSurfaceConfiguration.prototype.hasRenderTargetTextures = function () {
  55963. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  55964. return true;
  55965. }
  55966. return false;
  55967. };
  55968. /**
  55969. * Returns an array of the actively used textures.
  55970. * @param activeTextures Array of BaseTextures
  55971. */
  55972. PBRSubSurfaceConfiguration.prototype.getActiveTextures = function (activeTextures) {
  55973. if (this._thicknessTexture) {
  55974. activeTextures.push(this._thicknessTexture);
  55975. }
  55976. if (this._refractionTexture) {
  55977. activeTextures.push(this._refractionTexture);
  55978. }
  55979. };
  55980. /**
  55981. * Returns the animatable textures.
  55982. * @param animatables Array of animatable textures.
  55983. */
  55984. PBRSubSurfaceConfiguration.prototype.getAnimatables = function (animatables) {
  55985. if (this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0) {
  55986. animatables.push(this._thicknessTexture);
  55987. }
  55988. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  55989. animatables.push(this._refractionTexture);
  55990. }
  55991. };
  55992. /**
  55993. * Disposes the resources of the material.
  55994. * @param forceDisposeTextures - Forces the disposal of all textures.
  55995. */
  55996. PBRSubSurfaceConfiguration.prototype.dispose = function (forceDisposeTextures) {
  55997. if (forceDisposeTextures) {
  55998. if (this._thicknessTexture) {
  55999. this._thicknessTexture.dispose();
  56000. }
  56001. if (this._refractionTexture) {
  56002. this._refractionTexture.dispose();
  56003. }
  56004. }
  56005. };
  56006. /**
  56007. * Get the current class name of the texture useful for serialization or dynamic coding.
  56008. * @returns "PBRSubSurfaceConfiguration"
  56009. */
  56010. PBRSubSurfaceConfiguration.prototype.getClassName = function () {
  56011. return "PBRSubSurfaceConfiguration";
  56012. };
  56013. /**
  56014. * Add fallbacks to the effect fallbacks list.
  56015. * @param defines defines the Base texture to use.
  56016. * @param fallbacks defines the current fallback list.
  56017. * @param currentRank defines the current fallback rank.
  56018. * @returns the new fallback rank.
  56019. */
  56020. PBRSubSurfaceConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  56021. if (defines.SS_SCATERRING) {
  56022. fallbacks.addFallback(currentRank++, "SS_SCATERRING");
  56023. }
  56024. if (defines.SS_TRANSLUCENCY) {
  56025. fallbacks.addFallback(currentRank++, "SS_TRANSLUCENCY");
  56026. }
  56027. return currentRank;
  56028. };
  56029. /**
  56030. * Add the required uniforms to the current list.
  56031. * @param uniforms defines the current uniform list.
  56032. */
  56033. PBRSubSurfaceConfiguration.AddUniforms = function (uniforms) {
  56034. uniforms.push("vDiffusionDistance", "vTintColor", "vSubSurfaceIntensity", "vRefractionMicrosurfaceInfos", "vRefractionInfos", "vThicknessInfos", "vThicknessParam", "refractionMatrix", "thicknessMatrix");
  56035. };
  56036. /**
  56037. * Add the required samplers to the current list.
  56038. * @param samplers defines the current sampler list.
  56039. */
  56040. PBRSubSurfaceConfiguration.AddSamplers = function (samplers) {
  56041. samplers.push("thicknessSampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh");
  56042. };
  56043. /**
  56044. * Add the required uniforms to the current buffer.
  56045. * @param uniformBuffer defines the current uniform buffer.
  56046. */
  56047. PBRSubSurfaceConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  56048. uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  56049. uniformBuffer.addUniform("vRefractionInfos", 4);
  56050. uniformBuffer.addUniform("refractionMatrix", 16);
  56051. uniformBuffer.addUniform("vThicknessInfos", 2);
  56052. uniformBuffer.addUniform("thicknessMatrix", 16);
  56053. uniformBuffer.addUniform("vThicknessParam", 2);
  56054. uniformBuffer.addUniform("vDiffusionDistance", 3);
  56055. uniformBuffer.addUniform("vTintColor", 4);
  56056. uniformBuffer.addUniform("vSubSurfaceIntensity", 3);
  56057. };
  56058. /**
  56059. * Makes a duplicate of the current configuration into another one.
  56060. * @param configuration define the config where to copy the info
  56061. */
  56062. PBRSubSurfaceConfiguration.prototype.copyTo = function (configuration) {
  56063. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return configuration; }, this);
  56064. };
  56065. /**
  56066. * Serializes this Sub Surface configuration.
  56067. * @returns - An object with the serialized config.
  56068. */
  56069. PBRSubSurfaceConfiguration.prototype.serialize = function () {
  56070. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  56071. };
  56072. /**
  56073. * Parses a Sub Surface Configuration from a serialized object.
  56074. * @param source - Serialized object.
  56075. */
  56076. PBRSubSurfaceConfiguration.prototype.parse = function (source) {
  56077. var _this = this;
  56078. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  56079. };
  56080. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56081. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56082. ], PBRSubSurfaceConfiguration.prototype, "_isRefractionEnabled", void 0);
  56083. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56085. ], PBRSubSurfaceConfiguration.prototype, "isRefractionEnabled", void 0);
  56086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56088. ], PBRSubSurfaceConfiguration.prototype, "_isTranslucencyEnabled", void 0);
  56089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56091. ], PBRSubSurfaceConfiguration.prototype, "isTranslucencyEnabled", void 0);
  56092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56094. ], PBRSubSurfaceConfiguration.prototype, "_isScatteringEnabled", void 0);
  56095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56097. ], PBRSubSurfaceConfiguration.prototype, "refractionIntensity", void 0);
  56098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56100. ], PBRSubSurfaceConfiguration.prototype, "translucencyIntensity", void 0);
  56101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56103. ], PBRSubSurfaceConfiguration.prototype, "scatteringIntensity", void 0);
  56104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  56106. ], PBRSubSurfaceConfiguration.prototype, "_thicknessTexture", void 0);
  56107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56109. ], PBRSubSurfaceConfiguration.prototype, "thicknessTexture", void 0);
  56110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56113. ], PBRSubSurfaceConfiguration.prototype, "refractionTexture", void 0);
  56114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56117. ], PBRSubSurfaceConfiguration.prototype, "indexOfRefraction", void 0);
  56118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56121. ], PBRSubSurfaceConfiguration.prototype, "invertRefractionY", void 0);
  56122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56125. ], PBRSubSurfaceConfiguration.prototype, "linkRefractionWithTransparency", void 0);
  56126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56128. ], PBRSubSurfaceConfiguration.prototype, "minimumThickness", void 0);
  56129. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56130. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56131. ], PBRSubSurfaceConfiguration.prototype, "maximumThickness", void 0);
  56132. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  56134. ], PBRSubSurfaceConfiguration.prototype, "tintColor", void 0);
  56135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56137. ], PBRSubSurfaceConfiguration.prototype, "tintColorAtDistance", void 0);
  56138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  56140. ], PBRSubSurfaceConfiguration.prototype, "diffusionDistance", void 0);
  56141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56143. ], PBRSubSurfaceConfiguration.prototype, "_useMaskFromThicknessTexture", void 0);
  56144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56146. ], PBRSubSurfaceConfiguration.prototype, "useMaskFromThicknessTexture", void 0);
  56147. return PBRSubSurfaceConfiguration;
  56148. }());
  56149. /***/ }),
  56150. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  56151. /*!********************************************************!*\
  56152. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  56153. \********************************************************/
  56154. /*! exports provided: _DDSTextureLoader */
  56155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56156. "use strict";
  56157. __webpack_require__.r(__webpack_exports__);
  56158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  56159. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  56160. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56161. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  56162. /**
  56163. * Implementation of the DDS Texture Loader.
  56164. * @hidden
  56165. */
  56166. var _DDSTextureLoader = /** @class */ (function () {
  56167. function _DDSTextureLoader() {
  56168. /**
  56169. * Defines wether the loader supports cascade loading the different faces.
  56170. */
  56171. this.supportCascades = true;
  56172. }
  56173. /**
  56174. * This returns if the loader support the current file information.
  56175. * @param extension defines the file extension of the file being loaded
  56176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56177. * @param fallback defines the fallback internal texture if any
  56178. * @param isBase64 defines whether the texture is encoded as a base64
  56179. * @param isBuffer defines whether the texture data are stored as a buffer
  56180. * @returns true if the loader can load the specified file
  56181. */
  56182. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56183. return extension.indexOf(".dds") === 0;
  56184. };
  56185. /**
  56186. * Transform the url before loading if required.
  56187. * @param rootUrl the url of the texture
  56188. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56189. * @returns the transformed texture
  56190. */
  56191. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56192. return rootUrl;
  56193. };
  56194. /**
  56195. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56196. * @param rootUrl the url of the texture
  56197. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56198. * @returns the fallback texture
  56199. */
  56200. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56201. return null;
  56202. };
  56203. /**
  56204. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56205. * @param data contains the texture data
  56206. * @param texture defines the BabylonJS internal texture
  56207. * @param createPolynomials will be true if polynomials have been requested
  56208. * @param onLoad defines the callback to trigger once the texture is ready
  56209. * @param onError defines the callback to trigger in case of error
  56210. */
  56211. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  56212. var engine = texture.getEngine();
  56213. var info;
  56214. var loadMipmap = false;
  56215. if (Array.isArray(imgs)) {
  56216. for (var index = 0; index < imgs.length; index++) {
  56217. var data_1 = imgs[index];
  56218. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  56219. texture.width = info.width;
  56220. texture.height = info.height;
  56221. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  56222. engine._unpackFlipY(info.isCompressed);
  56223. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  56224. if (!info.isFourCC && info.mipmapCount === 1) {
  56225. engine.generateMipMapsForCubemap(texture);
  56226. }
  56227. }
  56228. }
  56229. else {
  56230. var data = imgs;
  56231. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  56232. texture.width = info.width;
  56233. texture.height = info.height;
  56234. if (createPolynomials) {
  56235. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  56236. }
  56237. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  56238. engine._unpackFlipY(info.isCompressed);
  56239. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  56240. if (!info.isFourCC && info.mipmapCount === 1) {
  56241. engine.generateMipMapsForCubemap(texture);
  56242. }
  56243. }
  56244. engine._setCubeMapTextureParams(loadMipmap);
  56245. texture.isReady = true;
  56246. if (onLoad) {
  56247. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  56248. }
  56249. };
  56250. /**
  56251. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56252. * @param data contains the texture data
  56253. * @param texture defines the BabylonJS internal texture
  56254. * @param callback defines the method to call once ready to upload
  56255. */
  56256. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  56257. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  56258. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  56259. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  56260. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  56261. });
  56262. };
  56263. return _DDSTextureLoader;
  56264. }());
  56265. // Register the loader.
  56266. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  56267. /***/ }),
  56268. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  56269. /*!********************************************************!*\
  56270. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  56271. \********************************************************/
  56272. /*! exports provided: _ENVTextureLoader */
  56273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56274. "use strict";
  56275. __webpack_require__.r(__webpack_exports__);
  56276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  56277. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  56278. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56279. /**
  56280. * Implementation of the ENV Texture Loader.
  56281. * @hidden
  56282. */
  56283. var _ENVTextureLoader = /** @class */ (function () {
  56284. function _ENVTextureLoader() {
  56285. /**
  56286. * Defines wether the loader supports cascade loading the different faces.
  56287. */
  56288. this.supportCascades = false;
  56289. }
  56290. /**
  56291. * This returns if the loader support the current file information.
  56292. * @param extension defines the file extension of the file being loaded
  56293. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56294. * @param fallback defines the fallback internal texture if any
  56295. * @param isBase64 defines whether the texture is encoded as a base64
  56296. * @param isBuffer defines whether the texture data are stored as a buffer
  56297. * @returns true if the loader can load the specified file
  56298. */
  56299. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56300. return extension.indexOf(".env") === 0;
  56301. };
  56302. /**
  56303. * Transform the url before loading if required.
  56304. * @param rootUrl the url of the texture
  56305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56306. * @returns the transformed texture
  56307. */
  56308. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56309. return rootUrl;
  56310. };
  56311. /**
  56312. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56313. * @param rootUrl the url of the texture
  56314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56315. * @returns the fallback texture
  56316. */
  56317. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56318. return null;
  56319. };
  56320. /**
  56321. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56322. * @param data contains the texture data
  56323. * @param texture defines the BabylonJS internal texture
  56324. * @param createPolynomials will be true if polynomials have been requested
  56325. * @param onLoad defines the callback to trigger once the texture is ready
  56326. * @param onError defines the callback to trigger in case of error
  56327. */
  56328. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  56329. if (Array.isArray(data)) {
  56330. return;
  56331. }
  56332. data = data;
  56333. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  56334. if (info) {
  56335. texture.width = info.width;
  56336. texture.height = info.width;
  56337. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  56338. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  56339. texture.isReady = true;
  56340. if (onLoad) {
  56341. onLoad();
  56342. }
  56343. });
  56344. }
  56345. else if (onError) {
  56346. onError("Can not parse the environment file", null);
  56347. }
  56348. };
  56349. /**
  56350. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56351. * @param data contains the texture data
  56352. * @param texture defines the BabylonJS internal texture
  56353. * @param callback defines the method to call once ready to upload
  56354. */
  56355. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  56356. throw ".env not supported in 2d.";
  56357. };
  56358. return _ENVTextureLoader;
  56359. }());
  56360. // Register the loader.
  56361. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  56362. /***/ }),
  56363. /***/ "./Materials/Textures/Loaders/index.ts":
  56364. /*!*********************************************!*\
  56365. !*** ./Materials/Textures/Loaders/index.ts ***!
  56366. \*********************************************/
  56367. /*! exports provided: _KTXTextureLoader, _DDSTextureLoader, _ENVTextureLoader, _TGATextureLoader */
  56368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56369. "use strict";
  56370. __webpack_require__.r(__webpack_exports__);
  56371. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  56372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  56373. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  56374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  56375. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  56376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  56377. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  56378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  56379. /***/ }),
  56380. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  56381. /*!********************************************************!*\
  56382. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  56383. \********************************************************/
  56384. /*! exports provided: _KTXTextureLoader */
  56385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56386. "use strict";
  56387. __webpack_require__.r(__webpack_exports__);
  56388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  56389. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  56390. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56391. /**
  56392. * Implementation of the KTX Texture Loader.
  56393. * @hidden
  56394. */
  56395. var _KTXTextureLoader = /** @class */ (function () {
  56396. function _KTXTextureLoader() {
  56397. /**
  56398. * Defines wether the loader supports cascade loading the different faces.
  56399. */
  56400. this.supportCascades = false;
  56401. }
  56402. /**
  56403. * This returns if the loader support the current file information.
  56404. * @param extension defines the file extension of the file being loaded
  56405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56406. * @param fallback defines the fallback internal texture if any
  56407. * @param isBase64 defines whether the texture is encoded as a base64
  56408. * @param isBuffer defines whether the texture data are stored as a buffer
  56409. * @returns true if the loader can load the specified file
  56410. */
  56411. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56412. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  56413. return true;
  56414. }
  56415. return false;
  56416. };
  56417. /**
  56418. * Transform the url before loading if required.
  56419. * @param rootUrl the url of the texture
  56420. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56421. * @returns the transformed texture
  56422. */
  56423. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56424. var lastDot = rootUrl.lastIndexOf('.');
  56425. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  56426. // Already transformed
  56427. return rootUrl;
  56428. }
  56429. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  56430. };
  56431. /**
  56432. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56433. * @param rootUrl the url of the texture
  56434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56435. * @returns the fallback texture
  56436. */
  56437. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56438. // remove the format appended to the rootUrl in the original createCubeTexture call.
  56439. var exp = new RegExp("" + textureFormatInUse + "$");
  56440. return rootUrl.replace(exp, "");
  56441. };
  56442. /**
  56443. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56444. * @param data contains the texture data
  56445. * @param texture defines the BabylonJS internal texture
  56446. * @param createPolynomials will be true if polynomials have been requested
  56447. * @param onLoad defines the callback to trigger once the texture is ready
  56448. * @param onError defines the callback to trigger in case of error
  56449. */
  56450. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  56451. if (Array.isArray(data)) {
  56452. return;
  56453. }
  56454. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  56455. texture._invertVScale = !texture.invertY;
  56456. var engine = texture.getEngine();
  56457. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  56458. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  56459. engine._unpackFlipY(true);
  56460. ktx.uploadLevels(texture, texture.generateMipMaps);
  56461. texture.width = ktx.pixelWidth;
  56462. texture.height = ktx.pixelHeight;
  56463. engine._setCubeMapTextureParams(loadMipmap);
  56464. texture.isReady = true;
  56465. };
  56466. /**
  56467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56468. * @param data contains the texture data
  56469. * @param texture defines the BabylonJS internal texture
  56470. * @param callback defines the method to call once ready to upload
  56471. */
  56472. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  56473. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  56474. texture._invertVScale = !texture.invertY;
  56475. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  56476. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  56477. ktx.uploadLevels(texture, texture.generateMipMaps);
  56478. }, ktx.isInvalid);
  56479. };
  56480. return _KTXTextureLoader;
  56481. }());
  56482. // Register the loader.
  56483. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  56484. /***/ }),
  56485. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  56486. /*!********************************************************!*\
  56487. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  56488. \********************************************************/
  56489. /*! exports provided: _TGATextureLoader */
  56490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56491. "use strict";
  56492. __webpack_require__.r(__webpack_exports__);
  56493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  56494. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  56495. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56496. /**
  56497. * Implementation of the TGA Texture Loader.
  56498. * @hidden
  56499. */
  56500. var _TGATextureLoader = /** @class */ (function () {
  56501. function _TGATextureLoader() {
  56502. /**
  56503. * Defines wether the loader supports cascade loading the different faces.
  56504. */
  56505. this.supportCascades = false;
  56506. }
  56507. /**
  56508. * This returns if the loader support the current file information.
  56509. * @param extension defines the file extension of the file being loaded
  56510. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56511. * @param fallback defines the fallback internal texture if any
  56512. * @param isBase64 defines whether the texture is encoded as a base64
  56513. * @param isBuffer defines whether the texture data are stored as a buffer
  56514. * @returns true if the loader can load the specified file
  56515. */
  56516. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56517. return extension.indexOf(".tga") === 0;
  56518. };
  56519. /**
  56520. * Transform the url before loading if required.
  56521. * @param rootUrl the url of the texture
  56522. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56523. * @returns the transformed texture
  56524. */
  56525. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56526. return rootUrl;
  56527. };
  56528. /**
  56529. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56530. * @param rootUrl the url of the texture
  56531. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56532. * @returns the fallback texture
  56533. */
  56534. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56535. return null;
  56536. };
  56537. /**
  56538. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56539. * @param data contains the texture data
  56540. * @param texture defines the BabylonJS internal texture
  56541. * @param createPolynomials will be true if polynomials have been requested
  56542. * @param onLoad defines the callback to trigger once the texture is ready
  56543. * @param onError defines the callback to trigger in case of error
  56544. */
  56545. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  56546. throw ".env not supported in Cube.";
  56547. };
  56548. /**
  56549. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56550. * @param data contains the texture data
  56551. * @param texture defines the BabylonJS internal texture
  56552. * @param callback defines the method to call once ready to upload
  56553. */
  56554. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  56555. var uintData = new Uint8Array(data);
  56556. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  56557. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  56558. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  56559. });
  56560. };
  56561. return _TGATextureLoader;
  56562. }());
  56563. // Register the loader.
  56564. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  56565. /***/ }),
  56566. /***/ "./Materials/Textures/MultiviewRenderTarget.ts":
  56567. /*!*****************************************************!*\
  56568. !*** ./Materials/Textures/MultiviewRenderTarget.ts ***!
  56569. \*****************************************************/
  56570. /*! exports provided: MultiviewRenderTarget */
  56571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56572. "use strict";
  56573. __webpack_require__.r(__webpack_exports__);
  56574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return MultiviewRenderTarget; });
  56575. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56576. /* harmony import */ var _Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56577. /* harmony import */ var _Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  56578. /**
  56579. * Renders to multiple views with a single draw call
  56580. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  56581. */
  56582. var MultiviewRenderTarget = /** @class */ (function (_super) {
  56583. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiviewRenderTarget, _super);
  56584. /**
  56585. * Creates a multiview render target
  56586. * @param scene scene used with the render target
  56587. * @param size the size of the render target (used for each view)
  56588. */
  56589. function MultiviewRenderTarget(scene, size) {
  56590. if (size === void 0) { size = 512; }
  56591. 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;
  56592. var internalTexture = scene.getEngine().createMultiviewRenderTargetTexture(_this.getRenderWidth(), _this.getRenderHeight());
  56593. internalTexture.isMultiview = true;
  56594. _this._texture = internalTexture;
  56595. return _this;
  56596. }
  56597. /**
  56598. * @hidden
  56599. * @param faceIndex the face index, if its a cube texture
  56600. */
  56601. MultiviewRenderTarget.prototype._bindFrameBuffer = function (faceIndex) {
  56602. if (faceIndex === void 0) { faceIndex = 0; }
  56603. if (!this._texture) {
  56604. return;
  56605. }
  56606. this.getScene().getEngine().bindMultiviewFramebuffer(this._texture);
  56607. };
  56608. /**
  56609. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  56610. * @returns the view count
  56611. */
  56612. MultiviewRenderTarget.prototype.getViewCount = function () {
  56613. return 2;
  56614. };
  56615. return MultiviewRenderTarget;
  56616. }(_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"]));
  56617. /***/ }),
  56618. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  56619. /*!*******************************************************************!*\
  56620. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  56621. \*******************************************************************/
  56622. /*! exports provided: CustomProceduralTexture */
  56623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56624. "use strict";
  56625. __webpack_require__.r(__webpack_exports__);
  56626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  56627. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56628. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  56629. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  56630. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56631. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56632. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Misc/webRequest */ "./Misc/webRequest.ts");
  56633. /**
  56634. * 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.
  56635. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56636. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56637. */
  56638. var CustomProceduralTexture = /** @class */ (function (_super) {
  56639. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  56640. /**
  56641. * Instantiates a new Custom Procedural Texture.
  56642. * 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.
  56643. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56644. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56645. * @param name Define the name of the texture
  56646. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56647. * @param size Define the size of the texture to create
  56648. * @param scene Define the scene the texture belongs to
  56649. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56650. * @param generateMipMaps Define if the texture should creates mip maps or not
  56651. */
  56652. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  56653. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  56654. _this._animate = true;
  56655. _this._time = 0;
  56656. _this._texturePath = texturePath;
  56657. //Try to load json
  56658. _this._loadJson(texturePath);
  56659. _this.refreshRate = 1;
  56660. return _this;
  56661. }
  56662. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  56663. var _this = this;
  56664. var noConfigFile = function () {
  56665. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  56666. try {
  56667. _this.setFragment(_this._texturePath);
  56668. }
  56669. catch (ex) {
  56670. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  56671. }
  56672. };
  56673. var configFileUrl = jsonUrl + "/config.json";
  56674. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__["WebRequest"]();
  56675. xhr.open("GET", configFileUrl);
  56676. xhr.addEventListener("load", function () {
  56677. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  56678. try {
  56679. _this._config = JSON.parse(xhr.response);
  56680. _this.updateShaderUniforms();
  56681. _this.updateTextures();
  56682. _this.setFragment(_this._texturePath + "/custom");
  56683. _this._animate = _this._config.animate;
  56684. _this.refreshRate = _this._config.refreshrate;
  56685. }
  56686. catch (ex) {
  56687. noConfigFile();
  56688. }
  56689. }
  56690. else {
  56691. noConfigFile();
  56692. }
  56693. }, false);
  56694. xhr.addEventListener("error", function () {
  56695. noConfigFile();
  56696. }, false);
  56697. try {
  56698. xhr.send();
  56699. }
  56700. catch (ex) {
  56701. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  56702. }
  56703. };
  56704. /**
  56705. * Is the texture ready to be used ? (rendered at least once)
  56706. * @returns true if ready, otherwise, false.
  56707. */
  56708. CustomProceduralTexture.prototype.isReady = function () {
  56709. if (!_super.prototype.isReady.call(this)) {
  56710. return false;
  56711. }
  56712. for (var name in this._textures) {
  56713. var texture = this._textures[name];
  56714. if (!texture.isReady()) {
  56715. return false;
  56716. }
  56717. }
  56718. return true;
  56719. };
  56720. /**
  56721. * Render the texture to its associated render target.
  56722. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56723. */
  56724. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56725. var scene = this.getScene();
  56726. if (this._animate && scene) {
  56727. this._time += scene.getAnimationRatio() * 0.03;
  56728. this.updateShaderUniforms();
  56729. }
  56730. _super.prototype.render.call(this, useCameraPostProcess);
  56731. };
  56732. /**
  56733. * Update the list of dependant textures samplers in the shader.
  56734. */
  56735. CustomProceduralTexture.prototype.updateTextures = function () {
  56736. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  56737. 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()));
  56738. }
  56739. };
  56740. /**
  56741. * Update the uniform values of the procedural texture in the shader.
  56742. */
  56743. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  56744. if (this._config) {
  56745. for (var j = 0; j < this._config.uniforms.length; j++) {
  56746. var uniform = this._config.uniforms[j];
  56747. switch (uniform.type) {
  56748. case "float":
  56749. this.setFloat(uniform.name, uniform.value);
  56750. break;
  56751. case "color3":
  56752. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](uniform.r, uniform.g, uniform.b));
  56753. break;
  56754. case "color4":
  56755. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  56756. break;
  56757. case "vector2":
  56758. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](uniform.x, uniform.y));
  56759. break;
  56760. case "vector3":
  56761. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](uniform.x, uniform.y, uniform.z));
  56762. break;
  56763. }
  56764. }
  56765. }
  56766. this.setFloat("time", this._time);
  56767. };
  56768. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  56769. /**
  56770. * Define if the texture animates or not.
  56771. */
  56772. get: function () {
  56773. return this._animate;
  56774. },
  56775. set: function (value) {
  56776. this._animate = value;
  56777. },
  56778. enumerable: true,
  56779. configurable: true
  56780. });
  56781. return CustomProceduralTexture;
  56782. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_4__["ProceduralTexture"]));
  56783. /***/ }),
  56784. /***/ "./Materials/Textures/Procedurals/index.ts":
  56785. /*!*************************************************!*\
  56786. !*** ./Materials/Textures/Procedurals/index.ts ***!
  56787. \*************************************************/
  56788. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  56789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56790. "use strict";
  56791. __webpack_require__.r(__webpack_exports__);
  56792. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  56793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  56794. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  56795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  56796. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  56798. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  56799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  56800. /***/ }),
  56801. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  56802. /*!******************************************************************!*\
  56803. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  56804. \******************************************************************/
  56805. /*! exports provided: NoiseProceduralTexture */
  56806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56807. "use strict";
  56808. __webpack_require__.r(__webpack_exports__);
  56809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  56810. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56811. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  56812. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56813. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  56814. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  56815. /**
  56816. * Class used to generate noise procedural textures
  56817. */
  56818. var NoiseProceduralTexture = /** @class */ (function (_super) {
  56819. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  56820. /**
  56821. * Creates a new NoiseProceduralTexture
  56822. * @param name defines the name fo the texture
  56823. * @param size defines the size of the texture (default is 256)
  56824. * @param scene defines the hosting scene
  56825. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56826. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56827. */
  56828. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  56829. if (size === void 0) { size = 256; }
  56830. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  56831. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  56832. _this._time = 0;
  56833. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56834. _this.brightness = 0.2;
  56835. /** Defines the number of octaves to process */
  56836. _this.octaves = 3;
  56837. /** Defines the level of persistence (0.8 by default) */
  56838. _this.persistence = 0.8;
  56839. /** Gets or sets animation speed factor (default is 1) */
  56840. _this.animationSpeedFactor = 1;
  56841. _this.autoClear = false;
  56842. _this._updateShaderUniforms();
  56843. return _this;
  56844. }
  56845. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  56846. var scene = this.getScene();
  56847. if (!scene) {
  56848. return;
  56849. }
  56850. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  56851. this.setFloat("brightness", this.brightness);
  56852. this.setFloat("persistence", this.persistence);
  56853. this.setFloat("timeScale", this._time);
  56854. };
  56855. NoiseProceduralTexture.prototype._getDefines = function () {
  56856. return "#define OCTAVES " + (this.octaves | 0);
  56857. };
  56858. /** Generate the current state of the procedural texture */
  56859. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56860. this._updateShaderUniforms();
  56861. _super.prototype.render.call(this, useCameraPostProcess);
  56862. };
  56863. /**
  56864. * Serializes this noise procedural texture
  56865. * @returns a serialized noise procedural texture object
  56866. */
  56867. NoiseProceduralTexture.prototype.serialize = function () {
  56868. var serializationObject = {};
  56869. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  56870. serializationObject.brightness = this.brightness;
  56871. serializationObject.octaves = this.octaves;
  56872. serializationObject.persistence = this.persistence;
  56873. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  56874. serializationObject.size = this.getSize().width;
  56875. serializationObject.generateMipMaps = this._generateMipMaps;
  56876. return serializationObject;
  56877. };
  56878. /**
  56879. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56880. * @param parsedTexture defines parsed texture data
  56881. * @param scene defines the current scene
  56882. * @param rootUrl defines the root URL containing noise procedural texture information
  56883. * @returns a parsed NoiseProceduralTexture
  56884. */
  56885. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  56886. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  56887. texture.brightness = parsedTexture.brightness;
  56888. texture.octaves = parsedTexture.octaves;
  56889. texture.persistence = parsedTexture.persistence;
  56890. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  56891. return texture;
  56892. };
  56893. return NoiseProceduralTexture;
  56894. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  56895. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  56896. /***/ }),
  56897. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  56898. /*!*************************************************************!*\
  56899. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  56900. \*************************************************************/
  56901. /*! exports provided: ProceduralTexture */
  56902. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56903. "use strict";
  56904. __webpack_require__.r(__webpack_exports__);
  56905. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  56906. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56907. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  56908. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  56909. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  56910. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  56911. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  56912. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56913. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56914. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  56915. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  56916. /**
  56917. * 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.
  56918. * This is the base class of any Procedural texture and contains most of the shareable code.
  56919. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  56920. */
  56921. var ProceduralTexture = /** @class */ (function (_super) {
  56922. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  56923. /**
  56924. * Instantiates a new procedural texture.
  56925. * 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.
  56926. * This is the base class of any Procedural texture and contains most of the shareable code.
  56927. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  56928. * @param name Define the name of the texture
  56929. * @param size Define the size of the texture to create
  56930. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  56931. * @param scene Define the scene the texture belongs to
  56932. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56933. * @param generateMipMaps Define if the texture should creates mip maps or not
  56934. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  56935. */
  56936. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  56937. if (fallbackTexture === void 0) { fallbackTexture = null; }
  56938. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56939. if (isCube === void 0) { isCube = false; }
  56940. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  56941. _this.isCube = isCube;
  56942. /**
  56943. * Define if the texture is enabled or not (disabled texture will not render)
  56944. */
  56945. _this.isEnabled = true;
  56946. /**
  56947. * Define if the texture must be cleared before rendering (default is true)
  56948. */
  56949. _this.autoClear = true;
  56950. /**
  56951. * Event raised when the texture is generated
  56952. */
  56953. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  56954. /** @hidden */
  56955. _this._textures = {};
  56956. _this._currentRefreshId = -1;
  56957. _this._refreshRate = 1;
  56958. _this._vertexBuffers = {};
  56959. _this._uniforms = new Array();
  56960. _this._samplers = new Array();
  56961. _this._floats = {};
  56962. _this._ints = {};
  56963. _this._floatsArrays = {};
  56964. _this._colors3 = {};
  56965. _this._colors4 = {};
  56966. _this._vectors2 = {};
  56967. _this._vectors3 = {};
  56968. _this._matrices = {};
  56969. _this._fallbackTextureUsed = false;
  56970. _this._cachedDefines = "";
  56971. _this._contentUpdateId = -1;
  56972. scene = _this.getScene();
  56973. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  56974. if (!component) {
  56975. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  56976. scene._addComponent(component);
  56977. }
  56978. scene.proceduralTextures.push(_this);
  56979. _this._engine = scene.getEngine();
  56980. _this.name = name;
  56981. _this.isRenderTarget = true;
  56982. _this._size = size;
  56983. _this._generateMipMaps = generateMipMaps;
  56984. _this.setFragment(fragment);
  56985. _this._fallbackTexture = fallbackTexture;
  56986. if (isCube) {
  56987. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56988. _this.setFloat("face", 0);
  56989. }
  56990. else {
  56991. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56992. }
  56993. // VBO
  56994. var vertices = [];
  56995. vertices.push(1, 1);
  56996. vertices.push(-1, 1);
  56997. vertices.push(-1, -1);
  56998. vertices.push(1, -1);
  56999. _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);
  57000. _this._createIndexBuffer();
  57001. return _this;
  57002. }
  57003. /**
  57004. * The effect that is created when initializing the post process.
  57005. * @returns The created effect corrisponding the the postprocess.
  57006. */
  57007. ProceduralTexture.prototype.getEffect = function () {
  57008. return this._effect;
  57009. };
  57010. /**
  57011. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  57012. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  57013. */
  57014. ProceduralTexture.prototype.getContent = function () {
  57015. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  57016. return this._contentData;
  57017. }
  57018. this._contentData = this.readPixels(0, 0, this._contentData);
  57019. this._contentUpdateId = this._currentRefreshId;
  57020. return this._contentData;
  57021. };
  57022. ProceduralTexture.prototype._createIndexBuffer = function () {
  57023. var engine = this._engine;
  57024. // Indices
  57025. var indices = [];
  57026. indices.push(0);
  57027. indices.push(1);
  57028. indices.push(2);
  57029. indices.push(0);
  57030. indices.push(2);
  57031. indices.push(3);
  57032. this._indexBuffer = engine.createIndexBuffer(indices);
  57033. };
  57034. /** @hidden */
  57035. ProceduralTexture.prototype._rebuild = function () {
  57036. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  57037. if (vb) {
  57038. vb._rebuild();
  57039. }
  57040. this._createIndexBuffer();
  57041. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  57042. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  57043. }
  57044. };
  57045. /**
  57046. * Resets the texture in order to recreate its associated resources.
  57047. * This can be called in case of context loss
  57048. */
  57049. ProceduralTexture.prototype.reset = function () {
  57050. if (this._effect === undefined) {
  57051. return;
  57052. }
  57053. this._effect.dispose();
  57054. };
  57055. ProceduralTexture.prototype._getDefines = function () {
  57056. return "";
  57057. };
  57058. /**
  57059. * Is the texture ready to be used ? (rendered at least once)
  57060. * @returns true if ready, otherwise, false.
  57061. */
  57062. ProceduralTexture.prototype.isReady = function () {
  57063. var _this = this;
  57064. var engine = this._engine;
  57065. var shaders;
  57066. if (!this._fragment) {
  57067. return false;
  57068. }
  57069. if (this._fallbackTextureUsed) {
  57070. return true;
  57071. }
  57072. var defines = this._getDefines();
  57073. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  57074. return true;
  57075. }
  57076. if (this._fragment.fragmentElement !== undefined) {
  57077. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  57078. }
  57079. else {
  57080. shaders = { vertex: "procedural", fragment: this._fragment };
  57081. }
  57082. this._cachedDefines = defines;
  57083. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  57084. _this.releaseInternalTexture();
  57085. if (_this._fallbackTexture) {
  57086. _this._texture = _this._fallbackTexture._texture;
  57087. if (_this._texture) {
  57088. _this._texture.incrementReferences();
  57089. }
  57090. }
  57091. _this._fallbackTextureUsed = true;
  57092. });
  57093. return this._effect.isReady();
  57094. };
  57095. /**
  57096. * Resets the refresh counter of the texture and start bak from scratch.
  57097. * Could be useful to regenerate the texture if it is setup to render only once.
  57098. */
  57099. ProceduralTexture.prototype.resetRefreshCounter = function () {
  57100. this._currentRefreshId = -1;
  57101. };
  57102. /**
  57103. * Set the fragment shader to use in order to render the texture.
  57104. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  57105. */
  57106. ProceduralTexture.prototype.setFragment = function (fragment) {
  57107. this._fragment = fragment;
  57108. };
  57109. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  57110. /**
  57111. * Define the refresh rate of the texture or the rendering frequency.
  57112. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57113. */
  57114. get: function () {
  57115. return this._refreshRate;
  57116. },
  57117. set: function (value) {
  57118. this._refreshRate = value;
  57119. this.resetRefreshCounter();
  57120. },
  57121. enumerable: true,
  57122. configurable: true
  57123. });
  57124. /** @hidden */
  57125. ProceduralTexture.prototype._shouldRender = function () {
  57126. if (!this.isEnabled || !this.isReady() || !this._texture) {
  57127. if (this._texture) {
  57128. this._texture.isReady = false;
  57129. }
  57130. return false;
  57131. }
  57132. if (this._fallbackTextureUsed) {
  57133. return false;
  57134. }
  57135. if (this._currentRefreshId === -1) { // At least render once
  57136. this._currentRefreshId = 1;
  57137. return true;
  57138. }
  57139. if (this.refreshRate === this._currentRefreshId) {
  57140. this._currentRefreshId = 1;
  57141. return true;
  57142. }
  57143. this._currentRefreshId++;
  57144. return false;
  57145. };
  57146. /**
  57147. * Get the size the texture is rendering at.
  57148. * @returns the size (texture is always squared)
  57149. */
  57150. ProceduralTexture.prototype.getRenderSize = function () {
  57151. return this._size;
  57152. };
  57153. /**
  57154. * Resize the texture to new value.
  57155. * @param size Define the new size the texture should have
  57156. * @param generateMipMaps Define whether the new texture should create mip maps
  57157. */
  57158. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  57159. if (this._fallbackTextureUsed) {
  57160. return;
  57161. }
  57162. this.releaseInternalTexture();
  57163. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  57164. // Update properties
  57165. this._size = size;
  57166. this._generateMipMaps = generateMipMaps;
  57167. };
  57168. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  57169. if (this._uniforms.indexOf(uniformName) === -1) {
  57170. this._uniforms.push(uniformName);
  57171. }
  57172. };
  57173. /**
  57174. * Set a texture in the shader program used to render.
  57175. * @param name Define the name of the uniform samplers as defined in the shader
  57176. * @param texture Define the texture to bind to this sampler
  57177. * @return the texture itself allowing "fluent" like uniform updates
  57178. */
  57179. ProceduralTexture.prototype.setTexture = function (name, texture) {
  57180. if (this._samplers.indexOf(name) === -1) {
  57181. this._samplers.push(name);
  57182. }
  57183. this._textures[name] = texture;
  57184. return this;
  57185. };
  57186. /**
  57187. * Set a float in the shader.
  57188. * @param name Define the name of the uniform as defined in the shader
  57189. * @param value Define the value to give to the uniform
  57190. * @return the texture itself allowing "fluent" like uniform updates
  57191. */
  57192. ProceduralTexture.prototype.setFloat = function (name, value) {
  57193. this._checkUniform(name);
  57194. this._floats[name] = value;
  57195. return this;
  57196. };
  57197. /**
  57198. * Set a int in the shader.
  57199. * @param name Define the name of the uniform as defined in the shader
  57200. * @param value Define the value to give to the uniform
  57201. * @return the texture itself allowing "fluent" like uniform updates
  57202. */
  57203. ProceduralTexture.prototype.setInt = function (name, value) {
  57204. this._checkUniform(name);
  57205. this._ints[name] = value;
  57206. return this;
  57207. };
  57208. /**
  57209. * Set an array of floats in the shader.
  57210. * @param name Define the name of the uniform as defined in the shader
  57211. * @param value Define the value to give to the uniform
  57212. * @return the texture itself allowing "fluent" like uniform updates
  57213. */
  57214. ProceduralTexture.prototype.setFloats = function (name, value) {
  57215. this._checkUniform(name);
  57216. this._floatsArrays[name] = value;
  57217. return this;
  57218. };
  57219. /**
  57220. * Set a vec3 in the shader from a Color3.
  57221. * @param name Define the name of the uniform as defined in the shader
  57222. * @param value Define the value to give to the uniform
  57223. * @return the texture itself allowing "fluent" like uniform updates
  57224. */
  57225. ProceduralTexture.prototype.setColor3 = function (name, value) {
  57226. this._checkUniform(name);
  57227. this._colors3[name] = value;
  57228. return this;
  57229. };
  57230. /**
  57231. * Set a vec4 in the shader from a Color4.
  57232. * @param name Define the name of the uniform as defined in the shader
  57233. * @param value Define the value to give to the uniform
  57234. * @return the texture itself allowing "fluent" like uniform updates
  57235. */
  57236. ProceduralTexture.prototype.setColor4 = function (name, value) {
  57237. this._checkUniform(name);
  57238. this._colors4[name] = value;
  57239. return this;
  57240. };
  57241. /**
  57242. * Set a vec2 in the shader from a Vector2.
  57243. * @param name Define the name of the uniform as defined in the shader
  57244. * @param value Define the value to give to the uniform
  57245. * @return the texture itself allowing "fluent" like uniform updates
  57246. */
  57247. ProceduralTexture.prototype.setVector2 = function (name, value) {
  57248. this._checkUniform(name);
  57249. this._vectors2[name] = value;
  57250. return this;
  57251. };
  57252. /**
  57253. * Set a vec3 in the shader from a Vector3.
  57254. * @param name Define the name of the uniform as defined in the shader
  57255. * @param value Define the value to give to the uniform
  57256. * @return the texture itself allowing "fluent" like uniform updates
  57257. */
  57258. ProceduralTexture.prototype.setVector3 = function (name, value) {
  57259. this._checkUniform(name);
  57260. this._vectors3[name] = value;
  57261. return this;
  57262. };
  57263. /**
  57264. * Set a mat4 in the shader from a MAtrix.
  57265. * @param name Define the name of the uniform as defined in the shader
  57266. * @param value Define the value to give to the uniform
  57267. * @return the texture itself allowing "fluent" like uniform updates
  57268. */
  57269. ProceduralTexture.prototype.setMatrix = function (name, value) {
  57270. this._checkUniform(name);
  57271. this._matrices[name] = value;
  57272. return this;
  57273. };
  57274. /**
  57275. * Render the texture to its associated render target.
  57276. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57277. */
  57278. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  57279. var scene = this.getScene();
  57280. if (!scene) {
  57281. return;
  57282. }
  57283. var engine = this._engine;
  57284. // Render
  57285. engine.enableEffect(this._effect);
  57286. engine.setState(false);
  57287. // Texture
  57288. for (var name in this._textures) {
  57289. this._effect.setTexture(name, this._textures[name]);
  57290. }
  57291. // Float
  57292. for (name in this._ints) {
  57293. this._effect.setInt(name, this._ints[name]);
  57294. }
  57295. // Float
  57296. for (name in this._floats) {
  57297. this._effect.setFloat(name, this._floats[name]);
  57298. }
  57299. // Floats
  57300. for (name in this._floatsArrays) {
  57301. this._effect.setArray(name, this._floatsArrays[name]);
  57302. }
  57303. // Color3
  57304. for (name in this._colors3) {
  57305. this._effect.setColor3(name, this._colors3[name]);
  57306. }
  57307. // Color4
  57308. for (name in this._colors4) {
  57309. var color = this._colors4[name];
  57310. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  57311. }
  57312. // Vector2
  57313. for (name in this._vectors2) {
  57314. this._effect.setVector2(name, this._vectors2[name]);
  57315. }
  57316. // Vector3
  57317. for (name in this._vectors3) {
  57318. this._effect.setVector3(name, this._vectors3[name]);
  57319. }
  57320. // Matrix
  57321. for (name in this._matrices) {
  57322. this._effect.setMatrix(name, this._matrices[name]);
  57323. }
  57324. if (!this._texture) {
  57325. return;
  57326. }
  57327. if (this.isCube) {
  57328. for (var face = 0; face < 6; face++) {
  57329. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  57330. // VBOs
  57331. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  57332. this._effect.setFloat("face", face);
  57333. // Clear
  57334. if (this.autoClear) {
  57335. engine.clear(scene.clearColor, true, false, false);
  57336. }
  57337. // Draw order
  57338. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  57339. // Mipmaps
  57340. if (face === 5) {
  57341. engine.generateMipMapsForCubemap(this._texture);
  57342. }
  57343. }
  57344. }
  57345. else {
  57346. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  57347. // VBOs
  57348. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  57349. // Clear
  57350. if (this.autoClear) {
  57351. engine.clear(scene.clearColor, true, false, false);
  57352. }
  57353. // Draw order
  57354. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  57355. }
  57356. // Unbind
  57357. engine.unBindFramebuffer(this._texture, this.isCube);
  57358. if (this.onGenerated) {
  57359. this.onGenerated();
  57360. }
  57361. this.onGeneratedObservable.notifyObservers(this);
  57362. };
  57363. /**
  57364. * Clone the texture.
  57365. * @returns the cloned texture
  57366. */
  57367. ProceduralTexture.prototype.clone = function () {
  57368. var textureSize = this.getSize();
  57369. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  57370. // Base texture
  57371. newTexture.hasAlpha = this.hasAlpha;
  57372. newTexture.level = this.level;
  57373. // RenderTarget Texture
  57374. newTexture.coordinatesMode = this.coordinatesMode;
  57375. return newTexture;
  57376. };
  57377. /**
  57378. * Dispose the texture and release its asoociated resources.
  57379. */
  57380. ProceduralTexture.prototype.dispose = function () {
  57381. var scene = this.getScene();
  57382. if (!scene) {
  57383. return;
  57384. }
  57385. var index = scene.proceduralTextures.indexOf(this);
  57386. if (index >= 0) {
  57387. scene.proceduralTextures.splice(index, 1);
  57388. }
  57389. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  57390. if (vertexBuffer) {
  57391. vertexBuffer.dispose();
  57392. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  57393. }
  57394. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  57395. this._indexBuffer = null;
  57396. }
  57397. _super.prototype.dispose.call(this);
  57398. };
  57399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57401. ], ProceduralTexture.prototype, "isEnabled", void 0);
  57402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57404. ], ProceduralTexture.prototype, "autoClear", void 0);
  57405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57407. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  57408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57410. ], ProceduralTexture.prototype, "_size", void 0);
  57411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57413. ], ProceduralTexture.prototype, "refreshRate", null);
  57414. return ProceduralTexture;
  57415. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  57416. /***/ }),
  57417. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  57418. /*!***************************************************************************!*\
  57419. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  57420. \***************************************************************************/
  57421. /*! exports provided: ProceduralTextureSceneComponent */
  57422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57423. "use strict";
  57424. __webpack_require__.r(__webpack_exports__);
  57425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  57426. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  57427. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  57428. /**
  57429. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  57430. * in a given scene.
  57431. */
  57432. var ProceduralTextureSceneComponent = /** @class */ (function () {
  57433. /**
  57434. * Creates a new instance of the component for the given scene
  57435. * @param scene Defines the scene to register the component in
  57436. */
  57437. function ProceduralTextureSceneComponent(scene) {
  57438. /**
  57439. * The component name helpfull to identify the component in the list of scene components.
  57440. */
  57441. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  57442. this.scene = scene;
  57443. this.scene.proceduralTextures = new Array();
  57444. scene.layers = new Array();
  57445. }
  57446. /**
  57447. * Registers the component in a given scene
  57448. */
  57449. ProceduralTextureSceneComponent.prototype.register = function () {
  57450. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  57451. };
  57452. /**
  57453. * Rebuilds the elements related to this component in case of
  57454. * context lost for instance.
  57455. */
  57456. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  57457. // Nothing to do here.
  57458. };
  57459. /**
  57460. * Disposes the component and the associated ressources.
  57461. */
  57462. ProceduralTextureSceneComponent.prototype.dispose = function () {
  57463. // Nothing to do here.
  57464. };
  57465. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  57466. if (this.scene.proceduralTexturesEnabled) {
  57467. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  57468. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  57469. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  57470. if (proceduralTexture._shouldRender()) {
  57471. proceduralTexture.render();
  57472. }
  57473. }
  57474. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  57475. }
  57476. };
  57477. return ProceduralTextureSceneComponent;
  57478. }());
  57479. /***/ }),
  57480. /***/ "./Materials/Textures/baseTexture.ts":
  57481. /*!*******************************************!*\
  57482. !*** ./Materials/Textures/baseTexture.ts ***!
  57483. \*******************************************/
  57484. /*! exports provided: BaseTexture */
  57485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57486. "use strict";
  57487. __webpack_require__.r(__webpack_exports__);
  57488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  57489. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57490. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57491. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57492. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57493. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  57494. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57495. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  57496. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57497. /**
  57498. * Base class of all the textures in babylon.
  57499. * It groups all the common properties the materials, post process, lights... might need
  57500. * in order to make a correct use of the texture.
  57501. */
  57502. var BaseTexture = /** @class */ (function () {
  57503. /**
  57504. * Instantiates a new BaseTexture.
  57505. * Base class of all the textures in babylon.
  57506. * It groups all the common properties the materials, post process, lights... might need
  57507. * in order to make a correct use of the texture.
  57508. * @param scene Define the scene the texture blongs to
  57509. */
  57510. function BaseTexture(scene) {
  57511. /**
  57512. * Gets or sets an object used to store user defined information.
  57513. */
  57514. this.metadata = null;
  57515. /**
  57516. * For internal use only. Please do not use.
  57517. */
  57518. this.reservedDataStore = null;
  57519. this._hasAlpha = false;
  57520. /**
  57521. * Defines if the alpha value should be determined via the rgb values.
  57522. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  57523. */
  57524. this.getAlphaFromRGB = false;
  57525. /**
  57526. * Intensity or strength of the texture.
  57527. * It is commonly used by materials to fine tune the intensity of the texture
  57528. */
  57529. this.level = 1;
  57530. /**
  57531. * Define the UV chanel to use starting from 0 and defaulting to 0.
  57532. * This is part of the texture as textures usually maps to one uv set.
  57533. */
  57534. this.coordinatesIndex = 0;
  57535. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  57536. /**
  57537. * | Value | Type | Description |
  57538. * | ----- | ------------------ | ----------- |
  57539. * | 0 | CLAMP_ADDRESSMODE | |
  57540. * | 1 | WRAP_ADDRESSMODE | |
  57541. * | 2 | MIRROR_ADDRESSMODE | |
  57542. */
  57543. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  57544. /**
  57545. * | Value | Type | Description |
  57546. * | ----- | ------------------ | ----------- |
  57547. * | 0 | CLAMP_ADDRESSMODE | |
  57548. * | 1 | WRAP_ADDRESSMODE | |
  57549. * | 2 | MIRROR_ADDRESSMODE | |
  57550. */
  57551. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  57552. /**
  57553. * | Value | Type | Description |
  57554. * | ----- | ------------------ | ----------- |
  57555. * | 0 | CLAMP_ADDRESSMODE | |
  57556. * | 1 | WRAP_ADDRESSMODE | |
  57557. * | 2 | MIRROR_ADDRESSMODE | |
  57558. */
  57559. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  57560. /**
  57561. * With compliant hardware and browser (supporting anisotropic filtering)
  57562. * this defines the level of anisotropic filtering in the texture.
  57563. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  57564. */
  57565. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  57566. /**
  57567. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  57568. * HDR texture are usually stored in linear space.
  57569. * This only impacts the PBR and Background materials
  57570. */
  57571. this.gammaSpace = true;
  57572. /**
  57573. * Is Z inverted in the texture (useful in a cube texture).
  57574. */
  57575. this.invertZ = false;
  57576. /**
  57577. * @hidden
  57578. */
  57579. this.lodLevelInAlpha = false;
  57580. /**
  57581. * Define if the texture is a render target.
  57582. */
  57583. this.isRenderTarget = false;
  57584. /**
  57585. * Define the list of animation attached to the texture.
  57586. */
  57587. this.animations = new Array();
  57588. /**
  57589. * An event triggered when the texture is disposed.
  57590. */
  57591. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  57592. this._onDisposeObserver = null;
  57593. /**
  57594. * Define the current state of the loading sequence when in delayed load mode.
  57595. */
  57596. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  57597. this._scene = null;
  57598. /** @hidden */
  57599. this._texture = null;
  57600. this._uid = null;
  57601. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  57602. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  57603. if (this._scene) {
  57604. this.uniqueId = this._scene.getUniqueId();
  57605. this._scene.addTexture(this);
  57606. }
  57607. this._uid = null;
  57608. }
  57609. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  57610. get: function () {
  57611. return this._hasAlpha;
  57612. },
  57613. /**
  57614. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  57615. */
  57616. set: function (value) {
  57617. if (this._hasAlpha === value) {
  57618. return;
  57619. }
  57620. this._hasAlpha = value;
  57621. if (this._scene) {
  57622. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  57623. }
  57624. },
  57625. enumerable: true,
  57626. configurable: true
  57627. });
  57628. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  57629. get: function () {
  57630. return this._coordinatesMode;
  57631. },
  57632. /**
  57633. * How a texture is mapped.
  57634. *
  57635. * | Value | Type | Description |
  57636. * | ----- | ----------------------------------- | ----------- |
  57637. * | 0 | EXPLICIT_MODE | |
  57638. * | 1 | SPHERICAL_MODE | |
  57639. * | 2 | PLANAR_MODE | |
  57640. * | 3 | CUBIC_MODE | |
  57641. * | 4 | PROJECTION_MODE | |
  57642. * | 5 | SKYBOX_MODE | |
  57643. * | 6 | INVCUBIC_MODE | |
  57644. * | 7 | EQUIRECTANGULAR_MODE | |
  57645. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  57646. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  57647. */
  57648. set: function (value) {
  57649. if (this._coordinatesMode === value) {
  57650. return;
  57651. }
  57652. this._coordinatesMode = value;
  57653. if (this._scene) {
  57654. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57655. }
  57656. },
  57657. enumerable: true,
  57658. configurable: true
  57659. });
  57660. Object.defineProperty(BaseTexture.prototype, "isCube", {
  57661. /**
  57662. * Define if the texture is a cube texture or if false a 2d texture.
  57663. */
  57664. get: function () {
  57665. if (!this._texture) {
  57666. return false;
  57667. }
  57668. return this._texture.isCube;
  57669. },
  57670. set: function (value) {
  57671. if (!this._texture) {
  57672. return;
  57673. }
  57674. this._texture.isCube = value;
  57675. },
  57676. enumerable: true,
  57677. configurable: true
  57678. });
  57679. Object.defineProperty(BaseTexture.prototype, "is3D", {
  57680. /**
  57681. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  57682. */
  57683. get: function () {
  57684. if (!this._texture) {
  57685. return false;
  57686. }
  57687. return this._texture.is3D;
  57688. },
  57689. set: function (value) {
  57690. if (!this._texture) {
  57691. return;
  57692. }
  57693. this._texture.is3D = value;
  57694. },
  57695. enumerable: true,
  57696. configurable: true
  57697. });
  57698. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  57699. /**
  57700. * Gets whether or not the texture contains RGBD data.
  57701. */
  57702. get: function () {
  57703. return this._texture != null && this._texture._isRGBD;
  57704. },
  57705. enumerable: true,
  57706. configurable: true
  57707. });
  57708. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  57709. /**
  57710. * Are mip maps generated for this texture or not.
  57711. */
  57712. get: function () {
  57713. return false;
  57714. },
  57715. enumerable: true,
  57716. configurable: true
  57717. });
  57718. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  57719. /**
  57720. * With prefiltered texture, defined the offset used during the prefiltering steps.
  57721. */
  57722. get: function () {
  57723. if (this._texture) {
  57724. return this._texture._lodGenerationOffset;
  57725. }
  57726. return 0.0;
  57727. },
  57728. set: function (value) {
  57729. if (this._texture) {
  57730. this._texture._lodGenerationOffset = value;
  57731. }
  57732. },
  57733. enumerable: true,
  57734. configurable: true
  57735. });
  57736. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  57737. /**
  57738. * With prefiltered texture, defined the scale used during the prefiltering steps.
  57739. */
  57740. get: function () {
  57741. if (this._texture) {
  57742. return this._texture._lodGenerationScale;
  57743. }
  57744. return 0.0;
  57745. },
  57746. set: function (value) {
  57747. if (this._texture) {
  57748. this._texture._lodGenerationScale = value;
  57749. }
  57750. },
  57751. enumerable: true,
  57752. configurable: true
  57753. });
  57754. Object.defineProperty(BaseTexture.prototype, "uid", {
  57755. /**
  57756. * Define the unique id of the texture in the scene.
  57757. */
  57758. get: function () {
  57759. if (!this._uid) {
  57760. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  57761. }
  57762. return this._uid;
  57763. },
  57764. enumerable: true,
  57765. configurable: true
  57766. });
  57767. /**
  57768. * Return a string representation of the texture.
  57769. * @returns the texture as a string
  57770. */
  57771. BaseTexture.prototype.toString = function () {
  57772. return this.name;
  57773. };
  57774. /**
  57775. * Get the class name of the texture.
  57776. * @returns "BaseTexture"
  57777. */
  57778. BaseTexture.prototype.getClassName = function () {
  57779. return "BaseTexture";
  57780. };
  57781. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  57782. /**
  57783. * Callback triggered when the texture has been disposed.
  57784. * Kept for back compatibility, you can use the onDisposeObservable instead.
  57785. */
  57786. set: function (callback) {
  57787. if (this._onDisposeObserver) {
  57788. this.onDisposeObservable.remove(this._onDisposeObserver);
  57789. }
  57790. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  57791. },
  57792. enumerable: true,
  57793. configurable: true
  57794. });
  57795. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  57796. /**
  57797. * Define if the texture is preventinga material to render or not.
  57798. * If not and the texture is not ready, the engine will use a default black texture instead.
  57799. */
  57800. get: function () {
  57801. return true;
  57802. },
  57803. enumerable: true,
  57804. configurable: true
  57805. });
  57806. /**
  57807. * Get the scene the texture belongs to.
  57808. * @returns the scene or null if undefined
  57809. */
  57810. BaseTexture.prototype.getScene = function () {
  57811. return this._scene;
  57812. };
  57813. /**
  57814. * Get the texture transform matrix used to offset tile the texture for istance.
  57815. * @returns the transformation matrix
  57816. */
  57817. BaseTexture.prototype.getTextureMatrix = function () {
  57818. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  57819. };
  57820. /**
  57821. * Get the texture reflection matrix used to rotate/transform the reflection.
  57822. * @returns the reflection matrix
  57823. */
  57824. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  57825. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  57826. };
  57827. /**
  57828. * Get the underlying lower level texture from Babylon.
  57829. * @returns the insternal texture
  57830. */
  57831. BaseTexture.prototype.getInternalTexture = function () {
  57832. return this._texture;
  57833. };
  57834. /**
  57835. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  57836. * @returns true if ready or not blocking
  57837. */
  57838. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  57839. return !this.isBlocking || this.isReady();
  57840. };
  57841. /**
  57842. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  57843. * @returns true if fully ready
  57844. */
  57845. BaseTexture.prototype.isReady = function () {
  57846. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57847. this.delayLoad();
  57848. return false;
  57849. }
  57850. if (this._texture) {
  57851. return this._texture.isReady;
  57852. }
  57853. return false;
  57854. };
  57855. /**
  57856. * Get the size of the texture.
  57857. * @returns the texture size.
  57858. */
  57859. BaseTexture.prototype.getSize = function () {
  57860. if (this._texture) {
  57861. if (this._texture.width) {
  57862. this._cachedSize.width = this._texture.width;
  57863. this._cachedSize.height = this._texture.height;
  57864. return this._cachedSize;
  57865. }
  57866. if (this._texture._size) {
  57867. this._cachedSize.width = this._texture._size;
  57868. this._cachedSize.height = this._texture._size;
  57869. return this._cachedSize;
  57870. }
  57871. }
  57872. return this._cachedSize;
  57873. };
  57874. /**
  57875. * Get the base size of the texture.
  57876. * It can be different from the size if the texture has been resized for POT for instance
  57877. * @returns the base size
  57878. */
  57879. BaseTexture.prototype.getBaseSize = function () {
  57880. if (!this.isReady() || !this._texture) {
  57881. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  57882. }
  57883. if (this._texture._size) {
  57884. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  57885. }
  57886. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  57887. };
  57888. /**
  57889. * Update the sampling mode of the texture.
  57890. * Default is Trilinear mode.
  57891. *
  57892. * | Value | Type | Description |
  57893. * | ----- | ------------------ | ----------- |
  57894. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  57895. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  57896. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  57897. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  57898. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  57899. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  57900. * | 7 | NEAREST_LINEAR | |
  57901. * | 8 | NEAREST_NEAREST | |
  57902. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  57903. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  57904. * | 11 | LINEAR_LINEAR | |
  57905. * | 12 | LINEAR_NEAREST | |
  57906. *
  57907. * > _mag_: magnification filter (close to the viewer)
  57908. * > _min_: minification filter (far from the viewer)
  57909. * > _mip_: filter used between mip map levels
  57910. *@param samplingMode Define the new sampling mode of the texture
  57911. */
  57912. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  57913. if (!this._texture) {
  57914. return;
  57915. }
  57916. var scene = this.getScene();
  57917. if (!scene) {
  57918. return;
  57919. }
  57920. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  57921. };
  57922. /**
  57923. * Scales the texture if is `canRescale()`
  57924. * @param ratio the resize factor we want to use to rescale
  57925. */
  57926. BaseTexture.prototype.scale = function (ratio) {
  57927. };
  57928. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  57929. /**
  57930. * Get if the texture can rescale.
  57931. */
  57932. get: function () {
  57933. return false;
  57934. },
  57935. enumerable: true,
  57936. configurable: true
  57937. });
  57938. /** @hidden */
  57939. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  57940. if (!this._scene) {
  57941. return null;
  57942. }
  57943. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  57944. for (var index = 0; index < texturesCache.length; index++) {
  57945. var texturesCacheEntry = texturesCache[index];
  57946. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  57947. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  57948. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  57949. texturesCacheEntry.incrementReferences();
  57950. return texturesCacheEntry;
  57951. }
  57952. }
  57953. }
  57954. }
  57955. return null;
  57956. };
  57957. /** @hidden */
  57958. BaseTexture.prototype._rebuild = function () {
  57959. };
  57960. /**
  57961. * Triggers the load sequence in delayed load mode.
  57962. */
  57963. BaseTexture.prototype.delayLoad = function () {
  57964. };
  57965. /**
  57966. * Clones the texture.
  57967. * @returns the cloned texture
  57968. */
  57969. BaseTexture.prototype.clone = function () {
  57970. return null;
  57971. };
  57972. Object.defineProperty(BaseTexture.prototype, "textureType", {
  57973. /**
  57974. * Get the texture underlying type (INT, FLOAT...)
  57975. */
  57976. get: function () {
  57977. if (!this._texture) {
  57978. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57979. }
  57980. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57981. },
  57982. enumerable: true,
  57983. configurable: true
  57984. });
  57985. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  57986. /**
  57987. * Get the texture underlying format (RGB, RGBA...)
  57988. */
  57989. get: function () {
  57990. if (!this._texture) {
  57991. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57992. }
  57993. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57994. },
  57995. enumerable: true,
  57996. configurable: true
  57997. });
  57998. /**
  57999. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  58000. * This will returns an RGBA array buffer containing either in values (0-255) or
  58001. * float values (0-1) depending of the underlying buffer type.
  58002. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  58003. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  58004. * @param buffer defines a user defined buffer to fill with data (can be null)
  58005. * @returns The Array buffer containing the pixels data.
  58006. */
  58007. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  58008. if (faceIndex === void 0) { faceIndex = 0; }
  58009. if (level === void 0) { level = 0; }
  58010. if (buffer === void 0) { buffer = null; }
  58011. if (!this._texture) {
  58012. return null;
  58013. }
  58014. var size = this.getSize();
  58015. var width = size.width;
  58016. var height = size.height;
  58017. var scene = this.getScene();
  58018. if (!scene) {
  58019. return null;
  58020. }
  58021. var engine = scene.getEngine();
  58022. if (level != 0) {
  58023. width = width / Math.pow(2, level);
  58024. height = height / Math.pow(2, level);
  58025. width = Math.round(width);
  58026. height = Math.round(height);
  58027. }
  58028. if (this._texture.isCube) {
  58029. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  58030. }
  58031. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  58032. };
  58033. /**
  58034. * Release and destroy the underlying lower level texture aka internalTexture.
  58035. */
  58036. BaseTexture.prototype.releaseInternalTexture = function () {
  58037. if (this._texture) {
  58038. this._texture.dispose();
  58039. this._texture = null;
  58040. }
  58041. };
  58042. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  58043. /**
  58044. * Get the polynomial representation of the texture data.
  58045. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  58046. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  58047. */
  58048. get: function () {
  58049. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  58050. return null;
  58051. }
  58052. if (!this._texture._sphericalPolynomial) {
  58053. this._texture._sphericalPolynomial =
  58054. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  58055. }
  58056. return this._texture._sphericalPolynomial;
  58057. },
  58058. set: function (value) {
  58059. if (this._texture) {
  58060. this._texture._sphericalPolynomial = value;
  58061. }
  58062. },
  58063. enumerable: true,
  58064. configurable: true
  58065. });
  58066. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  58067. /** @hidden */
  58068. get: function () {
  58069. if (this._texture) {
  58070. return this._texture._lodTextureHigh;
  58071. }
  58072. return null;
  58073. },
  58074. enumerable: true,
  58075. configurable: true
  58076. });
  58077. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  58078. /** @hidden */
  58079. get: function () {
  58080. if (this._texture) {
  58081. return this._texture._lodTextureMid;
  58082. }
  58083. return null;
  58084. },
  58085. enumerable: true,
  58086. configurable: true
  58087. });
  58088. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  58089. /** @hidden */
  58090. get: function () {
  58091. if (this._texture) {
  58092. return this._texture._lodTextureLow;
  58093. }
  58094. return null;
  58095. },
  58096. enumerable: true,
  58097. configurable: true
  58098. });
  58099. /**
  58100. * Dispose the texture and release its associated resources.
  58101. */
  58102. BaseTexture.prototype.dispose = function () {
  58103. if (!this._scene) {
  58104. return;
  58105. }
  58106. // Animations
  58107. this._scene.stopAnimation(this);
  58108. // Remove from scene
  58109. this._scene._removePendingData(this);
  58110. var index = this._scene.textures.indexOf(this);
  58111. if (index >= 0) {
  58112. this._scene.textures.splice(index, 1);
  58113. }
  58114. this._scene.onTextureRemovedObservable.notifyObservers(this);
  58115. if (this._texture === undefined) {
  58116. return;
  58117. }
  58118. // Release
  58119. this.releaseInternalTexture();
  58120. // Callback
  58121. this.onDisposeObservable.notifyObservers(this);
  58122. this.onDisposeObservable.clear();
  58123. };
  58124. /**
  58125. * Serialize the texture into a JSON representation that can be parsed later on.
  58126. * @returns the JSON representation of the texture
  58127. */
  58128. BaseTexture.prototype.serialize = function () {
  58129. if (!this.name) {
  58130. return null;
  58131. }
  58132. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  58133. // Animations
  58134. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  58135. return serializationObject;
  58136. };
  58137. /**
  58138. * Helper function to be called back once a list of texture contains only ready textures.
  58139. * @param textures Define the list of textures to wait for
  58140. * @param callback Define the callback triggered once the entire list will be ready
  58141. */
  58142. BaseTexture.WhenAllReady = function (textures, callback) {
  58143. var numRemaining = textures.length;
  58144. if (numRemaining === 0) {
  58145. callback();
  58146. return;
  58147. }
  58148. var _loop_1 = function () {
  58149. texture = textures[i];
  58150. if (texture.isReady()) {
  58151. if (--numRemaining === 0) {
  58152. callback();
  58153. }
  58154. }
  58155. else {
  58156. onLoadObservable = texture.onLoadObservable;
  58157. var onLoadCallback_1 = function () {
  58158. onLoadObservable.removeCallback(onLoadCallback_1);
  58159. if (--numRemaining === 0) {
  58160. callback();
  58161. }
  58162. };
  58163. onLoadObservable.add(onLoadCallback_1);
  58164. }
  58165. };
  58166. var texture, onLoadObservable;
  58167. for (var i = 0; i < textures.length; i++) {
  58168. _loop_1();
  58169. }
  58170. };
  58171. /**
  58172. * Default anisotropic filtering level for the application.
  58173. * It is set to 4 as a good tradeoff between perf and quality.
  58174. */
  58175. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  58176. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58177. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58178. ], BaseTexture.prototype, "uniqueId", void 0);
  58179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58181. ], BaseTexture.prototype, "name", void 0);
  58182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58184. ], BaseTexture.prototype, "metadata", void 0);
  58185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  58187. ], BaseTexture.prototype, "_hasAlpha", void 0);
  58188. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58189. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58190. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  58191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58193. ], BaseTexture.prototype, "level", void 0);
  58194. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58196. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  58197. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58198. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  58199. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  58200. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58202. ], BaseTexture.prototype, "wrapU", void 0);
  58203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58205. ], BaseTexture.prototype, "wrapV", void 0);
  58206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58208. ], BaseTexture.prototype, "wrapR", void 0);
  58209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58211. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  58212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58214. ], BaseTexture.prototype, "isCube", null);
  58215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58217. ], BaseTexture.prototype, "is3D", null);
  58218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58220. ], BaseTexture.prototype, "gammaSpace", void 0);
  58221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58223. ], BaseTexture.prototype, "invertZ", void 0);
  58224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58226. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  58227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58229. ], BaseTexture.prototype, "lodGenerationOffset", null);
  58230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58232. ], BaseTexture.prototype, "lodGenerationScale", null);
  58233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58235. ], BaseTexture.prototype, "isRenderTarget", void 0);
  58236. return BaseTexture;
  58237. }());
  58238. /***/ }),
  58239. /***/ "./Materials/Textures/colorGradingTexture.ts":
  58240. /*!***************************************************!*\
  58241. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  58242. \***************************************************/
  58243. /*! exports provided: ColorGradingTexture */
  58244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58245. "use strict";
  58246. __webpack_require__.r(__webpack_exports__);
  58247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  58248. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58249. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58250. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58251. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58252. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58253. /**
  58254. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58255. * It can help converting any input color in a desired output one. This can then be used to create effects
  58256. * from sepia, black and white to sixties or futuristic rendering...
  58257. *
  58258. * The only supported format is currently 3dl.
  58259. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58260. */
  58261. var ColorGradingTexture = /** @class */ (function (_super) {
  58262. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  58263. /**
  58264. * Instantiates a ColorGradingTexture from the following parameters.
  58265. *
  58266. * @param url The location of the color gradind data (currently only supporting 3dl)
  58267. * @param scene The scene the texture will be used in
  58268. */
  58269. function ColorGradingTexture(url, scene) {
  58270. var _this = _super.call(this, scene) || this;
  58271. if (!url) {
  58272. return _this;
  58273. }
  58274. _this._engine = scene.getEngine();
  58275. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  58276. _this.name = url;
  58277. _this.url = url;
  58278. _this.hasAlpha = false;
  58279. _this.isCube = false;
  58280. _this.is3D = _this._engine.webGLVersion > 1;
  58281. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58282. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58283. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58284. _this.anisotropicFilteringLevel = 1;
  58285. _this._texture = _this._getFromCache(url, true);
  58286. if (!_this._texture) {
  58287. if (!scene.useDelayedTextureLoading) {
  58288. _this.loadTexture();
  58289. }
  58290. else {
  58291. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58292. }
  58293. }
  58294. return _this;
  58295. }
  58296. /**
  58297. * Returns the texture matrix used in most of the material.
  58298. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58299. */
  58300. ColorGradingTexture.prototype.getTextureMatrix = function () {
  58301. return this._textureMatrix;
  58302. };
  58303. /**
  58304. * Occurs when the file being loaded is a .3dl LUT file.
  58305. */
  58306. ColorGradingTexture.prototype.load3dlTexture = function () {
  58307. var engine = this._engine;
  58308. var texture;
  58309. if (engine.webGLVersion === 1) {
  58310. 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);
  58311. }
  58312. else {
  58313. 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);
  58314. }
  58315. this._texture = texture;
  58316. var callback = function (text) {
  58317. if (typeof text !== "string") {
  58318. return;
  58319. }
  58320. var data = null;
  58321. var tempData = null;
  58322. var line;
  58323. var lines = text.split('\n');
  58324. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  58325. var maxColor = 0;
  58326. for (var i = 0; i < lines.length; i++) {
  58327. line = lines[i];
  58328. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  58329. continue;
  58330. }
  58331. if (line.indexOf('#') === 0) {
  58332. continue;
  58333. }
  58334. var words = line.split(" ");
  58335. if (size === 0) {
  58336. // Number of space + one
  58337. size = words.length;
  58338. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  58339. tempData = new Float32Array(size * size * size * 4);
  58340. continue;
  58341. }
  58342. if (size != 0) {
  58343. var r = Math.max(parseInt(words[0]), 0);
  58344. var g = Math.max(parseInt(words[1]), 0);
  58345. var b = Math.max(parseInt(words[2]), 0);
  58346. maxColor = Math.max(r, maxColor);
  58347. maxColor = Math.max(g, maxColor);
  58348. maxColor = Math.max(b, maxColor);
  58349. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  58350. if (tempData) {
  58351. tempData[pixelStorageIndex + 0] = r;
  58352. tempData[pixelStorageIndex + 1] = g;
  58353. tempData[pixelStorageIndex + 2] = b;
  58354. }
  58355. // Keep for reference in case of back compat problems.
  58356. // pixelIndexSlice++;
  58357. // if (pixelIndexSlice % size == 0) {
  58358. // pixelIndexH++;
  58359. // pixelIndexSlice = 0;
  58360. // if (pixelIndexH % size == 0) {
  58361. // pixelIndexW++;
  58362. // pixelIndexH = 0;
  58363. // }
  58364. // }
  58365. pixelIndexH++;
  58366. if (pixelIndexH % size == 0) {
  58367. pixelIndexSlice++;
  58368. pixelIndexH = 0;
  58369. if (pixelIndexSlice % size == 0) {
  58370. pixelIndexW++;
  58371. pixelIndexSlice = 0;
  58372. }
  58373. }
  58374. }
  58375. }
  58376. if (tempData && data) {
  58377. for (var i = 0; i < tempData.length; i++) {
  58378. if (i > 0 && (i + 1) % 4 === 0) {
  58379. data[i] = 255;
  58380. }
  58381. else {
  58382. var value = tempData[i];
  58383. data[i] = (value / maxColor * 255);
  58384. }
  58385. }
  58386. }
  58387. if (texture.is3D) {
  58388. texture.updateSize(size, size, size);
  58389. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  58390. }
  58391. else {
  58392. texture.updateSize(size * size, size);
  58393. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  58394. }
  58395. };
  58396. var scene = this.getScene();
  58397. if (scene) {
  58398. scene._loadFile(this.url, callback);
  58399. }
  58400. else {
  58401. this._engine._loadFile(this.url, callback);
  58402. }
  58403. return this._texture;
  58404. };
  58405. /**
  58406. * Starts the loading process of the texture.
  58407. */
  58408. ColorGradingTexture.prototype.loadTexture = function () {
  58409. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  58410. this.load3dlTexture();
  58411. }
  58412. };
  58413. /**
  58414. * Clones the color gradind texture.
  58415. */
  58416. ColorGradingTexture.prototype.clone = function () {
  58417. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  58418. // Base texture
  58419. newTexture.level = this.level;
  58420. return newTexture;
  58421. };
  58422. /**
  58423. * Called during delayed load for textures.
  58424. */
  58425. ColorGradingTexture.prototype.delayLoad = function () {
  58426. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58427. return;
  58428. }
  58429. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  58430. this._texture = this._getFromCache(this.url, true);
  58431. if (!this._texture) {
  58432. this.loadTexture();
  58433. }
  58434. };
  58435. /**
  58436. * Parses a color grading texture serialized by Babylon.
  58437. * @param parsedTexture The texture information being parsedTexture
  58438. * @param scene The scene to load the texture in
  58439. * @param rootUrl The root url of the data assets to load
  58440. * @return A color gradind texture
  58441. */
  58442. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  58443. var texture = null;
  58444. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  58445. texture = new ColorGradingTexture(parsedTexture.name, scene);
  58446. texture.name = parsedTexture.name;
  58447. texture.level = parsedTexture.level;
  58448. }
  58449. return texture;
  58450. };
  58451. /**
  58452. * Serializes the LUT texture to json format.
  58453. */
  58454. ColorGradingTexture.prototype.serialize = function () {
  58455. if (!this.name) {
  58456. return null;
  58457. }
  58458. var serializationObject = {};
  58459. serializationObject.name = this.name;
  58460. serializationObject.level = this.level;
  58461. serializationObject.customType = "BABYLON.ColorGradingTexture";
  58462. return serializationObject;
  58463. };
  58464. /**
  58465. * Empty line regex stored for GC.
  58466. */
  58467. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  58468. return ColorGradingTexture;
  58469. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  58470. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  58471. /***/ }),
  58472. /***/ "./Materials/Textures/cubeTexture.ts":
  58473. /*!*******************************************!*\
  58474. !*** ./Materials/Textures/cubeTexture.ts ***!
  58475. \*******************************************/
  58476. /*! exports provided: CubeTexture */
  58477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58478. "use strict";
  58479. __webpack_require__.r(__webpack_exports__);
  58480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  58481. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58482. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58483. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58484. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58485. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58486. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58487. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58488. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58489. /**
  58490. * Class for creating a cube texture
  58491. */
  58492. var CubeTexture = /** @class */ (function (_super) {
  58493. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  58494. /**
  58495. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  58496. * as prefiltered data.
  58497. * @param rootUrl defines the url of the texture or the root name of the six images
  58498. * @param scene defines the scene the texture is attached to
  58499. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  58500. * @param noMipmap defines if mipmaps should be created or not
  58501. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  58502. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  58503. * @param onError defines a callback triggered in case of error during load
  58504. * @param format defines the internal format to use for the texture once loaded
  58505. * @param prefiltered defines whether or not the texture is created from prefiltered data
  58506. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  58507. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  58508. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58509. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58510. * @return the cube texture
  58511. */
  58512. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  58513. if (extensions === void 0) { extensions = null; }
  58514. if (noMipmap === void 0) { noMipmap = false; }
  58515. if (files === void 0) { files = null; }
  58516. if (onLoad === void 0) { onLoad = null; }
  58517. if (onError === void 0) { onError = null; }
  58518. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58519. if (prefiltered === void 0) { prefiltered = false; }
  58520. if (forcedExtension === void 0) { forcedExtension = null; }
  58521. if (createPolynomials === void 0) { createPolynomials = false; }
  58522. if (lodScale === void 0) { lodScale = 0.8; }
  58523. if (lodOffset === void 0) { lodOffset = 0; }
  58524. var _this = _super.call(this, scene) || this;
  58525. /**
  58526. * Gets or sets the center of the bounding box associated with the cube texture.
  58527. * It must define where the camera used to render the texture was set
  58528. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  58529. */
  58530. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  58531. _this._rotationY = 0;
  58532. /** @hidden */
  58533. _this._prefiltered = false;
  58534. _this.name = rootUrl;
  58535. _this.url = rootUrl;
  58536. _this._noMipmap = noMipmap;
  58537. _this.hasAlpha = false;
  58538. _this._format = format;
  58539. _this.isCube = true;
  58540. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  58541. _this._createPolynomials = createPolynomials;
  58542. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  58543. if (!rootUrl && !files) {
  58544. return _this;
  58545. }
  58546. var lastDot = rootUrl.lastIndexOf(".");
  58547. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  58548. var isDDS = (extension === ".dds");
  58549. var isEnv = (extension === ".env");
  58550. if (isEnv) {
  58551. _this.gammaSpace = false;
  58552. _this._prefiltered = false;
  58553. }
  58554. else {
  58555. _this._prefiltered = prefiltered;
  58556. if (prefiltered) {
  58557. _this.gammaSpace = false;
  58558. }
  58559. }
  58560. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  58561. if (!files) {
  58562. if (!isEnv && !isDDS && !extensions) {
  58563. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  58564. }
  58565. files = [];
  58566. if (extensions) {
  58567. for (var index = 0; index < extensions.length; index++) {
  58568. files.push(rootUrl + extensions[index]);
  58569. }
  58570. }
  58571. }
  58572. _this._files = files;
  58573. if (!_this._texture) {
  58574. if (!scene.useDelayedTextureLoading) {
  58575. if (prefiltered) {
  58576. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  58577. }
  58578. else {
  58579. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  58580. }
  58581. }
  58582. else {
  58583. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58584. }
  58585. }
  58586. else if (onLoad) {
  58587. if (_this._texture.isReady) {
  58588. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  58589. }
  58590. else {
  58591. _this._texture.onLoadedObservable.add(onLoad);
  58592. }
  58593. }
  58594. return _this;
  58595. }
  58596. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  58597. /**
  58598. * Returns the bounding box size
  58599. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  58600. */
  58601. get: function () {
  58602. return this._boundingBoxSize;
  58603. },
  58604. /**
  58605. * Gets or sets the size of the bounding box associated with the cube texture
  58606. * When defined, the cubemap will switch to local mode
  58607. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58608. * @example https://www.babylonjs-playground.com/#RNASML
  58609. */
  58610. set: function (value) {
  58611. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  58612. return;
  58613. }
  58614. this._boundingBoxSize = value;
  58615. var scene = this.getScene();
  58616. if (scene) {
  58617. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58618. }
  58619. },
  58620. enumerable: true,
  58621. configurable: true
  58622. });
  58623. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  58624. /**
  58625. * Gets texture matrix rotation angle around Y axis radians.
  58626. */
  58627. get: function () {
  58628. return this._rotationY;
  58629. },
  58630. /**
  58631. * Sets texture matrix rotation angle around Y axis in radians.
  58632. */
  58633. set: function (value) {
  58634. this._rotationY = value;
  58635. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  58636. },
  58637. enumerable: true,
  58638. configurable: true
  58639. });
  58640. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  58641. /**
  58642. * Are mip maps generated for this texture or not.
  58643. */
  58644. get: function () {
  58645. return this._noMipmap;
  58646. },
  58647. enumerable: true,
  58648. configurable: true
  58649. });
  58650. /**
  58651. * Creates a cube texture from an array of image urls
  58652. * @param files defines an array of image urls
  58653. * @param scene defines the hosting scene
  58654. * @param noMipmap specifies if mip maps are not used
  58655. * @returns a cube texture
  58656. */
  58657. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  58658. var rootUrlKey = "";
  58659. files.forEach(function (url) { return rootUrlKey += url; });
  58660. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  58661. };
  58662. /**
  58663. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  58664. * @param url defines the url of the prefiltered texture
  58665. * @param scene defines the scene the texture is attached to
  58666. * @param forcedExtension defines the extension of the file if different from the url
  58667. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  58668. * @return the prefiltered texture
  58669. */
  58670. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  58671. if (forcedExtension === void 0) { forcedExtension = null; }
  58672. if (createPolynomials === void 0) { createPolynomials = true; }
  58673. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  58674. };
  58675. /**
  58676. * Get the current class name of the texture useful for serialization or dynamic coding.
  58677. * @returns "CubeTexture"
  58678. */
  58679. CubeTexture.prototype.getClassName = function () {
  58680. return "CubeTexture";
  58681. };
  58682. /**
  58683. * Update the url (and optional buffer) of this texture if url was null during construction.
  58684. * @param url the url of the texture
  58685. * @param forcedExtension defines the extension to use
  58686. * @param onLoad callback called when the texture is loaded (defaults to null)
  58687. */
  58688. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  58689. if (this.url) {
  58690. this.releaseInternalTexture();
  58691. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58692. }
  58693. this.url = url;
  58694. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58695. this._prefiltered = false;
  58696. if (onLoad) {
  58697. this._delayedOnLoad = onLoad;
  58698. }
  58699. this.delayLoad(forcedExtension);
  58700. };
  58701. /**
  58702. * Delays loading of the cube texture
  58703. * @param forcedExtension defines the extension to use
  58704. */
  58705. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  58706. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58707. return;
  58708. }
  58709. var scene = this.getScene();
  58710. if (!scene) {
  58711. return;
  58712. }
  58713. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58714. this._texture = this._getFromCache(this.url, this._noMipmap);
  58715. if (!this._texture) {
  58716. if (this._prefiltered) {
  58717. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  58718. }
  58719. else {
  58720. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  58721. }
  58722. }
  58723. };
  58724. /**
  58725. * Returns the reflection texture matrix
  58726. * @returns the reflection texture matrix
  58727. */
  58728. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  58729. return this._textureMatrix;
  58730. };
  58731. /**
  58732. * Sets the reflection texture matrix
  58733. * @param value Reflection texture matrix
  58734. */
  58735. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  58736. var _this = this;
  58737. if (value.updateFlag === this._textureMatrix.updateFlag) {
  58738. return;
  58739. }
  58740. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  58741. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  58742. }
  58743. this._textureMatrix = value;
  58744. };
  58745. /**
  58746. * Parses text to create a cube texture
  58747. * @param parsedTexture define the serialized text to read from
  58748. * @param scene defines the hosting scene
  58749. * @param rootUrl defines the root url of the cube texture
  58750. * @returns a cube texture
  58751. */
  58752. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  58753. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58754. var prefiltered = false;
  58755. if (parsedTexture.prefiltered) {
  58756. prefiltered = parsedTexture.prefiltered;
  58757. }
  58758. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  58759. }, parsedTexture, scene);
  58760. // Local Cubemaps
  58761. if (parsedTexture.boundingBoxPosition) {
  58762. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  58763. }
  58764. if (parsedTexture.boundingBoxSize) {
  58765. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  58766. }
  58767. // Animations
  58768. if (parsedTexture.animations) {
  58769. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58770. var parsedAnimation = parsedTexture.animations[animationIndex];
  58771. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  58772. if (internalClass) {
  58773. texture.animations.push(internalClass.Parse(parsedAnimation));
  58774. }
  58775. }
  58776. }
  58777. return texture;
  58778. };
  58779. /**
  58780. * Makes a clone, or deep copy, of the cube texture
  58781. * @returns a new cube texture
  58782. */
  58783. CubeTexture.prototype.clone = function () {
  58784. var _this = this;
  58785. var scene = this.getScene();
  58786. var uniqueId = 0;
  58787. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58788. if (!scene) {
  58789. return _this;
  58790. }
  58791. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  58792. uniqueId = cubeTexture.uniqueId;
  58793. return cubeTexture;
  58794. }, this);
  58795. newCubeTexture.uniqueId = uniqueId;
  58796. return newCubeTexture;
  58797. };
  58798. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58799. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  58800. ], CubeTexture.prototype, "rotationY", null);
  58801. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58802. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMatrix"])("textureMatrix")
  58803. ], CubeTexture.prototype, "_textureMatrix", void 0);
  58804. return CubeTexture;
  58805. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  58806. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  58807. // Some exporters relies on Tools.Instantiate
  58808. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  58809. /***/ }),
  58810. /***/ "./Materials/Textures/dynamicTexture.ts":
  58811. /*!**********************************************!*\
  58812. !*** ./Materials/Textures/dynamicTexture.ts ***!
  58813. \**********************************************/
  58814. /*! exports provided: DynamicTexture */
  58815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58816. "use strict";
  58817. __webpack_require__.r(__webpack_exports__);
  58818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  58819. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58820. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  58821. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58822. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58823. /**
  58824. * A class extending Texture allowing drawing on a texture
  58825. * @see http://doc.babylonjs.com/how_to/dynamictexture
  58826. */
  58827. var DynamicTexture = /** @class */ (function (_super) {
  58828. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  58829. /**
  58830. * Creates a DynamicTexture
  58831. * @param name defines the name of the texture
  58832. * @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
  58833. * @param scene defines the scene where you want the texture
  58834. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  58835. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58836. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  58837. */
  58838. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  58839. if (scene === void 0) { scene = null; }
  58840. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58841. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  58842. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  58843. _this.name = name;
  58844. _this._engine = _this.getScene().getEngine();
  58845. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  58846. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  58847. _this._generateMipMaps = generateMipMaps;
  58848. if (options.getContext) {
  58849. _this._canvas = options;
  58850. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  58851. }
  58852. else {
  58853. _this._canvas = document.createElement("canvas");
  58854. if (options.width || options.width === 0) {
  58855. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  58856. }
  58857. else {
  58858. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  58859. }
  58860. }
  58861. var textureSize = _this.getSize();
  58862. _this._canvas.width = textureSize.width;
  58863. _this._canvas.height = textureSize.height;
  58864. _this._context = _this._canvas.getContext("2d");
  58865. return _this;
  58866. }
  58867. /**
  58868. * Get the current class name of the texture useful for serialization or dynamic coding.
  58869. * @returns "DynamicTexture"
  58870. */
  58871. DynamicTexture.prototype.getClassName = function () {
  58872. return "DynamicTexture";
  58873. };
  58874. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  58875. /**
  58876. * Gets the current state of canRescale
  58877. */
  58878. get: function () {
  58879. return true;
  58880. },
  58881. enumerable: true,
  58882. configurable: true
  58883. });
  58884. DynamicTexture.prototype._recreate = function (textureSize) {
  58885. this._canvas.width = textureSize.width;
  58886. this._canvas.height = textureSize.height;
  58887. this.releaseInternalTexture();
  58888. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  58889. };
  58890. /**
  58891. * Scales the texture
  58892. * @param ratio the scale factor to apply to both width and height
  58893. */
  58894. DynamicTexture.prototype.scale = function (ratio) {
  58895. var textureSize = this.getSize();
  58896. textureSize.width *= ratio;
  58897. textureSize.height *= ratio;
  58898. this._recreate(textureSize);
  58899. };
  58900. /**
  58901. * Resizes the texture
  58902. * @param width the new width
  58903. * @param height the new height
  58904. */
  58905. DynamicTexture.prototype.scaleTo = function (width, height) {
  58906. var textureSize = this.getSize();
  58907. textureSize.width = width;
  58908. textureSize.height = height;
  58909. this._recreate(textureSize);
  58910. };
  58911. /**
  58912. * Gets the context of the canvas used by the texture
  58913. * @returns the canvas context of the dynamic texture
  58914. */
  58915. DynamicTexture.prototype.getContext = function () {
  58916. return this._context;
  58917. };
  58918. /**
  58919. * Clears the texture
  58920. */
  58921. DynamicTexture.prototype.clear = function () {
  58922. var size = this.getSize();
  58923. this._context.fillRect(0, 0, size.width, size.height);
  58924. };
  58925. /**
  58926. * Updates the texture
  58927. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  58928. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  58929. */
  58930. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  58931. if (premulAlpha === void 0) { premulAlpha = false; }
  58932. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  58933. };
  58934. /**
  58935. * Draws text onto the texture
  58936. * @param text defines the text to be drawn
  58937. * @param x defines the placement of the text from the left
  58938. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  58939. * @param font defines the font to be used with font-style, font-size, font-name
  58940. * @param color defines the color used for the text
  58941. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  58942. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  58943. * @param update defines whether texture is immediately update (default is true)
  58944. */
  58945. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  58946. if (update === void 0) { update = true; }
  58947. var size = this.getSize();
  58948. if (clearColor) {
  58949. this._context.fillStyle = clearColor;
  58950. this._context.fillRect(0, 0, size.width, size.height);
  58951. }
  58952. this._context.font = font;
  58953. if (x === null || x === undefined) {
  58954. var textSize = this._context.measureText(text);
  58955. x = (size.width - textSize.width) / 2;
  58956. }
  58957. if (y === null || y === undefined) {
  58958. var fontSize = parseInt((font.replace(/\D/g, '')));
  58959. y = (size.height / 2) + (fontSize / 3.65);
  58960. }
  58961. this._context.fillStyle = color;
  58962. this._context.fillText(text, x, y);
  58963. if (update) {
  58964. this.update(invertY);
  58965. }
  58966. };
  58967. /**
  58968. * Clones the texture
  58969. * @returns the clone of the texture.
  58970. */
  58971. DynamicTexture.prototype.clone = function () {
  58972. var scene = this.getScene();
  58973. if (!scene) {
  58974. return this;
  58975. }
  58976. var textureSize = this.getSize();
  58977. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  58978. // Base texture
  58979. newTexture.hasAlpha = this.hasAlpha;
  58980. newTexture.level = this.level;
  58981. // Dynamic Texture
  58982. newTexture.wrapU = this.wrapU;
  58983. newTexture.wrapV = this.wrapV;
  58984. return newTexture;
  58985. };
  58986. /**
  58987. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  58988. * @returns a serialized dynamic texture object
  58989. */
  58990. DynamicTexture.prototype.serialize = function () {
  58991. var scene = this.getScene();
  58992. if (scene && !scene.isReady()) {
  58993. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  58994. }
  58995. var serializationObject = _super.prototype.serialize.call(this);
  58996. serializationObject.base64String = this._canvas.toDataURL();
  58997. serializationObject.invertY = this._invertY;
  58998. serializationObject.samplingMode = this.samplingMode;
  58999. return serializationObject;
  59000. };
  59001. /** @hidden */
  59002. DynamicTexture.prototype._rebuild = function () {
  59003. this.update();
  59004. };
  59005. return DynamicTexture;
  59006. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  59007. /***/ }),
  59008. /***/ "./Materials/Textures/equiRectangularCubeTexture.ts":
  59009. /*!**********************************************************!*\
  59010. !*** ./Materials/Textures/equiRectangularCubeTexture.ts ***!
  59011. \**********************************************************/
  59012. /*! exports provided: EquiRectangularCubeTexture */
  59013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59014. "use strict";
  59015. __webpack_require__.r(__webpack_exports__);
  59016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return EquiRectangularCubeTexture; });
  59017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59018. /* harmony import */ var _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  59019. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  59020. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  59021. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  59022. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59023. /**
  59024. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59025. */
  59026. var EquiRectangularCubeTexture = /** @class */ (function (_super) {
  59027. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTexture, _super);
  59028. /**
  59029. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59030. * @param url The location of the image
  59031. * @param scene The scene the texture will be used in
  59032. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59033. * @param noMipmap Forces to not generate the mipmap if true
  59034. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59035. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59036. * @param onLoad — defines a callback called when texture is loaded
  59037. * @param onError — defines a callback called if there is an error
  59038. */
  59039. function EquiRectangularCubeTexture(url, scene, size, noMipmap, gammaSpace, onLoad, onError) {
  59040. if (noMipmap === void 0) { noMipmap = false; }
  59041. if (gammaSpace === void 0) { gammaSpace = true; }
  59042. if (onLoad === void 0) { onLoad = null; }
  59043. if (onError === void 0) { onError = null; }
  59044. var _this = _super.call(this, scene) || this;
  59045. _this._onLoad = null;
  59046. _this._onError = null;
  59047. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59048. _this.coordinatesMode = _texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  59049. if (!url) {
  59050. throw new Error('Image url is not set');
  59051. }
  59052. _this.name = url;
  59053. _this.url = url;
  59054. _this._size = size;
  59055. _this._noMipmap = noMipmap;
  59056. _this.gammaSpace = gammaSpace;
  59057. _this._onLoad = onLoad;
  59058. _this._onError = onError;
  59059. _this.hasAlpha = false;
  59060. _this.isCube = true;
  59061. _this._texture = _this._getFromCache(url, _this._noMipmap);
  59062. if (!_this._texture) {
  59063. if (!scene.useDelayedTextureLoading) {
  59064. _this.loadImage(_this.loadTexture.bind(_this), _this._onError);
  59065. }
  59066. else {
  59067. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  59068. }
  59069. }
  59070. else if (onLoad) {
  59071. if (_this._texture.isReady) {
  59072. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].SetImmediate(function () { return onLoad(); });
  59073. }
  59074. else {
  59075. _this._texture.onLoadedObservable.add(onLoad);
  59076. }
  59077. }
  59078. return _this;
  59079. }
  59080. /**
  59081. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59082. */
  59083. EquiRectangularCubeTexture.prototype.loadImage = function (loadTextureCallback, onError) {
  59084. var _this = this;
  59085. var canvas = document.createElement('canvas');
  59086. var image = new Image();
  59087. image.addEventListener('load', function () {
  59088. _this._width = image.width;
  59089. _this._height = image.height;
  59090. canvas.width = _this._width;
  59091. canvas.height = _this._height;
  59092. var ctx = canvas.getContext('2d');
  59093. ctx.drawImage(image, 0, 0);
  59094. var imageData = ctx.getImageData(0, 0, image.width, image.height);
  59095. _this._buffer = imageData.data.buffer;
  59096. canvas.remove();
  59097. loadTextureCallback();
  59098. });
  59099. image.addEventListener('error', function (error) {
  59100. if (onError) {
  59101. onError(_this.getClassName() + " could not be loaded", error);
  59102. }
  59103. });
  59104. image.src = this.url;
  59105. };
  59106. /**
  59107. * Convert the image buffer into a cubemap and create a CubeTexture.
  59108. */
  59109. EquiRectangularCubeTexture.prototype.loadTexture = function () {
  59110. var _this = this;
  59111. var scene = this.getScene();
  59112. var callback = function () {
  59113. var imageData = _this.getFloat32ArrayFromArrayBuffer(_this._buffer);
  59114. // Extract the raw linear data.
  59115. var data = _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(imageData, _this._width, _this._height, _this._size);
  59116. var results = [];
  59117. // Push each faces.
  59118. for (var i = 0; i < 6; i++) {
  59119. var dataFace = data[EquiRectangularCubeTexture._FacesMapping[i]];
  59120. results.push(dataFace);
  59121. }
  59122. return results;
  59123. };
  59124. if (!scene) {
  59125. return;
  59126. }
  59127. this._texture = scene
  59128. .getEngine()
  59129. .createRawCubeTextureFromUrl(this.url, scene, this._size, _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat
  59130. ? _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_FLOAT
  59131. : _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, callback, null, this._onLoad, this._onError);
  59132. };
  59133. /**
  59134. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59135. * @param buffer The ArrayBuffer that should be converted.
  59136. * @returns The buffer as Float32Array.
  59137. */
  59138. EquiRectangularCubeTexture.prototype.getFloat32ArrayFromArrayBuffer = function (buffer) {
  59139. var dataView = new DataView(buffer);
  59140. var floatImageData = new Float32Array((buffer.byteLength * 3) / 4);
  59141. var k = 0;
  59142. for (var i = 0; i < buffer.byteLength; i++) {
  59143. // We drop the transparency channel, because we do not need/want it
  59144. if ((i + 1) % 4 !== 0) {
  59145. floatImageData[k++] = dataView.getUint8(i) / 255;
  59146. }
  59147. }
  59148. return floatImageData;
  59149. };
  59150. /**
  59151. * Get the current class name of the texture useful for serialization or dynamic coding.
  59152. * @returns "EquiRectangularCubeTexture"
  59153. */
  59154. EquiRectangularCubeTexture.prototype.getClassName = function () {
  59155. return "EquiRectangularCubeTexture";
  59156. };
  59157. /**
  59158. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59159. * @returns A clone of the current EquiRectangularCubeTexture.
  59160. */
  59161. EquiRectangularCubeTexture.prototype.clone = function () {
  59162. var scene = this.getScene();
  59163. if (!scene) {
  59164. return this;
  59165. }
  59166. var newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);
  59167. // Base texture
  59168. newTexture.level = this.level;
  59169. newTexture.wrapU = this.wrapU;
  59170. newTexture.wrapV = this.wrapV;
  59171. newTexture.coordinatesIndex = this.coordinatesIndex;
  59172. newTexture.coordinatesMode = this.coordinatesMode;
  59173. return newTexture;
  59174. };
  59175. /** The six faces of the cube. */
  59176. EquiRectangularCubeTexture._FacesMapping = ['right', 'left', 'up', 'down', 'front', 'back'];
  59177. return EquiRectangularCubeTexture;
  59178. }(_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  59179. /***/ }),
  59180. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  59181. /*!**********************************************!*\
  59182. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  59183. \**********************************************/
  59184. /*! exports provided: HDRCubeTexture */
  59185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59186. "use strict";
  59187. __webpack_require__.r(__webpack_exports__);
  59188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  59189. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59190. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59191. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  59192. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  59193. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59194. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59195. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  59196. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  59197. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  59198. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59199. /**
  59200. * This represents a texture coming from an HDR input.
  59201. *
  59202. * The only supported format is currently panorama picture stored in RGBE format.
  59203. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59204. */
  59205. var HDRCubeTexture = /** @class */ (function (_super) {
  59206. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  59207. /**
  59208. * Instantiates an HDRTexture from the following parameters.
  59209. *
  59210. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59211. * @param scene The scene the texture will be used in
  59212. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59213. * @param noMipmap Forces to not generate the mipmap if true
  59214. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59215. * @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)
  59216. * @param reserved Reserved flag for internal use.
  59217. */
  59218. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  59219. if (noMipmap === void 0) { noMipmap = false; }
  59220. if (generateHarmonics === void 0) { generateHarmonics = true; }
  59221. if (gammaSpace === void 0) { gammaSpace = false; }
  59222. if (reserved === void 0) { reserved = false; }
  59223. if (onLoad === void 0) { onLoad = null; }
  59224. if (onError === void 0) { onError = null; }
  59225. var _this = _super.call(this, scene) || this;
  59226. _this._generateHarmonics = true;
  59227. _this._onLoad = null;
  59228. _this._onError = null;
  59229. /**
  59230. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59231. */
  59232. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  59233. _this._isBlocking = true;
  59234. _this._rotationY = 0;
  59235. /**
  59236. * Gets or sets the center of the bounding box associated with the cube texture
  59237. * It must define where the camera used to render the texture was set
  59238. */
  59239. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  59240. if (!url) {
  59241. return _this;
  59242. }
  59243. _this.name = url;
  59244. _this.url = url;
  59245. _this.hasAlpha = false;
  59246. _this.isCube = true;
  59247. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  59248. _this._onLoad = onLoad;
  59249. _this._onError = onError;
  59250. _this.gammaSpace = gammaSpace;
  59251. _this._noMipmap = noMipmap;
  59252. _this._size = size;
  59253. _this._texture = _this._getFromCache(url, _this._noMipmap);
  59254. if (!_this._texture) {
  59255. if (!scene.useDelayedTextureLoading) {
  59256. _this.loadTexture();
  59257. }
  59258. else {
  59259. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  59260. }
  59261. }
  59262. else if (onLoad) {
  59263. if (_this._texture.isReady) {
  59264. _Misc_tools__WEBPACK_IMPORTED_MODULE_9__["Tools"].SetImmediate(function () { return onLoad(); });
  59265. }
  59266. else {
  59267. _this._texture.onLoadedObservable.add(onLoad);
  59268. }
  59269. }
  59270. return _this;
  59271. }
  59272. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  59273. /**
  59274. * Gets wether or not the texture is blocking during loading.
  59275. */
  59276. get: function () {
  59277. return this._isBlocking;
  59278. },
  59279. /**
  59280. * Sets wether or not the texture is blocking during loading.
  59281. */
  59282. set: function (value) {
  59283. this._isBlocking = value;
  59284. },
  59285. enumerable: true,
  59286. configurable: true
  59287. });
  59288. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  59289. /**
  59290. * Gets texture matrix rotation angle around Y axis radians.
  59291. */
  59292. get: function () {
  59293. return this._rotationY;
  59294. },
  59295. /**
  59296. * Sets texture matrix rotation angle around Y axis in radians.
  59297. */
  59298. set: function (value) {
  59299. this._rotationY = value;
  59300. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  59301. },
  59302. enumerable: true,
  59303. configurable: true
  59304. });
  59305. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  59306. get: function () {
  59307. return this._boundingBoxSize;
  59308. },
  59309. /**
  59310. * Gets or sets the size of the bounding box associated with the cube texture
  59311. * When defined, the cubemap will switch to local mode
  59312. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59313. * @example https://www.babylonjs-playground.com/#RNASML
  59314. */
  59315. set: function (value) {
  59316. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  59317. return;
  59318. }
  59319. this._boundingBoxSize = value;
  59320. var scene = this.getScene();
  59321. if (scene) {
  59322. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  59323. }
  59324. },
  59325. enumerable: true,
  59326. configurable: true
  59327. });
  59328. /**
  59329. * Get the current class name of the texture useful for serialization or dynamic coding.
  59330. * @returns "HDRCubeTexture"
  59331. */
  59332. HDRCubeTexture.prototype.getClassName = function () {
  59333. return "HDRCubeTexture";
  59334. };
  59335. /**
  59336. * Occurs when the file is raw .hdr file.
  59337. */
  59338. HDRCubeTexture.prototype.loadTexture = function () {
  59339. var _this = this;
  59340. var callback = function (buffer) {
  59341. _this.lodGenerationOffset = 0.0;
  59342. _this.lodGenerationScale = 0.8;
  59343. var scene = _this.getScene();
  59344. if (!scene) {
  59345. return null;
  59346. }
  59347. // Extract the raw linear data.
  59348. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  59349. // Generate harmonics if needed.
  59350. if (_this._generateHarmonics) {
  59351. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  59352. _this.sphericalPolynomial = sphericalPolynomial;
  59353. }
  59354. var results = [];
  59355. var byteArray = null;
  59356. // Push each faces.
  59357. for (var j = 0; j < 6; j++) {
  59358. // Create uintarray fallback.
  59359. if (!scene.getEngine().getCaps().textureFloat) {
  59360. // 3 channels of 1 bytes per pixel in bytes.
  59361. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  59362. byteArray = new Uint8Array(byteBuffer);
  59363. }
  59364. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  59365. // If special cases.
  59366. if (_this.gammaSpace || byteArray) {
  59367. for (var i = 0; i < _this._size * _this._size; i++) {
  59368. // Put in gamma space if requested.
  59369. if (_this.gammaSpace) {
  59370. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  59371. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  59372. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  59373. }
  59374. // Convert to int texture for fallback.
  59375. if (byteArray) {
  59376. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  59377. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  59378. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  59379. // May use luminance instead if the result is not accurate.
  59380. var max = Math.max(Math.max(r, g), b);
  59381. if (max > 255) {
  59382. var scale = 255 / max;
  59383. r *= scale;
  59384. g *= scale;
  59385. b *= scale;
  59386. }
  59387. byteArray[(i * 3) + 0] = r;
  59388. byteArray[(i * 3) + 1] = g;
  59389. byteArray[(i * 3) + 2] = b;
  59390. }
  59391. }
  59392. }
  59393. if (byteArray) {
  59394. results.push(byteArray);
  59395. }
  59396. else {
  59397. results.push(dataFace);
  59398. }
  59399. }
  59400. return results;
  59401. };
  59402. var scene = this.getScene();
  59403. if (scene) {
  59404. 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);
  59405. }
  59406. };
  59407. HDRCubeTexture.prototype.clone = function () {
  59408. var scene = this.getScene();
  59409. if (!scene) {
  59410. return this;
  59411. }
  59412. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  59413. // Base texture
  59414. newTexture.level = this.level;
  59415. newTexture.wrapU = this.wrapU;
  59416. newTexture.wrapV = this.wrapV;
  59417. newTexture.coordinatesIndex = this.coordinatesIndex;
  59418. newTexture.coordinatesMode = this.coordinatesMode;
  59419. return newTexture;
  59420. };
  59421. // Methods
  59422. HDRCubeTexture.prototype.delayLoad = function () {
  59423. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  59424. return;
  59425. }
  59426. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  59427. this._texture = this._getFromCache(this.url, this._noMipmap);
  59428. if (!this._texture) {
  59429. this.loadTexture();
  59430. }
  59431. };
  59432. /**
  59433. * Get the texture reflection matrix used to rotate/transform the reflection.
  59434. * @returns the reflection matrix
  59435. */
  59436. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  59437. return this._textureMatrix;
  59438. };
  59439. /**
  59440. * Set the texture reflection matrix used to rotate/transform the reflection.
  59441. * @param value Define the reflection matrix to set
  59442. */
  59443. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  59444. var _this = this;
  59445. this._textureMatrix = value;
  59446. if (value.updateFlag === this._textureMatrix.updateFlag) {
  59447. return;
  59448. }
  59449. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  59450. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  59451. }
  59452. };
  59453. /**
  59454. * Parses a JSON representation of an HDR Texture in order to create the texture
  59455. * @param parsedTexture Define the JSON representation
  59456. * @param scene Define the scene the texture should be created in
  59457. * @param rootUrl Define the root url in case we need to load relative dependencies
  59458. * @returns the newly created texture after parsing
  59459. */
  59460. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  59461. var texture = null;
  59462. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  59463. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  59464. texture.name = parsedTexture.name;
  59465. texture.hasAlpha = parsedTexture.hasAlpha;
  59466. texture.level = parsedTexture.level;
  59467. texture.coordinatesMode = parsedTexture.coordinatesMode;
  59468. texture.isBlocking = parsedTexture.isBlocking;
  59469. }
  59470. if (texture) {
  59471. if (parsedTexture.boundingBoxPosition) {
  59472. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  59473. }
  59474. if (parsedTexture.boundingBoxSize) {
  59475. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  59476. }
  59477. if (parsedTexture.rotationY) {
  59478. texture.rotationY = parsedTexture.rotationY;
  59479. }
  59480. }
  59481. return texture;
  59482. };
  59483. HDRCubeTexture.prototype.serialize = function () {
  59484. if (!this.name) {
  59485. return null;
  59486. }
  59487. var serializationObject = {};
  59488. serializationObject.name = this.name;
  59489. serializationObject.hasAlpha = this.hasAlpha;
  59490. serializationObject.isCube = true;
  59491. serializationObject.level = this.level;
  59492. serializationObject.size = this._size;
  59493. serializationObject.coordinatesMode = this.coordinatesMode;
  59494. serializationObject.useInGammaSpace = this.gammaSpace;
  59495. serializationObject.generateHarmonics = this._generateHarmonics;
  59496. serializationObject.customType = "BABYLON.HDRCubeTexture";
  59497. serializationObject.noMipmap = this._noMipmap;
  59498. serializationObject.isBlocking = this._isBlocking;
  59499. serializationObject.rotationY = this._rotationY;
  59500. return serializationObject;
  59501. };
  59502. HDRCubeTexture._facesMapping = [
  59503. "right",
  59504. "left",
  59505. "up",
  59506. "down",
  59507. "front",
  59508. "back"
  59509. ];
  59510. return HDRCubeTexture;
  59511. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  59512. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  59513. /***/ }),
  59514. /***/ "./Materials/Textures/index.ts":
  59515. /*!*************************************!*\
  59516. !*** ./Materials/Textures/index.ts ***!
  59517. \*************************************/
  59518. /*! exports provided: BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, _KTXTextureLoader, MultiRenderTarget, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  59519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59520. "use strict";
  59521. __webpack_require__.r(__webpack_exports__);
  59522. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  59523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  59524. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  59525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  59526. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  59527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  59528. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  59529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  59530. /* harmony import */ var _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  59531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__["EquiRectangularCubeTexture"]; });
  59532. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  59533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__["HDRCubeTexture"]; });
  59534. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  59535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_6__["InternalTexture"]; });
  59536. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  59537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  59538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  59539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  59540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  59541. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  59542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  59543. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  59544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  59545. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  59546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  59547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  59548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  59549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  59550. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  59551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  59552. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  59553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  59554. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  59555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  59556. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  59557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  59558. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  59560. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  59561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  59562. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  59563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  59564. /***/ }),
  59565. /***/ "./Materials/Textures/internalTexture.ts":
  59566. /*!***********************************************!*\
  59567. !*** ./Materials/Textures/internalTexture.ts ***!
  59568. \***********************************************/
  59569. /*! exports provided: InternalTexture */
  59570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59571. "use strict";
  59572. __webpack_require__.r(__webpack_exports__);
  59573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  59574. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59575. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  59576. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59577. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  59578. /**
  59579. * Class used to store data associated with WebGL texture data for the engine
  59580. * This class should not be used directly
  59581. */
  59582. var InternalTexture = /** @class */ (function () {
  59583. /**
  59584. * Creates a new InternalTexture
  59585. * @param engine defines the engine to use
  59586. * @param dataSource defines the type of data that will be used
  59587. * @param delayAllocation if the texture allocation should be delayed (default: false)
  59588. */
  59589. function InternalTexture(engine, dataSource, delayAllocation) {
  59590. if (delayAllocation === void 0) { delayAllocation = false; }
  59591. /**
  59592. * Defines if the texture is ready
  59593. */
  59594. this.isReady = false;
  59595. /**
  59596. * Defines if the texture is a cube texture
  59597. */
  59598. this.isCube = false;
  59599. /**
  59600. * Defines if the texture contains 3D data
  59601. */
  59602. this.is3D = false;
  59603. /**
  59604. * Defines if the texture contains multiview data
  59605. */
  59606. this.isMultiview = false;
  59607. /**
  59608. * Gets the URL used to load this texture
  59609. */
  59610. this.url = "";
  59611. /**
  59612. * Gets the sampling mode of the texture
  59613. */
  59614. this.samplingMode = -1;
  59615. /**
  59616. * Gets a boolean indicating if the texture needs mipmaps generation
  59617. */
  59618. this.generateMipMaps = false;
  59619. /**
  59620. * Gets the number of samples used by the texture (WebGL2+ only)
  59621. */
  59622. this.samples = 0;
  59623. /**
  59624. * Gets the type of the texture (int, float...)
  59625. */
  59626. this.type = -1;
  59627. /**
  59628. * Gets the format of the texture (RGB, RGBA...)
  59629. */
  59630. this.format = -1;
  59631. /**
  59632. * Observable called when the texture is loaded
  59633. */
  59634. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59635. /**
  59636. * Gets the width of the texture
  59637. */
  59638. this.width = 0;
  59639. /**
  59640. * Gets the height of the texture
  59641. */
  59642. this.height = 0;
  59643. /**
  59644. * Gets the depth of the texture
  59645. */
  59646. this.depth = 0;
  59647. /**
  59648. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  59649. */
  59650. this.baseWidth = 0;
  59651. /**
  59652. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  59653. */
  59654. this.baseHeight = 0;
  59655. /**
  59656. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  59657. */
  59658. this.baseDepth = 0;
  59659. /**
  59660. * Gets a boolean indicating if the texture is inverted on Y axis
  59661. */
  59662. this.invertY = false;
  59663. // Private
  59664. /** @hidden */
  59665. this._invertVScale = false;
  59666. /** @hidden */
  59667. this._associatedChannel = -1;
  59668. /** @hidden */
  59669. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  59670. /** @hidden */
  59671. this._buffer = null;
  59672. /** @hidden */
  59673. this._bufferView = null;
  59674. /** @hidden */
  59675. this._bufferViewArray = null;
  59676. /** @hidden */
  59677. this._bufferViewArrayArray = null;
  59678. /** @hidden */
  59679. this._size = 0;
  59680. /** @hidden */
  59681. this._extension = "";
  59682. /** @hidden */
  59683. this._files = null;
  59684. /** @hidden */
  59685. this._workingCanvas = null;
  59686. /** @hidden */
  59687. this._workingContext = null;
  59688. /** @hidden */
  59689. this._framebuffer = null;
  59690. /** @hidden */
  59691. this._depthStencilBuffer = null;
  59692. /** @hidden */
  59693. this._MSAAFramebuffer = null;
  59694. /** @hidden */
  59695. this._MSAARenderBuffer = null;
  59696. /** @hidden */
  59697. this._attachments = null;
  59698. /** @hidden */
  59699. this._cachedCoordinatesMode = null;
  59700. /** @hidden */
  59701. this._cachedWrapU = null;
  59702. /** @hidden */
  59703. this._cachedWrapV = null;
  59704. /** @hidden */
  59705. this._cachedWrapR = null;
  59706. /** @hidden */
  59707. this._cachedAnisotropicFilteringLevel = null;
  59708. /** @hidden */
  59709. this._isDisabled = false;
  59710. /** @hidden */
  59711. this._compression = null;
  59712. /** @hidden */
  59713. this._generateStencilBuffer = false;
  59714. /** @hidden */
  59715. this._generateDepthBuffer = false;
  59716. /** @hidden */
  59717. this._comparisonFunction = 0;
  59718. /** @hidden */
  59719. this._sphericalPolynomial = null;
  59720. /** @hidden */
  59721. this._lodGenerationScale = 0;
  59722. /** @hidden */
  59723. this._lodGenerationOffset = 0;
  59724. // Multiview
  59725. /** @hidden */
  59726. this._colorTextureArray = null;
  59727. /** @hidden */
  59728. this._depthStencilTextureArray = null;
  59729. // The following three fields helps sharing generated fixed LODs for texture filtering
  59730. // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.
  59731. // They are at the level of the gl texture to benefit from the cache.
  59732. /** @hidden */
  59733. this._lodTextureHigh = null;
  59734. /** @hidden */
  59735. this._lodTextureMid = null;
  59736. /** @hidden */
  59737. this._lodTextureLow = null;
  59738. /** @hidden */
  59739. this._isRGBD = false;
  59740. /** @hidden */
  59741. this._webGLTexture = null;
  59742. /** @hidden */
  59743. this._references = 1;
  59744. this._engine = engine;
  59745. this._dataSource = dataSource;
  59746. if (!delayAllocation) {
  59747. this._webGLTexture = engine._createTexture();
  59748. }
  59749. }
  59750. /**
  59751. * Gets the Engine the texture belongs to.
  59752. * @returns The babylon engine
  59753. */
  59754. InternalTexture.prototype.getEngine = function () {
  59755. return this._engine;
  59756. };
  59757. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  59758. /**
  59759. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  59760. */
  59761. get: function () {
  59762. return this._dataSource;
  59763. },
  59764. enumerable: true,
  59765. configurable: true
  59766. });
  59767. /**
  59768. * Increments the number of references (ie. the number of Texture that point to it)
  59769. */
  59770. InternalTexture.prototype.incrementReferences = function () {
  59771. this._references++;
  59772. };
  59773. /**
  59774. * Change the size of the texture (not the size of the content)
  59775. * @param width defines the new width
  59776. * @param height defines the new height
  59777. * @param depth defines the new depth (1 by default)
  59778. */
  59779. InternalTexture.prototype.updateSize = function (width, height, depth) {
  59780. if (depth === void 0) { depth = 1; }
  59781. this.width = width;
  59782. this.height = height;
  59783. this.depth = depth;
  59784. this.baseWidth = width;
  59785. this.baseHeight = height;
  59786. this.baseDepth = depth;
  59787. this._size = width * height * depth;
  59788. };
  59789. /** @hidden */
  59790. InternalTexture.prototype._rebuild = function () {
  59791. var _this = this;
  59792. var proxy;
  59793. this.isReady = false;
  59794. this._cachedCoordinatesMode = null;
  59795. this._cachedWrapU = null;
  59796. this._cachedWrapV = null;
  59797. this._cachedAnisotropicFilteringLevel = null;
  59798. switch (this._dataSource) {
  59799. case InternalTexture.DATASOURCE_TEMP:
  59800. return;
  59801. case InternalTexture.DATASOURCE_URL:
  59802. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  59803. proxy._swapAndDie(_this);
  59804. _this.isReady = true;
  59805. }, null, this._buffer, undefined, this.format);
  59806. return;
  59807. case InternalTexture.DATASOURCE_RAW:
  59808. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59809. proxy._swapAndDie(this);
  59810. this.isReady = true;
  59811. return;
  59812. case InternalTexture.DATASOURCE_RAW3D:
  59813. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59814. proxy._swapAndDie(this);
  59815. this.isReady = true;
  59816. return;
  59817. case InternalTexture.DATASOURCE_DYNAMIC:
  59818. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  59819. proxy._swapAndDie(this);
  59820. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  59821. // The engine will make sure to update content so no need to flag it as isReady = true
  59822. return;
  59823. case InternalTexture.DATASOURCE_RENDERTARGET:
  59824. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  59825. options.generateDepthBuffer = this._generateDepthBuffer;
  59826. options.generateMipMaps = this.generateMipMaps;
  59827. options.generateStencilBuffer = this._generateStencilBuffer;
  59828. options.samplingMode = this.samplingMode;
  59829. options.type = this.type;
  59830. if (this.isCube) {
  59831. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  59832. }
  59833. else {
  59834. var size = {
  59835. width: this.width,
  59836. height: this.height
  59837. };
  59838. proxy = this._engine.createRenderTargetTexture(size, options);
  59839. }
  59840. proxy._swapAndDie(this);
  59841. this.isReady = true;
  59842. return;
  59843. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  59844. var depthTextureOptions = {
  59845. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  59846. comparisonFunction: this._comparisonFunction,
  59847. generateStencil: this._generateStencilBuffer,
  59848. isCube: this.isCube
  59849. };
  59850. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  59851. proxy._swapAndDie(this);
  59852. this.isReady = true;
  59853. return;
  59854. case InternalTexture.DATASOURCE_CUBE:
  59855. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  59856. proxy._swapAndDie(_this);
  59857. _this.isReady = true;
  59858. }, null, this.format, this._extension);
  59859. return;
  59860. case InternalTexture.DATASOURCE_CUBERAW:
  59861. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59862. proxy._swapAndDie(this);
  59863. this.isReady = true;
  59864. return;
  59865. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  59866. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59867. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  59868. proxy._swapAndDie(_this);
  59869. _this.isReady = true;
  59870. });
  59871. return;
  59872. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  59873. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  59874. if (proxy) {
  59875. proxy._swapAndDie(_this);
  59876. }
  59877. _this.isReady = true;
  59878. }, null, this.format, this._extension);
  59879. proxy._sphericalPolynomial = this._sphericalPolynomial;
  59880. return;
  59881. }
  59882. };
  59883. /** @hidden */
  59884. InternalTexture.prototype._swapAndDie = function (target) {
  59885. target._webGLTexture = this._webGLTexture;
  59886. target._isRGBD = this._isRGBD;
  59887. if (this._framebuffer) {
  59888. target._framebuffer = this._framebuffer;
  59889. }
  59890. if (this._depthStencilBuffer) {
  59891. target._depthStencilBuffer = this._depthStencilBuffer;
  59892. }
  59893. if (this._lodTextureHigh) {
  59894. if (target._lodTextureHigh) {
  59895. target._lodTextureHigh.dispose();
  59896. }
  59897. target._lodTextureHigh = this._lodTextureHigh;
  59898. }
  59899. if (this._lodTextureMid) {
  59900. if (target._lodTextureMid) {
  59901. target._lodTextureMid.dispose();
  59902. }
  59903. target._lodTextureMid = this._lodTextureMid;
  59904. }
  59905. if (this._lodTextureLow) {
  59906. if (target._lodTextureLow) {
  59907. target._lodTextureLow.dispose();
  59908. }
  59909. target._lodTextureLow = this._lodTextureLow;
  59910. }
  59911. var cache = this._engine.getLoadedTexturesCache();
  59912. var index = cache.indexOf(this);
  59913. if (index !== -1) {
  59914. cache.splice(index, 1);
  59915. }
  59916. };
  59917. /**
  59918. * Dispose the current allocated resources
  59919. */
  59920. InternalTexture.prototype.dispose = function () {
  59921. if (!this._webGLTexture) {
  59922. return;
  59923. }
  59924. this._references--;
  59925. if (this._references === 0) {
  59926. this._engine._releaseTexture(this);
  59927. this._webGLTexture = null;
  59928. }
  59929. };
  59930. /** hidden */
  59931. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  59932. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  59933. };
  59934. /**
  59935. * The source of the texture data is unknown
  59936. */
  59937. InternalTexture.DATASOURCE_UNKNOWN = 0;
  59938. /**
  59939. * Texture data comes from an URL
  59940. */
  59941. InternalTexture.DATASOURCE_URL = 1;
  59942. /**
  59943. * Texture data is only used for temporary storage
  59944. */
  59945. InternalTexture.DATASOURCE_TEMP = 2;
  59946. /**
  59947. * Texture data comes from raw data (ArrayBuffer)
  59948. */
  59949. InternalTexture.DATASOURCE_RAW = 3;
  59950. /**
  59951. * Texture content is dynamic (video or dynamic texture)
  59952. */
  59953. InternalTexture.DATASOURCE_DYNAMIC = 4;
  59954. /**
  59955. * Texture content is generated by rendering to it
  59956. */
  59957. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  59958. /**
  59959. * Texture content is part of a multi render target process
  59960. */
  59961. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  59962. /**
  59963. * Texture data comes from a cube data file
  59964. */
  59965. InternalTexture.DATASOURCE_CUBE = 7;
  59966. /**
  59967. * Texture data comes from a raw cube data
  59968. */
  59969. InternalTexture.DATASOURCE_CUBERAW = 8;
  59970. /**
  59971. * Texture data come from a prefiltered cube data file
  59972. */
  59973. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  59974. /**
  59975. * Texture content is raw 3D data
  59976. */
  59977. InternalTexture.DATASOURCE_RAW3D = 10;
  59978. /**
  59979. * Texture content is a depth texture
  59980. */
  59981. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  59982. /**
  59983. * Texture data comes from a raw cube data encoded with RGBD
  59984. */
  59985. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  59986. return InternalTexture;
  59987. }());
  59988. /***/ }),
  59989. /***/ "./Materials/Textures/mirrorTexture.ts":
  59990. /*!*********************************************!*\
  59991. !*** ./Materials/Textures/mirrorTexture.ts ***!
  59992. \*********************************************/
  59993. /*! exports provided: MirrorTexture */
  59994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59995. "use strict";
  59996. __webpack_require__.r(__webpack_exports__);
  59997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  59998. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59999. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60000. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60001. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  60002. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  60003. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60004. /**
  60005. * Mirror texture can be used to simulate the view from a mirror in a scene.
  60006. * It will dynamically be rendered every frame to adapt to the camera point of view.
  60007. * You can then easily use it as a reflectionTexture on a flat surface.
  60008. * In case the surface is not a plane, please consider relying on reflection probes.
  60009. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  60010. */
  60011. var MirrorTexture = /** @class */ (function (_super) {
  60012. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  60013. /**
  60014. * Instantiates a Mirror Texture.
  60015. * Mirror texture can be used to simulate the view from a mirror in a scene.
  60016. * It will dynamically be rendered every frame to adapt to the camera point of view.
  60017. * You can then easily use it as a reflectionTexture on a flat surface.
  60018. * In case the surface is not a plane, please consider relying on reflection probes.
  60019. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  60020. * @param name
  60021. * @param size
  60022. * @param scene
  60023. * @param generateMipMaps
  60024. * @param type
  60025. * @param samplingMode
  60026. * @param generateDepthBuffer
  60027. */
  60028. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  60029. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60030. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  60031. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  60032. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  60033. _this.scene = scene;
  60034. /**
  60035. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  60036. * 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.
  60037. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  60038. */
  60039. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  60040. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  60041. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  60042. _this._adaptiveBlurKernel = 0;
  60043. _this._blurKernelX = 0;
  60044. _this._blurKernelY = 0;
  60045. _this._blurRatio = 1.0;
  60046. _this.ignoreCameraViewport = true;
  60047. _this._updateGammaSpace();
  60048. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  60049. _this._updateGammaSpace;
  60050. });
  60051. _this.onBeforeRenderObservable.add(function () {
  60052. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  60053. _this._savedViewMatrix = scene.getViewMatrix();
  60054. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  60055. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  60056. scene.clipPlane = _this.mirrorPlane;
  60057. scene.getEngine().cullBackFaces = false;
  60058. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  60059. });
  60060. _this.onAfterRenderObservable.add(function () {
  60061. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  60062. scene.getEngine().cullBackFaces = true;
  60063. scene._mirroredCameraPosition = null;
  60064. delete scene.clipPlane;
  60065. });
  60066. return _this;
  60067. }
  60068. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  60069. get: function () {
  60070. return this._blurRatio;
  60071. },
  60072. /**
  60073. * Define the blur ratio used to blur the reflection if needed.
  60074. */
  60075. set: function (value) {
  60076. if (this._blurRatio === value) {
  60077. return;
  60078. }
  60079. this._blurRatio = value;
  60080. this._preparePostProcesses();
  60081. },
  60082. enumerable: true,
  60083. configurable: true
  60084. });
  60085. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  60086. /**
  60087. * Define the adaptive blur kernel used to blur the reflection if needed.
  60088. * This will autocompute the closest best match for the `blurKernel`
  60089. */
  60090. set: function (value) {
  60091. this._adaptiveBlurKernel = value;
  60092. this._autoComputeBlurKernel();
  60093. },
  60094. enumerable: true,
  60095. configurable: true
  60096. });
  60097. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  60098. /**
  60099. * Define the blur kernel used to blur the reflection if needed.
  60100. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  60101. */
  60102. set: function (value) {
  60103. this.blurKernelX = value;
  60104. this.blurKernelY = value;
  60105. },
  60106. enumerable: true,
  60107. configurable: true
  60108. });
  60109. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  60110. get: function () {
  60111. return this._blurKernelX;
  60112. },
  60113. /**
  60114. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  60115. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  60116. */
  60117. set: function (value) {
  60118. if (this._blurKernelX === value) {
  60119. return;
  60120. }
  60121. this._blurKernelX = value;
  60122. this._preparePostProcesses();
  60123. },
  60124. enumerable: true,
  60125. configurable: true
  60126. });
  60127. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  60128. get: function () {
  60129. return this._blurKernelY;
  60130. },
  60131. /**
  60132. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  60133. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  60134. */
  60135. set: function (value) {
  60136. if (this._blurKernelY === value) {
  60137. return;
  60138. }
  60139. this._blurKernelY = value;
  60140. this._preparePostProcesses();
  60141. },
  60142. enumerable: true,
  60143. configurable: true
  60144. });
  60145. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  60146. var engine = this.getScene().getEngine();
  60147. var dw = this.getRenderWidth() / engine.getRenderWidth();
  60148. var dh = this.getRenderHeight() / engine.getRenderHeight();
  60149. this.blurKernelX = this._adaptiveBlurKernel * dw;
  60150. this.blurKernelY = this._adaptiveBlurKernel * dh;
  60151. };
  60152. MirrorTexture.prototype._onRatioRescale = function () {
  60153. if (this._sizeRatio) {
  60154. this.resize(this._initialSizeParameter);
  60155. if (!this._adaptiveBlurKernel) {
  60156. this._preparePostProcesses();
  60157. }
  60158. }
  60159. if (this._adaptiveBlurKernel) {
  60160. this._autoComputeBlurKernel();
  60161. }
  60162. };
  60163. MirrorTexture.prototype._updateGammaSpace = function () {
  60164. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  60165. };
  60166. MirrorTexture.prototype._preparePostProcesses = function () {
  60167. this.clearPostProcesses(true);
  60168. if (this._blurKernelX && this._blurKernelY) {
  60169. var engine = this.getScene().getEngine();
  60170. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  60171. 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);
  60172. this._blurX.autoClear = false;
  60173. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  60174. this._blurX.inputTexture = this._texture;
  60175. }
  60176. else {
  60177. this._blurX.alwaysForcePOT = true;
  60178. }
  60179. 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);
  60180. this._blurY.autoClear = false;
  60181. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  60182. this.addPostProcess(this._blurX);
  60183. this.addPostProcess(this._blurY);
  60184. }
  60185. else {
  60186. if (this._blurY) {
  60187. this.removePostProcess(this._blurY);
  60188. this._blurY.dispose();
  60189. this._blurY = null;
  60190. }
  60191. if (this._blurX) {
  60192. this.removePostProcess(this._blurX);
  60193. this._blurX.dispose();
  60194. this._blurX = null;
  60195. }
  60196. }
  60197. };
  60198. /**
  60199. * Clone the mirror texture.
  60200. * @returns the cloned texture
  60201. */
  60202. MirrorTexture.prototype.clone = function () {
  60203. var scene = this.getScene();
  60204. if (!scene) {
  60205. return this;
  60206. }
  60207. var textureSize = this.getSize();
  60208. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  60209. // Base texture
  60210. newTexture.hasAlpha = this.hasAlpha;
  60211. newTexture.level = this.level;
  60212. // Mirror Texture
  60213. newTexture.mirrorPlane = this.mirrorPlane.clone();
  60214. if (this.renderList) {
  60215. newTexture.renderList = this.renderList.slice(0);
  60216. }
  60217. return newTexture;
  60218. };
  60219. /**
  60220. * Serialize the texture to a JSON representation you could use in Parse later on
  60221. * @returns the serialized JSON representation
  60222. */
  60223. MirrorTexture.prototype.serialize = function () {
  60224. if (!this.name) {
  60225. return null;
  60226. }
  60227. var serializationObject = _super.prototype.serialize.call(this);
  60228. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  60229. return serializationObject;
  60230. };
  60231. /**
  60232. * Dispose the texture and release its associated resources.
  60233. */
  60234. MirrorTexture.prototype.dispose = function () {
  60235. _super.prototype.dispose.call(this);
  60236. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  60237. };
  60238. return MirrorTexture;
  60239. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  60240. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  60241. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  60242. };
  60243. /***/ }),
  60244. /***/ "./Materials/Textures/multiRenderTarget.ts":
  60245. /*!*************************************************!*\
  60246. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  60247. \*************************************************/
  60248. /*! exports provided: MultiRenderTarget */
  60249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60250. "use strict";
  60251. __webpack_require__.r(__webpack_exports__);
  60252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  60253. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60254. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60255. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  60256. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60257. /**
  60258. * A multi render target, like a render target provides the ability to render to a texture.
  60259. * Unlike the render target, it can render to several draw buffers in one draw.
  60260. * This is specially interesting in deferred rendering or for any effects requiring more than
  60261. * just one color from a single pass.
  60262. */
  60263. var MultiRenderTarget = /** @class */ (function (_super) {
  60264. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  60265. /**
  60266. * Instantiate a new multi render target texture.
  60267. * A multi render target, like a render target provides the ability to render to a texture.
  60268. * Unlike the render target, it can render to several draw buffers in one draw.
  60269. * This is specially interesting in deferred rendering or for any effects requiring more than
  60270. * just one color from a single pass.
  60271. * @param name Define the name of the texture
  60272. * @param size Define the size of the buffers to render to
  60273. * @param count Define the number of target we are rendering into
  60274. * @param scene Define the scene the texture belongs to
  60275. * @param options Define the options used to create the multi render target
  60276. */
  60277. function MultiRenderTarget(name, size, count, scene, options) {
  60278. var _this = this;
  60279. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  60280. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  60281. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  60282. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  60283. _this._engine = scene.getEngine();
  60284. if (!_this.isSupported) {
  60285. _this.dispose();
  60286. return;
  60287. }
  60288. var types = [];
  60289. var samplingModes = [];
  60290. for (var i = 0; i < count; i++) {
  60291. if (options && options.types && options.types[i] !== undefined) {
  60292. types.push(options.types[i]);
  60293. }
  60294. else {
  60295. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  60296. }
  60297. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  60298. samplingModes.push(options.samplingModes[i]);
  60299. }
  60300. else {
  60301. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  60302. }
  60303. }
  60304. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  60305. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  60306. _this._size = size;
  60307. _this._multiRenderTargetOptions = {
  60308. samplingModes: samplingModes,
  60309. generateMipMaps: generateMipMaps,
  60310. generateDepthBuffer: generateDepthBuffer,
  60311. generateStencilBuffer: generateStencilBuffer,
  60312. generateDepthTexture: generateDepthTexture,
  60313. types: types,
  60314. textureCount: count
  60315. };
  60316. _this._createInternalTextures();
  60317. _this._createTextures();
  60318. return _this;
  60319. }
  60320. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  60321. /**
  60322. * Get if draw buffers are currently supported by the used hardware and browser.
  60323. */
  60324. get: function () {
  60325. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  60326. },
  60327. enumerable: true,
  60328. configurable: true
  60329. });
  60330. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  60331. /**
  60332. * Get the list of textures generated by the multi render target.
  60333. */
  60334. get: function () {
  60335. return this._textures;
  60336. },
  60337. enumerable: true,
  60338. configurable: true
  60339. });
  60340. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  60341. /**
  60342. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  60343. */
  60344. get: function () {
  60345. return this._textures[this._textures.length - 1];
  60346. },
  60347. enumerable: true,
  60348. configurable: true
  60349. });
  60350. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  60351. /**
  60352. * Set the wrapping mode on U of all the textures we are rendering to.
  60353. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  60354. */
  60355. set: function (wrap) {
  60356. if (this._textures) {
  60357. for (var i = 0; i < this._textures.length; i++) {
  60358. this._textures[i].wrapU = wrap;
  60359. }
  60360. }
  60361. },
  60362. enumerable: true,
  60363. configurable: true
  60364. });
  60365. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  60366. /**
  60367. * Set the wrapping mode on V of all the textures we are rendering to.
  60368. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  60369. */
  60370. set: function (wrap) {
  60371. if (this._textures) {
  60372. for (var i = 0; i < this._textures.length; i++) {
  60373. this._textures[i].wrapV = wrap;
  60374. }
  60375. }
  60376. },
  60377. enumerable: true,
  60378. configurable: true
  60379. });
  60380. /** @hidden */
  60381. MultiRenderTarget.prototype._rebuild = function () {
  60382. this.releaseInternalTextures();
  60383. this._createInternalTextures();
  60384. for (var i = 0; i < this._internalTextures.length; i++) {
  60385. var texture = this._textures[i];
  60386. texture._texture = this._internalTextures[i];
  60387. }
  60388. // Keeps references to frame buffer and stencil/depth buffer
  60389. this._texture = this._internalTextures[0];
  60390. };
  60391. MultiRenderTarget.prototype._createInternalTextures = function () {
  60392. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  60393. };
  60394. MultiRenderTarget.prototype._createTextures = function () {
  60395. this._textures = [];
  60396. for (var i = 0; i < this._internalTextures.length; i++) {
  60397. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  60398. texture._texture = this._internalTextures[i];
  60399. this._textures.push(texture);
  60400. }
  60401. // Keeps references to frame buffer and stencil/depth buffer
  60402. this._texture = this._internalTextures[0];
  60403. };
  60404. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  60405. /**
  60406. * Define the number of samples used if MSAA is enabled.
  60407. */
  60408. get: function () {
  60409. return this._samples;
  60410. },
  60411. set: function (value) {
  60412. if (this._samples === value) {
  60413. return;
  60414. }
  60415. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  60416. },
  60417. enumerable: true,
  60418. configurable: true
  60419. });
  60420. /**
  60421. * Resize all the textures in the multi render target.
  60422. * Be carrefull as it will recreate all the data in the new texture.
  60423. * @param size Define the new size
  60424. */
  60425. MultiRenderTarget.prototype.resize = function (size) {
  60426. this.releaseInternalTextures();
  60427. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  60428. this._createInternalTextures();
  60429. };
  60430. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  60431. var _this = this;
  60432. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  60433. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  60434. });
  60435. };
  60436. /**
  60437. * Dispose the render targets and their associated resources
  60438. */
  60439. MultiRenderTarget.prototype.dispose = function () {
  60440. this.releaseInternalTextures();
  60441. _super.prototype.dispose.call(this);
  60442. };
  60443. /**
  60444. * Release all the underlying texture used as draw buffers.
  60445. */
  60446. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  60447. if (!this._internalTextures) {
  60448. return;
  60449. }
  60450. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  60451. if (this._internalTextures[i] !== undefined) {
  60452. this._internalTextures[i].dispose();
  60453. this._internalTextures.splice(i, 1);
  60454. }
  60455. }
  60456. };
  60457. return MultiRenderTarget;
  60458. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  60459. /***/ }),
  60460. /***/ "./Materials/Textures/rawCubeTexture.ts":
  60461. /*!**********************************************!*\
  60462. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  60463. \**********************************************/
  60464. /*! exports provided: RawCubeTexture */
  60465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60466. "use strict";
  60467. __webpack_require__.r(__webpack_exports__);
  60468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  60469. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60470. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  60471. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  60472. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  60473. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  60474. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60475. /**
  60476. * Raw cube texture where the raw buffers are passed in
  60477. */
  60478. var RawCubeTexture = /** @class */ (function (_super) {
  60479. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  60480. /**
  60481. * Creates a cube texture where the raw buffers are passed in.
  60482. * @param scene defines the scene the texture is attached to
  60483. * @param data defines the array of data to use to create each face
  60484. * @param size defines the size of the textures
  60485. * @param format defines the format of the data
  60486. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60487. * @param generateMipMaps defines if the engine should generate the mip levels
  60488. * @param invertY defines if data must be stored with Y axis inverted
  60489. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60490. * @param compression defines the compression used (null by default)
  60491. */
  60492. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  60493. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  60494. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60495. if (generateMipMaps === void 0) { generateMipMaps = false; }
  60496. if (invertY === void 0) { invertY = false; }
  60497. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60498. if (compression === void 0) { compression = null; }
  60499. var _this = _super.call(this, "", scene) || this;
  60500. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  60501. return _this;
  60502. }
  60503. /**
  60504. * Updates the raw cube texture.
  60505. * @param data defines the data to store
  60506. * @param format defines the data format
  60507. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60508. * @param invertY defines if data must be stored with Y axis inverted
  60509. * @param compression defines the compression used (null by default)
  60510. * @param level defines which level of the texture to update
  60511. */
  60512. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  60513. if (compression === void 0) { compression = null; }
  60514. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  60515. };
  60516. /**
  60517. * Updates a raw cube texture with RGBD encoded data.
  60518. * @param data defines the array of data [mipmap][face] to use to create each face
  60519. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60520. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60521. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60522. * @returns a promsie that resolves when the operation is complete
  60523. */
  60524. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  60525. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  60526. if (lodScale === void 0) { lodScale = 0.8; }
  60527. if (lodOffset === void 0) { lodOffset = 0; }
  60528. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  60529. };
  60530. /**
  60531. * Clones the raw cube texture.
  60532. * @return a new cube texture
  60533. */
  60534. RawCubeTexture.prototype.clone = function () {
  60535. var _this = this;
  60536. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  60537. var scene = _this.getScene();
  60538. var internalTexture = _this._texture;
  60539. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  60540. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  60541. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  60542. }
  60543. return texture;
  60544. }, this);
  60545. };
  60546. /** @hidden */
  60547. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  60548. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  60549. internalTexture._bufferViewArrayArray = data;
  60550. internalTexture._lodGenerationScale = lodScale;
  60551. internalTexture._lodGenerationOffset = lodOffset;
  60552. internalTexture._sphericalPolynomial = sphericalPolynomial;
  60553. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  60554. internalTexture.isReady = true;
  60555. });
  60556. };
  60557. return RawCubeTexture;
  60558. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  60559. /***/ }),
  60560. /***/ "./Materials/Textures/rawTexture.ts":
  60561. /*!******************************************!*\
  60562. !*** ./Materials/Textures/rawTexture.ts ***!
  60563. \******************************************/
  60564. /*! exports provided: RawTexture */
  60565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60566. "use strict";
  60567. __webpack_require__.r(__webpack_exports__);
  60568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  60569. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60570. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60572. /**
  60573. * Raw texture can help creating a texture directly from an array of data.
  60574. * This can be super useful if you either get the data from an uncompressed source or
  60575. * if you wish to create your texture pixel by pixel.
  60576. */
  60577. var RawTexture = /** @class */ (function (_super) {
  60578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  60579. /**
  60580. * Instantiates a new RawTexture.
  60581. * Raw texture can help creating a texture directly from an array of data.
  60582. * This can be super useful if you either get the data from an uncompressed source or
  60583. * if you wish to create your texture pixel by pixel.
  60584. * @param data define the array of data to use to create the texture
  60585. * @param width define the width of the texture
  60586. * @param height define the height of the texture
  60587. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  60588. * @param scene define the scene the texture belongs to
  60589. * @param generateMipMaps define whether mip maps should be generated or not
  60590. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60591. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60592. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60593. */
  60594. function RawTexture(data, width, height,
  60595. /**
  60596. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  60597. */
  60598. format, scene, generateMipMaps, invertY, samplingMode, type) {
  60599. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60600. if (invertY === void 0) { invertY = false; }
  60601. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60602. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60603. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  60604. _this.format = format;
  60605. _this._engine = scene.getEngine();
  60606. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  60607. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  60608. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  60609. return _this;
  60610. }
  60611. /**
  60612. * Updates the texture underlying data.
  60613. * @param data Define the new data of the texture
  60614. */
  60615. RawTexture.prototype.update = function (data) {
  60616. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  60617. };
  60618. /**
  60619. * Creates a luminance texture from some data.
  60620. * @param data Define the texture data
  60621. * @param width Define the width of the texture
  60622. * @param height Define the height of the texture
  60623. * @param scene Define the scene the texture belongs to
  60624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60627. * @returns the luminance texture
  60628. */
  60629. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  60630. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60631. if (invertY === void 0) { invertY = false; }
  60632. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60633. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  60634. };
  60635. /**
  60636. * Creates a luminance alpha texture from some data.
  60637. * @param data Define the texture data
  60638. * @param width Define the width of the texture
  60639. * @param height Define the height of the texture
  60640. * @param scene Define the scene the texture belongs to
  60641. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60642. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60643. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60644. * @returns the luminance alpha texture
  60645. */
  60646. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  60647. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60648. if (invertY === void 0) { invertY = false; }
  60649. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60650. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  60651. };
  60652. /**
  60653. * Creates an alpha texture from some data.
  60654. * @param data Define the texture data
  60655. * @param width Define the width of the texture
  60656. * @param height Define the height of the texture
  60657. * @param scene Define the scene the texture belongs to
  60658. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60661. * @returns the alpha texture
  60662. */
  60663. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  60664. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60665. if (invertY === void 0) { invertY = false; }
  60666. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60667. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  60668. };
  60669. /**
  60670. * Creates a RGB texture from some data.
  60671. * @param data Define the texture data
  60672. * @param width Define the width of the texture
  60673. * @param height Define the height of the texture
  60674. * @param scene Define the scene the texture belongs to
  60675. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60676. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60677. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60678. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60679. * @returns the RGB alpha texture
  60680. */
  60681. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60682. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60683. if (invertY === void 0) { invertY = false; }
  60684. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60685. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60686. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  60687. };
  60688. /**
  60689. * Creates a RGBA texture from some data.
  60690. * @param data Define the texture data
  60691. * @param width Define the width of the texture
  60692. * @param height Define the height of the texture
  60693. * @param scene Define the scene the texture belongs to
  60694. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60695. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60696. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60697. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60698. * @returns the RGBA texture
  60699. */
  60700. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60701. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60702. if (invertY === void 0) { invertY = false; }
  60703. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60704. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60705. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  60706. };
  60707. /**
  60708. * Creates a R texture from some data.
  60709. * @param data Define the texture data
  60710. * @param width Define the width of the texture
  60711. * @param height Define the height of the texture
  60712. * @param scene Define the scene the texture belongs to
  60713. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60714. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60715. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60716. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60717. * @returns the R texture
  60718. */
  60719. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60720. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60721. if (invertY === void 0) { invertY = false; }
  60722. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60723. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  60724. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  60725. };
  60726. return RawTexture;
  60727. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  60728. /***/ }),
  60729. /***/ "./Materials/Textures/rawTexture3D.ts":
  60730. /*!********************************************!*\
  60731. !*** ./Materials/Textures/rawTexture3D.ts ***!
  60732. \********************************************/
  60733. /*! exports provided: RawTexture3D */
  60734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60735. "use strict";
  60736. __webpack_require__.r(__webpack_exports__);
  60737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  60738. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60739. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60740. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60741. /**
  60742. * Class used to store 3D textures containing user data
  60743. */
  60744. var RawTexture3D = /** @class */ (function (_super) {
  60745. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  60746. /**
  60747. * Create a new RawTexture3D
  60748. * @param data defines the data of the texture
  60749. * @param width defines the width of the texture
  60750. * @param height defines the height of the texture
  60751. * @param depth defines the depth of the texture
  60752. * @param format defines the texture format to use
  60753. * @param scene defines the hosting scene
  60754. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60755. * @param invertY defines if texture must be stored with Y axis inverted
  60756. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60757. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60758. */
  60759. function RawTexture3D(data, width, height, depth,
  60760. /** Gets or sets the texture format to use */
  60761. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  60762. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60763. if (invertY === void 0) { invertY = false; }
  60764. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60765. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60766. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  60767. _this.format = format;
  60768. _this._engine = scene.getEngine();
  60769. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  60770. _this.is3D = true;
  60771. return _this;
  60772. }
  60773. /**
  60774. * Update the texture with new data
  60775. * @param data defines the data to store in the texture
  60776. */
  60777. RawTexture3D.prototype.update = function (data) {
  60778. if (!this._texture) {
  60779. return;
  60780. }
  60781. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  60782. };
  60783. return RawTexture3D;
  60784. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  60785. /***/ }),
  60786. /***/ "./Materials/Textures/refractionTexture.ts":
  60787. /*!*************************************************!*\
  60788. !*** ./Materials/Textures/refractionTexture.ts ***!
  60789. \*************************************************/
  60790. /*! exports provided: RefractionTexture */
  60791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60792. "use strict";
  60793. __webpack_require__.r(__webpack_exports__);
  60794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  60795. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60796. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60797. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  60798. /**
  60799. * Creates a refraction texture used by refraction channel of the standard material.
  60800. * It is like a mirror but to see through a material.
  60801. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60802. */
  60803. var RefractionTexture = /** @class */ (function (_super) {
  60804. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  60805. /**
  60806. * Creates a refraction texture used by refraction channel of the standard material.
  60807. * It is like a mirror but to see through a material.
  60808. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60809. * @param name Define the texture name
  60810. * @param size Define the size of the underlying texture
  60811. * @param scene Define the scene the refraction belongs to
  60812. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60813. */
  60814. function RefractionTexture(name, size, scene, generateMipMaps) {
  60815. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  60816. /**
  60817. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60818. * 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.
  60819. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60820. */
  60821. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  60822. /**
  60823. * Define how deep under the surface we should see.
  60824. */
  60825. _this.depth = 2.0;
  60826. _this.onBeforeRenderObservable.add(function () {
  60827. scene.clipPlane = _this.refractionPlane;
  60828. });
  60829. _this.onAfterRenderObservable.add(function () {
  60830. delete scene.clipPlane;
  60831. });
  60832. return _this;
  60833. }
  60834. /**
  60835. * Clone the refraction texture.
  60836. * @returns the cloned texture
  60837. */
  60838. RefractionTexture.prototype.clone = function () {
  60839. var scene = this.getScene();
  60840. if (!scene) {
  60841. return this;
  60842. }
  60843. var textureSize = this.getSize();
  60844. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  60845. // Base texture
  60846. newTexture.hasAlpha = this.hasAlpha;
  60847. newTexture.level = this.level;
  60848. // Refraction Texture
  60849. newTexture.refractionPlane = this.refractionPlane.clone();
  60850. if (this.renderList) {
  60851. newTexture.renderList = this.renderList.slice(0);
  60852. }
  60853. newTexture.depth = this.depth;
  60854. return newTexture;
  60855. };
  60856. /**
  60857. * Serialize the texture to a JSON representation you could use in Parse later on
  60858. * @returns the serialized JSON representation
  60859. */
  60860. RefractionTexture.prototype.serialize = function () {
  60861. if (!this.name) {
  60862. return null;
  60863. }
  60864. var serializationObject = _super.prototype.serialize.call(this);
  60865. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  60866. serializationObject.depth = this.depth;
  60867. return serializationObject;
  60868. };
  60869. return RefractionTexture;
  60870. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  60871. /***/ }),
  60872. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  60873. /*!***********************************************************!*\
  60874. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  60875. \***********************************************************/
  60876. /*! exports provided: RenderTargetCreationOptions */
  60877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60878. "use strict";
  60879. __webpack_require__.r(__webpack_exports__);
  60880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  60881. /**
  60882. * Define options used to create a render target texture
  60883. */
  60884. var RenderTargetCreationOptions = /** @class */ (function () {
  60885. function RenderTargetCreationOptions() {
  60886. }
  60887. return RenderTargetCreationOptions;
  60888. }());
  60889. /***/ }),
  60890. /***/ "./Materials/Textures/renderTargetTexture.ts":
  60891. /*!***************************************************!*\
  60892. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  60893. \***************************************************/
  60894. /*! exports provided: RenderTargetTexture */
  60895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60896. "use strict";
  60897. __webpack_require__.r(__webpack_exports__);
  60898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  60899. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60900. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60901. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60902. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60903. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60904. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  60905. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  60906. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60907. /**
  60908. * This Helps creating a texture that will be created from a camera in your scene.
  60909. * It is basically a dynamic texture that could be used to create special effects for instance.
  60910. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  60911. */
  60912. var RenderTargetTexture = /** @class */ (function (_super) {
  60913. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  60914. /**
  60915. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  60916. * or used a shadow, depth texture...
  60917. * @param name The friendly name of the texture
  60918. * @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)
  60919. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  60920. * @param generateMipMaps True if mip maps need to be generated after render.
  60921. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  60922. * @param type The type of the buffer in the RTT (int, half float, float...)
  60923. * @param isCube True if a cube texture needs to be created
  60924. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  60925. * @param generateDepthBuffer True to generate a depth buffer
  60926. * @param generateStencilBuffer True to generate a stencil buffer
  60927. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  60928. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  60929. * @param delayAllocation if the texture allocation should be delayed (default: false)
  60930. */
  60931. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  60932. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  60933. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60934. if (isCube === void 0) { isCube = false; }
  60935. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60936. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  60937. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  60938. if (isMulti === void 0) { isMulti = false; }
  60939. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  60940. if (delayAllocation === void 0) { delayAllocation = false; }
  60941. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  60942. _this.isCube = isCube;
  60943. /**
  60944. * Define if particles should be rendered in your texture.
  60945. */
  60946. _this.renderParticles = true;
  60947. /**
  60948. * Define if sprites should be rendered in your texture.
  60949. */
  60950. _this.renderSprites = false;
  60951. /**
  60952. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  60953. */
  60954. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  60955. /**
  60956. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  60957. */
  60958. _this.ignoreCameraViewport = false;
  60959. /**
  60960. * An event triggered when the texture is unbind.
  60961. */
  60962. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60963. /**
  60964. * An event triggered when the texture is unbind.
  60965. */
  60966. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60967. /**
  60968. * An event triggered before rendering the texture
  60969. */
  60970. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60971. /**
  60972. * An event triggered after rendering the texture
  60973. */
  60974. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60975. /**
  60976. * An event triggered after the texture clear
  60977. */
  60978. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60979. _this._currentRefreshId = -1;
  60980. _this._refreshRate = 1;
  60981. _this._samples = 1;
  60982. /**
  60983. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  60984. * It must define where the camera used to render the texture is set
  60985. */
  60986. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  60987. scene = _this.getScene();
  60988. if (!scene) {
  60989. return _this;
  60990. }
  60991. _this.renderList = new Array();
  60992. _this._engine = scene.getEngine();
  60993. _this.name = name;
  60994. _this.isRenderTarget = true;
  60995. _this._initialSizeParameter = size;
  60996. _this._processSizeParameter(size);
  60997. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  60998. });
  60999. _this._generateMipMaps = generateMipMaps ? true : false;
  61000. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  61001. // Rendering groups
  61002. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  61003. _this._renderingManager._useSceneAutoClearSetup = true;
  61004. if (isMulti) {
  61005. return _this;
  61006. }
  61007. _this._renderTargetOptions = {
  61008. generateMipMaps: generateMipMaps,
  61009. type: type,
  61010. format: format,
  61011. samplingMode: samplingMode,
  61012. generateDepthBuffer: generateDepthBuffer,
  61013. generateStencilBuffer: generateStencilBuffer
  61014. };
  61015. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  61016. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  61017. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  61018. }
  61019. if (!delayAllocation) {
  61020. if (isCube) {
  61021. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  61022. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  61023. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  61024. }
  61025. else {
  61026. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  61027. }
  61028. }
  61029. return _this;
  61030. }
  61031. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  61032. /**
  61033. * Use this list to define the list of mesh you want to render.
  61034. */
  61035. get: function () {
  61036. return this._renderList;
  61037. },
  61038. set: function (value) {
  61039. this._renderList = value;
  61040. if (this._renderList) {
  61041. this._hookArray(this._renderList);
  61042. }
  61043. },
  61044. enumerable: true,
  61045. configurable: true
  61046. });
  61047. RenderTargetTexture.prototype._hookArray = function (array) {
  61048. var _this = this;
  61049. var oldPush = array.push;
  61050. array.push = function () {
  61051. var items = [];
  61052. for (var _i = 0; _i < arguments.length; _i++) {
  61053. items[_i] = arguments[_i];
  61054. }
  61055. var wasEmpty = array.length === 0;
  61056. var result = oldPush.apply(array, items);
  61057. if (wasEmpty) {
  61058. _this.getScene().meshes.forEach(function (mesh) {
  61059. mesh._markSubMeshesAsLightDirty();
  61060. });
  61061. }
  61062. return result;
  61063. };
  61064. var oldSplice = array.splice;
  61065. array.splice = function (index, deleteCount) {
  61066. var deleted = oldSplice.apply(array, [index, deleteCount]);
  61067. if (array.length === 0) {
  61068. _this.getScene().meshes.forEach(function (mesh) {
  61069. mesh._markSubMeshesAsLightDirty();
  61070. });
  61071. }
  61072. return deleted;
  61073. };
  61074. };
  61075. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  61076. /**
  61077. * Set a after unbind callback in the texture.
  61078. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  61079. */
  61080. set: function (callback) {
  61081. if (this._onAfterUnbindObserver) {
  61082. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  61083. }
  61084. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  61085. },
  61086. enumerable: true,
  61087. configurable: true
  61088. });
  61089. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  61090. /**
  61091. * Set a before render callback in the texture.
  61092. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  61093. */
  61094. set: function (callback) {
  61095. if (this._onBeforeRenderObserver) {
  61096. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  61097. }
  61098. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  61099. },
  61100. enumerable: true,
  61101. configurable: true
  61102. });
  61103. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  61104. /**
  61105. * Set a after render callback in the texture.
  61106. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  61107. */
  61108. set: function (callback) {
  61109. if (this._onAfterRenderObserver) {
  61110. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  61111. }
  61112. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  61113. },
  61114. enumerable: true,
  61115. configurable: true
  61116. });
  61117. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  61118. /**
  61119. * Set a clear callback in the texture.
  61120. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  61121. */
  61122. set: function (callback) {
  61123. if (this._onClearObserver) {
  61124. this.onClearObservable.remove(this._onClearObserver);
  61125. }
  61126. this._onClearObserver = this.onClearObservable.add(callback);
  61127. },
  61128. enumerable: true,
  61129. configurable: true
  61130. });
  61131. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  61132. /**
  61133. * Gets render target creation options that were used.
  61134. */
  61135. get: function () {
  61136. return this._renderTargetOptions;
  61137. },
  61138. enumerable: true,
  61139. configurable: true
  61140. });
  61141. RenderTargetTexture.prototype._onRatioRescale = function () {
  61142. if (this._sizeRatio) {
  61143. this.resize(this._initialSizeParameter);
  61144. }
  61145. };
  61146. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  61147. get: function () {
  61148. return this._boundingBoxSize;
  61149. },
  61150. /**
  61151. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  61152. * When defined, the cubemap will switch to local mode
  61153. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61154. * @example https://www.babylonjs-playground.com/#RNASML
  61155. */
  61156. set: function (value) {
  61157. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  61158. return;
  61159. }
  61160. this._boundingBoxSize = value;
  61161. var scene = this.getScene();
  61162. if (scene) {
  61163. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  61164. }
  61165. },
  61166. enumerable: true,
  61167. configurable: true
  61168. });
  61169. /**
  61170. * Creates a depth stencil texture.
  61171. * This is only available in WebGL 2 or with the depth texture extension available.
  61172. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  61173. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  61174. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  61175. */
  61176. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  61177. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  61178. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  61179. if (generateStencil === void 0) { generateStencil = false; }
  61180. if (!this.getScene()) {
  61181. return;
  61182. }
  61183. var engine = this.getScene().getEngine();
  61184. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  61185. bilinearFiltering: bilinearFiltering,
  61186. comparisonFunction: comparisonFunction,
  61187. generateStencil: generateStencil,
  61188. isCube: this.isCube
  61189. });
  61190. engine.setFrameBufferDepthStencilTexture(this);
  61191. };
  61192. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  61193. if (size.ratio) {
  61194. this._sizeRatio = size.ratio;
  61195. this._size = {
  61196. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  61197. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  61198. };
  61199. }
  61200. else {
  61201. this._size = size;
  61202. }
  61203. };
  61204. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  61205. /**
  61206. * Define the number of samples to use in case of MSAA.
  61207. * It defaults to one meaning no MSAA has been enabled.
  61208. */
  61209. get: function () {
  61210. return this._samples;
  61211. },
  61212. set: function (value) {
  61213. if (this._samples === value) {
  61214. return;
  61215. }
  61216. var scene = this.getScene();
  61217. if (!scene) {
  61218. return;
  61219. }
  61220. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  61221. },
  61222. enumerable: true,
  61223. configurable: true
  61224. });
  61225. /**
  61226. * Resets the refresh counter of the texture and start bak from scratch.
  61227. * Could be useful to regenerate the texture if it is setup to render only once.
  61228. */
  61229. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  61230. this._currentRefreshId = -1;
  61231. };
  61232. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  61233. /**
  61234. * Define the refresh rate of the texture or the rendering frequency.
  61235. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  61236. */
  61237. get: function () {
  61238. return this._refreshRate;
  61239. },
  61240. set: function (value) {
  61241. this._refreshRate = value;
  61242. this.resetRefreshCounter();
  61243. },
  61244. enumerable: true,
  61245. configurable: true
  61246. });
  61247. /**
  61248. * Adds a post process to the render target rendering passes.
  61249. * @param postProcess define the post process to add
  61250. */
  61251. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  61252. if (!this._postProcessManager) {
  61253. var scene = this.getScene();
  61254. if (!scene) {
  61255. return;
  61256. }
  61257. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  61258. this._postProcesses = new Array();
  61259. }
  61260. this._postProcesses.push(postProcess);
  61261. this._postProcesses[0].autoClear = false;
  61262. };
  61263. /**
  61264. * Clear all the post processes attached to the render target
  61265. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  61266. */
  61267. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  61268. if (dispose === void 0) { dispose = false; }
  61269. if (!this._postProcesses) {
  61270. return;
  61271. }
  61272. if (dispose) {
  61273. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  61274. var postProcess = _a[_i];
  61275. postProcess.dispose();
  61276. }
  61277. }
  61278. this._postProcesses = [];
  61279. };
  61280. /**
  61281. * Remove one of the post process from the list of attached post processes to the texture
  61282. * @param postProcess define the post process to remove from the list
  61283. */
  61284. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  61285. if (!this._postProcesses) {
  61286. return;
  61287. }
  61288. var index = this._postProcesses.indexOf(postProcess);
  61289. if (index === -1) {
  61290. return;
  61291. }
  61292. this._postProcesses.splice(index, 1);
  61293. if (this._postProcesses.length > 0) {
  61294. this._postProcesses[0].autoClear = false;
  61295. }
  61296. };
  61297. /** @hidden */
  61298. RenderTargetTexture.prototype._shouldRender = function () {
  61299. if (this._currentRefreshId === -1) { // At least render once
  61300. this._currentRefreshId = 1;
  61301. return true;
  61302. }
  61303. if (this.refreshRate === this._currentRefreshId) {
  61304. this._currentRefreshId = 1;
  61305. return true;
  61306. }
  61307. this._currentRefreshId++;
  61308. return false;
  61309. };
  61310. /**
  61311. * Gets the actual render size of the texture.
  61312. * @returns the width of the render size
  61313. */
  61314. RenderTargetTexture.prototype.getRenderSize = function () {
  61315. return this.getRenderWidth();
  61316. };
  61317. /**
  61318. * Gets the actual render width of the texture.
  61319. * @returns the width of the render size
  61320. */
  61321. RenderTargetTexture.prototype.getRenderWidth = function () {
  61322. if (this._size.width) {
  61323. return this._size.width;
  61324. }
  61325. return this._size;
  61326. };
  61327. /**
  61328. * Gets the actual render height of the texture.
  61329. * @returns the height of the render size
  61330. */
  61331. RenderTargetTexture.prototype.getRenderHeight = function () {
  61332. if (this._size.width) {
  61333. return this._size.height;
  61334. }
  61335. return this._size;
  61336. };
  61337. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  61338. /**
  61339. * Get if the texture can be rescaled or not.
  61340. */
  61341. get: function () {
  61342. return true;
  61343. },
  61344. enumerable: true,
  61345. configurable: true
  61346. });
  61347. /**
  61348. * Resize the texture using a ratio.
  61349. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  61350. */
  61351. RenderTargetTexture.prototype.scale = function (ratio) {
  61352. var newSize = this.getRenderSize() * ratio;
  61353. this.resize(newSize);
  61354. };
  61355. /**
  61356. * Get the texture reflection matrix used to rotate/transform the reflection.
  61357. * @returns the reflection matrix
  61358. */
  61359. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  61360. if (this.isCube) {
  61361. return this._textureMatrix;
  61362. }
  61363. return _super.prototype.getReflectionTextureMatrix.call(this);
  61364. };
  61365. /**
  61366. * Resize the texture to a new desired size.
  61367. * Be carrefull as it will recreate all the data in the new texture.
  61368. * @param size Define the new size. It can be:
  61369. * - a number for squared texture,
  61370. * - an object containing { width: number, height: number }
  61371. * - or an object containing a ratio { ratio: number }
  61372. */
  61373. RenderTargetTexture.prototype.resize = function (size) {
  61374. var wasCube = this.isCube;
  61375. this.releaseInternalTexture();
  61376. var scene = this.getScene();
  61377. if (!scene) {
  61378. return;
  61379. }
  61380. this._processSizeParameter(size);
  61381. if (wasCube) {
  61382. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  61383. }
  61384. else {
  61385. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  61386. }
  61387. };
  61388. /**
  61389. * Renders all the objects from the render list into the texture.
  61390. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  61391. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  61392. */
  61393. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  61394. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  61395. if (dumpForDebug === void 0) { dumpForDebug = false; }
  61396. var scene = this.getScene();
  61397. if (!scene) {
  61398. return;
  61399. }
  61400. var engine = scene.getEngine();
  61401. if (this.useCameraPostProcesses !== undefined) {
  61402. useCameraPostProcess = this.useCameraPostProcesses;
  61403. }
  61404. if (this._waitingRenderList) {
  61405. this.renderList = [];
  61406. for (var index = 0; index < this._waitingRenderList.length; index++) {
  61407. var id = this._waitingRenderList[index];
  61408. var mesh_1 = scene.getMeshByID(id);
  61409. if (mesh_1) {
  61410. this.renderList.push(mesh_1);
  61411. }
  61412. }
  61413. delete this._waitingRenderList;
  61414. }
  61415. // Is predicate defined?
  61416. if (this.renderListPredicate) {
  61417. if (this.renderList) {
  61418. this.renderList.length = 0; // Clear previous renderList
  61419. }
  61420. else {
  61421. this.renderList = [];
  61422. }
  61423. var scene = this.getScene();
  61424. if (!scene) {
  61425. return;
  61426. }
  61427. var sceneMeshes = scene.meshes;
  61428. for (var index = 0; index < sceneMeshes.length; index++) {
  61429. var mesh = sceneMeshes[index];
  61430. if (this.renderListPredicate(mesh)) {
  61431. this.renderList.push(mesh);
  61432. }
  61433. }
  61434. }
  61435. this.onBeforeBindObservable.notifyObservers(this);
  61436. // Set custom projection.
  61437. // Needs to be before binding to prevent changing the aspect ratio.
  61438. var camera;
  61439. if (this.activeCamera) {
  61440. camera = this.activeCamera;
  61441. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  61442. if (this.activeCamera !== scene.activeCamera) {
  61443. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  61444. }
  61445. }
  61446. else {
  61447. camera = scene.activeCamera;
  61448. if (camera) {
  61449. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  61450. }
  61451. }
  61452. // Prepare renderingManager
  61453. this._renderingManager.reset();
  61454. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  61455. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  61456. var sceneRenderId = scene.getRenderId();
  61457. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  61458. var mesh = currentRenderList[meshIndex];
  61459. if (mesh) {
  61460. if (!mesh.isReady(this.refreshRate === 0)) {
  61461. this.resetRefreshCounter();
  61462. continue;
  61463. }
  61464. mesh._preActivateForIntermediateRendering(sceneRenderId);
  61465. var isMasked = void 0;
  61466. if (!this.renderList && camera) {
  61467. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  61468. }
  61469. else {
  61470. isMasked = false;
  61471. }
  61472. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  61473. mesh._activate(sceneRenderId);
  61474. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  61475. var subMesh = mesh.subMeshes[subIndex];
  61476. scene._activeIndices.addCount(subMesh.indexCount, false);
  61477. this._renderingManager.dispatch(subMesh, mesh);
  61478. }
  61479. }
  61480. }
  61481. }
  61482. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  61483. var particleSystem = scene.particleSystems[particleIndex];
  61484. var emitter = particleSystem.emitter;
  61485. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  61486. continue;
  61487. }
  61488. if (currentRenderList.indexOf(emitter) >= 0) {
  61489. this._renderingManager.dispatchParticles(particleSystem);
  61490. }
  61491. }
  61492. if (this.isCube) {
  61493. for (var face = 0; face < 6; face++) {
  61494. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  61495. scene.incrementRenderId();
  61496. scene.resetCachedMaterial();
  61497. }
  61498. }
  61499. else {
  61500. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  61501. }
  61502. this.onAfterUnbindObservable.notifyObservers(this);
  61503. if (scene.activeCamera) {
  61504. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  61505. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  61506. }
  61507. engine.setViewport(scene.activeCamera.viewport);
  61508. }
  61509. scene.resetCachedMaterial();
  61510. };
  61511. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  61512. var minimum = 128;
  61513. var x = renderDimension * scale;
  61514. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  61515. // Ensure we don't exceed the render dimension (while staying POT)
  61516. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  61517. };
  61518. /**
  61519. * @hidden
  61520. * @param faceIndex face index to bind to if this is a cubetexture
  61521. */
  61522. RenderTargetTexture.prototype._bindFrameBuffer = function (faceIndex) {
  61523. if (faceIndex === void 0) { faceIndex = 0; }
  61524. var scene = this.getScene();
  61525. if (!scene) {
  61526. return;
  61527. }
  61528. var engine = scene.getEngine();
  61529. if (this._texture) {
  61530. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  61531. }
  61532. };
  61533. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  61534. var _this = this;
  61535. if (!this._texture) {
  61536. return;
  61537. }
  61538. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  61539. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  61540. });
  61541. };
  61542. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  61543. var scene = this.getScene();
  61544. if (!scene) {
  61545. return;
  61546. }
  61547. var engine = scene.getEngine();
  61548. if (!this._texture) {
  61549. return;
  61550. }
  61551. // Bind
  61552. if (this._postProcessManager) {
  61553. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  61554. }
  61555. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  61556. this._bindFrameBuffer(faceIndex);
  61557. }
  61558. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  61559. // Clear
  61560. if (this.onClearObservable.hasObservers()) {
  61561. this.onClearObservable.notifyObservers(engine);
  61562. }
  61563. else {
  61564. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  61565. }
  61566. if (!this._doNotChangeAspectRatio) {
  61567. scene.updateTransformMatrix(true);
  61568. }
  61569. // Before Camera Draw
  61570. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  61571. var step = _a[_i];
  61572. step.action(this);
  61573. }
  61574. // Render
  61575. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  61576. // After Camera Draw
  61577. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  61578. var step = _c[_b];
  61579. step.action(this);
  61580. }
  61581. if (this._postProcessManager) {
  61582. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  61583. }
  61584. else if (useCameraPostProcess) {
  61585. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  61586. }
  61587. if (!this._doNotChangeAspectRatio) {
  61588. scene.updateTransformMatrix(true);
  61589. }
  61590. // Dump ?
  61591. if (dumpForDebug) {
  61592. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  61593. }
  61594. // Unbind
  61595. if (!this.isCube || faceIndex === 5) {
  61596. if (this.isCube) {
  61597. if (faceIndex === 5) {
  61598. engine.generateMipMapsForCubemap(this._texture);
  61599. }
  61600. }
  61601. this.unbindFrameBuffer(engine, faceIndex);
  61602. }
  61603. else {
  61604. this.onAfterRenderObservable.notifyObservers(faceIndex);
  61605. }
  61606. };
  61607. /**
  61608. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  61609. * This allowed control for front to back rendering or reversly depending of the special needs.
  61610. *
  61611. * @param renderingGroupId The rendering group id corresponding to its index
  61612. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  61613. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  61614. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  61615. */
  61616. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  61617. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  61618. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  61619. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  61620. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  61621. };
  61622. /**
  61623. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  61624. *
  61625. * @param renderingGroupId The rendering group id corresponding to its index
  61626. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61627. */
  61628. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  61629. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  61630. this._renderingManager._useSceneAutoClearSetup = false;
  61631. };
  61632. /**
  61633. * Clones the texture.
  61634. * @returns the cloned texture
  61635. */
  61636. RenderTargetTexture.prototype.clone = function () {
  61637. var textureSize = this.getSize();
  61638. 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);
  61639. // Base texture
  61640. newTexture.hasAlpha = this.hasAlpha;
  61641. newTexture.level = this.level;
  61642. // RenderTarget Texture
  61643. newTexture.coordinatesMode = this.coordinatesMode;
  61644. if (this.renderList) {
  61645. newTexture.renderList = this.renderList.slice(0);
  61646. }
  61647. return newTexture;
  61648. };
  61649. /**
  61650. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  61651. * @returns The JSON representation of the texture
  61652. */
  61653. RenderTargetTexture.prototype.serialize = function () {
  61654. if (!this.name) {
  61655. return null;
  61656. }
  61657. var serializationObject = _super.prototype.serialize.call(this);
  61658. serializationObject.renderTargetSize = this.getRenderSize();
  61659. serializationObject.renderList = [];
  61660. if (this.renderList) {
  61661. for (var index = 0; index < this.renderList.length; index++) {
  61662. serializationObject.renderList.push(this.renderList[index].id);
  61663. }
  61664. }
  61665. return serializationObject;
  61666. };
  61667. /**
  61668. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  61669. */
  61670. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  61671. var objBuffer = this.getInternalTexture();
  61672. var scene = this.getScene();
  61673. if (objBuffer && scene) {
  61674. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  61675. }
  61676. };
  61677. /**
  61678. * Dispose the texture and release its associated resources.
  61679. */
  61680. RenderTargetTexture.prototype.dispose = function () {
  61681. if (this._postProcessManager) {
  61682. this._postProcessManager.dispose();
  61683. this._postProcessManager = null;
  61684. }
  61685. this.clearPostProcesses(true);
  61686. if (this._resizeObserver) {
  61687. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  61688. this._resizeObserver = null;
  61689. }
  61690. this.renderList = null;
  61691. // Remove from custom render targets
  61692. var scene = this.getScene();
  61693. if (!scene) {
  61694. return;
  61695. }
  61696. var index = scene.customRenderTargets.indexOf(this);
  61697. if (index >= 0) {
  61698. scene.customRenderTargets.splice(index, 1);
  61699. }
  61700. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  61701. var camera = _a[_i];
  61702. index = camera.customRenderTargets.indexOf(this);
  61703. if (index >= 0) {
  61704. camera.customRenderTargets.splice(index, 1);
  61705. }
  61706. }
  61707. _super.prototype.dispose.call(this);
  61708. };
  61709. /** @hidden */
  61710. RenderTargetTexture.prototype._rebuild = function () {
  61711. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  61712. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  61713. }
  61714. if (this._postProcessManager) {
  61715. this._postProcessManager._rebuild();
  61716. }
  61717. };
  61718. /**
  61719. * Clear the info related to rendering groups preventing retention point in material dispose.
  61720. */
  61721. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  61722. if (this._renderingManager) {
  61723. this._renderingManager.freeRenderingGroups();
  61724. }
  61725. };
  61726. /**
  61727. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  61728. * @returns the view count
  61729. */
  61730. RenderTargetTexture.prototype.getViewCount = function () {
  61731. return 1;
  61732. };
  61733. /**
  61734. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  61735. */
  61736. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  61737. /**
  61738. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  61739. */
  61740. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  61741. /**
  61742. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  61743. * the central point of your effect and can save a lot of performances.
  61744. */
  61745. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  61746. return RenderTargetTexture;
  61747. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  61748. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  61749. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  61750. };
  61751. /***/ }),
  61752. /***/ "./Materials/Textures/texture.ts":
  61753. /*!***************************************!*\
  61754. !*** ./Materials/Textures/texture.ts ***!
  61755. \***************************************/
  61756. /*! exports provided: Texture */
  61757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61758. "use strict";
  61759. __webpack_require__.r(__webpack_exports__);
  61760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  61761. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61762. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  61763. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  61764. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  61765. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  61766. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  61767. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  61768. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  61769. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  61770. /**
  61771. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  61772. * @see http://doc.babylonjs.com/babylon101/materials#texture
  61773. */
  61774. var Texture = /** @class */ (function (_super) {
  61775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  61776. /**
  61777. * Instantiates a new texture.
  61778. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  61779. * @see http://doc.babylonjs.com/babylon101/materials#texture
  61780. * @param url define the url of the picture to load as a texture
  61781. * @param scene define the scene the texture will belong to
  61782. * @param noMipmap define if the texture will require mip maps or not
  61783. * @param invertY define if the texture needs to be inverted on the y axis during loading
  61784. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  61785. * @param onLoad define a callback triggered when the texture has been loaded
  61786. * @param onError define a callback triggered when an error occurred during the loading session
  61787. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  61788. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  61789. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  61790. */
  61791. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  61792. if (noMipmap === void 0) { noMipmap = false; }
  61793. if (invertY === void 0) { invertY = true; }
  61794. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  61795. if (onLoad === void 0) { onLoad = null; }
  61796. if (onError === void 0) { onError = null; }
  61797. if (buffer === void 0) { buffer = null; }
  61798. if (deleteBuffer === void 0) { deleteBuffer = false; }
  61799. var _this = _super.call(this, scene) || this;
  61800. /**
  61801. * Define the url of the texture.
  61802. */
  61803. _this.url = null;
  61804. /**
  61805. * Define an offset on the texture to offset the u coordinates of the UVs
  61806. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  61807. */
  61808. _this.uOffset = 0;
  61809. /**
  61810. * Define an offset on the texture to offset the v coordinates of the UVs
  61811. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  61812. */
  61813. _this.vOffset = 0;
  61814. /**
  61815. * Define an offset on the texture to scale the u coordinates of the UVs
  61816. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  61817. */
  61818. _this.uScale = 1.0;
  61819. /**
  61820. * Define an offset on the texture to scale the v coordinates of the UVs
  61821. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  61822. */
  61823. _this.vScale = 1.0;
  61824. /**
  61825. * Define an offset on the texture to rotate around the u coordinates of the UVs
  61826. * @see http://doc.babylonjs.com/how_to/more_materials
  61827. */
  61828. _this.uAng = 0;
  61829. /**
  61830. * Define an offset on the texture to rotate around the v coordinates of the UVs
  61831. * @see http://doc.babylonjs.com/how_to/more_materials
  61832. */
  61833. _this.vAng = 0;
  61834. /**
  61835. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  61836. * @see http://doc.babylonjs.com/how_to/more_materials
  61837. */
  61838. _this.wAng = 0;
  61839. /**
  61840. * Defines the center of rotation (U)
  61841. */
  61842. _this.uRotationCenter = 0.5;
  61843. /**
  61844. * Defines the center of rotation (V)
  61845. */
  61846. _this.vRotationCenter = 0.5;
  61847. /**
  61848. * Defines the center of rotation (W)
  61849. */
  61850. _this.wRotationCenter = 0.5;
  61851. /**
  61852. * List of inspectable custom properties (used by the Inspector)
  61853. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  61854. */
  61855. _this.inspectableCustomProperties = null;
  61856. _this._noMipmap = false;
  61857. /** @hidden */
  61858. _this._invertY = false;
  61859. _this._rowGenerationMatrix = null;
  61860. _this._cachedTextureMatrix = null;
  61861. _this._projectionModeMatrix = null;
  61862. _this._t0 = null;
  61863. _this._t1 = null;
  61864. _this._t2 = null;
  61865. _this._cachedUOffset = -1;
  61866. _this._cachedVOffset = -1;
  61867. _this._cachedUScale = 0;
  61868. _this._cachedVScale = 0;
  61869. _this._cachedUAng = -1;
  61870. _this._cachedVAng = -1;
  61871. _this._cachedWAng = -1;
  61872. _this._cachedProjectionMatrixId = -1;
  61873. _this._cachedCoordinatesMode = -1;
  61874. /** @hidden */
  61875. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  61876. /** @hidden */
  61877. _this._buffer = null;
  61878. _this._deleteBuffer = false;
  61879. _this._format = null;
  61880. _this._delayedOnLoad = null;
  61881. _this._delayedOnError = null;
  61882. /**
  61883. * Observable triggered once the texture has been loaded.
  61884. */
  61885. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61886. _this._isBlocking = true;
  61887. _this.name = url || "";
  61888. _this.url = url;
  61889. _this._noMipmap = noMipmap;
  61890. _this._invertY = invertY;
  61891. _this._initialSamplingMode = samplingMode;
  61892. _this._buffer = buffer;
  61893. _this._deleteBuffer = deleteBuffer;
  61894. if (format) {
  61895. _this._format = format;
  61896. }
  61897. scene = _this.getScene();
  61898. if (!scene) {
  61899. return _this;
  61900. }
  61901. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  61902. var load = function () {
  61903. if (_this._texture && _this._texture._invertVScale) {
  61904. _this.vScale = -1;
  61905. }
  61906. if (_this.onLoadObservable.hasObservers()) {
  61907. _this.onLoadObservable.notifyObservers(_this);
  61908. }
  61909. if (onLoad) {
  61910. onLoad();
  61911. }
  61912. if (!_this.isBlocking && scene) {
  61913. scene.resetCachedMaterial();
  61914. }
  61915. };
  61916. if (!_this.url) {
  61917. _this._delayedOnLoad = load;
  61918. _this._delayedOnError = onError;
  61919. return _this;
  61920. }
  61921. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  61922. if (!_this._texture) {
  61923. if (!scene.useDelayedTextureLoading) {
  61924. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  61925. if (deleteBuffer) {
  61926. delete _this._buffer;
  61927. }
  61928. }
  61929. else {
  61930. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  61931. _this._delayedOnLoad = load;
  61932. _this._delayedOnError = onError;
  61933. }
  61934. }
  61935. else {
  61936. if (_this._texture.isReady) {
  61937. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  61938. }
  61939. else {
  61940. _this._texture.onLoadedObservable.add(load);
  61941. }
  61942. }
  61943. return _this;
  61944. }
  61945. Object.defineProperty(Texture.prototype, "noMipmap", {
  61946. /**
  61947. * Are mip maps generated for this texture or not.
  61948. */
  61949. get: function () {
  61950. return this._noMipmap;
  61951. },
  61952. enumerable: true,
  61953. configurable: true
  61954. });
  61955. Object.defineProperty(Texture.prototype, "isBlocking", {
  61956. get: function () {
  61957. return this._isBlocking;
  61958. },
  61959. /**
  61960. * Is the texture preventing material to render while loading.
  61961. * If false, a default texture will be used instead of the loading one during the preparation step.
  61962. */
  61963. set: function (value) {
  61964. this._isBlocking = value;
  61965. },
  61966. enumerable: true,
  61967. configurable: true
  61968. });
  61969. Object.defineProperty(Texture.prototype, "samplingMode", {
  61970. /**
  61971. * Get the current sampling mode associated with the texture.
  61972. */
  61973. get: function () {
  61974. if (!this._texture) {
  61975. return this._initialSamplingMode;
  61976. }
  61977. return this._texture.samplingMode;
  61978. },
  61979. enumerable: true,
  61980. configurable: true
  61981. });
  61982. Object.defineProperty(Texture.prototype, "invertY", {
  61983. /**
  61984. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  61985. */
  61986. get: function () {
  61987. return this._invertY;
  61988. },
  61989. enumerable: true,
  61990. configurable: true
  61991. });
  61992. /**
  61993. * Update the url (and optional buffer) of this texture if url was null during construction.
  61994. * @param url the url of the texture
  61995. * @param buffer the buffer of the texture (defaults to null)
  61996. * @param onLoad callback called when the texture is loaded (defaults to null)
  61997. */
  61998. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  61999. if (buffer === void 0) { buffer = null; }
  62000. if (this.url) {
  62001. this.releaseInternalTexture();
  62002. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  62003. }
  62004. this.url = url;
  62005. this._buffer = buffer;
  62006. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  62007. if (onLoad) {
  62008. this._delayedOnLoad = onLoad;
  62009. }
  62010. this.delayLoad();
  62011. };
  62012. /**
  62013. * Finish the loading sequence of a texture flagged as delayed load.
  62014. * @hidden
  62015. */
  62016. Texture.prototype.delayLoad = function () {
  62017. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  62018. return;
  62019. }
  62020. var scene = this.getScene();
  62021. if (!scene) {
  62022. return;
  62023. }
  62024. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  62025. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  62026. if (!this._texture) {
  62027. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  62028. if (this._deleteBuffer) {
  62029. delete this._buffer;
  62030. }
  62031. }
  62032. else {
  62033. if (this._delayedOnLoad) {
  62034. if (this._texture.isReady) {
  62035. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  62036. }
  62037. else {
  62038. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  62039. }
  62040. }
  62041. }
  62042. this._delayedOnLoad = null;
  62043. this._delayedOnError = null;
  62044. };
  62045. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  62046. x *= this.uScale;
  62047. y *= this.vScale;
  62048. x -= this.uRotationCenter * this.uScale;
  62049. y -= this.vRotationCenter * this.vScale;
  62050. z -= this.wRotationCenter;
  62051. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  62052. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  62053. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  62054. t.z += this.wRotationCenter;
  62055. };
  62056. /**
  62057. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  62058. * @returns the transform matrix of the texture.
  62059. */
  62060. Texture.prototype.getTextureMatrix = function () {
  62061. var _this = this;
  62062. if (this.uOffset === this._cachedUOffset &&
  62063. this.vOffset === this._cachedVOffset &&
  62064. this.uScale === this._cachedUScale &&
  62065. this.vScale === this._cachedVScale &&
  62066. this.uAng === this._cachedUAng &&
  62067. this.vAng === this._cachedVAng &&
  62068. this.wAng === this._cachedWAng) {
  62069. return this._cachedTextureMatrix;
  62070. }
  62071. this._cachedUOffset = this.uOffset;
  62072. this._cachedVOffset = this.vOffset;
  62073. this._cachedUScale = this.uScale;
  62074. this._cachedVScale = this.vScale;
  62075. this._cachedUAng = this.uAng;
  62076. this._cachedVAng = this.vAng;
  62077. this._cachedWAng = this.wAng;
  62078. if (!this._cachedTextureMatrix) {
  62079. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  62080. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  62081. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  62082. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  62083. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  62084. }
  62085. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  62086. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  62087. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  62088. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  62089. this._t1.subtractInPlace(this._t0);
  62090. this._t2.subtractInPlace(this._t0);
  62091. _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);
  62092. var scene = this.getScene();
  62093. if (!scene) {
  62094. return this._cachedTextureMatrix;
  62095. }
  62096. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  62097. return mat.hasTexture(_this);
  62098. });
  62099. return this._cachedTextureMatrix;
  62100. };
  62101. /**
  62102. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  62103. * @returns The reflection texture transform
  62104. */
  62105. Texture.prototype.getReflectionTextureMatrix = function () {
  62106. var _this = this;
  62107. var scene = this.getScene();
  62108. if (!scene) {
  62109. return this._cachedTextureMatrix;
  62110. }
  62111. if (this.uOffset === this._cachedUOffset &&
  62112. this.vOffset === this._cachedVOffset &&
  62113. this.uScale === this._cachedUScale &&
  62114. this.vScale === this._cachedVScale &&
  62115. this.coordinatesMode === this._cachedCoordinatesMode) {
  62116. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  62117. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  62118. return this._cachedTextureMatrix;
  62119. }
  62120. }
  62121. else {
  62122. return this._cachedTextureMatrix;
  62123. }
  62124. }
  62125. if (!this._cachedTextureMatrix) {
  62126. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  62127. }
  62128. if (!this._projectionModeMatrix) {
  62129. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  62130. }
  62131. this._cachedUOffset = this.uOffset;
  62132. this._cachedVOffset = this.vOffset;
  62133. this._cachedUScale = this.uScale;
  62134. this._cachedVScale = this.vScale;
  62135. this._cachedCoordinatesMode = this.coordinatesMode;
  62136. switch (this.coordinatesMode) {
  62137. case Texture.PLANAR_MODE:
  62138. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  62139. this._cachedTextureMatrix[0] = this.uScale;
  62140. this._cachedTextureMatrix[5] = this.vScale;
  62141. this._cachedTextureMatrix[12] = this.uOffset;
  62142. this._cachedTextureMatrix[13] = this.vOffset;
  62143. break;
  62144. case Texture.PROJECTION_MODE:
  62145. _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);
  62146. var projectionMatrix = scene.getProjectionMatrix();
  62147. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  62148. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  62149. break;
  62150. default:
  62151. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  62152. break;
  62153. }
  62154. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  62155. return (mat.getActiveTextures().indexOf(_this) !== -1);
  62156. });
  62157. return this._cachedTextureMatrix;
  62158. };
  62159. /**
  62160. * Clones the texture.
  62161. * @returns the cloned texture
  62162. */
  62163. Texture.prototype.clone = function () {
  62164. var _this = this;
  62165. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  62166. 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);
  62167. }, this);
  62168. };
  62169. /**
  62170. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  62171. * @returns The JSON representation of the texture
  62172. */
  62173. Texture.prototype.serialize = function () {
  62174. var serializationObject = _super.prototype.serialize.call(this);
  62175. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  62176. serializationObject.base64String = this._buffer;
  62177. serializationObject.name = serializationObject.name.replace("data:", "");
  62178. }
  62179. serializationObject.invertY = this._invertY;
  62180. serializationObject.samplingMode = this.samplingMode;
  62181. return serializationObject;
  62182. };
  62183. /**
  62184. * Get the current class name of the texture useful for serialization or dynamic coding.
  62185. * @returns "Texture"
  62186. */
  62187. Texture.prototype.getClassName = function () {
  62188. return "Texture";
  62189. };
  62190. /**
  62191. * Dispose the texture and release its associated resources.
  62192. */
  62193. Texture.prototype.dispose = function () {
  62194. _super.prototype.dispose.call(this);
  62195. this.onLoadObservable.clear();
  62196. this._delayedOnLoad = null;
  62197. this._delayedOnError = null;
  62198. };
  62199. /**
  62200. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  62201. * @param parsedTexture Define the JSON representation of the texture
  62202. * @param scene Define the scene the parsed texture should be instantiated in
  62203. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62204. * @returns The parsed texture if successful
  62205. */
  62206. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  62207. if (parsedTexture.customType) {
  62208. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  62209. // Update Sampling Mode
  62210. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  62211. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  62212. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  62213. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  62214. }
  62215. }
  62216. return parsedCustomTexture;
  62217. }
  62218. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  62219. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  62220. }
  62221. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  62222. return null;
  62223. }
  62224. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  62225. var generateMipMaps = true;
  62226. if (parsedTexture.noMipmap) {
  62227. generateMipMaps = false;
  62228. }
  62229. if (parsedTexture.mirrorPlane) {
  62230. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  62231. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  62232. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  62233. return mirrorTexture;
  62234. }
  62235. else if (parsedTexture.isRenderTarget) {
  62236. var renderTargetTexture = null;
  62237. if (parsedTexture.isCube) {
  62238. // Search for an existing reflection probe (which contains a cube render target texture)
  62239. if (scene.reflectionProbes) {
  62240. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  62241. var probe = scene.reflectionProbes[index];
  62242. if (probe.name === parsedTexture.name) {
  62243. return probe.cubeTexture;
  62244. }
  62245. }
  62246. }
  62247. }
  62248. else {
  62249. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  62250. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  62251. }
  62252. return renderTargetTexture;
  62253. }
  62254. else {
  62255. var texture;
  62256. if (parsedTexture.base64String) {
  62257. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  62258. }
  62259. else {
  62260. var url = rootUrl + parsedTexture.name;
  62261. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  62262. url = parsedTexture.url;
  62263. }
  62264. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  62265. }
  62266. return texture;
  62267. }
  62268. }, parsedTexture, scene);
  62269. // Update Sampling Mode
  62270. if (parsedTexture.samplingMode) {
  62271. var sampling = parsedTexture.samplingMode;
  62272. if (texture && texture.samplingMode !== sampling) {
  62273. texture.updateSamplingMode(sampling);
  62274. }
  62275. }
  62276. // Animations
  62277. if (texture && parsedTexture.animations) {
  62278. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  62279. var parsedAnimation = parsedTexture.animations[animationIndex];
  62280. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  62281. if (internalClass) {
  62282. texture.animations.push(internalClass.Parse(parsedAnimation));
  62283. }
  62284. }
  62285. }
  62286. return texture;
  62287. };
  62288. /**
  62289. * Creates a texture from its base 64 representation.
  62290. * @param data Define the base64 payload without the data: prefix
  62291. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  62292. * @param scene Define the scene the texture should belong to
  62293. * @param noMipmap Forces the texture to not create mip map information if true
  62294. * @param invertY define if the texture needs to be inverted on the y axis during loading
  62295. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  62296. * @param onLoad define a callback triggered when the texture has been loaded
  62297. * @param onError define a callback triggered when an error occurred during the loading session
  62298. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  62299. * @returns the created texture
  62300. */
  62301. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  62302. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  62303. if (onLoad === void 0) { onLoad = null; }
  62304. if (onError === void 0) { onError = null; }
  62305. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  62306. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  62307. };
  62308. /**
  62309. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  62310. * @param data Define the base64 payload without the data: prefix
  62311. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  62312. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  62313. * @param scene Define the scene the texture should belong to
  62314. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  62315. * @param noMipmap Forces the texture to not create mip map information if true
  62316. * @param invertY define if the texture needs to be inverted on the y axis during loading
  62317. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  62318. * @param onLoad define a callback triggered when the texture has been loaded
  62319. * @param onError define a callback triggered when an error occurred during the loading session
  62320. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  62321. * @returns the created texture
  62322. */
  62323. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  62324. if (deleteBuffer === void 0) { deleteBuffer = false; }
  62325. if (noMipmap === void 0) { noMipmap = false; }
  62326. if (invertY === void 0) { invertY = true; }
  62327. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  62328. if (onLoad === void 0) { onLoad = null; }
  62329. if (onError === void 0) { onError = null; }
  62330. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  62331. if (name.substr(0, 5) !== "data:") {
  62332. name = "data:" + name;
  62333. }
  62334. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  62335. };
  62336. /** @hidden */
  62337. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  62338. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  62339. };
  62340. /** @hidden */
  62341. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  62342. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  62343. };
  62344. /** @hidden */
  62345. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  62346. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  62347. };
  62348. /** nearest is mag = nearest and min = nearest and mip = linear */
  62349. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  62350. /** nearest is mag = nearest and min = nearest and mip = linear */
  62351. 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
  62352. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62353. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  62354. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62355. 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
  62356. /** Trilinear is mag = linear and min = linear and mip = linear */
  62357. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  62358. /** Trilinear is mag = linear and min = linear and mip = linear */
  62359. 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
  62360. /** mag = nearest and min = nearest and mip = nearest */
  62361. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  62362. /** mag = nearest and min = linear and mip = nearest */
  62363. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  62364. /** mag = nearest and min = linear and mip = linear */
  62365. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  62366. /** mag = nearest and min = linear and mip = none */
  62367. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  62368. /** mag = nearest and min = nearest and mip = none */
  62369. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  62370. /** mag = linear and min = nearest and mip = nearest */
  62371. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  62372. /** mag = linear and min = nearest and mip = linear */
  62373. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  62374. /** mag = linear and min = linear and mip = none */
  62375. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  62376. /** mag = linear and min = nearest and mip = none */
  62377. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  62378. /** Explicit coordinates mode */
  62379. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  62380. /** Spherical coordinates mode */
  62381. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  62382. /** Planar coordinates mode */
  62383. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  62384. /** Cubic coordinates mode */
  62385. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  62386. /** Projection coordinates mode */
  62387. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  62388. /** Inverse Cubic coordinates mode */
  62389. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  62390. /** Inverse Cubic coordinates mode */
  62391. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  62392. /** Equirectangular coordinates mode */
  62393. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  62394. /** Equirectangular Fixed coordinates mode */
  62395. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  62396. /** Equirectangular Fixed Mirrored coordinates mode */
  62397. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  62398. /** Texture is not repeating outside of 0..1 UVs */
  62399. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  62400. /** Texture is repeating outside of 0..1 UVs */
  62401. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  62402. /** Texture is repeating and mirrored */
  62403. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  62404. /**
  62405. * 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
  62406. */
  62407. Texture.UseSerializedUrlIfAny = false;
  62408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62410. ], Texture.prototype, "url", void 0);
  62411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62413. ], Texture.prototype, "uOffset", void 0);
  62414. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62416. ], Texture.prototype, "vOffset", void 0);
  62417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62419. ], Texture.prototype, "uScale", void 0);
  62420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62422. ], Texture.prototype, "vScale", void 0);
  62423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62425. ], Texture.prototype, "uAng", void 0);
  62426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62428. ], Texture.prototype, "vAng", void 0);
  62429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62431. ], Texture.prototype, "wAng", void 0);
  62432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62434. ], Texture.prototype, "uRotationCenter", void 0);
  62435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62437. ], Texture.prototype, "vRotationCenter", void 0);
  62438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62440. ], Texture.prototype, "wRotationCenter", void 0);
  62441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62443. ], Texture.prototype, "isBlocking", null);
  62444. return Texture;
  62445. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  62446. // References the dependencies.
  62447. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  62448. /***/ }),
  62449. /***/ "./Materials/Textures/videoTexture.ts":
  62450. /*!********************************************!*\
  62451. !*** ./Materials/Textures/videoTexture.ts ***!
  62452. \********************************************/
  62453. /*! exports provided: VideoTexture */
  62454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62455. "use strict";
  62456. __webpack_require__.r(__webpack_exports__);
  62457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  62458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62459. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  62460. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  62461. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  62462. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  62463. /**
  62464. * If you want to display a video in your scene, this is the special texture for that.
  62465. * This special texture works similar to other textures, with the exception of a few parameters.
  62466. * @see https://doc.babylonjs.com/how_to/video_texture
  62467. */
  62468. var VideoTexture = /** @class */ (function (_super) {
  62469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  62470. /**
  62471. * Creates a video texture.
  62472. * If you want to display a video in your scene, this is the special texture for that.
  62473. * This special texture works similar to other textures, with the exception of a few parameters.
  62474. * @see https://doc.babylonjs.com/how_to/video_texture
  62475. * @param name optional name, will detect from video source, if not defined
  62476. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  62477. * @param scene is obviously the current scene.
  62478. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  62479. * @param invertY is false by default but can be used to invert video on Y axis
  62480. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  62481. * @param settings allows finer control over video usage
  62482. */
  62483. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  62484. if (generateMipMaps === void 0) { generateMipMaps = false; }
  62485. if (invertY === void 0) { invertY = false; }
  62486. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  62487. if (settings === void 0) { settings = {
  62488. autoPlay: true,
  62489. loop: true,
  62490. autoUpdateTexture: true,
  62491. }; }
  62492. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  62493. _this._onUserActionRequestedObservable = null;
  62494. _this._stillImageCaptured = false;
  62495. _this._displayingPosterTexture = false;
  62496. _this._createInternalTexture = function () {
  62497. if (_this._texture != null) {
  62498. if (_this._displayingPosterTexture) {
  62499. _this._texture.dispose();
  62500. _this._displayingPosterTexture = false;
  62501. }
  62502. else {
  62503. return;
  62504. }
  62505. }
  62506. if (!_this._engine.needPOTTextures ||
  62507. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  62508. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  62509. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  62510. }
  62511. else {
  62512. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  62513. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  62514. _this._generateMipMaps = false;
  62515. }
  62516. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  62517. if (!_this.video.autoplay && !_this._settings.poster) {
  62518. var oldHandler_1 = _this.video.onplaying;
  62519. var error_1 = false;
  62520. var oldMuted_1 = _this.video.muted;
  62521. _this.video.muted = true;
  62522. _this.video.onplaying = function () {
  62523. _this.video.muted = oldMuted_1;
  62524. _this.video.onplaying = oldHandler_1;
  62525. _this._texture.isReady = true;
  62526. _this._updateInternalTexture();
  62527. if (!error_1) {
  62528. _this.video.pause();
  62529. }
  62530. if (_this.onLoadObservable.hasObservers()) {
  62531. _this.onLoadObservable.notifyObservers(_this);
  62532. }
  62533. };
  62534. var playing = _this.video.play();
  62535. if (playing) {
  62536. playing.then(function () {
  62537. // Everything is good.
  62538. })
  62539. .catch(function () {
  62540. error_1 = true;
  62541. // On Chrome for instance, new policies might prevent playing without user interaction.
  62542. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  62543. _this._onUserActionRequestedObservable.notifyObservers(_this);
  62544. }
  62545. });
  62546. }
  62547. else {
  62548. _this.video.onplaying = oldHandler_1;
  62549. _this._texture.isReady = true;
  62550. _this._updateInternalTexture();
  62551. if (_this.onLoadObservable.hasObservers()) {
  62552. _this.onLoadObservable.notifyObservers(_this);
  62553. }
  62554. }
  62555. }
  62556. else {
  62557. _this._texture.isReady = true;
  62558. _this._updateInternalTexture();
  62559. if (_this.onLoadObservable.hasObservers()) {
  62560. _this.onLoadObservable.notifyObservers(_this);
  62561. }
  62562. }
  62563. };
  62564. _this.reset = function () {
  62565. if (_this._texture == null) {
  62566. return;
  62567. }
  62568. if (!_this._displayingPosterTexture) {
  62569. _this._texture.dispose();
  62570. _this._texture = null;
  62571. }
  62572. };
  62573. _this._updateInternalTexture = function () {
  62574. if (_this._texture == null || !_this._texture.isReady) {
  62575. return;
  62576. }
  62577. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  62578. return;
  62579. }
  62580. if (_this._displayingPosterTexture) {
  62581. return;
  62582. }
  62583. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  62584. };
  62585. _this._engine = _this.getScene().getEngine();
  62586. _this._generateMipMaps = generateMipMaps;
  62587. _this._initialSamplingMode = samplingMode;
  62588. _this.autoUpdateTexture = settings.autoUpdateTexture;
  62589. _this.name = name || _this._getName(src);
  62590. _this.video = _this._getVideo(src);
  62591. _this._settings = settings;
  62592. if (settings.poster) {
  62593. _this.video.poster = settings.poster;
  62594. }
  62595. if (settings.autoPlay !== undefined) {
  62596. _this.video.autoplay = settings.autoPlay;
  62597. }
  62598. if (settings.loop !== undefined) {
  62599. _this.video.loop = settings.loop;
  62600. }
  62601. _this.video.setAttribute("playsinline", "");
  62602. _this.video.addEventListener("paused", _this._updateInternalTexture);
  62603. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  62604. _this.video.addEventListener("emptied", _this.reset);
  62605. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  62606. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  62607. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  62608. if (settings.poster &&
  62609. (!settings.autoPlay || !videoHasEnoughData)) {
  62610. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  62611. _this._displayingPosterTexture = true;
  62612. }
  62613. else if (videoHasEnoughData) {
  62614. _this._createInternalTexture();
  62615. }
  62616. return _this;
  62617. }
  62618. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  62619. /**
  62620. * Event triggerd when a dom action is required by the user to play the video.
  62621. * This happens due to recent changes in browser policies preventing video to auto start.
  62622. */
  62623. get: function () {
  62624. if (!this._onUserActionRequestedObservable) {
  62625. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  62626. }
  62627. return this._onUserActionRequestedObservable;
  62628. },
  62629. enumerable: true,
  62630. configurable: true
  62631. });
  62632. VideoTexture.prototype._getName = function (src) {
  62633. if (src instanceof HTMLVideoElement) {
  62634. return src.currentSrc;
  62635. }
  62636. if (typeof src === "object") {
  62637. return src.toString();
  62638. }
  62639. return src;
  62640. };
  62641. VideoTexture.prototype._getVideo = function (src) {
  62642. if (src instanceof HTMLVideoElement) {
  62643. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  62644. return src;
  62645. }
  62646. var video = document.createElement("video");
  62647. if (typeof src === "string") {
  62648. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  62649. video.src = src;
  62650. }
  62651. else {
  62652. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  62653. src.forEach(function (url) {
  62654. var source = document.createElement("source");
  62655. source.src = url;
  62656. video.appendChild(source);
  62657. });
  62658. }
  62659. return video;
  62660. };
  62661. /**
  62662. * @hidden Internal method to initiate `update`.
  62663. */
  62664. VideoTexture.prototype._rebuild = function () {
  62665. this.update();
  62666. };
  62667. /**
  62668. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  62669. */
  62670. VideoTexture.prototype.update = function () {
  62671. if (!this.autoUpdateTexture) {
  62672. // Expecting user to call `updateTexture` manually
  62673. return;
  62674. }
  62675. this.updateTexture(true);
  62676. };
  62677. /**
  62678. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  62679. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  62680. */
  62681. VideoTexture.prototype.updateTexture = function (isVisible) {
  62682. if (!isVisible) {
  62683. return;
  62684. }
  62685. if (this.video.paused && this._stillImageCaptured) {
  62686. return;
  62687. }
  62688. this._stillImageCaptured = true;
  62689. this._updateInternalTexture();
  62690. };
  62691. /**
  62692. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  62693. * @param url New url.
  62694. */
  62695. VideoTexture.prototype.updateURL = function (url) {
  62696. this.video.src = url;
  62697. };
  62698. /**
  62699. * Dispose the texture and release its associated resources.
  62700. */
  62701. VideoTexture.prototype.dispose = function () {
  62702. _super.prototype.dispose.call(this);
  62703. if (this._onUserActionRequestedObservable) {
  62704. this._onUserActionRequestedObservable.clear();
  62705. this._onUserActionRequestedObservable = null;
  62706. }
  62707. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  62708. this.video.removeEventListener("paused", this._updateInternalTexture);
  62709. this.video.removeEventListener("seeked", this._updateInternalTexture);
  62710. this.video.removeEventListener("emptied", this.reset);
  62711. this.video.pause();
  62712. };
  62713. /**
  62714. * Creates a video texture straight from a stream.
  62715. * @param scene Define the scene the texture should be created in
  62716. * @param stream Define the stream the texture should be created from
  62717. * @returns The created video texture as a promise
  62718. */
  62719. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  62720. var video = document.createElement("video");
  62721. video.setAttribute('autoplay', '');
  62722. video.setAttribute('muted', 'true');
  62723. video.setAttribute('playsinline', '');
  62724. video.muted = true;
  62725. if (video.mozSrcObject !== undefined) {
  62726. // hack for Firefox < 19
  62727. video.mozSrcObject = stream;
  62728. }
  62729. else {
  62730. if (typeof video.srcObject == "object") {
  62731. video.srcObject = stream;
  62732. }
  62733. else {
  62734. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  62735. video.src = (window.URL && window.URL.createObjectURL(stream));
  62736. }
  62737. }
  62738. return new Promise(function (resolve) {
  62739. var onPlaying = function () {
  62740. resolve(new VideoTexture("video", video, scene, true, true));
  62741. video.removeEventListener("playing", onPlaying);
  62742. };
  62743. video.addEventListener("playing", onPlaying);
  62744. video.play();
  62745. });
  62746. };
  62747. /**
  62748. * Creates a video texture straight from your WebCam video feed.
  62749. * @param scene Define the scene the texture should be created in
  62750. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  62751. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  62752. * @returns The created video texture as a promise
  62753. */
  62754. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  62755. var _this = this;
  62756. if (audioConstaints === void 0) { audioConstaints = false; }
  62757. var constraintsDeviceId;
  62758. if (constraints && constraints.deviceId) {
  62759. constraintsDeviceId = {
  62760. exact: constraints.deviceId,
  62761. };
  62762. }
  62763. if (navigator.mediaDevices) {
  62764. return navigator.mediaDevices.getUserMedia({
  62765. video: constraints,
  62766. audio: audioConstaints
  62767. })
  62768. .then(function (stream) {
  62769. return _this.CreateFromStreamAsync(scene, stream);
  62770. });
  62771. }
  62772. else {
  62773. navigator.getUserMedia =
  62774. navigator.getUserMedia ||
  62775. navigator.webkitGetUserMedia ||
  62776. navigator.mozGetUserMedia ||
  62777. navigator.msGetUserMedia;
  62778. if (navigator.getUserMedia) {
  62779. navigator.getUserMedia({
  62780. video: {
  62781. deviceId: constraintsDeviceId,
  62782. width: {
  62783. min: (constraints && constraints.minWidth) || 256,
  62784. max: (constraints && constraints.maxWidth) || 640,
  62785. },
  62786. height: {
  62787. min: (constraints && constraints.minHeight) || 256,
  62788. max: (constraints && constraints.maxHeight) || 480,
  62789. },
  62790. },
  62791. audio: audioConstaints
  62792. }, function (stream) {
  62793. return _this.CreateFromStreamAsync(scene, stream);
  62794. }, function (e) {
  62795. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  62796. });
  62797. }
  62798. }
  62799. return Promise.reject("No support for userMedia on this device");
  62800. };
  62801. /**
  62802. * Creates a video texture straight from your WebCam video feed.
  62803. * @param scene Define the scene the texture should be created in
  62804. * @param onReady Define a callback to triggered once the texture will be ready
  62805. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  62806. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  62807. */
  62808. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  62809. if (audioConstaints === void 0) { audioConstaints = false; }
  62810. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  62811. .then(function (videoTexture) {
  62812. if (onReady) {
  62813. onReady(videoTexture);
  62814. }
  62815. })
  62816. .catch(function (err) {
  62817. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  62818. });
  62819. };
  62820. return VideoTexture;
  62821. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  62822. /***/ }),
  62823. /***/ "./Materials/colorCurves.ts":
  62824. /*!**********************************!*\
  62825. !*** ./Materials/colorCurves.ts ***!
  62826. \**********************************/
  62827. /*! exports provided: ColorCurves */
  62828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62829. "use strict";
  62830. __webpack_require__.r(__webpack_exports__);
  62831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  62832. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62833. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62834. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62835. /**
  62836. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  62837. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  62838. * 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;
  62839. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  62840. */
  62841. var ColorCurves = /** @class */ (function () {
  62842. function ColorCurves() {
  62843. this._dirty = true;
  62844. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62845. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62846. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62847. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62848. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62849. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62850. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62851. this._globalHue = 30;
  62852. this._globalDensity = 0;
  62853. this._globalSaturation = 0;
  62854. this._globalExposure = 0;
  62855. this._highlightsHue = 30;
  62856. this._highlightsDensity = 0;
  62857. this._highlightsSaturation = 0;
  62858. this._highlightsExposure = 0;
  62859. this._midtonesHue = 30;
  62860. this._midtonesDensity = 0;
  62861. this._midtonesSaturation = 0;
  62862. this._midtonesExposure = 0;
  62863. this._shadowsHue = 30;
  62864. this._shadowsDensity = 0;
  62865. this._shadowsSaturation = 0;
  62866. this._shadowsExposure = 0;
  62867. }
  62868. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  62869. /**
  62870. * Gets the global Hue value.
  62871. * 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).
  62872. */
  62873. get: function () {
  62874. return this._globalHue;
  62875. },
  62876. /**
  62877. * Sets the global Hue value.
  62878. * 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).
  62879. */
  62880. set: function (value) {
  62881. this._globalHue = value;
  62882. this._dirty = true;
  62883. },
  62884. enumerable: true,
  62885. configurable: true
  62886. });
  62887. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  62888. /**
  62889. * Gets the global Density value.
  62890. * 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.
  62891. * Values less than zero provide a filter of opposite hue.
  62892. */
  62893. get: function () {
  62894. return this._globalDensity;
  62895. },
  62896. /**
  62897. * Sets the global Density value.
  62898. * 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.
  62899. * Values less than zero provide a filter of opposite hue.
  62900. */
  62901. set: function (value) {
  62902. this._globalDensity = value;
  62903. this._dirty = true;
  62904. },
  62905. enumerable: true,
  62906. configurable: true
  62907. });
  62908. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  62909. /**
  62910. * Gets the global Saturation value.
  62911. * 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.
  62912. */
  62913. get: function () {
  62914. return this._globalSaturation;
  62915. },
  62916. /**
  62917. * Sets the global Saturation value.
  62918. * 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.
  62919. */
  62920. set: function (value) {
  62921. this._globalSaturation = value;
  62922. this._dirty = true;
  62923. },
  62924. enumerable: true,
  62925. configurable: true
  62926. });
  62927. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  62928. /**
  62929. * Gets the global Exposure value.
  62930. * 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.
  62931. */
  62932. get: function () {
  62933. return this._globalExposure;
  62934. },
  62935. /**
  62936. * Sets the global Exposure value.
  62937. * 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.
  62938. */
  62939. set: function (value) {
  62940. this._globalExposure = value;
  62941. this._dirty = true;
  62942. },
  62943. enumerable: true,
  62944. configurable: true
  62945. });
  62946. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  62947. /**
  62948. * Gets the highlights Hue value.
  62949. * 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).
  62950. */
  62951. get: function () {
  62952. return this._highlightsHue;
  62953. },
  62954. /**
  62955. * Sets the highlights Hue value.
  62956. * 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).
  62957. */
  62958. set: function (value) {
  62959. this._highlightsHue = value;
  62960. this._dirty = true;
  62961. },
  62962. enumerable: true,
  62963. configurable: true
  62964. });
  62965. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  62966. /**
  62967. * Gets the highlights Density value.
  62968. * 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.
  62969. * Values less than zero provide a filter of opposite hue.
  62970. */
  62971. get: function () {
  62972. return this._highlightsDensity;
  62973. },
  62974. /**
  62975. * Sets the highlights Density value.
  62976. * 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.
  62977. * Values less than zero provide a filter of opposite hue.
  62978. */
  62979. set: function (value) {
  62980. this._highlightsDensity = value;
  62981. this._dirty = true;
  62982. },
  62983. enumerable: true,
  62984. configurable: true
  62985. });
  62986. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  62987. /**
  62988. * Gets the highlights Saturation value.
  62989. * 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.
  62990. */
  62991. get: function () {
  62992. return this._highlightsSaturation;
  62993. },
  62994. /**
  62995. * Sets the highlights Saturation value.
  62996. * 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.
  62997. */
  62998. set: function (value) {
  62999. this._highlightsSaturation = value;
  63000. this._dirty = true;
  63001. },
  63002. enumerable: true,
  63003. configurable: true
  63004. });
  63005. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  63006. /**
  63007. * Gets the highlights Exposure value.
  63008. * 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.
  63009. */
  63010. get: function () {
  63011. return this._highlightsExposure;
  63012. },
  63013. /**
  63014. * Sets the highlights Exposure value.
  63015. * 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.
  63016. */
  63017. set: function (value) {
  63018. this._highlightsExposure = value;
  63019. this._dirty = true;
  63020. },
  63021. enumerable: true,
  63022. configurable: true
  63023. });
  63024. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  63025. /**
  63026. * Gets the midtones Hue value.
  63027. * 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).
  63028. */
  63029. get: function () {
  63030. return this._midtonesHue;
  63031. },
  63032. /**
  63033. * Sets the midtones Hue value.
  63034. * 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).
  63035. */
  63036. set: function (value) {
  63037. this._midtonesHue = value;
  63038. this._dirty = true;
  63039. },
  63040. enumerable: true,
  63041. configurable: true
  63042. });
  63043. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  63044. /**
  63045. * Gets the midtones Density value.
  63046. * 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.
  63047. * Values less than zero provide a filter of opposite hue.
  63048. */
  63049. get: function () {
  63050. return this._midtonesDensity;
  63051. },
  63052. /**
  63053. * Sets the midtones Density value.
  63054. * 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.
  63055. * Values less than zero provide a filter of opposite hue.
  63056. */
  63057. set: function (value) {
  63058. this._midtonesDensity = value;
  63059. this._dirty = true;
  63060. },
  63061. enumerable: true,
  63062. configurable: true
  63063. });
  63064. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  63065. /**
  63066. * Gets the midtones Saturation value.
  63067. * 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.
  63068. */
  63069. get: function () {
  63070. return this._midtonesSaturation;
  63071. },
  63072. /**
  63073. * Sets the midtones Saturation value.
  63074. * 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.
  63075. */
  63076. set: function (value) {
  63077. this._midtonesSaturation = value;
  63078. this._dirty = true;
  63079. },
  63080. enumerable: true,
  63081. configurable: true
  63082. });
  63083. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  63084. /**
  63085. * Gets the midtones Exposure value.
  63086. * 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.
  63087. */
  63088. get: function () {
  63089. return this._midtonesExposure;
  63090. },
  63091. /**
  63092. * Sets the midtones Exposure value.
  63093. * 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.
  63094. */
  63095. set: function (value) {
  63096. this._midtonesExposure = value;
  63097. this._dirty = true;
  63098. },
  63099. enumerable: true,
  63100. configurable: true
  63101. });
  63102. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  63103. /**
  63104. * Gets the shadows Hue value.
  63105. * 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).
  63106. */
  63107. get: function () {
  63108. return this._shadowsHue;
  63109. },
  63110. /**
  63111. * Sets the shadows Hue value.
  63112. * 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).
  63113. */
  63114. set: function (value) {
  63115. this._shadowsHue = value;
  63116. this._dirty = true;
  63117. },
  63118. enumerable: true,
  63119. configurable: true
  63120. });
  63121. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  63122. /**
  63123. * Gets the shadows Density value.
  63124. * 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.
  63125. * Values less than zero provide a filter of opposite hue.
  63126. */
  63127. get: function () {
  63128. return this._shadowsDensity;
  63129. },
  63130. /**
  63131. * Sets the shadows Density value.
  63132. * 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.
  63133. * Values less than zero provide a filter of opposite hue.
  63134. */
  63135. set: function (value) {
  63136. this._shadowsDensity = value;
  63137. this._dirty = true;
  63138. },
  63139. enumerable: true,
  63140. configurable: true
  63141. });
  63142. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  63143. /**
  63144. * Gets the shadows Saturation value.
  63145. * 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.
  63146. */
  63147. get: function () {
  63148. return this._shadowsSaturation;
  63149. },
  63150. /**
  63151. * Sets the shadows Saturation value.
  63152. * 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.
  63153. */
  63154. set: function (value) {
  63155. this._shadowsSaturation = value;
  63156. this._dirty = true;
  63157. },
  63158. enumerable: true,
  63159. configurable: true
  63160. });
  63161. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  63162. /**
  63163. * Gets the shadows Exposure value.
  63164. * 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.
  63165. */
  63166. get: function () {
  63167. return this._shadowsExposure;
  63168. },
  63169. /**
  63170. * Sets the shadows Exposure value.
  63171. * 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.
  63172. */
  63173. set: function (value) {
  63174. this._shadowsExposure = value;
  63175. this._dirty = true;
  63176. },
  63177. enumerable: true,
  63178. configurable: true
  63179. });
  63180. /**
  63181. * Returns the class name
  63182. * @returns The class name
  63183. */
  63184. ColorCurves.prototype.getClassName = function () {
  63185. return "ColorCurves";
  63186. };
  63187. /**
  63188. * Binds the color curves to the shader.
  63189. * @param colorCurves The color curve to bind
  63190. * @param effect The effect to bind to
  63191. * @param positiveUniform The positive uniform shader parameter
  63192. * @param neutralUniform The neutral uniform shader parameter
  63193. * @param negativeUniform The negative uniform shader parameter
  63194. */
  63195. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  63196. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  63197. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  63198. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  63199. if (colorCurves._dirty) {
  63200. colorCurves._dirty = false;
  63201. // Fill in global info.
  63202. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  63203. // Compute highlights info.
  63204. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  63205. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  63206. // Compute midtones info.
  63207. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  63208. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  63209. // Compute shadows info.
  63210. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  63211. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  63212. // Compute deltas (neutral is midtones).
  63213. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  63214. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  63215. }
  63216. if (effect) {
  63217. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  63218. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  63219. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  63220. }
  63221. };
  63222. /**
  63223. * Prepare the list of uniforms associated with the ColorCurves effects.
  63224. * @param uniformsList The list of uniforms used in the effect
  63225. */
  63226. ColorCurves.PrepareUniforms = function (uniformsList) {
  63227. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  63228. };
  63229. /**
  63230. * Returns color grading data based on a hue, density, saturation and exposure value.
  63231. * @param filterHue The hue of the color filter.
  63232. * @param filterDensity The density of the color filter.
  63233. * @param saturation The saturation.
  63234. * @param exposure The exposure.
  63235. * @param result The result data container.
  63236. */
  63237. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  63238. if (hue == null) {
  63239. return;
  63240. }
  63241. hue = ColorCurves.clamp(hue, 0, 360);
  63242. density = ColorCurves.clamp(density, -100, 100);
  63243. saturation = ColorCurves.clamp(saturation, -100, 100);
  63244. exposure = ColorCurves.clamp(exposure, -100, 100);
  63245. // Remap the slider/config filter density with non-linear mapping and also scale by half
  63246. // so that the maximum filter density is only 50% control. This provides fine control
  63247. // for small values and reasonable range.
  63248. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  63249. density *= 0.5;
  63250. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  63251. if (density < 0) {
  63252. density *= -1;
  63253. hue = (hue + 180) % 360;
  63254. }
  63255. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  63256. result.scaleToRef(2, result);
  63257. result.a = 1 + 0.01 * saturation;
  63258. };
  63259. /**
  63260. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  63261. * @param value The input slider value in range [-100,100].
  63262. * @returns Adjusted value.
  63263. */
  63264. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  63265. value /= 100;
  63266. var x = Math.abs(value);
  63267. x = Math.pow(x, 2);
  63268. if (value < 0) {
  63269. x *= -1;
  63270. }
  63271. x *= 100;
  63272. return x;
  63273. };
  63274. /**
  63275. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  63276. * @param hue The hue (H) input.
  63277. * @param saturation The saturation (S) input.
  63278. * @param brightness The brightness (B) input.
  63279. * @result An RGBA color represented as Vector4.
  63280. */
  63281. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  63282. var h = ColorCurves.clamp(hue, 0, 360);
  63283. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  63284. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  63285. if (s === 0) {
  63286. result.r = v;
  63287. result.g = v;
  63288. result.b = v;
  63289. }
  63290. else {
  63291. // sector 0 to 5
  63292. h /= 60;
  63293. var i = Math.floor(h);
  63294. // fractional part of h
  63295. var f = h - i;
  63296. var p = v * (1 - s);
  63297. var q = v * (1 - s * f);
  63298. var t = v * (1 - s * (1 - f));
  63299. switch (i) {
  63300. case 0:
  63301. result.r = v;
  63302. result.g = t;
  63303. result.b = p;
  63304. break;
  63305. case 1:
  63306. result.r = q;
  63307. result.g = v;
  63308. result.b = p;
  63309. break;
  63310. case 2:
  63311. result.r = p;
  63312. result.g = v;
  63313. result.b = t;
  63314. break;
  63315. case 3:
  63316. result.r = p;
  63317. result.g = q;
  63318. result.b = v;
  63319. break;
  63320. case 4:
  63321. result.r = t;
  63322. result.g = p;
  63323. result.b = v;
  63324. break;
  63325. default: // case 5:
  63326. result.r = v;
  63327. result.g = p;
  63328. result.b = q;
  63329. break;
  63330. }
  63331. }
  63332. result.a = 1;
  63333. };
  63334. /**
  63335. * Returns a value clamped between min and max
  63336. * @param value The value to clamp
  63337. * @param min The minimum of value
  63338. * @param max The maximum of value
  63339. * @returns The clamped value.
  63340. */
  63341. ColorCurves.clamp = function (value, min, max) {
  63342. return Math.min(Math.max(value, min), max);
  63343. };
  63344. /**
  63345. * Clones the current color curve instance.
  63346. * @return The cloned curves
  63347. */
  63348. ColorCurves.prototype.clone = function () {
  63349. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  63350. };
  63351. /**
  63352. * Serializes the current color curve instance to a json representation.
  63353. * @return a JSON representation
  63354. */
  63355. ColorCurves.prototype.serialize = function () {
  63356. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63357. };
  63358. /**
  63359. * Parses the color curve from a json representation.
  63360. * @param source the JSON source to parse
  63361. * @return The parsed curves
  63362. */
  63363. ColorCurves.Parse = function (source) {
  63364. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  63365. };
  63366. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63368. ], ColorCurves.prototype, "_globalHue", void 0);
  63369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63371. ], ColorCurves.prototype, "_globalDensity", void 0);
  63372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63374. ], ColorCurves.prototype, "_globalSaturation", void 0);
  63375. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63377. ], ColorCurves.prototype, "_globalExposure", void 0);
  63378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63380. ], ColorCurves.prototype, "_highlightsHue", void 0);
  63381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63383. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  63384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63386. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  63387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63389. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  63390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63392. ], ColorCurves.prototype, "_midtonesHue", void 0);
  63393. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63395. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  63396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63398. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  63399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63401. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  63402. return ColorCurves;
  63403. }());
  63404. // References the dependencies.
  63405. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  63406. /***/ }),
  63407. /***/ "./Materials/effect.ts":
  63408. /*!*****************************!*\
  63409. !*** ./Materials/effect.ts ***!
  63410. \*****************************/
  63411. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  63412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63413. "use strict";
  63414. __webpack_require__.r(__webpack_exports__);
  63415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  63416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  63417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  63418. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  63419. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63420. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  63421. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63422. /**
  63423. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  63424. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  63425. */
  63426. var EffectFallbacks = /** @class */ (function () {
  63427. function EffectFallbacks() {
  63428. this._defines = {};
  63429. this._currentRank = 32;
  63430. this._maxRank = -1;
  63431. }
  63432. /**
  63433. * Removes the fallback from the bound mesh.
  63434. */
  63435. EffectFallbacks.prototype.unBindMesh = function () {
  63436. this._mesh = null;
  63437. };
  63438. /**
  63439. * Adds a fallback on the specified property.
  63440. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  63441. * @param define The name of the define in the shader
  63442. */
  63443. EffectFallbacks.prototype.addFallback = function (rank, define) {
  63444. if (!this._defines[rank]) {
  63445. if (rank < this._currentRank) {
  63446. this._currentRank = rank;
  63447. }
  63448. if (rank > this._maxRank) {
  63449. this._maxRank = rank;
  63450. }
  63451. this._defines[rank] = new Array();
  63452. }
  63453. this._defines[rank].push(define);
  63454. };
  63455. /**
  63456. * Sets the mesh to use CPU skinning when needing to fallback.
  63457. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  63458. * @param mesh The mesh to use the fallbacks.
  63459. */
  63460. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  63461. this._mesh = mesh;
  63462. if (rank < this._currentRank) {
  63463. this._currentRank = rank;
  63464. }
  63465. if (rank > this._maxRank) {
  63466. this._maxRank = rank;
  63467. }
  63468. };
  63469. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  63470. /**
  63471. * Checks to see if more fallbacks are still availible.
  63472. */
  63473. get: function () {
  63474. return this._currentRank <= this._maxRank;
  63475. },
  63476. enumerable: true,
  63477. configurable: true
  63478. });
  63479. /**
  63480. * Removes the defines that shoould be removed when falling back.
  63481. * @param currentDefines defines the current define statements for the shader.
  63482. * @param effect defines the current effect we try to compile
  63483. * @returns The resulting defines with defines of the current rank removed.
  63484. */
  63485. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  63486. // First we try to switch to CPU skinning
  63487. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  63488. this._mesh.computeBonesUsingShaders = false;
  63489. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  63490. effect._bonesComputationForcedToCPU = true;
  63491. var scene = this._mesh.getScene();
  63492. for (var index = 0; index < scene.meshes.length; index++) {
  63493. var otherMesh = scene.meshes[index];
  63494. if (!otherMesh.material) {
  63495. continue;
  63496. }
  63497. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  63498. continue;
  63499. }
  63500. if (otherMesh.material.getEffect() === effect) {
  63501. otherMesh.computeBonesUsingShaders = false;
  63502. }
  63503. else if (otherMesh.subMeshes) {
  63504. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  63505. var subMesh = _a[_i];
  63506. var subMeshEffect = subMesh.effect;
  63507. if (subMeshEffect === effect) {
  63508. otherMesh.computeBonesUsingShaders = false;
  63509. break;
  63510. }
  63511. }
  63512. }
  63513. }
  63514. }
  63515. else {
  63516. var currentFallbacks = this._defines[this._currentRank];
  63517. if (currentFallbacks) {
  63518. for (var index = 0; index < currentFallbacks.length; index++) {
  63519. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  63520. }
  63521. }
  63522. this._currentRank++;
  63523. }
  63524. return currentDefines;
  63525. };
  63526. return EffectFallbacks;
  63527. }());
  63528. /**
  63529. * Options to be used when creating an effect.
  63530. */
  63531. var EffectCreationOptions = /** @class */ (function () {
  63532. function EffectCreationOptions() {
  63533. }
  63534. return EffectCreationOptions;
  63535. }());
  63536. /**
  63537. * Effect containing vertex and fragment shader that can be executed on an object.
  63538. */
  63539. var Effect = /** @class */ (function () {
  63540. /**
  63541. * Instantiates an effect.
  63542. * An effect can be used to create/manage/execute vertex and fragment shaders.
  63543. * @param baseName Name of the effect.
  63544. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  63545. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  63546. * @param samplers List of sampler variables that will be passed to the shader.
  63547. * @param engine Engine to be used to render the effect
  63548. * @param defines Define statements to be added to the shader.
  63549. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  63550. * @param onCompiled Callback that will be called when the shader is compiled.
  63551. * @param onError Callback that will be called if an error occurs during shader compilation.
  63552. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  63553. */
  63554. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  63555. if (samplers === void 0) { samplers = null; }
  63556. if (defines === void 0) { defines = null; }
  63557. if (fallbacks === void 0) { fallbacks = null; }
  63558. if (onCompiled === void 0) { onCompiled = null; }
  63559. if (onError === void 0) { onError = null; }
  63560. var _this = this;
  63561. /**
  63562. * Unique ID of the effect.
  63563. */
  63564. this.uniqueId = 0;
  63565. /**
  63566. * Observable that will be called when the shader is compiled.
  63567. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  63568. */
  63569. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  63570. /**
  63571. * Observable that will be called if an error occurs during shader compilation.
  63572. */
  63573. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  63574. /** @hidden */
  63575. this._bonesComputationForcedToCPU = false;
  63576. this._uniformBuffersNames = {};
  63577. this._samplers = {};
  63578. this._isReady = false;
  63579. this._compilationError = "";
  63580. this._uniforms = {};
  63581. this.name = baseName;
  63582. if (attributesNamesOrOptions.attributes) {
  63583. var options = attributesNamesOrOptions;
  63584. this._engine = uniformsNamesOrEngine;
  63585. this._attributesNames = options.attributes;
  63586. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  63587. this._samplerList = options.samplers.slice();
  63588. this.defines = options.defines;
  63589. this.onError = options.onError;
  63590. this.onCompiled = options.onCompiled;
  63591. this._fallbacks = options.fallbacks;
  63592. this._indexParameters = options.indexParameters;
  63593. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  63594. if (options.uniformBuffersNames) {
  63595. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  63596. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  63597. }
  63598. }
  63599. }
  63600. else {
  63601. this._engine = engine;
  63602. this.defines = (defines == null ? "" : defines);
  63603. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  63604. this._samplerList = samplers ? samplers.slice() : [];
  63605. this._attributesNames = attributesNamesOrOptions;
  63606. this.onError = onError;
  63607. this.onCompiled = onCompiled;
  63608. this._indexParameters = indexParameters;
  63609. this._fallbacks = fallbacks;
  63610. }
  63611. this.uniqueId = Effect._uniqueIdSeed++;
  63612. var vertexSource;
  63613. var fragmentSource;
  63614. if (baseName.vertexElement) {
  63615. vertexSource = document.getElementById(baseName.vertexElement);
  63616. if (!vertexSource) {
  63617. vertexSource = baseName.vertexElement;
  63618. }
  63619. }
  63620. else {
  63621. vertexSource = baseName.vertex || baseName;
  63622. }
  63623. if (baseName.fragmentElement) {
  63624. fragmentSource = document.getElementById(baseName.fragmentElement);
  63625. if (!fragmentSource) {
  63626. fragmentSource = baseName.fragmentElement;
  63627. }
  63628. }
  63629. else {
  63630. fragmentSource = baseName.fragment || baseName;
  63631. }
  63632. this._loadVertexShader(vertexSource, function (vertexCode) {
  63633. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  63634. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  63635. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  63636. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  63637. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  63638. if (baseName) {
  63639. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  63640. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  63641. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  63642. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  63643. }
  63644. else {
  63645. _this._vertexSourceCode = migratedVertexCode;
  63646. _this._fragmentSourceCode = migratedFragmentCode;
  63647. }
  63648. _this._prepareEffect();
  63649. });
  63650. });
  63651. });
  63652. });
  63653. });
  63654. });
  63655. }
  63656. Object.defineProperty(Effect.prototype, "onBindObservable", {
  63657. /**
  63658. * Observable that will be called when effect is bound.
  63659. */
  63660. get: function () {
  63661. if (!this._onBindObservable) {
  63662. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  63663. }
  63664. return this._onBindObservable;
  63665. },
  63666. enumerable: true,
  63667. configurable: true
  63668. });
  63669. Object.defineProperty(Effect.prototype, "key", {
  63670. /**
  63671. * Unique key for this effect
  63672. */
  63673. get: function () {
  63674. return this._key;
  63675. },
  63676. enumerable: true,
  63677. configurable: true
  63678. });
  63679. /**
  63680. * If the effect has been compiled and prepared.
  63681. * @returns if the effect is compiled and prepared.
  63682. */
  63683. Effect.prototype.isReady = function () {
  63684. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  63685. return this._engine._isProgramCompiled(this._program);
  63686. }
  63687. return this._isReady;
  63688. };
  63689. /**
  63690. * The engine the effect was initialized with.
  63691. * @returns the engine.
  63692. */
  63693. Effect.prototype.getEngine = function () {
  63694. return this._engine;
  63695. };
  63696. /**
  63697. * The compiled webGL program for the effect
  63698. * @returns the webGL program.
  63699. */
  63700. Effect.prototype.getProgram = function () {
  63701. return this._program;
  63702. };
  63703. /**
  63704. * The set of names of attribute variables for the shader.
  63705. * @returns An array of attribute names.
  63706. */
  63707. Effect.prototype.getAttributesNames = function () {
  63708. return this._attributesNames;
  63709. };
  63710. /**
  63711. * Returns the attribute at the given index.
  63712. * @param index The index of the attribute.
  63713. * @returns The location of the attribute.
  63714. */
  63715. Effect.prototype.getAttributeLocation = function (index) {
  63716. return this._attributes[index];
  63717. };
  63718. /**
  63719. * Returns the attribute based on the name of the variable.
  63720. * @param name of the attribute to look up.
  63721. * @returns the attribute location.
  63722. */
  63723. Effect.prototype.getAttributeLocationByName = function (name) {
  63724. var index = this._attributesNames.indexOf(name);
  63725. return this._attributes[index];
  63726. };
  63727. /**
  63728. * The number of attributes.
  63729. * @returns the numnber of attributes.
  63730. */
  63731. Effect.prototype.getAttributesCount = function () {
  63732. return this._attributes.length;
  63733. };
  63734. /**
  63735. * Gets the index of a uniform variable.
  63736. * @param uniformName of the uniform to look up.
  63737. * @returns the index.
  63738. */
  63739. Effect.prototype.getUniformIndex = function (uniformName) {
  63740. return this._uniformsNames.indexOf(uniformName);
  63741. };
  63742. /**
  63743. * Returns the attribute based on the name of the variable.
  63744. * @param uniformName of the uniform to look up.
  63745. * @returns the location of the uniform.
  63746. */
  63747. Effect.prototype.getUniform = function (uniformName) {
  63748. return this._uniforms[uniformName];
  63749. };
  63750. /**
  63751. * Returns an array of sampler variable names
  63752. * @returns The array of sampler variable neames.
  63753. */
  63754. Effect.prototype.getSamplers = function () {
  63755. return this._samplerList;
  63756. };
  63757. /**
  63758. * The error from the last compilation.
  63759. * @returns the error string.
  63760. */
  63761. Effect.prototype.getCompilationError = function () {
  63762. return this._compilationError;
  63763. };
  63764. /**
  63765. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  63766. * @param func The callback to be used.
  63767. */
  63768. Effect.prototype.executeWhenCompiled = function (func) {
  63769. var _this = this;
  63770. if (this.isReady()) {
  63771. func(this);
  63772. return;
  63773. }
  63774. this.onCompileObservable.add(function (effect) {
  63775. func(effect);
  63776. });
  63777. if (!this._program || this._program.isParallelCompiled) {
  63778. setTimeout(function () {
  63779. _this._checkIsReady();
  63780. }, 16);
  63781. }
  63782. };
  63783. Effect.prototype._checkIsReady = function () {
  63784. var _this = this;
  63785. if (this.isReady()) {
  63786. return;
  63787. }
  63788. setTimeout(function () {
  63789. _this._checkIsReady();
  63790. }, 16);
  63791. };
  63792. /** @hidden */
  63793. Effect.prototype._loadVertexShader = function (vertex, callback) {
  63794. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  63795. // DOM element ?
  63796. if (vertex instanceof HTMLElement) {
  63797. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  63798. callback(vertexCode);
  63799. return;
  63800. }
  63801. }
  63802. // Base64 encoded ?
  63803. if (vertex.substr(0, 7) === "base64:") {
  63804. var vertexBinary = window.atob(vertex.substr(7));
  63805. callback(vertexBinary);
  63806. return;
  63807. }
  63808. // Is in local store ?
  63809. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  63810. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  63811. return;
  63812. }
  63813. var vertexShaderUrl;
  63814. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  63815. vertexShaderUrl = vertex;
  63816. }
  63817. else {
  63818. vertexShaderUrl = Effect.ShadersRepository + vertex;
  63819. }
  63820. // Vertex shader
  63821. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  63822. };
  63823. /** @hidden */
  63824. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  63825. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  63826. // DOM element ?
  63827. if (fragment instanceof HTMLElement) {
  63828. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  63829. callback(fragmentCode);
  63830. return;
  63831. }
  63832. }
  63833. // Base64 encoded ?
  63834. if (fragment.substr(0, 7) === "base64:") {
  63835. var fragmentBinary = window.atob(fragment.substr(7));
  63836. callback(fragmentBinary);
  63837. return;
  63838. }
  63839. // Is in local store ?
  63840. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  63841. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  63842. return;
  63843. }
  63844. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  63845. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  63846. return;
  63847. }
  63848. var fragmentShaderUrl;
  63849. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  63850. fragmentShaderUrl = fragment;
  63851. }
  63852. else {
  63853. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  63854. }
  63855. // Fragment shader
  63856. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  63857. };
  63858. /** @hidden */
  63859. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  63860. // Rebuild shaders source code
  63861. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  63862. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  63863. vertexCode = prefix + vertexCode;
  63864. fragmentCode = prefix + fragmentCode;
  63865. // Number lines of shaders source code
  63866. var i = 2;
  63867. var regex = /\n/gm;
  63868. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  63869. i = 2;
  63870. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  63871. // Dump shaders name and formatted source code
  63872. if (this.name.vertexElement) {
  63873. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  63874. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  63875. }
  63876. else if (this.name.vertex) {
  63877. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  63878. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  63879. }
  63880. else {
  63881. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  63882. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  63883. }
  63884. };
  63885. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  63886. var preparedSourceCode = this._processPrecision(sourceCode);
  63887. if (this._engine.webGLVersion == 1) {
  63888. callback(preparedSourceCode);
  63889. return;
  63890. }
  63891. // Already converted
  63892. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  63893. callback(preparedSourceCode.replace("#version 300 es", ""));
  63894. return;
  63895. }
  63896. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  63897. // Remove extensions
  63898. // #extension GL_OES_standard_derivatives : enable
  63899. // #extension GL_EXT_shader_texture_lod : enable
  63900. // #extension GL_EXT_frag_depth : enable
  63901. // #extension GL_EXT_draw_buffers : require
  63902. 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;
  63903. var result = preparedSourceCode.replace(regex, "");
  63904. // Migrate to GLSL v300
  63905. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  63906. result = result.replace(/attribute[ \t]/g, "in ");
  63907. result = result.replace(/[ \t]attribute/g, " in");
  63908. result = result.replace(/texture2D\s*\(/g, "texture(");
  63909. if (isFragment) {
  63910. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  63911. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  63912. result = result.replace(/textureCube\s*\(/g, "texture(");
  63913. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  63914. result = result.replace(/gl_FragColor/g, "glFragColor");
  63915. result = result.replace(/gl_FragData/g, "glFragData");
  63916. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  63917. }
  63918. // Add multiview setup to top of file when defined
  63919. var hasMultiviewExtension = this.defines.indexOf("#define MULTIVIEW\n") !== -1;
  63920. if (hasMultiviewExtension && !isFragment) {
  63921. result = "#extension GL_OVR_multiview : require\nlayout (num_views = 2) in;\n" + result;
  63922. }
  63923. callback(result);
  63924. };
  63925. Effect.prototype._processIncludes = function (sourceCode, callback) {
  63926. var _this = this;
  63927. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  63928. var match = regex.exec(sourceCode);
  63929. var returnValue = new String(sourceCode);
  63930. while (match != null) {
  63931. var includeFile = match[1];
  63932. // Uniform declaration
  63933. if (includeFile.indexOf("__decl__") !== -1) {
  63934. includeFile = includeFile.replace(/__decl__/, "");
  63935. if (this._engine.supportsUniformBuffers) {
  63936. includeFile = includeFile.replace(/Vertex/, "Ubo");
  63937. includeFile = includeFile.replace(/Fragment/, "Ubo");
  63938. }
  63939. includeFile = includeFile + "Declaration";
  63940. }
  63941. if (Effect.IncludesShadersStore[includeFile]) {
  63942. // Substitution
  63943. var includeContent = Effect.IncludesShadersStore[includeFile];
  63944. if (match[2]) {
  63945. var splits = match[3].split(",");
  63946. for (var index = 0; index < splits.length; index += 2) {
  63947. var source = new RegExp(splits[index], "g");
  63948. var dest = splits[index + 1];
  63949. includeContent = includeContent.replace(source, dest);
  63950. }
  63951. }
  63952. if (match[4]) {
  63953. var indexString = match[5];
  63954. if (indexString.indexOf("..") !== -1) {
  63955. var indexSplits = indexString.split("..");
  63956. var minIndex = parseInt(indexSplits[0]);
  63957. var maxIndex = parseInt(indexSplits[1]);
  63958. var sourceIncludeContent = includeContent.slice(0);
  63959. includeContent = "";
  63960. if (isNaN(maxIndex)) {
  63961. maxIndex = this._indexParameters[indexSplits[1]];
  63962. }
  63963. for (var i = minIndex; i < maxIndex; i++) {
  63964. if (!this._engine.supportsUniformBuffers) {
  63965. // Ubo replacement
  63966. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  63967. return p1 + "{X}";
  63968. });
  63969. }
  63970. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  63971. }
  63972. }
  63973. else {
  63974. if (!this._engine.supportsUniformBuffers) {
  63975. // Ubo replacement
  63976. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  63977. return p1 + "{X}";
  63978. });
  63979. }
  63980. includeContent = includeContent.replace(/\{X\}/g, indexString);
  63981. }
  63982. }
  63983. // Replace
  63984. returnValue = returnValue.replace(match[0], includeContent);
  63985. }
  63986. else {
  63987. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  63988. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  63989. Effect.IncludesShadersStore[includeFile] = fileContent;
  63990. _this._processIncludes(returnValue, callback);
  63991. });
  63992. return;
  63993. }
  63994. match = regex.exec(sourceCode);
  63995. }
  63996. callback(returnValue);
  63997. };
  63998. Effect.prototype._processPrecision = function (source) {
  63999. var shouldUseHighPrecisionShader = this._engine._shouldUseHighPrecisionShader;
  64000. if (source.indexOf("precision highp float") === -1) {
  64001. if (!shouldUseHighPrecisionShader) {
  64002. source = "precision mediump float;\n" + source;
  64003. }
  64004. else {
  64005. source = "precision highp float;\n" + source;
  64006. }
  64007. }
  64008. else {
  64009. if (!shouldUseHighPrecisionShader) { // Moving highp to mediump
  64010. source = source.replace("precision highp float", "precision mediump float");
  64011. }
  64012. }
  64013. return source;
  64014. };
  64015. /**
  64016. * Recompiles the webGL program
  64017. * @param vertexSourceCode The source code for the vertex shader.
  64018. * @param fragmentSourceCode The source code for the fragment shader.
  64019. * @param onCompiled Callback called when completed.
  64020. * @param onError Callback called on error.
  64021. * @hidden
  64022. */
  64023. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  64024. var _this = this;
  64025. this._isReady = false;
  64026. this._vertexSourceCodeOverride = vertexSourceCode;
  64027. this._fragmentSourceCodeOverride = fragmentSourceCode;
  64028. this.onError = function (effect, error) {
  64029. if (onError) {
  64030. onError(error);
  64031. }
  64032. };
  64033. this.onCompiled = function () {
  64034. var scenes = _this.getEngine().scenes;
  64035. for (var i = 0; i < scenes.length; i++) {
  64036. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  64037. }
  64038. if (onCompiled) {
  64039. onCompiled(_this._program);
  64040. }
  64041. };
  64042. this._fallbacks = null;
  64043. this._prepareEffect();
  64044. };
  64045. /**
  64046. * Gets the uniform locations of the the specified variable names
  64047. * @param names THe names of the variables to lookup.
  64048. * @returns Array of locations in the same order as variable names.
  64049. */
  64050. Effect.prototype.getSpecificUniformLocations = function (names) {
  64051. var engine = this._engine;
  64052. return engine.getUniforms(this._program, names);
  64053. };
  64054. /**
  64055. * Prepares the effect
  64056. * @hidden
  64057. */
  64058. Effect.prototype._prepareEffect = function () {
  64059. var _this = this;
  64060. var attributesNames = this._attributesNames;
  64061. var defines = this.defines;
  64062. var fallbacks = this._fallbacks;
  64063. this._valueCache = {};
  64064. var previousProgram = this._program;
  64065. try {
  64066. var engine_1 = this._engine;
  64067. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  64068. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  64069. }
  64070. else {
  64071. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  64072. }
  64073. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  64074. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  64075. if (engine_1.supportsUniformBuffers) {
  64076. for (var name in _this._uniformBuffersNames) {
  64077. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  64078. }
  64079. }
  64080. var uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  64081. uniforms.forEach(function (uniform, index) {
  64082. _this._uniforms[_this._uniformsNames[index]] = uniform;
  64083. });
  64084. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  64085. var index;
  64086. for (index = 0; index < _this._samplerList.length; index++) {
  64087. var sampler = _this.getUniform(_this._samplerList[index]);
  64088. if (sampler == null) {
  64089. _this._samplerList.splice(index, 1);
  64090. index--;
  64091. }
  64092. }
  64093. _this._samplerList.forEach(function (name, index) {
  64094. _this._samplers[name] = index;
  64095. });
  64096. engine_1.bindSamplers(_this);
  64097. _this._compilationError = "";
  64098. _this._isReady = true;
  64099. if (_this.onCompiled) {
  64100. _this.onCompiled(_this);
  64101. }
  64102. _this.onCompileObservable.notifyObservers(_this);
  64103. _this.onCompileObservable.clear();
  64104. // Unbind mesh reference in fallbacks
  64105. if (_this._fallbacks) {
  64106. _this._fallbacks.unBindMesh();
  64107. }
  64108. if (previousProgram) {
  64109. _this.getEngine()._deleteProgram(previousProgram);
  64110. }
  64111. });
  64112. if (this._program.isParallelCompiled) {
  64113. this._checkIsReady();
  64114. }
  64115. }
  64116. catch (e) {
  64117. this._compilationError = e.message;
  64118. // Let's go through fallbacks then
  64119. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  64120. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  64121. return " " + uniform;
  64122. }));
  64123. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  64124. return " " + attribute;
  64125. }));
  64126. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  64127. if (previousProgram) {
  64128. this._program = previousProgram;
  64129. this._isReady = true;
  64130. if (this.onError) {
  64131. this.onError(this, this._compilationError);
  64132. }
  64133. this.onErrorObservable.notifyObservers(this);
  64134. }
  64135. if (fallbacks && fallbacks.isMoreFallbacks) {
  64136. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  64137. this.defines = fallbacks.reduce(this.defines, this);
  64138. this._prepareEffect();
  64139. }
  64140. else { // Sorry we did everything we can
  64141. if (this.onError) {
  64142. this.onError(this, this._compilationError);
  64143. }
  64144. this.onErrorObservable.notifyObservers(this);
  64145. this.onErrorObservable.clear();
  64146. // Unbind mesh reference in fallbacks
  64147. if (this._fallbacks) {
  64148. this._fallbacks.unBindMesh();
  64149. }
  64150. }
  64151. }
  64152. };
  64153. Object.defineProperty(Effect.prototype, "isSupported", {
  64154. /**
  64155. * Checks if the effect is supported. (Must be called after compilation)
  64156. */
  64157. get: function () {
  64158. return this._compilationError === "";
  64159. },
  64160. enumerable: true,
  64161. configurable: true
  64162. });
  64163. /**
  64164. * Binds a texture to the engine to be used as output of the shader.
  64165. * @param channel Name of the output variable.
  64166. * @param texture Texture to bind.
  64167. * @hidden
  64168. */
  64169. Effect.prototype._bindTexture = function (channel, texture) {
  64170. this._engine._bindTexture(this._samplers[channel], texture);
  64171. };
  64172. /**
  64173. * Sets a texture on the engine to be used in the shader.
  64174. * @param channel Name of the sampler variable.
  64175. * @param texture Texture to set.
  64176. */
  64177. Effect.prototype.setTexture = function (channel, texture) {
  64178. this._engine.setTexture(this._samplers[channel], this._uniforms[channel], texture);
  64179. };
  64180. /**
  64181. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  64182. * @param channel Name of the sampler variable.
  64183. * @param texture Texture to set.
  64184. */
  64185. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  64186. this._engine.setDepthStencilTexture(this._samplers[channel], this._uniforms[channel], texture);
  64187. };
  64188. /**
  64189. * Sets an array of textures on the engine to be used in the shader.
  64190. * @param channel Name of the variable.
  64191. * @param textures Textures to set.
  64192. */
  64193. Effect.prototype.setTextureArray = function (channel, textures) {
  64194. var exName = channel + "Ex";
  64195. if (this._samplerList.indexOf(exName) === -1) {
  64196. var initialPos = this._samplers[channel];
  64197. for (var index = 1; index < textures.length; index++) {
  64198. this._samplerList.splice(initialPos + index, 0, exName);
  64199. this._samplers[exName] = initialPos + index;
  64200. }
  64201. }
  64202. this._engine.setTextureArray(this._samplers[channel], this._uniforms[channel], textures);
  64203. };
  64204. /**
  64205. * 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)
  64206. * @param channel Name of the sampler variable.
  64207. * @param postProcess Post process to get the input texture from.
  64208. */
  64209. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  64210. this._engine.setTextureFromPostProcess(this._samplers[channel], postProcess);
  64211. };
  64212. /**
  64213. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  64214. * 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)
  64215. * @param channel Name of the sampler variable.
  64216. * @param postProcess Post process to get the output texture from.
  64217. */
  64218. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  64219. this._engine.setTextureFromPostProcessOutput(this._samplers[channel], postProcess);
  64220. };
  64221. /** @hidden */
  64222. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  64223. var cache = this._valueCache[uniformName];
  64224. var flag = matrix.updateFlag;
  64225. if (cache !== undefined && cache === flag) {
  64226. return false;
  64227. }
  64228. this._valueCache[uniformName] = flag;
  64229. return true;
  64230. };
  64231. /** @hidden */
  64232. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  64233. var cache = this._valueCache[uniformName];
  64234. if (!cache) {
  64235. cache = [x, y];
  64236. this._valueCache[uniformName] = cache;
  64237. return true;
  64238. }
  64239. var changed = false;
  64240. if (cache[0] !== x) {
  64241. cache[0] = x;
  64242. changed = true;
  64243. }
  64244. if (cache[1] !== y) {
  64245. cache[1] = y;
  64246. changed = true;
  64247. }
  64248. return changed;
  64249. };
  64250. /** @hidden */
  64251. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  64252. var cache = this._valueCache[uniformName];
  64253. if (!cache) {
  64254. cache = [x, y, z];
  64255. this._valueCache[uniformName] = cache;
  64256. return true;
  64257. }
  64258. var changed = false;
  64259. if (cache[0] !== x) {
  64260. cache[0] = x;
  64261. changed = true;
  64262. }
  64263. if (cache[1] !== y) {
  64264. cache[1] = y;
  64265. changed = true;
  64266. }
  64267. if (cache[2] !== z) {
  64268. cache[2] = z;
  64269. changed = true;
  64270. }
  64271. return changed;
  64272. };
  64273. /** @hidden */
  64274. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  64275. var cache = this._valueCache[uniformName];
  64276. if (!cache) {
  64277. cache = [x, y, z, w];
  64278. this._valueCache[uniformName] = cache;
  64279. return true;
  64280. }
  64281. var changed = false;
  64282. if (cache[0] !== x) {
  64283. cache[0] = x;
  64284. changed = true;
  64285. }
  64286. if (cache[1] !== y) {
  64287. cache[1] = y;
  64288. changed = true;
  64289. }
  64290. if (cache[2] !== z) {
  64291. cache[2] = z;
  64292. changed = true;
  64293. }
  64294. if (cache[3] !== w) {
  64295. cache[3] = w;
  64296. changed = true;
  64297. }
  64298. return changed;
  64299. };
  64300. /**
  64301. * Binds a buffer to a uniform.
  64302. * @param buffer Buffer to bind.
  64303. * @param name Name of the uniform variable to bind to.
  64304. */
  64305. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  64306. var bufferName = this._uniformBuffersNames[name];
  64307. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  64308. return;
  64309. }
  64310. Effect._baseCache[bufferName] = buffer;
  64311. this._engine.bindUniformBufferBase(buffer, bufferName);
  64312. };
  64313. /**
  64314. * Binds block to a uniform.
  64315. * @param blockName Name of the block to bind.
  64316. * @param index Index to bind.
  64317. */
  64318. Effect.prototype.bindUniformBlock = function (blockName, index) {
  64319. this._engine.bindUniformBlock(this._program, blockName, index);
  64320. };
  64321. /**
  64322. * Sets an interger value on a uniform variable.
  64323. * @param uniformName Name of the variable.
  64324. * @param value Value to be set.
  64325. * @returns this effect.
  64326. */
  64327. Effect.prototype.setInt = function (uniformName, value) {
  64328. var cache = this._valueCache[uniformName];
  64329. if (cache !== undefined && cache === value) {
  64330. return this;
  64331. }
  64332. this._valueCache[uniformName] = value;
  64333. this._engine.setInt(this._uniforms[uniformName], value);
  64334. return this;
  64335. };
  64336. /**
  64337. * Sets an int array on a uniform variable.
  64338. * @param uniformName Name of the variable.
  64339. * @param array array to be set.
  64340. * @returns this effect.
  64341. */
  64342. Effect.prototype.setIntArray = function (uniformName, array) {
  64343. this._valueCache[uniformName] = null;
  64344. this._engine.setIntArray(this._uniforms[uniformName], array);
  64345. return this;
  64346. };
  64347. /**
  64348. * 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)
  64349. * @param uniformName Name of the variable.
  64350. * @param array array to be set.
  64351. * @returns this effect.
  64352. */
  64353. Effect.prototype.setIntArray2 = function (uniformName, array) {
  64354. this._valueCache[uniformName] = null;
  64355. this._engine.setIntArray2(this._uniforms[uniformName], array);
  64356. return this;
  64357. };
  64358. /**
  64359. * 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)
  64360. * @param uniformName Name of the variable.
  64361. * @param array array to be set.
  64362. * @returns this effect.
  64363. */
  64364. Effect.prototype.setIntArray3 = function (uniformName, array) {
  64365. this._valueCache[uniformName] = null;
  64366. this._engine.setIntArray3(this._uniforms[uniformName], array);
  64367. return this;
  64368. };
  64369. /**
  64370. * 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)
  64371. * @param uniformName Name of the variable.
  64372. * @param array array to be set.
  64373. * @returns this effect.
  64374. */
  64375. Effect.prototype.setIntArray4 = function (uniformName, array) {
  64376. this._valueCache[uniformName] = null;
  64377. this._engine.setIntArray4(this._uniforms[uniformName], array);
  64378. return this;
  64379. };
  64380. /**
  64381. * Sets an float array on a uniform variable.
  64382. * @param uniformName Name of the variable.
  64383. * @param array array to be set.
  64384. * @returns this effect.
  64385. */
  64386. Effect.prototype.setFloatArray = function (uniformName, array) {
  64387. this._valueCache[uniformName] = null;
  64388. this._engine.setFloatArray(this._uniforms[uniformName], array);
  64389. return this;
  64390. };
  64391. /**
  64392. * 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)
  64393. * @param uniformName Name of the variable.
  64394. * @param array array to be set.
  64395. * @returns this effect.
  64396. */
  64397. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  64398. this._valueCache[uniformName] = null;
  64399. this._engine.setFloatArray2(this._uniforms[uniformName], array);
  64400. return this;
  64401. };
  64402. /**
  64403. * 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)
  64404. * @param uniformName Name of the variable.
  64405. * @param array array to be set.
  64406. * @returns this effect.
  64407. */
  64408. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  64409. this._valueCache[uniformName] = null;
  64410. this._engine.setFloatArray3(this._uniforms[uniformName], array);
  64411. return this;
  64412. };
  64413. /**
  64414. * 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)
  64415. * @param uniformName Name of the variable.
  64416. * @param array array to be set.
  64417. * @returns this effect.
  64418. */
  64419. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  64420. this._valueCache[uniformName] = null;
  64421. this._engine.setFloatArray4(this._uniforms[uniformName], array);
  64422. return this;
  64423. };
  64424. /**
  64425. * Sets an array on a uniform variable.
  64426. * @param uniformName Name of the variable.
  64427. * @param array array to be set.
  64428. * @returns this effect.
  64429. */
  64430. Effect.prototype.setArray = function (uniformName, array) {
  64431. this._valueCache[uniformName] = null;
  64432. this._engine.setArray(this._uniforms[uniformName], array);
  64433. return this;
  64434. };
  64435. /**
  64436. * 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)
  64437. * @param uniformName Name of the variable.
  64438. * @param array array to be set.
  64439. * @returns this effect.
  64440. */
  64441. Effect.prototype.setArray2 = function (uniformName, array) {
  64442. this._valueCache[uniformName] = null;
  64443. this._engine.setArray2(this._uniforms[uniformName], array);
  64444. return this;
  64445. };
  64446. /**
  64447. * 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)
  64448. * @param uniformName Name of the variable.
  64449. * @param array array to be set.
  64450. * @returns this effect.
  64451. */
  64452. Effect.prototype.setArray3 = function (uniformName, array) {
  64453. this._valueCache[uniformName] = null;
  64454. this._engine.setArray3(this._uniforms[uniformName], array);
  64455. return this;
  64456. };
  64457. /**
  64458. * 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)
  64459. * @param uniformName Name of the variable.
  64460. * @param array array to be set.
  64461. * @returns this effect.
  64462. */
  64463. Effect.prototype.setArray4 = function (uniformName, array) {
  64464. this._valueCache[uniformName] = null;
  64465. this._engine.setArray4(this._uniforms[uniformName], array);
  64466. return this;
  64467. };
  64468. /**
  64469. * Sets matrices on a uniform variable.
  64470. * @param uniformName Name of the variable.
  64471. * @param matrices matrices to be set.
  64472. * @returns this effect.
  64473. */
  64474. Effect.prototype.setMatrices = function (uniformName, matrices) {
  64475. if (!matrices) {
  64476. return this;
  64477. }
  64478. this._valueCache[uniformName] = null;
  64479. this._engine.setMatrices(this._uniforms[uniformName], matrices);
  64480. return this;
  64481. };
  64482. /**
  64483. * Sets matrix on a uniform variable.
  64484. * @param uniformName Name of the variable.
  64485. * @param matrix matrix to be set.
  64486. * @returns this effect.
  64487. */
  64488. Effect.prototype.setMatrix = function (uniformName, matrix) {
  64489. if (this._cacheMatrix(uniformName, matrix)) {
  64490. this._engine.setMatrix(this._uniforms[uniformName], matrix);
  64491. }
  64492. return this;
  64493. };
  64494. /**
  64495. * 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)
  64496. * @param uniformName Name of the variable.
  64497. * @param matrix matrix to be set.
  64498. * @returns this effect.
  64499. */
  64500. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  64501. this._valueCache[uniformName] = null;
  64502. this._engine.setMatrix3x3(this._uniforms[uniformName], matrix);
  64503. return this;
  64504. };
  64505. /**
  64506. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  64507. * @param uniformName Name of the variable.
  64508. * @param matrix matrix to be set.
  64509. * @returns this effect.
  64510. */
  64511. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  64512. this._valueCache[uniformName] = null;
  64513. this._engine.setMatrix2x2(this._uniforms[uniformName], matrix);
  64514. return this;
  64515. };
  64516. /**
  64517. * Sets a float on a uniform variable.
  64518. * @param uniformName Name of the variable.
  64519. * @param value value to be set.
  64520. * @returns this effect.
  64521. */
  64522. Effect.prototype.setFloat = function (uniformName, value) {
  64523. var cache = this._valueCache[uniformName];
  64524. if (cache !== undefined && cache === value) {
  64525. return this;
  64526. }
  64527. this._valueCache[uniformName] = value;
  64528. this._engine.setFloat(this._uniforms[uniformName], value);
  64529. return this;
  64530. };
  64531. /**
  64532. * Sets a boolean on a uniform variable.
  64533. * @param uniformName Name of the variable.
  64534. * @param bool value to be set.
  64535. * @returns this effect.
  64536. */
  64537. Effect.prototype.setBool = function (uniformName, bool) {
  64538. var cache = this._valueCache[uniformName];
  64539. if (cache !== undefined && cache === bool) {
  64540. return this;
  64541. }
  64542. this._valueCache[uniformName] = bool;
  64543. this._engine.setBool(this._uniforms[uniformName], bool ? 1 : 0);
  64544. return this;
  64545. };
  64546. /**
  64547. * Sets a Vector2 on a uniform variable.
  64548. * @param uniformName Name of the variable.
  64549. * @param vector2 vector2 to be set.
  64550. * @returns this effect.
  64551. */
  64552. Effect.prototype.setVector2 = function (uniformName, vector2) {
  64553. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  64554. this._engine.setFloat2(this._uniforms[uniformName], vector2.x, vector2.y);
  64555. }
  64556. return this;
  64557. };
  64558. /**
  64559. * Sets a float2 on a uniform variable.
  64560. * @param uniformName Name of the variable.
  64561. * @param x First float in float2.
  64562. * @param y Second float in float2.
  64563. * @returns this effect.
  64564. */
  64565. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  64566. if (this._cacheFloat2(uniformName, x, y)) {
  64567. this._engine.setFloat2(this._uniforms[uniformName], x, y);
  64568. }
  64569. return this;
  64570. };
  64571. /**
  64572. * Sets a Vector3 on a uniform variable.
  64573. * @param uniformName Name of the variable.
  64574. * @param vector3 Value to be set.
  64575. * @returns this effect.
  64576. */
  64577. Effect.prototype.setVector3 = function (uniformName, vector3) {
  64578. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  64579. this._engine.setFloat3(this._uniforms[uniformName], vector3.x, vector3.y, vector3.z);
  64580. }
  64581. return this;
  64582. };
  64583. /**
  64584. * Sets a float3 on a uniform variable.
  64585. * @param uniformName Name of the variable.
  64586. * @param x First float in float3.
  64587. * @param y Second float in float3.
  64588. * @param z Third float in float3.
  64589. * @returns this effect.
  64590. */
  64591. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  64592. if (this._cacheFloat3(uniformName, x, y, z)) {
  64593. this._engine.setFloat3(this._uniforms[uniformName], x, y, z);
  64594. }
  64595. return this;
  64596. };
  64597. /**
  64598. * Sets a Vector4 on a uniform variable.
  64599. * @param uniformName Name of the variable.
  64600. * @param vector4 Value to be set.
  64601. * @returns this effect.
  64602. */
  64603. Effect.prototype.setVector4 = function (uniformName, vector4) {
  64604. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  64605. this._engine.setFloat4(this._uniforms[uniformName], vector4.x, vector4.y, vector4.z, vector4.w);
  64606. }
  64607. return this;
  64608. };
  64609. /**
  64610. * Sets a float4 on a uniform variable.
  64611. * @param uniformName Name of the variable.
  64612. * @param x First float in float4.
  64613. * @param y Second float in float4.
  64614. * @param z Third float in float4.
  64615. * @param w Fourth float in float4.
  64616. * @returns this effect.
  64617. */
  64618. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  64619. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  64620. this._engine.setFloat4(this._uniforms[uniformName], x, y, z, w);
  64621. }
  64622. return this;
  64623. };
  64624. /**
  64625. * Sets a Color3 on a uniform variable.
  64626. * @param uniformName Name of the variable.
  64627. * @param color3 Value to be set.
  64628. * @returns this effect.
  64629. */
  64630. Effect.prototype.setColor3 = function (uniformName, color3) {
  64631. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  64632. this._engine.setColor3(this._uniforms[uniformName], color3);
  64633. }
  64634. return this;
  64635. };
  64636. /**
  64637. * Sets a Color4 on a uniform variable.
  64638. * @param uniformName Name of the variable.
  64639. * @param color3 Value to be set.
  64640. * @param alpha Alpha value to be set.
  64641. * @returns this effect.
  64642. */
  64643. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  64644. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  64645. this._engine.setColor4(this._uniforms[uniformName], color3, alpha);
  64646. }
  64647. return this;
  64648. };
  64649. /**
  64650. * Sets a Color4 on a uniform variable
  64651. * @param uniformName defines the name of the variable
  64652. * @param color4 defines the value to be set
  64653. * @returns this effect.
  64654. */
  64655. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  64656. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  64657. this._engine.setDirectColor4(this._uniforms[uniformName], color4);
  64658. }
  64659. return this;
  64660. };
  64661. /** Release all associated resources */
  64662. Effect.prototype.dispose = function () {
  64663. this._engine._releaseEffect(this);
  64664. };
  64665. /**
  64666. * This function will add a new shader to the shader store
  64667. * @param name the name of the shader
  64668. * @param pixelShader optional pixel shader content
  64669. * @param vertexShader optional vertex shader content
  64670. */
  64671. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  64672. if (pixelShader) {
  64673. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  64674. }
  64675. if (vertexShader) {
  64676. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  64677. }
  64678. };
  64679. /**
  64680. * Resets the cache of effects.
  64681. */
  64682. Effect.ResetCache = function () {
  64683. Effect._baseCache = {};
  64684. };
  64685. /**
  64686. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  64687. */
  64688. Effect.ShadersRepository = "src/Shaders/";
  64689. Effect._uniqueIdSeed = 0;
  64690. Effect._baseCache = {};
  64691. /**
  64692. * Store of each shader (The can be looked up using effect.key)
  64693. */
  64694. Effect.ShadersStore = {};
  64695. /**
  64696. * Store of each included file for a shader (The can be looked up using effect.key)
  64697. */
  64698. Effect.IncludesShadersStore = {};
  64699. return Effect;
  64700. }());
  64701. /***/ }),
  64702. /***/ "./Materials/fresnelParameters.ts":
  64703. /*!****************************************!*\
  64704. !*** ./Materials/fresnelParameters.ts ***!
  64705. \****************************************/
  64706. /*! exports provided: FresnelParameters */
  64707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64708. "use strict";
  64709. __webpack_require__.r(__webpack_exports__);
  64710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  64711. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  64712. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64713. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  64714. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64715. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64716. /**
  64717. * This represents all the required information to add a fresnel effect on a material:
  64718. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  64719. */
  64720. var FresnelParameters = /** @class */ (function () {
  64721. function FresnelParameters() {
  64722. this._isEnabled = true;
  64723. /**
  64724. * Define the color used on edges (grazing angle)
  64725. */
  64726. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  64727. /**
  64728. * Define the color used on center
  64729. */
  64730. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  64731. /**
  64732. * Define bias applied to computed fresnel term
  64733. */
  64734. this.bias = 0;
  64735. /**
  64736. * Defined the power exponent applied to fresnel term
  64737. */
  64738. this.power = 1;
  64739. }
  64740. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  64741. /**
  64742. * Define if the fresnel effect is enable or not.
  64743. */
  64744. get: function () {
  64745. return this._isEnabled;
  64746. },
  64747. set: function (value) {
  64748. if (this._isEnabled === value) {
  64749. return;
  64750. }
  64751. this._isEnabled = value;
  64752. _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);
  64753. },
  64754. enumerable: true,
  64755. configurable: true
  64756. });
  64757. /**
  64758. * Clones the current fresnel and its valuues
  64759. * @returns a clone fresnel configuration
  64760. */
  64761. FresnelParameters.prototype.clone = function () {
  64762. var newFresnelParameters = new FresnelParameters();
  64763. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  64764. return newFresnelParameters;
  64765. };
  64766. /**
  64767. * Serializes the current fresnel parameters to a JSON representation.
  64768. * @return the JSON serialization
  64769. */
  64770. FresnelParameters.prototype.serialize = function () {
  64771. var serializationObject = {};
  64772. serializationObject.isEnabled = this.isEnabled;
  64773. serializationObject.leftColor = this.leftColor.asArray();
  64774. serializationObject.rightColor = this.rightColor.asArray();
  64775. serializationObject.bias = this.bias;
  64776. serializationObject.power = this.power;
  64777. return serializationObject;
  64778. };
  64779. /**
  64780. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  64781. * @param parsedFresnelParameters Define the JSON representation
  64782. * @returns the parsed parameters
  64783. */
  64784. FresnelParameters.Parse = function (parsedFresnelParameters) {
  64785. var fresnelParameters = new FresnelParameters();
  64786. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  64787. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  64788. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  64789. fresnelParameters.bias = parsedFresnelParameters.bias;
  64790. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  64791. return fresnelParameters;
  64792. };
  64793. return FresnelParameters;
  64794. }());
  64795. // References the dependencies.
  64796. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  64797. /***/ }),
  64798. /***/ "./Materials/imageProcessingConfiguration.ts":
  64799. /*!***************************************************!*\
  64800. !*** ./Materials/imageProcessingConfiguration.ts ***!
  64801. \***************************************************/
  64802. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  64803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64804. "use strict";
  64805. __webpack_require__.r(__webpack_exports__);
  64806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  64807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  64808. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64809. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64810. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  64811. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  64812. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64813. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  64814. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  64815. /**
  64816. * @hidden
  64817. */
  64818. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  64819. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  64820. function ImageProcessingConfigurationDefines() {
  64821. var _this = _super.call(this) || this;
  64822. _this.IMAGEPROCESSING = false;
  64823. _this.VIGNETTE = false;
  64824. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  64825. _this.VIGNETTEBLENDMODEOPAQUE = false;
  64826. _this.TONEMAPPING = false;
  64827. _this.TONEMAPPING_ACES = false;
  64828. _this.CONTRAST = false;
  64829. _this.COLORCURVES = false;
  64830. _this.COLORGRADING = false;
  64831. _this.COLORGRADING3D = false;
  64832. _this.SAMPLER3DGREENDEPTH = false;
  64833. _this.SAMPLER3DBGRMAP = false;
  64834. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  64835. _this.EXPOSURE = false;
  64836. _this.rebuild();
  64837. return _this;
  64838. }
  64839. return ImageProcessingConfigurationDefines;
  64840. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  64841. /**
  64842. * This groups together the common properties used for image processing either in direct forward pass
  64843. * or through post processing effect depending on the use of the image processing pipeline in your scene
  64844. * or not.
  64845. */
  64846. var ImageProcessingConfiguration = /** @class */ (function () {
  64847. function ImageProcessingConfiguration() {
  64848. /**
  64849. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  64850. */
  64851. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  64852. this._colorCurvesEnabled = false;
  64853. this._colorGradingEnabled = false;
  64854. this._colorGradingWithGreenDepth = true;
  64855. this._colorGradingBGR = true;
  64856. /** @hidden */
  64857. this._exposure = 1.0;
  64858. this._toneMappingEnabled = false;
  64859. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  64860. this._contrast = 1.0;
  64861. /**
  64862. * Vignette stretch size.
  64863. */
  64864. this.vignetteStretch = 0;
  64865. /**
  64866. * Vignette centre X Offset.
  64867. */
  64868. this.vignetteCentreX = 0;
  64869. /**
  64870. * Vignette centre Y Offset.
  64871. */
  64872. this.vignetteCentreY = 0;
  64873. /**
  64874. * Vignette weight or intensity of the vignette effect.
  64875. */
  64876. this.vignetteWeight = 1.5;
  64877. /**
  64878. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  64879. * if vignetteEnabled is set to true.
  64880. */
  64881. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  64882. /**
  64883. * Camera field of view used by the Vignette effect.
  64884. */
  64885. this.vignetteCameraFov = 0.5;
  64886. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  64887. this._vignetteEnabled = false;
  64888. this._applyByPostProcess = false;
  64889. this._isEnabled = true;
  64890. /**
  64891. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  64892. */
  64893. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  64894. }
  64895. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  64896. /**
  64897. * Gets wether the color curves effect is enabled.
  64898. */
  64899. get: function () {
  64900. return this._colorCurvesEnabled;
  64901. },
  64902. /**
  64903. * Sets wether the color curves effect is enabled.
  64904. */
  64905. set: function (value) {
  64906. if (this._colorCurvesEnabled === value) {
  64907. return;
  64908. }
  64909. this._colorCurvesEnabled = value;
  64910. this._updateParameters();
  64911. },
  64912. enumerable: true,
  64913. configurable: true
  64914. });
  64915. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  64916. /**
  64917. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  64918. */
  64919. get: function () {
  64920. return this._colorGradingTexture;
  64921. },
  64922. /**
  64923. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  64924. */
  64925. set: function (value) {
  64926. if (this._colorGradingTexture === value) {
  64927. return;
  64928. }
  64929. this._colorGradingTexture = value;
  64930. this._updateParameters();
  64931. },
  64932. enumerable: true,
  64933. configurable: true
  64934. });
  64935. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  64936. /**
  64937. * Gets wether the color grading effect is enabled.
  64938. */
  64939. get: function () {
  64940. return this._colorGradingEnabled;
  64941. },
  64942. /**
  64943. * Sets wether the color grading effect is enabled.
  64944. */
  64945. set: function (value) {
  64946. if (this._colorGradingEnabled === value) {
  64947. return;
  64948. }
  64949. this._colorGradingEnabled = value;
  64950. this._updateParameters();
  64951. },
  64952. enumerable: true,
  64953. configurable: true
  64954. });
  64955. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  64956. /**
  64957. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  64958. */
  64959. get: function () {
  64960. return this._colorGradingWithGreenDepth;
  64961. },
  64962. /**
  64963. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  64964. */
  64965. set: function (value) {
  64966. if (this._colorGradingWithGreenDepth === value) {
  64967. return;
  64968. }
  64969. this._colorGradingWithGreenDepth = value;
  64970. this._updateParameters();
  64971. },
  64972. enumerable: true,
  64973. configurable: true
  64974. });
  64975. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  64976. /**
  64977. * Gets wether the color grading texture contains BGR values.
  64978. */
  64979. get: function () {
  64980. return this._colorGradingBGR;
  64981. },
  64982. /**
  64983. * Sets wether the color grading texture contains BGR values.
  64984. */
  64985. set: function (value) {
  64986. if (this._colorGradingBGR === value) {
  64987. return;
  64988. }
  64989. this._colorGradingBGR = value;
  64990. this._updateParameters();
  64991. },
  64992. enumerable: true,
  64993. configurable: true
  64994. });
  64995. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  64996. /**
  64997. * Gets the Exposure used in the effect.
  64998. */
  64999. get: function () {
  65000. return this._exposure;
  65001. },
  65002. /**
  65003. * Sets the Exposure used in the effect.
  65004. */
  65005. set: function (value) {
  65006. if (this._exposure === value) {
  65007. return;
  65008. }
  65009. this._exposure = value;
  65010. this._updateParameters();
  65011. },
  65012. enumerable: true,
  65013. configurable: true
  65014. });
  65015. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  65016. /**
  65017. * Gets wether the tone mapping effect is enabled.
  65018. */
  65019. get: function () {
  65020. return this._toneMappingEnabled;
  65021. },
  65022. /**
  65023. * Sets wether the tone mapping effect is enabled.
  65024. */
  65025. set: function (value) {
  65026. if (this._toneMappingEnabled === value) {
  65027. return;
  65028. }
  65029. this._toneMappingEnabled = value;
  65030. this._updateParameters();
  65031. },
  65032. enumerable: true,
  65033. configurable: true
  65034. });
  65035. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  65036. /**
  65037. * Gets the type of tone mapping effect.
  65038. */
  65039. get: function () {
  65040. return this._toneMappingType;
  65041. },
  65042. /**
  65043. * Sets the type of tone mapping effect used in BabylonJS.
  65044. */
  65045. set: function (value) {
  65046. if (this._toneMappingType === value) {
  65047. return;
  65048. }
  65049. this._toneMappingType = value;
  65050. this._updateParameters();
  65051. },
  65052. enumerable: true,
  65053. configurable: true
  65054. });
  65055. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  65056. /**
  65057. * Gets the contrast used in the effect.
  65058. */
  65059. get: function () {
  65060. return this._contrast;
  65061. },
  65062. /**
  65063. * Sets the contrast used in the effect.
  65064. */
  65065. set: function (value) {
  65066. if (this._contrast === value) {
  65067. return;
  65068. }
  65069. this._contrast = value;
  65070. this._updateParameters();
  65071. },
  65072. enumerable: true,
  65073. configurable: true
  65074. });
  65075. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  65076. /**
  65077. * Gets the vignette blend mode allowing different kind of effect.
  65078. */
  65079. get: function () {
  65080. return this._vignetteBlendMode;
  65081. },
  65082. /**
  65083. * Sets the vignette blend mode allowing different kind of effect.
  65084. */
  65085. set: function (value) {
  65086. if (this._vignetteBlendMode === value) {
  65087. return;
  65088. }
  65089. this._vignetteBlendMode = value;
  65090. this._updateParameters();
  65091. },
  65092. enumerable: true,
  65093. configurable: true
  65094. });
  65095. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  65096. /**
  65097. * Gets wether the vignette effect is enabled.
  65098. */
  65099. get: function () {
  65100. return this._vignetteEnabled;
  65101. },
  65102. /**
  65103. * Sets wether the vignette effect is enabled.
  65104. */
  65105. set: function (value) {
  65106. if (this._vignetteEnabled === value) {
  65107. return;
  65108. }
  65109. this._vignetteEnabled = value;
  65110. this._updateParameters();
  65111. },
  65112. enumerable: true,
  65113. configurable: true
  65114. });
  65115. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  65116. /**
  65117. * Gets wether the image processing is applied through a post process or not.
  65118. */
  65119. get: function () {
  65120. return this._applyByPostProcess;
  65121. },
  65122. /**
  65123. * Sets wether the image processing is applied through a post process or not.
  65124. */
  65125. set: function (value) {
  65126. if (this._applyByPostProcess === value) {
  65127. return;
  65128. }
  65129. this._applyByPostProcess = value;
  65130. this._updateParameters();
  65131. },
  65132. enumerable: true,
  65133. configurable: true
  65134. });
  65135. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  65136. /**
  65137. * Gets wether the image processing is enabled or not.
  65138. */
  65139. get: function () {
  65140. return this._isEnabled;
  65141. },
  65142. /**
  65143. * Sets wether the image processing is enabled or not.
  65144. */
  65145. set: function (value) {
  65146. if (this._isEnabled === value) {
  65147. return;
  65148. }
  65149. this._isEnabled = value;
  65150. this._updateParameters();
  65151. },
  65152. enumerable: true,
  65153. configurable: true
  65154. });
  65155. /**
  65156. * Method called each time the image processing information changes requires to recompile the effect.
  65157. */
  65158. ImageProcessingConfiguration.prototype._updateParameters = function () {
  65159. this.onUpdateParameters.notifyObservers(this);
  65160. };
  65161. /**
  65162. * Gets the current class name.
  65163. * @return "ImageProcessingConfiguration"
  65164. */
  65165. ImageProcessingConfiguration.prototype.getClassName = function () {
  65166. return "ImageProcessingConfiguration";
  65167. };
  65168. /**
  65169. * Prepare the list of uniforms associated with the Image Processing effects.
  65170. * @param uniforms The list of uniforms used in the effect
  65171. * @param defines the list of defines currently in use
  65172. */
  65173. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  65174. if (defines.EXPOSURE) {
  65175. uniforms.push("exposureLinear");
  65176. }
  65177. if (defines.CONTRAST) {
  65178. uniforms.push("contrast");
  65179. }
  65180. if (defines.COLORGRADING) {
  65181. uniforms.push("colorTransformSettings");
  65182. }
  65183. if (defines.VIGNETTE) {
  65184. uniforms.push("vInverseScreenSize");
  65185. uniforms.push("vignetteSettings1");
  65186. uniforms.push("vignetteSettings2");
  65187. }
  65188. if (defines.COLORCURVES) {
  65189. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  65190. }
  65191. };
  65192. /**
  65193. * Prepare the list of samplers associated with the Image Processing effects.
  65194. * @param samplersList The list of uniforms used in the effect
  65195. * @param defines the list of defines currently in use
  65196. */
  65197. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  65198. if (defines.COLORGRADING) {
  65199. samplersList.push("txColorTransform");
  65200. }
  65201. };
  65202. /**
  65203. * Prepare the list of defines associated to the shader.
  65204. * @param defines the list of defines to complete
  65205. * @param forPostProcess Define if we are currently in post process mode or not
  65206. */
  65207. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  65208. if (forPostProcess === void 0) { forPostProcess = false; }
  65209. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  65210. defines.VIGNETTE = false;
  65211. defines.TONEMAPPING = false;
  65212. defines.TONEMAPPING_ACES = false;
  65213. defines.CONTRAST = false;
  65214. defines.EXPOSURE = false;
  65215. defines.COLORCURVES = false;
  65216. defines.COLORGRADING = false;
  65217. defines.COLORGRADING3D = false;
  65218. defines.IMAGEPROCESSING = false;
  65219. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  65220. return;
  65221. }
  65222. defines.VIGNETTE = this.vignetteEnabled;
  65223. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  65224. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  65225. defines.TONEMAPPING = this.toneMappingEnabled;
  65226. switch (this._toneMappingType) {
  65227. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  65228. defines.TONEMAPPING_ACES = true;
  65229. break;
  65230. default:
  65231. defines.TONEMAPPING_ACES = false;
  65232. break;
  65233. }
  65234. defines.CONTRAST = (this.contrast !== 1.0);
  65235. defines.EXPOSURE = (this.exposure !== 1.0);
  65236. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  65237. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  65238. if (defines.COLORGRADING) {
  65239. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  65240. }
  65241. else {
  65242. defines.COLORGRADING3D = false;
  65243. }
  65244. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  65245. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  65246. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  65247. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  65248. };
  65249. /**
  65250. * Returns true if all the image processing information are ready.
  65251. * @returns True if ready, otherwise, false
  65252. */
  65253. ImageProcessingConfiguration.prototype.isReady = function () {
  65254. // Color Grading texure can not be none blocking.
  65255. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  65256. };
  65257. /**
  65258. * Binds the image processing to the shader.
  65259. * @param effect The effect to bind to
  65260. * @param aspectRatio Define the current aspect ratio of the effect
  65261. */
  65262. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  65263. if (aspectRatio === void 0) { aspectRatio = 1; }
  65264. // Color Curves
  65265. if (this._colorCurvesEnabled && this.colorCurves) {
  65266. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  65267. }
  65268. // Vignette
  65269. if (this._vignetteEnabled) {
  65270. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  65271. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  65272. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  65273. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  65274. var vignetteScaleX = vignetteScaleY * aspectRatio;
  65275. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  65276. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  65277. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  65278. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  65279. var vignettePower = -2.0 * this.vignetteWeight;
  65280. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  65281. }
  65282. // Exposure
  65283. effect.setFloat("exposureLinear", this.exposure);
  65284. // Contrast
  65285. effect.setFloat("contrast", this.contrast);
  65286. // Color transform settings
  65287. if (this.colorGradingTexture) {
  65288. effect.setTexture("txColorTransform", this.colorGradingTexture);
  65289. var textureSize = this.colorGradingTexture.getSize().height;
  65290. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  65291. 0.5 / textureSize, // textureOffset
  65292. textureSize, // textureSize
  65293. this.colorGradingTexture.level // weight
  65294. );
  65295. }
  65296. };
  65297. /**
  65298. * Clones the current image processing instance.
  65299. * @return The cloned image processing
  65300. */
  65301. ImageProcessingConfiguration.prototype.clone = function () {
  65302. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  65303. };
  65304. /**
  65305. * Serializes the current image processing instance to a json representation.
  65306. * @return a JSON representation
  65307. */
  65308. ImageProcessingConfiguration.prototype.serialize = function () {
  65309. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65310. };
  65311. /**
  65312. * Parses the image processing from a json representation.
  65313. * @param source the JSON source to parse
  65314. * @return The parsed image processing
  65315. */
  65316. ImageProcessingConfiguration.Parse = function (source) {
  65317. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  65318. };
  65319. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  65320. /**
  65321. * Used to apply the vignette as a mix with the pixel color.
  65322. */
  65323. get: function () {
  65324. return this._VIGNETTEMODE_MULTIPLY;
  65325. },
  65326. enumerable: true,
  65327. configurable: true
  65328. });
  65329. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  65330. /**
  65331. * Used to apply the vignette as a replacement of the pixel color.
  65332. */
  65333. get: function () {
  65334. return this._VIGNETTEMODE_OPAQUE;
  65335. },
  65336. enumerable: true,
  65337. configurable: true
  65338. });
  65339. /**
  65340. * Default tone mapping applied in BabylonJS.
  65341. */
  65342. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  65343. /**
  65344. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  65345. * to other engines rendering to increase portability.
  65346. */
  65347. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  65348. // Static constants associated to the image processing.
  65349. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  65350. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  65351. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65352. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  65353. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  65354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65356. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  65357. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  65359. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  65360. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65362. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  65363. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65364. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65365. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  65366. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65368. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  65369. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65371. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  65372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65374. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  65375. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65377. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  65378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65380. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  65381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65383. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  65384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65386. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  65387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65389. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  65390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65392. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  65393. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  65395. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  65396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65398. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  65399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65401. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  65402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65404. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  65405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65407. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  65408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65410. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  65411. return ImageProcessingConfiguration;
  65412. }());
  65413. // References the dependencies.
  65414. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  65415. /***/ }),
  65416. /***/ "./Materials/index.ts":
  65417. /*!****************************!*\
  65418. !*** ./Materials/index.ts ***!
  65419. \****************************/
  65420. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, _KTXTextureLoader, MultiRenderTarget, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  65421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65422. "use strict";
  65423. __webpack_require__.r(__webpack_exports__);
  65424. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  65425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  65426. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  65427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  65428. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  65430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  65431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  65432. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  65433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  65434. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  65435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  65436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  65437. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  65438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  65439. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  65440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  65441. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  65443. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  65444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  65445. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  65446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterialDefines"]; });
  65447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  65448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  65449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  65450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  65451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  65452. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  65453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  65454. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  65455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  65456. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  65457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  65458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  65459. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  65460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  65461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  65462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["EquiRectangularCubeTexture"]; });
  65463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  65464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  65465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  65466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  65467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  65468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  65469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  65470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  65471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  65472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  65473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  65474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  65475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  65476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  65477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  65478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  65479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  65480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  65481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  65482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  65483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  65484. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  65485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  65486. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  65487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  65488. /***/ }),
  65489. /***/ "./Materials/material.ts":
  65490. /*!*******************************!*\
  65491. !*** ./Materials/material.ts ***!
  65492. \*******************************/
  65493. /*! exports provided: Material */
  65494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65495. "use strict";
  65496. __webpack_require__.r(__webpack_exports__);
  65497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  65498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65499. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65500. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  65501. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  65502. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65503. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  65504. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  65505. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  65506. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65507. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  65508. /**
  65509. * Base class for the main features of a material in Babylon.js
  65510. */
  65511. var Material = /** @class */ (function () {
  65512. /**
  65513. * Creates a material instance
  65514. * @param name defines the name of the material
  65515. * @param scene defines the scene to reference
  65516. * @param doNotAdd specifies if the material should be added to the scene
  65517. */
  65518. function Material(name, scene, doNotAdd) {
  65519. /**
  65520. * Gets or sets user defined metadata
  65521. */
  65522. this.metadata = null;
  65523. /**
  65524. * For internal use only. Please do not use.
  65525. */
  65526. this.reservedDataStore = null;
  65527. /**
  65528. * Specifies if the ready state should be checked on each call
  65529. */
  65530. this.checkReadyOnEveryCall = false;
  65531. /**
  65532. * Specifies if the ready state should be checked once
  65533. */
  65534. this.checkReadyOnlyOnce = false;
  65535. /**
  65536. * The state of the material
  65537. */
  65538. this.state = "";
  65539. /**
  65540. * The alpha value of the material
  65541. */
  65542. this._alpha = 1.0;
  65543. /**
  65544. * Specifies if back face culling is enabled
  65545. */
  65546. this._backFaceCulling = true;
  65547. /**
  65548. * Callback triggered when the material is compiled
  65549. */
  65550. this.onCompiled = null;
  65551. /**
  65552. * Callback triggered when an error occurs
  65553. */
  65554. this.onError = null;
  65555. /**
  65556. * Callback triggered to get the render target textures
  65557. */
  65558. this.getRenderTargetTextures = null;
  65559. /**
  65560. * Specifies if the material should be serialized
  65561. */
  65562. this.doNotSerialize = false;
  65563. /**
  65564. * @hidden
  65565. */
  65566. this._storeEffectOnSubMeshes = false;
  65567. /**
  65568. * Stores the animations for the material
  65569. */
  65570. this.animations = null;
  65571. /**
  65572. * An event triggered when the material is disposed
  65573. */
  65574. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  65575. /**
  65576. * An observer which watches for dispose events
  65577. */
  65578. this._onDisposeObserver = null;
  65579. this._onUnBindObservable = null;
  65580. /**
  65581. * An observer which watches for bind events
  65582. */
  65583. this._onBindObserver = null;
  65584. /**
  65585. * Stores the value of the alpha mode
  65586. */
  65587. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  65588. /**
  65589. * Stores the state of the need depth pre-pass value
  65590. */
  65591. this._needDepthPrePass = false;
  65592. /**
  65593. * Specifies if depth writing should be disabled
  65594. */
  65595. this.disableDepthWrite = false;
  65596. /**
  65597. * Specifies if depth writing should be forced
  65598. */
  65599. this.forceDepthWrite = false;
  65600. /**
  65601. * Specifies if there should be a separate pass for culling
  65602. */
  65603. this.separateCullingPass = false;
  65604. /**
  65605. * Stores the state specifing if fog should be enabled
  65606. */
  65607. this._fogEnabled = true;
  65608. /**
  65609. * Stores the size of points
  65610. */
  65611. this.pointSize = 1.0;
  65612. /**
  65613. * Stores the z offset value
  65614. */
  65615. this.zOffset = 0;
  65616. /**
  65617. * @hidden
  65618. * Stores the effects for the material
  65619. */
  65620. this._effect = null;
  65621. /**
  65622. * @hidden
  65623. * Specifies if the material was previously ready
  65624. */
  65625. this._wasPreviouslyReady = false;
  65626. /**
  65627. * Specifies if uniform buffers should be used
  65628. */
  65629. this._useUBO = false;
  65630. /**
  65631. * Stores the fill mode state
  65632. */
  65633. this._fillMode = Material.TriangleFillMode;
  65634. /**
  65635. * Specifies if the depth write state should be cached
  65636. */
  65637. this._cachedDepthWriteState = false;
  65638. /** @hidden */
  65639. this._indexInSceneMaterialArray = -1;
  65640. /** @hidden */
  65641. this.meshMap = null;
  65642. this.name = name;
  65643. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  65644. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  65645. this.uniqueId = this._scene.getUniqueId();
  65646. if (this._scene.useRightHandedSystem) {
  65647. this.sideOrientation = Material.ClockWiseSideOrientation;
  65648. }
  65649. else {
  65650. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  65651. }
  65652. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  65653. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  65654. if (!doNotAdd) {
  65655. this._scene.addMaterial(this);
  65656. }
  65657. if (this._scene.useMaterialMeshMap) {
  65658. this.meshMap = {};
  65659. }
  65660. }
  65661. Object.defineProperty(Material.prototype, "alpha", {
  65662. /**
  65663. * Gets the alpha value of the material
  65664. */
  65665. get: function () {
  65666. return this._alpha;
  65667. },
  65668. /**
  65669. * Sets the alpha value of the material
  65670. */
  65671. set: function (value) {
  65672. if (this._alpha === value) {
  65673. return;
  65674. }
  65675. this._alpha = value;
  65676. this.markAsDirty(Material.MiscDirtyFlag);
  65677. },
  65678. enumerable: true,
  65679. configurable: true
  65680. });
  65681. Object.defineProperty(Material.prototype, "backFaceCulling", {
  65682. /**
  65683. * Gets the back-face culling state
  65684. */
  65685. get: function () {
  65686. return this._backFaceCulling;
  65687. },
  65688. /**
  65689. * Sets the back-face culling state
  65690. */
  65691. set: function (value) {
  65692. if (this._backFaceCulling === value) {
  65693. return;
  65694. }
  65695. this._backFaceCulling = value;
  65696. this.markAsDirty(Material.TextureDirtyFlag);
  65697. },
  65698. enumerable: true,
  65699. configurable: true
  65700. });
  65701. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  65702. /**
  65703. * Gets a boolean indicating that current material needs to register RTT
  65704. */
  65705. get: function () {
  65706. return false;
  65707. },
  65708. enumerable: true,
  65709. configurable: true
  65710. });
  65711. Object.defineProperty(Material.prototype, "onDispose", {
  65712. /**
  65713. * Called during a dispose event
  65714. */
  65715. set: function (callback) {
  65716. if (this._onDisposeObserver) {
  65717. this.onDisposeObservable.remove(this._onDisposeObserver);
  65718. }
  65719. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  65720. },
  65721. enumerable: true,
  65722. configurable: true
  65723. });
  65724. Object.defineProperty(Material.prototype, "onBindObservable", {
  65725. /**
  65726. * An event triggered when the material is bound
  65727. */
  65728. get: function () {
  65729. if (!this._onBindObservable) {
  65730. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  65731. }
  65732. return this._onBindObservable;
  65733. },
  65734. enumerable: true,
  65735. configurable: true
  65736. });
  65737. Object.defineProperty(Material.prototype, "onBind", {
  65738. /**
  65739. * Called during a bind event
  65740. */
  65741. set: function (callback) {
  65742. if (this._onBindObserver) {
  65743. this.onBindObservable.remove(this._onBindObserver);
  65744. }
  65745. this._onBindObserver = this.onBindObservable.add(callback);
  65746. },
  65747. enumerable: true,
  65748. configurable: true
  65749. });
  65750. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  65751. /**
  65752. * An event triggered when the material is unbound
  65753. */
  65754. get: function () {
  65755. if (!this._onUnBindObservable) {
  65756. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  65757. }
  65758. return this._onUnBindObservable;
  65759. },
  65760. enumerable: true,
  65761. configurable: true
  65762. });
  65763. Object.defineProperty(Material.prototype, "alphaMode", {
  65764. /**
  65765. * Gets the value of the alpha mode
  65766. */
  65767. get: function () {
  65768. return this._alphaMode;
  65769. },
  65770. /**
  65771. * Sets the value of the alpha mode.
  65772. *
  65773. * | Value | Type | Description |
  65774. * | --- | --- | --- |
  65775. * | 0 | ALPHA_DISABLE | |
  65776. * | 1 | ALPHA_ADD | |
  65777. * | 2 | ALPHA_COMBINE | |
  65778. * | 3 | ALPHA_SUBTRACT | |
  65779. * | 4 | ALPHA_MULTIPLY | |
  65780. * | 5 | ALPHA_MAXIMIZED | |
  65781. * | 6 | ALPHA_ONEONE | |
  65782. * | 7 | ALPHA_PREMULTIPLIED | |
  65783. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  65784. * | 9 | ALPHA_INTERPOLATE | |
  65785. * | 10 | ALPHA_SCREENMODE | |
  65786. *
  65787. */
  65788. set: function (value) {
  65789. if (this._alphaMode === value) {
  65790. return;
  65791. }
  65792. this._alphaMode = value;
  65793. this.markAsDirty(Material.TextureDirtyFlag);
  65794. },
  65795. enumerable: true,
  65796. configurable: true
  65797. });
  65798. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  65799. /**
  65800. * Gets the depth pre-pass value
  65801. */
  65802. get: function () {
  65803. return this._needDepthPrePass;
  65804. },
  65805. /**
  65806. * Sets the need depth pre-pass value
  65807. */
  65808. set: function (value) {
  65809. if (this._needDepthPrePass === value) {
  65810. return;
  65811. }
  65812. this._needDepthPrePass = value;
  65813. if (this._needDepthPrePass) {
  65814. this.checkReadyOnEveryCall = true;
  65815. }
  65816. },
  65817. enumerable: true,
  65818. configurable: true
  65819. });
  65820. Object.defineProperty(Material.prototype, "fogEnabled", {
  65821. /**
  65822. * Gets the value of the fog enabled state
  65823. */
  65824. get: function () {
  65825. return this._fogEnabled;
  65826. },
  65827. /**
  65828. * Sets the state for enabling fog
  65829. */
  65830. set: function (value) {
  65831. if (this._fogEnabled === value) {
  65832. return;
  65833. }
  65834. this._fogEnabled = value;
  65835. this.markAsDirty(Material.MiscDirtyFlag);
  65836. },
  65837. enumerable: true,
  65838. configurable: true
  65839. });
  65840. Object.defineProperty(Material.prototype, "wireframe", {
  65841. /**
  65842. * Gets a value specifying if wireframe mode is enabled
  65843. */
  65844. get: function () {
  65845. switch (this._fillMode) {
  65846. case Material.WireFrameFillMode:
  65847. case Material.LineListDrawMode:
  65848. case Material.LineLoopDrawMode:
  65849. case Material.LineStripDrawMode:
  65850. return true;
  65851. }
  65852. return this._scene.forceWireframe;
  65853. },
  65854. /**
  65855. * Sets the state of wireframe mode
  65856. */
  65857. set: function (value) {
  65858. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  65859. },
  65860. enumerable: true,
  65861. configurable: true
  65862. });
  65863. Object.defineProperty(Material.prototype, "pointsCloud", {
  65864. /**
  65865. * Gets the value specifying if point clouds are enabled
  65866. */
  65867. get: function () {
  65868. switch (this._fillMode) {
  65869. case Material.PointFillMode:
  65870. case Material.PointListDrawMode:
  65871. return true;
  65872. }
  65873. return this._scene.forcePointsCloud;
  65874. },
  65875. /**
  65876. * Sets the state of point cloud mode
  65877. */
  65878. set: function (value) {
  65879. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  65880. },
  65881. enumerable: true,
  65882. configurable: true
  65883. });
  65884. Object.defineProperty(Material.prototype, "fillMode", {
  65885. /**
  65886. * Gets the material fill mode
  65887. */
  65888. get: function () {
  65889. return this._fillMode;
  65890. },
  65891. /**
  65892. * Sets the material fill mode
  65893. */
  65894. set: function (value) {
  65895. if (this._fillMode === value) {
  65896. return;
  65897. }
  65898. this._fillMode = value;
  65899. this.markAsDirty(Material.MiscDirtyFlag);
  65900. },
  65901. enumerable: true,
  65902. configurable: true
  65903. });
  65904. /**
  65905. * Returns a string representation of the current material
  65906. * @param fullDetails defines a boolean indicating which levels of logging is desired
  65907. * @returns a string with material information
  65908. */
  65909. Material.prototype.toString = function (fullDetails) {
  65910. var ret = "Name: " + this.name;
  65911. if (fullDetails) {
  65912. }
  65913. return ret;
  65914. };
  65915. /**
  65916. * Gets the class name of the material
  65917. * @returns a string with the class name of the material
  65918. */
  65919. Material.prototype.getClassName = function () {
  65920. return "Material";
  65921. };
  65922. Object.defineProperty(Material.prototype, "isFrozen", {
  65923. /**
  65924. * Specifies if updates for the material been locked
  65925. */
  65926. get: function () {
  65927. return this.checkReadyOnlyOnce;
  65928. },
  65929. enumerable: true,
  65930. configurable: true
  65931. });
  65932. /**
  65933. * Locks updates for the material
  65934. */
  65935. Material.prototype.freeze = function () {
  65936. this.checkReadyOnlyOnce = true;
  65937. };
  65938. /**
  65939. * Unlocks updates for the material
  65940. */
  65941. Material.prototype.unfreeze = function () {
  65942. this.checkReadyOnlyOnce = false;
  65943. };
  65944. /**
  65945. * Specifies if the material is ready to be used
  65946. * @param mesh defines the mesh to check
  65947. * @param useInstances specifies if instances should be used
  65948. * @returns a boolean indicating if the material is ready to be used
  65949. */
  65950. Material.prototype.isReady = function (mesh, useInstances) {
  65951. return true;
  65952. };
  65953. /**
  65954. * Specifies that the submesh is ready to be used
  65955. * @param mesh defines the mesh to check
  65956. * @param subMesh defines which submesh to check
  65957. * @param useInstances specifies that instances should be used
  65958. * @returns a boolean indicating that the submesh is ready or not
  65959. */
  65960. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65961. return false;
  65962. };
  65963. /**
  65964. * Returns the material effect
  65965. * @returns the effect associated with the material
  65966. */
  65967. Material.prototype.getEffect = function () {
  65968. return this._effect;
  65969. };
  65970. /**
  65971. * Returns the current scene
  65972. * @returns a Scene
  65973. */
  65974. Material.prototype.getScene = function () {
  65975. return this._scene;
  65976. };
  65977. /**
  65978. * Specifies if the material will require alpha blending
  65979. * @returns a boolean specifying if alpha blending is needed
  65980. */
  65981. Material.prototype.needAlphaBlending = function () {
  65982. return (this.alpha < 1.0);
  65983. };
  65984. /**
  65985. * Specifies if the mesh will require alpha blending
  65986. * @param mesh defines the mesh to check
  65987. * @returns a boolean specifying if alpha blending is needed for the mesh
  65988. */
  65989. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  65990. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  65991. };
  65992. /**
  65993. * Specifies if this material should be rendered in alpha test mode
  65994. * @returns a boolean specifying if an alpha test is needed.
  65995. */
  65996. Material.prototype.needAlphaTesting = function () {
  65997. return false;
  65998. };
  65999. /**
  66000. * Gets the texture used for the alpha test
  66001. * @returns the texture to use for alpha testing
  66002. */
  66003. Material.prototype.getAlphaTestTexture = function () {
  66004. return null;
  66005. };
  66006. /**
  66007. * Marks the material to indicate that it needs to be re-calculated
  66008. */
  66009. Material.prototype.markDirty = function () {
  66010. this._wasPreviouslyReady = false;
  66011. };
  66012. /** @hidden */
  66013. Material.prototype._preBind = function (effect, overrideOrientation) {
  66014. if (overrideOrientation === void 0) { overrideOrientation = null; }
  66015. var engine = this._scene.getEngine();
  66016. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  66017. var reverse = orientation === Material.ClockWiseSideOrientation;
  66018. engine.enableEffect(effect ? effect : this._effect);
  66019. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  66020. return reverse;
  66021. };
  66022. /**
  66023. * Binds the material to the mesh
  66024. * @param world defines the world transformation matrix
  66025. * @param mesh defines the mesh to bind the material to
  66026. */
  66027. Material.prototype.bind = function (world, mesh) {
  66028. };
  66029. /**
  66030. * Binds the submesh to the material
  66031. * @param world defines the world transformation matrix
  66032. * @param mesh defines the mesh containing the submesh
  66033. * @param subMesh defines the submesh to bind the material to
  66034. */
  66035. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  66036. };
  66037. /**
  66038. * Binds the world matrix to the material
  66039. * @param world defines the world transformation matrix
  66040. */
  66041. Material.prototype.bindOnlyWorldMatrix = function (world) {
  66042. };
  66043. /**
  66044. * Binds the scene's uniform buffer to the effect.
  66045. * @param effect defines the effect to bind to the scene uniform buffer
  66046. * @param sceneUbo defines the uniform buffer storing scene data
  66047. */
  66048. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  66049. sceneUbo.bindToEffect(effect, "Scene");
  66050. };
  66051. /**
  66052. * Binds the view matrix to the effect
  66053. * @param effect defines the effect to bind the view matrix to
  66054. */
  66055. Material.prototype.bindView = function (effect) {
  66056. if (!this._useUBO) {
  66057. effect.setMatrix("view", this.getScene().getViewMatrix());
  66058. }
  66059. else {
  66060. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  66061. }
  66062. };
  66063. /**
  66064. * Binds the view projection matrix to the effect
  66065. * @param effect defines the effect to bind the view projection matrix to
  66066. */
  66067. Material.prototype.bindViewProjection = function (effect) {
  66068. if (!this._useUBO) {
  66069. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  66070. }
  66071. else {
  66072. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  66073. }
  66074. };
  66075. /**
  66076. * Specifies if material alpha testing should be turned on for the mesh
  66077. * @param mesh defines the mesh to check
  66078. */
  66079. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  66080. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  66081. };
  66082. /**
  66083. * Processes to execute after binding the material to a mesh
  66084. * @param mesh defines the rendered mesh
  66085. */
  66086. Material.prototype._afterBind = function (mesh) {
  66087. this._scene._cachedMaterial = this;
  66088. if (mesh) {
  66089. this._scene._cachedVisibility = mesh.visibility;
  66090. }
  66091. else {
  66092. this._scene._cachedVisibility = 1;
  66093. }
  66094. if (this._onBindObservable && mesh) {
  66095. this._onBindObservable.notifyObservers(mesh);
  66096. }
  66097. if (this.disableDepthWrite) {
  66098. var engine = this._scene.getEngine();
  66099. this._cachedDepthWriteState = engine.getDepthWrite();
  66100. engine.setDepthWrite(false);
  66101. }
  66102. };
  66103. /**
  66104. * Unbinds the material from the mesh
  66105. */
  66106. Material.prototype.unbind = function () {
  66107. if (this._onUnBindObservable) {
  66108. this._onUnBindObservable.notifyObservers(this);
  66109. }
  66110. if (this.disableDepthWrite) {
  66111. var engine = this._scene.getEngine();
  66112. engine.setDepthWrite(this._cachedDepthWriteState);
  66113. }
  66114. };
  66115. /**
  66116. * Gets the active textures from the material
  66117. * @returns an array of textures
  66118. */
  66119. Material.prototype.getActiveTextures = function () {
  66120. return [];
  66121. };
  66122. /**
  66123. * Specifies if the material uses a texture
  66124. * @param texture defines the texture to check against the material
  66125. * @returns a boolean specifying if the material uses the texture
  66126. */
  66127. Material.prototype.hasTexture = function (texture) {
  66128. return false;
  66129. };
  66130. /**
  66131. * Makes a duplicate of the material, and gives it a new name
  66132. * @param name defines the new name for the duplicated material
  66133. * @returns the cloned material
  66134. */
  66135. Material.prototype.clone = function (name) {
  66136. return null;
  66137. };
  66138. /**
  66139. * Gets the meshes bound to the material
  66140. * @returns an array of meshes bound to the material
  66141. */
  66142. Material.prototype.getBindedMeshes = function () {
  66143. var _this = this;
  66144. if (this.meshMap) {
  66145. var result = new Array();
  66146. for (var meshId in this.meshMap) {
  66147. var mesh = this.meshMap[meshId];
  66148. if (mesh) {
  66149. result.push(mesh);
  66150. }
  66151. }
  66152. return result;
  66153. }
  66154. else {
  66155. var meshes = this._scene.meshes;
  66156. return meshes.filter(function (mesh) { return mesh.material === _this; });
  66157. }
  66158. };
  66159. /**
  66160. * Force shader compilation
  66161. * @param mesh defines the mesh associated with this material
  66162. * @param onCompiled defines a function to execute once the material is compiled
  66163. * @param options defines the options to configure the compilation
  66164. */
  66165. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  66166. var _this = this;
  66167. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  66168. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  66169. var scene = this.getScene();
  66170. var checkReady = function () {
  66171. if (!_this._scene || !_this._scene.getEngine()) {
  66172. return;
  66173. }
  66174. if (subMesh._materialDefines) {
  66175. subMesh._materialDefines._renderId = -1;
  66176. }
  66177. var clipPlaneState = scene.clipPlane;
  66178. if (localOptions.clipPlane) {
  66179. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  66180. }
  66181. if (_this._storeEffectOnSubMeshes) {
  66182. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  66183. if (onCompiled) {
  66184. onCompiled(_this);
  66185. }
  66186. }
  66187. else {
  66188. setTimeout(checkReady, 16);
  66189. }
  66190. }
  66191. else {
  66192. if (_this.isReady()) {
  66193. if (onCompiled) {
  66194. onCompiled(_this);
  66195. }
  66196. }
  66197. else {
  66198. setTimeout(checkReady, 16);
  66199. }
  66200. }
  66201. if (localOptions.clipPlane) {
  66202. scene.clipPlane = clipPlaneState;
  66203. }
  66204. };
  66205. checkReady();
  66206. };
  66207. /**
  66208. * Force shader compilation
  66209. * @param mesh defines the mesh that will use this material
  66210. * @param options defines additional options for compiling the shaders
  66211. * @returns a promise that resolves when the compilation completes
  66212. */
  66213. Material.prototype.forceCompilationAsync = function (mesh, options) {
  66214. var _this = this;
  66215. return new Promise(function (resolve) {
  66216. _this.forceCompilation(mesh, function () {
  66217. resolve();
  66218. }, options);
  66219. });
  66220. };
  66221. /**
  66222. * Marks a define in the material to indicate that it needs to be re-computed
  66223. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  66224. */
  66225. Material.prototype.markAsDirty = function (flag) {
  66226. if (this.getScene().blockMaterialDirtyMechanism) {
  66227. return;
  66228. }
  66229. Material._DirtyCallbackArray.length = 0;
  66230. if (flag & Material.TextureDirtyFlag) {
  66231. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  66232. }
  66233. if (flag & Material.LightDirtyFlag) {
  66234. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  66235. }
  66236. if (flag & Material.FresnelDirtyFlag) {
  66237. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  66238. }
  66239. if (flag & Material.AttributesDirtyFlag) {
  66240. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  66241. }
  66242. if (flag & Material.MiscDirtyFlag) {
  66243. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  66244. }
  66245. if (Material._DirtyCallbackArray.length) {
  66246. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  66247. }
  66248. this.getScene().resetCachedMaterial();
  66249. };
  66250. /**
  66251. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  66252. * @param func defines a function which checks material defines against the submeshes
  66253. */
  66254. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  66255. if (this.getScene().blockMaterialDirtyMechanism) {
  66256. return;
  66257. }
  66258. var meshes = this.getScene().meshes;
  66259. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  66260. var mesh = meshes_1[_i];
  66261. if (!mesh.subMeshes) {
  66262. continue;
  66263. }
  66264. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  66265. var subMesh = _b[_a];
  66266. if (subMesh.getMaterial() !== this) {
  66267. continue;
  66268. }
  66269. if (!subMesh._materialDefines) {
  66270. continue;
  66271. }
  66272. func(subMesh._materialDefines);
  66273. }
  66274. }
  66275. };
  66276. /**
  66277. * Indicates that image processing needs to be re-calculated for all submeshes
  66278. */
  66279. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  66280. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  66281. };
  66282. /**
  66283. * Indicates that textures need to be re-calculated for all submeshes
  66284. */
  66285. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  66286. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  66287. };
  66288. /**
  66289. * Indicates that fresnel needs to be re-calculated for all submeshes
  66290. */
  66291. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  66292. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  66293. };
  66294. /**
  66295. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  66296. */
  66297. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  66298. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  66299. };
  66300. /**
  66301. * Indicates that lights need to be re-calculated for all submeshes
  66302. */
  66303. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  66304. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  66305. };
  66306. /**
  66307. * Indicates that attributes need to be re-calculated for all submeshes
  66308. */
  66309. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  66310. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  66311. };
  66312. /**
  66313. * Indicates that misc needs to be re-calculated for all submeshes
  66314. */
  66315. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  66316. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  66317. };
  66318. /**
  66319. * Indicates that textures and misc need to be re-calculated for all submeshes
  66320. */
  66321. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  66322. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  66323. };
  66324. /**
  66325. * Disposes the material
  66326. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66327. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66328. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  66329. */
  66330. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  66331. var scene = this.getScene();
  66332. // Animations
  66333. scene.stopAnimation(this);
  66334. scene.freeProcessedMaterials();
  66335. // Remove from scene
  66336. scene.removeMaterial(this);
  66337. if (notBoundToMesh !== true) {
  66338. // Remove from meshes
  66339. if (this.meshMap) {
  66340. for (var meshId in this.meshMap) {
  66341. var mesh = this.meshMap[meshId];
  66342. if (mesh) {
  66343. mesh.material = null; // will set the entry in the map to undefined
  66344. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  66345. }
  66346. }
  66347. }
  66348. else {
  66349. var meshes = scene.meshes;
  66350. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  66351. var mesh = meshes_2[_i];
  66352. if (mesh.material === this) {
  66353. mesh.material = null;
  66354. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  66355. }
  66356. }
  66357. }
  66358. }
  66359. this._uniformBuffer.dispose();
  66360. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  66361. if (forceDisposeEffect && this._effect) {
  66362. if (!this._storeEffectOnSubMeshes) {
  66363. this._effect.dispose();
  66364. }
  66365. this._effect = null;
  66366. }
  66367. // Callback
  66368. this.onDisposeObservable.notifyObservers(this);
  66369. this.onDisposeObservable.clear();
  66370. if (this._onBindObservable) {
  66371. this._onBindObservable.clear();
  66372. }
  66373. if (this._onUnBindObservable) {
  66374. this._onUnBindObservable.clear();
  66375. }
  66376. };
  66377. /** @hidden */
  66378. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  66379. if (mesh.geometry) {
  66380. var geometry = (mesh.geometry);
  66381. if (this._storeEffectOnSubMeshes) {
  66382. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  66383. var subMesh = _a[_i];
  66384. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  66385. if (forceDisposeEffect && subMesh._materialEffect) {
  66386. subMesh._materialEffect.dispose();
  66387. }
  66388. }
  66389. }
  66390. else {
  66391. geometry._releaseVertexArrayObject(this._effect);
  66392. }
  66393. }
  66394. };
  66395. /**
  66396. * Serializes this material
  66397. * @returns the serialized material object
  66398. */
  66399. Material.prototype.serialize = function () {
  66400. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66401. };
  66402. /**
  66403. * Creates a material from parsed material data
  66404. * @param parsedMaterial defines parsed material data
  66405. * @param scene defines the hosting scene
  66406. * @param rootUrl defines the root URL to use to load textures
  66407. * @returns a new material
  66408. */
  66409. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  66410. if (!parsedMaterial.customType) {
  66411. parsedMaterial.customType = "BABYLON.StandardMaterial";
  66412. }
  66413. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  66414. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  66415. if (!BABYLON.LegacyPBRMaterial) {
  66416. _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.");
  66417. return null;
  66418. }
  66419. }
  66420. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  66421. return materialType.Parse(parsedMaterial, scene, rootUrl);
  66422. };
  66423. /**
  66424. * Returns the triangle fill mode
  66425. */
  66426. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  66427. /**
  66428. * Returns the wireframe mode
  66429. */
  66430. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  66431. /**
  66432. * Returns the point fill mode
  66433. */
  66434. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  66435. /**
  66436. * Returns the point list draw mode
  66437. */
  66438. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  66439. /**
  66440. * Returns the line list draw mode
  66441. */
  66442. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  66443. /**
  66444. * Returns the line loop draw mode
  66445. */
  66446. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  66447. /**
  66448. * Returns the line strip draw mode
  66449. */
  66450. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  66451. /**
  66452. * Returns the triangle strip draw mode
  66453. */
  66454. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  66455. /**
  66456. * Returns the triangle fan draw mode
  66457. */
  66458. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  66459. /**
  66460. * Stores the clock-wise side orientation
  66461. */
  66462. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  66463. /**
  66464. * Stores the counter clock-wise side orientation
  66465. */
  66466. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  66467. /**
  66468. * The dirty texture flag value
  66469. */
  66470. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  66471. /**
  66472. * The dirty light flag value
  66473. */
  66474. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  66475. /**
  66476. * The dirty fresnel flag value
  66477. */
  66478. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  66479. /**
  66480. * The dirty attribute flag value
  66481. */
  66482. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  66483. /**
  66484. * The dirty misc flag value
  66485. */
  66486. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  66487. /**
  66488. * The all dirty flag value
  66489. */
  66490. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  66491. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  66492. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  66493. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  66494. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  66495. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  66496. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  66497. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  66498. Material._FresnelDirtyCallBack(defines);
  66499. Material._MiscDirtyCallBack(defines);
  66500. };
  66501. Material._TextureAndMiscDirtyCallBack = function (defines) {
  66502. Material._TextureDirtyCallBack(defines);
  66503. Material._MiscDirtyCallBack(defines);
  66504. };
  66505. Material._DirtyCallbackArray = [];
  66506. Material._RunDirtyCallBacks = function (defines) {
  66507. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  66508. var cb = _a[_i];
  66509. cb(defines);
  66510. }
  66511. };
  66512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66514. ], Material.prototype, "id", void 0);
  66515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66517. ], Material.prototype, "uniqueId", void 0);
  66518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66520. ], Material.prototype, "name", void 0);
  66521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66523. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  66524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66526. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  66527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66529. ], Material.prototype, "state", void 0);
  66530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  66532. ], Material.prototype, "_alpha", void 0);
  66533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  66535. ], Material.prototype, "_backFaceCulling", void 0);
  66536. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66537. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66538. ], Material.prototype, "sideOrientation", void 0);
  66539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  66541. ], Material.prototype, "_alphaMode", void 0);
  66542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66544. ], Material.prototype, "_needDepthPrePass", void 0);
  66545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66547. ], Material.prototype, "disableDepthWrite", void 0);
  66548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66550. ], Material.prototype, "forceDepthWrite", void 0);
  66551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66553. ], Material.prototype, "separateCullingPass", void 0);
  66554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  66556. ], Material.prototype, "_fogEnabled", void 0);
  66557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66559. ], Material.prototype, "pointSize", void 0);
  66560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66562. ], Material.prototype, "zOffset", void 0);
  66563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66565. ], Material.prototype, "wireframe", null);
  66566. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66568. ], Material.prototype, "pointsCloud", null);
  66569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66571. ], Material.prototype, "fillMode", null);
  66572. return Material;
  66573. }());
  66574. /***/ }),
  66575. /***/ "./Materials/materialDefines.ts":
  66576. /*!**************************************!*\
  66577. !*** ./Materials/materialDefines.ts ***!
  66578. \**************************************/
  66579. /*! exports provided: MaterialDefines */
  66580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66581. "use strict";
  66582. __webpack_require__.r(__webpack_exports__);
  66583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  66584. /**
  66585. * Manages the defines for the Material
  66586. */
  66587. var MaterialDefines = /** @class */ (function () {
  66588. function MaterialDefines() {
  66589. this._isDirty = true;
  66590. /** @hidden */
  66591. this._areLightsDirty = true;
  66592. /** @hidden */
  66593. this._areAttributesDirty = true;
  66594. /** @hidden */
  66595. this._areTexturesDirty = true;
  66596. /** @hidden */
  66597. this._areFresnelDirty = true;
  66598. /** @hidden */
  66599. this._areMiscDirty = true;
  66600. /** @hidden */
  66601. this._areImageProcessingDirty = true;
  66602. /** @hidden */
  66603. this._normals = false;
  66604. /** @hidden */
  66605. this._uvs = false;
  66606. /** @hidden */
  66607. this._needNormals = false;
  66608. /** @hidden */
  66609. this._needUVs = false;
  66610. }
  66611. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  66612. /**
  66613. * Specifies if the material needs to be re-calculated
  66614. */
  66615. get: function () {
  66616. return this._isDirty;
  66617. },
  66618. enumerable: true,
  66619. configurable: true
  66620. });
  66621. /**
  66622. * Marks the material to indicate that it has been re-calculated
  66623. */
  66624. MaterialDefines.prototype.markAsProcessed = function () {
  66625. this._isDirty = false;
  66626. this._areAttributesDirty = false;
  66627. this._areTexturesDirty = false;
  66628. this._areFresnelDirty = false;
  66629. this._areLightsDirty = false;
  66630. this._areMiscDirty = false;
  66631. this._areImageProcessingDirty = false;
  66632. };
  66633. /**
  66634. * Marks the material to indicate that it needs to be re-calculated
  66635. */
  66636. MaterialDefines.prototype.markAsUnprocessed = function () {
  66637. this._isDirty = true;
  66638. };
  66639. /**
  66640. * Marks the material to indicate all of its defines need to be re-calculated
  66641. */
  66642. MaterialDefines.prototype.markAllAsDirty = function () {
  66643. this._areTexturesDirty = true;
  66644. this._areAttributesDirty = true;
  66645. this._areLightsDirty = true;
  66646. this._areFresnelDirty = true;
  66647. this._areMiscDirty = true;
  66648. this._areImageProcessingDirty = true;
  66649. this._isDirty = true;
  66650. };
  66651. /**
  66652. * Marks the material to indicate that image processing needs to be re-calculated
  66653. */
  66654. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  66655. this._areImageProcessingDirty = true;
  66656. this._isDirty = true;
  66657. };
  66658. /**
  66659. * Marks the material to indicate the lights need to be re-calculated
  66660. */
  66661. MaterialDefines.prototype.markAsLightDirty = function () {
  66662. this._areLightsDirty = true;
  66663. this._isDirty = true;
  66664. };
  66665. /**
  66666. * Marks the attribute state as changed
  66667. */
  66668. MaterialDefines.prototype.markAsAttributesDirty = function () {
  66669. this._areAttributesDirty = true;
  66670. this._isDirty = true;
  66671. };
  66672. /**
  66673. * Marks the texture state as changed
  66674. */
  66675. MaterialDefines.prototype.markAsTexturesDirty = function () {
  66676. this._areTexturesDirty = true;
  66677. this._isDirty = true;
  66678. };
  66679. /**
  66680. * Marks the fresnel state as changed
  66681. */
  66682. MaterialDefines.prototype.markAsFresnelDirty = function () {
  66683. this._areFresnelDirty = true;
  66684. this._isDirty = true;
  66685. };
  66686. /**
  66687. * Marks the misc state as changed
  66688. */
  66689. MaterialDefines.prototype.markAsMiscDirty = function () {
  66690. this._areMiscDirty = true;
  66691. this._isDirty = true;
  66692. };
  66693. /**
  66694. * Rebuilds the material defines
  66695. */
  66696. MaterialDefines.prototype.rebuild = function () {
  66697. if (this._keys) {
  66698. delete this._keys;
  66699. }
  66700. this._keys = [];
  66701. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  66702. var key = _a[_i];
  66703. if (key[0] === "_") {
  66704. continue;
  66705. }
  66706. this._keys.push(key);
  66707. }
  66708. };
  66709. /**
  66710. * Specifies if two material defines are equal
  66711. * @param other - A material define instance to compare to
  66712. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  66713. */
  66714. MaterialDefines.prototype.isEqual = function (other) {
  66715. if (this._keys.length !== other._keys.length) {
  66716. return false;
  66717. }
  66718. for (var index = 0; index < this._keys.length; index++) {
  66719. var prop = this._keys[index];
  66720. if (this[prop] !== other[prop]) {
  66721. return false;
  66722. }
  66723. }
  66724. return true;
  66725. };
  66726. /**
  66727. * Clones this instance's defines to another instance
  66728. * @param other - material defines to clone values to
  66729. */
  66730. MaterialDefines.prototype.cloneTo = function (other) {
  66731. if (this._keys.length !== other._keys.length) {
  66732. other._keys = this._keys.slice(0);
  66733. }
  66734. for (var index = 0; index < this._keys.length; index++) {
  66735. var prop = this._keys[index];
  66736. other[prop] = this[prop];
  66737. }
  66738. };
  66739. /**
  66740. * Resets the material define values
  66741. */
  66742. MaterialDefines.prototype.reset = function () {
  66743. for (var index = 0; index < this._keys.length; index++) {
  66744. var prop = this._keys[index];
  66745. var type = typeof this[prop];
  66746. switch (type) {
  66747. case "number":
  66748. this[prop] = 0;
  66749. break;
  66750. case "string":
  66751. this[prop] = "";
  66752. break;
  66753. default:
  66754. this[prop] = false;
  66755. break;
  66756. }
  66757. }
  66758. };
  66759. /**
  66760. * Converts the material define values to a string
  66761. * @returns - String of material define information
  66762. */
  66763. MaterialDefines.prototype.toString = function () {
  66764. var result = "";
  66765. for (var index = 0; index < this._keys.length; index++) {
  66766. var prop = this._keys[index];
  66767. var value = this[prop];
  66768. var type = typeof value;
  66769. switch (type) {
  66770. case "number":
  66771. case "string":
  66772. result += "#define " + prop + " " + value + "\n";
  66773. break;
  66774. default:
  66775. if (value) {
  66776. result += "#define " + prop + "\n";
  66777. }
  66778. break;
  66779. }
  66780. }
  66781. return result;
  66782. };
  66783. return MaterialDefines;
  66784. }());
  66785. /***/ }),
  66786. /***/ "./Materials/materialFlags.ts":
  66787. /*!************************************!*\
  66788. !*** ./Materials/materialFlags.ts ***!
  66789. \************************************/
  66790. /*! exports provided: MaterialFlags */
  66791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66792. "use strict";
  66793. __webpack_require__.r(__webpack_exports__);
  66794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  66795. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  66796. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  66797. /**
  66798. * This groups all the flags used to control the materials channel.
  66799. */
  66800. var MaterialFlags = /** @class */ (function () {
  66801. function MaterialFlags() {
  66802. }
  66803. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  66804. /**
  66805. * Are diffuse textures enabled in the application.
  66806. */
  66807. get: function () {
  66808. return this._DiffuseTextureEnabled;
  66809. },
  66810. set: function (value) {
  66811. if (this._DiffuseTextureEnabled === value) {
  66812. return;
  66813. }
  66814. this._DiffuseTextureEnabled = value;
  66815. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66816. },
  66817. enumerable: true,
  66818. configurable: true
  66819. });
  66820. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  66821. /**
  66822. * Are ambient textures enabled in the application.
  66823. */
  66824. get: function () {
  66825. return this._AmbientTextureEnabled;
  66826. },
  66827. set: function (value) {
  66828. if (this._AmbientTextureEnabled === value) {
  66829. return;
  66830. }
  66831. this._AmbientTextureEnabled = value;
  66832. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66833. },
  66834. enumerable: true,
  66835. configurable: true
  66836. });
  66837. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  66838. /**
  66839. * Are opacity textures enabled in the application.
  66840. */
  66841. get: function () {
  66842. return this._OpacityTextureEnabled;
  66843. },
  66844. set: function (value) {
  66845. if (this._OpacityTextureEnabled === value) {
  66846. return;
  66847. }
  66848. this._OpacityTextureEnabled = value;
  66849. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66850. },
  66851. enumerable: true,
  66852. configurable: true
  66853. });
  66854. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  66855. /**
  66856. * Are reflection textures enabled in the application.
  66857. */
  66858. get: function () {
  66859. return this._ReflectionTextureEnabled;
  66860. },
  66861. set: function (value) {
  66862. if (this._ReflectionTextureEnabled === value) {
  66863. return;
  66864. }
  66865. this._ReflectionTextureEnabled = value;
  66866. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66867. },
  66868. enumerable: true,
  66869. configurable: true
  66870. });
  66871. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  66872. /**
  66873. * Are emissive textures enabled in the application.
  66874. */
  66875. get: function () {
  66876. return this._EmissiveTextureEnabled;
  66877. },
  66878. set: function (value) {
  66879. if (this._EmissiveTextureEnabled === value) {
  66880. return;
  66881. }
  66882. this._EmissiveTextureEnabled = value;
  66883. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66884. },
  66885. enumerable: true,
  66886. configurable: true
  66887. });
  66888. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  66889. /**
  66890. * Are specular textures enabled in the application.
  66891. */
  66892. get: function () {
  66893. return this._SpecularTextureEnabled;
  66894. },
  66895. set: function (value) {
  66896. if (this._SpecularTextureEnabled === value) {
  66897. return;
  66898. }
  66899. this._SpecularTextureEnabled = value;
  66900. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66901. },
  66902. enumerable: true,
  66903. configurable: true
  66904. });
  66905. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  66906. /**
  66907. * Are bump textures enabled in the application.
  66908. */
  66909. get: function () {
  66910. return this._BumpTextureEnabled;
  66911. },
  66912. set: function (value) {
  66913. if (this._BumpTextureEnabled === value) {
  66914. return;
  66915. }
  66916. this._BumpTextureEnabled = value;
  66917. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66918. },
  66919. enumerable: true,
  66920. configurable: true
  66921. });
  66922. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  66923. /**
  66924. * Are lightmap textures enabled in the application.
  66925. */
  66926. get: function () {
  66927. return this._LightmapTextureEnabled;
  66928. },
  66929. set: function (value) {
  66930. if (this._LightmapTextureEnabled === value) {
  66931. return;
  66932. }
  66933. this._LightmapTextureEnabled = value;
  66934. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66935. },
  66936. enumerable: true,
  66937. configurable: true
  66938. });
  66939. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  66940. /**
  66941. * Are refraction textures enabled in the application.
  66942. */
  66943. get: function () {
  66944. return this._RefractionTextureEnabled;
  66945. },
  66946. set: function (value) {
  66947. if (this._RefractionTextureEnabled === value) {
  66948. return;
  66949. }
  66950. this._RefractionTextureEnabled = value;
  66951. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66952. },
  66953. enumerable: true,
  66954. configurable: true
  66955. });
  66956. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  66957. /**
  66958. * Are color grading textures enabled in the application.
  66959. */
  66960. get: function () {
  66961. return this._ColorGradingTextureEnabled;
  66962. },
  66963. set: function (value) {
  66964. if (this._ColorGradingTextureEnabled === value) {
  66965. return;
  66966. }
  66967. this._ColorGradingTextureEnabled = value;
  66968. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66969. },
  66970. enumerable: true,
  66971. configurable: true
  66972. });
  66973. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  66974. /**
  66975. * Are fresnels enabled in the application.
  66976. */
  66977. get: function () {
  66978. return this._FresnelEnabled;
  66979. },
  66980. set: function (value) {
  66981. if (this._FresnelEnabled === value) {
  66982. return;
  66983. }
  66984. this._FresnelEnabled = value;
  66985. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  66986. },
  66987. enumerable: true,
  66988. configurable: true
  66989. });
  66990. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  66991. /**
  66992. * Are clear coat textures enabled in the application.
  66993. */
  66994. get: function () {
  66995. return this._ClearCoatTextureEnabled;
  66996. },
  66997. set: function (value) {
  66998. if (this._ClearCoatTextureEnabled === value) {
  66999. return;
  67000. }
  67001. this._ClearCoatTextureEnabled = value;
  67002. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  67003. },
  67004. enumerable: true,
  67005. configurable: true
  67006. });
  67007. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  67008. /**
  67009. * Are clear coat bump textures enabled in the application.
  67010. */
  67011. get: function () {
  67012. return this._ClearCoatBumpTextureEnabled;
  67013. },
  67014. set: function (value) {
  67015. if (this._ClearCoatBumpTextureEnabled === value) {
  67016. return;
  67017. }
  67018. this._ClearCoatBumpTextureEnabled = value;
  67019. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  67020. },
  67021. enumerable: true,
  67022. configurable: true
  67023. });
  67024. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  67025. /**
  67026. * Are clear coat tint textures enabled in the application.
  67027. */
  67028. get: function () {
  67029. return this._ClearCoatTintTextureEnabled;
  67030. },
  67031. set: function (value) {
  67032. if (this._ClearCoatTintTextureEnabled === value) {
  67033. return;
  67034. }
  67035. this._ClearCoatTintTextureEnabled = value;
  67036. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  67037. },
  67038. enumerable: true,
  67039. configurable: true
  67040. });
  67041. Object.defineProperty(MaterialFlags, "SheenTextureEnabled", {
  67042. /**
  67043. * Are sheen textures enabled in the application.
  67044. */
  67045. get: function () {
  67046. return this._SheenTextureEnabled;
  67047. },
  67048. set: function (value) {
  67049. if (this._SheenTextureEnabled === value) {
  67050. return;
  67051. }
  67052. this._SheenTextureEnabled = value;
  67053. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  67054. },
  67055. enumerable: true,
  67056. configurable: true
  67057. });
  67058. Object.defineProperty(MaterialFlags, "AnisotropicTextureEnabled", {
  67059. /**
  67060. * Are anisotropic textures enabled in the application.
  67061. */
  67062. get: function () {
  67063. return this._AnisotropicTextureEnabled;
  67064. },
  67065. set: function (value) {
  67066. if (this._AnisotropicTextureEnabled === value) {
  67067. return;
  67068. }
  67069. this._AnisotropicTextureEnabled = value;
  67070. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  67071. },
  67072. enumerable: true,
  67073. configurable: true
  67074. });
  67075. Object.defineProperty(MaterialFlags, "ThicknessTextureEnabled", {
  67076. /**
  67077. * Are thickness textures enabled in the application.
  67078. */
  67079. get: function () {
  67080. return this._ThicknessTextureEnabled;
  67081. },
  67082. set: function (value) {
  67083. if (this._ThicknessTextureEnabled === value) {
  67084. return;
  67085. }
  67086. this._ThicknessTextureEnabled = value;
  67087. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  67088. },
  67089. enumerable: true,
  67090. configurable: true
  67091. });
  67092. // Flags used to enable or disable a type of texture for all Standard Materials
  67093. MaterialFlags._DiffuseTextureEnabled = true;
  67094. MaterialFlags._AmbientTextureEnabled = true;
  67095. MaterialFlags._OpacityTextureEnabled = true;
  67096. MaterialFlags._ReflectionTextureEnabled = true;
  67097. MaterialFlags._EmissiveTextureEnabled = true;
  67098. MaterialFlags._SpecularTextureEnabled = true;
  67099. MaterialFlags._BumpTextureEnabled = true;
  67100. MaterialFlags._LightmapTextureEnabled = true;
  67101. MaterialFlags._RefractionTextureEnabled = true;
  67102. MaterialFlags._ColorGradingTextureEnabled = true;
  67103. MaterialFlags._FresnelEnabled = true;
  67104. MaterialFlags._ClearCoatTextureEnabled = true;
  67105. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  67106. MaterialFlags._ClearCoatTintTextureEnabled = true;
  67107. MaterialFlags._SheenTextureEnabled = true;
  67108. MaterialFlags._AnisotropicTextureEnabled = true;
  67109. MaterialFlags._ThicknessTextureEnabled = true;
  67110. return MaterialFlags;
  67111. }());
  67112. /***/ }),
  67113. /***/ "./Materials/materialHelper.ts":
  67114. /*!*************************************!*\
  67115. !*** ./Materials/materialHelper.ts ***!
  67116. \*************************************/
  67117. /*! exports provided: MaterialHelper */
  67118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67119. "use strict";
  67120. __webpack_require__.r(__webpack_exports__);
  67121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  67122. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  67123. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  67124. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67125. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  67126. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  67127. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  67128. /**
  67129. * "Static Class" containing the most commonly used helper while dealing with material for
  67130. * rendering purpose.
  67131. *
  67132. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  67133. *
  67134. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  67135. */
  67136. var MaterialHelper = /** @class */ (function () {
  67137. function MaterialHelper() {
  67138. }
  67139. /**
  67140. * Bind the current view position to an effect.
  67141. * @param effect The effect to be bound
  67142. * @param scene The scene the eyes position is used from
  67143. */
  67144. MaterialHelper.BindEyePosition = function (effect, scene) {
  67145. if (scene._forcedViewPosition) {
  67146. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  67147. return;
  67148. }
  67149. var globalPosition = scene.activeCamera.globalPosition;
  67150. if (!globalPosition) {
  67151. // Use WebVRFreecamera's device position as global position is not it's actual position in babylon space
  67152. globalPosition = scene.activeCamera.devicePosition;
  67153. }
  67154. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : globalPosition);
  67155. };
  67156. /**
  67157. * Helps preparing the defines values about the UVs in used in the effect.
  67158. * UVs are shared as much as we can accross channels in the shaders.
  67159. * @param texture The texture we are preparing the UVs for
  67160. * @param defines The defines to update
  67161. * @param key The channel key "diffuse", "specular"... used in the shader
  67162. */
  67163. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  67164. defines._needUVs = true;
  67165. defines[key] = true;
  67166. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  67167. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  67168. if (texture.coordinatesIndex === 0) {
  67169. defines["MAINUV1"] = true;
  67170. }
  67171. else {
  67172. defines["MAINUV2"] = true;
  67173. }
  67174. }
  67175. else {
  67176. defines[key + "DIRECTUV"] = 0;
  67177. }
  67178. };
  67179. /**
  67180. * Binds a texture matrix value to its corrsponding uniform
  67181. * @param texture The texture to bind the matrix for
  67182. * @param uniformBuffer The uniform buffer receivin the data
  67183. * @param key The channel key "diffuse", "specular"... used in the shader
  67184. */
  67185. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  67186. var matrix = texture.getTextureMatrix();
  67187. if (!matrix.isIdentityAs3x2()) {
  67188. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  67189. }
  67190. };
  67191. /**
  67192. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  67193. * @param mesh defines the current mesh
  67194. * @param scene defines the current scene
  67195. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  67196. * @param pointsCloud defines if point cloud rendering has to be turned on
  67197. * @param fogEnabled defines if fog has to be turned on
  67198. * @param alphaTest defines if alpha testing has to be turned on
  67199. * @param defines defines the current list of defines
  67200. */
  67201. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  67202. if (defines._areMiscDirty) {
  67203. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  67204. defines["POINTSIZE"] = pointsCloud;
  67205. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  67206. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  67207. defines["ALPHATEST"] = alphaTest;
  67208. }
  67209. };
  67210. /**
  67211. * Helper used to prepare the list of defines associated with frame values for shader compilation
  67212. * @param scene defines the current scene
  67213. * @param engine defines the current engine
  67214. * @param defines specifies the list of active defines
  67215. * @param useInstances defines if instances have to be turned on
  67216. * @param useClipPlane defines if clip plane have to be turned on
  67217. */
  67218. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  67219. if (useClipPlane === void 0) { useClipPlane = null; }
  67220. var changed = false;
  67221. var useClipPlane1 = false;
  67222. var useClipPlane2 = false;
  67223. var useClipPlane3 = false;
  67224. var useClipPlane4 = false;
  67225. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  67226. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  67227. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  67228. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  67229. if (defines["CLIPPLANE"] !== useClipPlane1) {
  67230. defines["CLIPPLANE"] = useClipPlane1;
  67231. changed = true;
  67232. }
  67233. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  67234. defines["CLIPPLANE2"] = useClipPlane2;
  67235. changed = true;
  67236. }
  67237. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  67238. defines["CLIPPLANE3"] = useClipPlane3;
  67239. changed = true;
  67240. }
  67241. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  67242. defines["CLIPPLANE4"] = useClipPlane4;
  67243. changed = true;
  67244. }
  67245. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  67246. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  67247. changed = true;
  67248. }
  67249. if (defines["INSTANCES"] !== useInstances) {
  67250. defines["INSTANCES"] = useInstances;
  67251. changed = true;
  67252. }
  67253. if (changed) {
  67254. defines.markAsUnprocessed();
  67255. }
  67256. };
  67257. /**
  67258. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67259. * @param mesh The mesh containing the geometry data we will draw
  67260. * @param defines The defines to update
  67261. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67262. * @param useBones Precise whether bones should be used or not (override mesh info)
  67263. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67264. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67265. * @returns false if defines are considered not dirty and have not been checked
  67266. */
  67267. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  67268. if (useMorphTargets === void 0) { useMorphTargets = false; }
  67269. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  67270. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  67271. return false;
  67272. }
  67273. defines._normals = defines._needNormals;
  67274. defines._uvs = defines._needUVs;
  67275. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  67276. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  67277. defines["TANGENT"] = true;
  67278. }
  67279. if (defines._needUVs) {
  67280. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  67281. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  67282. }
  67283. else {
  67284. defines["UV1"] = false;
  67285. defines["UV2"] = false;
  67286. }
  67287. if (useVertexColor) {
  67288. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  67289. defines["VERTEXCOLOR"] = hasVertexColors;
  67290. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  67291. }
  67292. if (useBones) {
  67293. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  67294. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  67295. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  67296. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  67297. defines["BONETEXTURE"] = true;
  67298. }
  67299. else {
  67300. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  67301. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  67302. }
  67303. }
  67304. else {
  67305. defines["NUM_BONE_INFLUENCERS"] = 0;
  67306. defines["BonesPerMesh"] = 0;
  67307. }
  67308. }
  67309. if (useMorphTargets) {
  67310. var manager = mesh.morphTargetManager;
  67311. if (manager) {
  67312. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  67313. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  67314. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  67315. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  67316. }
  67317. else {
  67318. defines["MORPHTARGETS_TANGENT"] = false;
  67319. defines["MORPHTARGETS_NORMAL"] = false;
  67320. defines["MORPHTARGETS"] = false;
  67321. defines["NUM_MORPH_INFLUENCERS"] = 0;
  67322. }
  67323. }
  67324. return true;
  67325. };
  67326. /**
  67327. * Prepares the defines related to multiview
  67328. * @param scene The scene we are intending to draw
  67329. * @param defines The defines to update
  67330. */
  67331. MaterialHelper.PrepareDefinesForMultiview = function (scene, defines) {
  67332. if (scene.activeCamera) {
  67333. var previousMultiview = defines.MULTIVIEW;
  67334. defines.MULTIVIEW = (scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1);
  67335. if (defines.MULTIVIEW != previousMultiview) {
  67336. defines.markAsUnprocessed();
  67337. }
  67338. }
  67339. };
  67340. /**
  67341. * Prepares the defines related to the light information passed in parameter
  67342. * @param scene The scene we are intending to draw
  67343. * @param mesh The mesh the effect is compiling for
  67344. * @param defines The defines to update
  67345. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67346. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67347. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67348. * @returns true if normals will be required for the rest of the effect
  67349. */
  67350. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  67351. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67352. if (disableLighting === void 0) { disableLighting = false; }
  67353. if (!defines._areLightsDirty) {
  67354. return defines._needNormals;
  67355. }
  67356. var lightIndex = 0;
  67357. var needNormals = false;
  67358. var needRebuild = false;
  67359. var lightmapMode = false;
  67360. var shadowEnabled = false;
  67361. var specularEnabled = false;
  67362. if (scene.lightsEnabled && !disableLighting) {
  67363. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  67364. var light = _a[_i];
  67365. needNormals = true;
  67366. if (defines["LIGHT" + lightIndex] === undefined) {
  67367. needRebuild = true;
  67368. }
  67369. defines["LIGHT" + lightIndex] = true;
  67370. defines["SPOTLIGHT" + lightIndex] = false;
  67371. defines["HEMILIGHT" + lightIndex] = false;
  67372. defines["POINTLIGHT" + lightIndex] = false;
  67373. defines["DIRLIGHT" + lightIndex] = false;
  67374. light.prepareLightSpecificDefines(defines, lightIndex);
  67375. // FallOff.
  67376. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  67377. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  67378. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  67379. switch (light.falloffType) {
  67380. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  67381. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  67382. break;
  67383. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  67384. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  67385. break;
  67386. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  67387. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  67388. break;
  67389. }
  67390. // Specular
  67391. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  67392. specularEnabled = true;
  67393. }
  67394. // Shadows
  67395. defines["SHADOW" + lightIndex] = false;
  67396. defines["SHADOWPCF" + lightIndex] = false;
  67397. defines["SHADOWPCSS" + lightIndex] = false;
  67398. defines["SHADOWPOISSON" + lightIndex] = false;
  67399. defines["SHADOWESM" + lightIndex] = false;
  67400. defines["SHADOWCUBE" + lightIndex] = false;
  67401. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  67402. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  67403. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  67404. var shadowGenerator = light.getShadowGenerator();
  67405. if (shadowGenerator) {
  67406. var shadowMap = shadowGenerator.getShadowMap();
  67407. if (shadowMap) {
  67408. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  67409. shadowEnabled = true;
  67410. shadowGenerator.prepareDefines(defines, lightIndex);
  67411. }
  67412. }
  67413. }
  67414. }
  67415. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  67416. lightmapMode = true;
  67417. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  67418. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  67419. }
  67420. else {
  67421. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  67422. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  67423. }
  67424. lightIndex++;
  67425. if (lightIndex === maxSimultaneousLights) {
  67426. break;
  67427. }
  67428. }
  67429. }
  67430. defines["SPECULARTERM"] = specularEnabled;
  67431. defines["SHADOWS"] = shadowEnabled;
  67432. // Resetting all other lights if any
  67433. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  67434. if (defines["LIGHT" + index] !== undefined) {
  67435. defines["LIGHT" + index] = false;
  67436. defines["HEMILIGHT" + index] = false;
  67437. defines["POINTLIGHT" + index] = false;
  67438. defines["DIRLIGHT" + index] = false;
  67439. defines["SPOTLIGHT" + index] = false;
  67440. defines["SHADOW" + index] = false;
  67441. defines["SHADOWPCF" + index] = false;
  67442. defines["SHADOWPCSS" + index] = false;
  67443. defines["SHADOWPOISSON" + index] = false;
  67444. defines["SHADOWESM" + index] = false;
  67445. defines["SHADOWCUBE" + index] = false;
  67446. defines["SHADOWLOWQUALITY" + index] = false;
  67447. defines["SHADOWMEDIUMQUALITY" + index] = false;
  67448. }
  67449. }
  67450. var caps = scene.getEngine().getCaps();
  67451. if (defines["SHADOWFLOAT"] === undefined) {
  67452. needRebuild = true;
  67453. }
  67454. defines["SHADOWFLOAT"] = shadowEnabled &&
  67455. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  67456. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  67457. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  67458. if (needRebuild) {
  67459. defines.rebuild();
  67460. }
  67461. return needNormals;
  67462. };
  67463. /**
  67464. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67465. * that won t be acctive due to defines being turned off.
  67466. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67467. * @param samplersList The samplers list
  67468. * @param defines The defines helping in the list generation
  67469. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67470. */
  67471. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  67472. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67473. var uniformsList;
  67474. var uniformBuffersList = null;
  67475. if (uniformsListOrOptions.uniformsNames) {
  67476. var options = uniformsListOrOptions;
  67477. uniformsList = options.uniformsNames;
  67478. uniformBuffersList = options.uniformBuffersNames;
  67479. samplersList = options.samplers;
  67480. defines = options.defines;
  67481. maxSimultaneousLights = options.maxSimultaneousLights;
  67482. }
  67483. else {
  67484. uniformsList = uniformsListOrOptions;
  67485. if (!samplersList) {
  67486. samplersList = [];
  67487. }
  67488. }
  67489. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  67490. if (!defines["LIGHT" + lightIndex]) {
  67491. break;
  67492. }
  67493. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  67494. if (uniformBuffersList) {
  67495. uniformBuffersList.push("Light" + lightIndex);
  67496. }
  67497. samplersList.push("shadowSampler" + lightIndex);
  67498. samplersList.push("depthSampler" + lightIndex);
  67499. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  67500. samplersList.push("projectionLightSampler" + lightIndex);
  67501. uniformsList.push("textureProjectionMatrix" + lightIndex);
  67502. }
  67503. }
  67504. if (defines["NUM_MORPH_INFLUENCERS"]) {
  67505. uniformsList.push("morphTargetInfluences");
  67506. }
  67507. };
  67508. /**
  67509. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67510. * @param defines The defines to update while falling back
  67511. * @param fallbacks The authorized effect fallbacks
  67512. * @param maxSimultaneousLights The maximum number of lights allowed
  67513. * @param rank the current rank of the Effect
  67514. * @returns The newly affected rank
  67515. */
  67516. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  67517. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67518. if (rank === void 0) { rank = 0; }
  67519. var lightFallbackRank = 0;
  67520. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  67521. if (!defines["LIGHT" + lightIndex]) {
  67522. break;
  67523. }
  67524. if (lightIndex > 0) {
  67525. lightFallbackRank = rank + lightIndex;
  67526. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  67527. }
  67528. if (!defines["SHADOWS"]) {
  67529. if (defines["SHADOW" + lightIndex]) {
  67530. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  67531. }
  67532. if (defines["SHADOWPCF" + lightIndex]) {
  67533. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  67534. }
  67535. if (defines["SHADOWPCSS" + lightIndex]) {
  67536. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  67537. }
  67538. if (defines["SHADOWPOISSON" + lightIndex]) {
  67539. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  67540. }
  67541. if (defines["SHADOWESM" + lightIndex]) {
  67542. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  67543. }
  67544. }
  67545. }
  67546. return lightFallbackRank++;
  67547. };
  67548. /**
  67549. * Prepares the list of attributes required for morph targets according to the effect defines.
  67550. * @param attribs The current list of supported attribs
  67551. * @param mesh The mesh to prepare the morph targets attributes for
  67552. * @param defines The current Defines of the effect
  67553. */
  67554. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  67555. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  67556. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  67557. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  67558. var manager = mesh.morphTargetManager;
  67559. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  67560. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  67561. for (var index = 0; index < influencers; index++) {
  67562. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  67563. if (normal) {
  67564. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  67565. }
  67566. if (tangent) {
  67567. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  67568. }
  67569. if (attribs.length > maxAttributesCount) {
  67570. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  67571. }
  67572. }
  67573. }
  67574. };
  67575. /**
  67576. * Prepares the list of attributes required for bones according to the effect defines.
  67577. * @param attribs The current list of supported attribs
  67578. * @param mesh The mesh to prepare the bones attributes for
  67579. * @param defines The current Defines of the effect
  67580. * @param fallbacks The current efffect fallback strategy
  67581. */
  67582. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  67583. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  67584. fallbacks.addCPUSkinningFallback(0, mesh);
  67585. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  67586. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  67587. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  67588. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  67589. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  67590. }
  67591. }
  67592. };
  67593. /**
  67594. * Prepares the list of attributes required for instances according to the effect defines.
  67595. * @param attribs The current list of supported attribs
  67596. * @param defines The current Defines of the effect
  67597. */
  67598. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  67599. if (defines["INSTANCES"]) {
  67600. attribs.push("world0");
  67601. attribs.push("world1");
  67602. attribs.push("world2");
  67603. attribs.push("world3");
  67604. }
  67605. };
  67606. /**
  67607. * Binds the light shadow information to the effect for the given mesh.
  67608. * @param light The light containing the generator
  67609. * @param scene The scene the lights belongs to
  67610. * @param mesh The mesh we are binding the information to render
  67611. * @param lightIndex The light index in the effect used to render the mesh
  67612. * @param effect The effect we are binding the data to
  67613. */
  67614. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  67615. if (light.shadowEnabled && mesh.receiveShadows) {
  67616. var shadowGenerator = light.getShadowGenerator();
  67617. if (shadowGenerator) {
  67618. shadowGenerator.bindShadowLight(lightIndex, effect);
  67619. }
  67620. }
  67621. };
  67622. /**
  67623. * Binds the light information to the effect.
  67624. * @param light The light containing the generator
  67625. * @param effect The effect we are binding the data to
  67626. * @param lightIndex The light index in the effect used to render
  67627. */
  67628. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  67629. light.transferToEffect(effect, lightIndex + "");
  67630. };
  67631. /**
  67632. * Binds the lights information from the scene to the effect for the given mesh.
  67633. * @param scene The scene the lights belongs to
  67634. * @param mesh The mesh we are binding the information to render
  67635. * @param effect The effect we are binding the data to
  67636. * @param defines The generated defines for the effect
  67637. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67638. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67639. */
  67640. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  67641. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67642. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  67643. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  67644. for (var i = 0; i < len; i++) {
  67645. var light = mesh._lightSources[i];
  67646. var iAsString = i.toString();
  67647. var scaledIntensity = light.getScaledIntensity();
  67648. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  67649. MaterialHelper.BindLightProperties(light, effect, i);
  67650. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  67651. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  67652. if (defines["SPECULARTERM"]) {
  67653. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  67654. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  67655. }
  67656. // Shadows
  67657. if (scene.shadowsEnabled) {
  67658. this.BindLightShadow(light, mesh, iAsString, effect);
  67659. }
  67660. light._uniformBuffer.update();
  67661. }
  67662. };
  67663. /**
  67664. * Binds the fog information from the scene to the effect for the given mesh.
  67665. * @param scene The scene the lights belongs to
  67666. * @param mesh The mesh we are binding the information to render
  67667. * @param effect The effect we are binding the data to
  67668. * @param linearSpace Defines if the fog effect is applied in linear space
  67669. */
  67670. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  67671. if (linearSpace === void 0) { linearSpace = false; }
  67672. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  67673. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  67674. // Convert fog color to linear space if used in a linear space computed shader.
  67675. if (linearSpace) {
  67676. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  67677. effect.setColor3("vFogColor", this._tempFogColor);
  67678. }
  67679. else {
  67680. effect.setColor3("vFogColor", scene.fogColor);
  67681. }
  67682. }
  67683. };
  67684. /**
  67685. * Binds the bones information from the mesh to the effect.
  67686. * @param mesh The mesh we are binding the information to render
  67687. * @param effect The effect we are binding the data to
  67688. */
  67689. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  67690. if (!effect || !mesh) {
  67691. return;
  67692. }
  67693. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  67694. mesh.computeBonesUsingShaders = false;
  67695. }
  67696. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  67697. var skeleton = mesh.skeleton;
  67698. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  67699. var boneTexture = skeleton.getTransformMatrixTexture();
  67700. effect.setTexture("boneSampler", boneTexture);
  67701. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  67702. }
  67703. else {
  67704. var matrices = skeleton.getTransformMatrices(mesh);
  67705. if (matrices) {
  67706. effect.setMatrices("mBones", matrices);
  67707. }
  67708. }
  67709. }
  67710. };
  67711. /**
  67712. * Binds the morph targets information from the mesh to the effect.
  67713. * @param abstractMesh The mesh we are binding the information to render
  67714. * @param effect The effect we are binding the data to
  67715. */
  67716. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  67717. var manager = abstractMesh.morphTargetManager;
  67718. if (!abstractMesh || !manager) {
  67719. return;
  67720. }
  67721. effect.setFloatArray("morphTargetInfluences", manager.influences);
  67722. };
  67723. /**
  67724. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67725. * @param defines The generated defines used in the effect
  67726. * @param effect The effect we are binding the data to
  67727. * @param scene The scene we are willing to render with logarithmic scale for
  67728. */
  67729. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  67730. if (defines["LOGARITHMICDEPTH"]) {
  67731. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  67732. }
  67733. };
  67734. /**
  67735. * Binds the clip plane information from the scene to the effect.
  67736. * @param scene The scene the clip plane information are extracted from
  67737. * @param effect The effect we are binding the data to
  67738. */
  67739. MaterialHelper.BindClipPlane = function (effect, scene) {
  67740. if (scene.clipPlane) {
  67741. var clipPlane = scene.clipPlane;
  67742. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67743. }
  67744. if (scene.clipPlane2) {
  67745. var clipPlane = scene.clipPlane2;
  67746. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67747. }
  67748. if (scene.clipPlane3) {
  67749. var clipPlane = scene.clipPlane3;
  67750. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67751. }
  67752. if (scene.clipPlane4) {
  67753. var clipPlane = scene.clipPlane4;
  67754. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67755. }
  67756. };
  67757. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  67758. return MaterialHelper;
  67759. }());
  67760. /***/ }),
  67761. /***/ "./Materials/multiMaterial.ts":
  67762. /*!************************************!*\
  67763. !*** ./Materials/multiMaterial.ts ***!
  67764. \************************************/
  67765. /*! exports provided: MultiMaterial */
  67766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67767. "use strict";
  67768. __webpack_require__.r(__webpack_exports__);
  67769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  67770. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67771. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  67772. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  67773. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  67774. /**
  67775. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67776. * separate meshes. This can be use to improve performances.
  67777. * @see http://doc.babylonjs.com/how_to/multi_materials
  67778. */
  67779. var MultiMaterial = /** @class */ (function (_super) {
  67780. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  67781. /**
  67782. * Instantiates a new Multi Material
  67783. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67784. * separate meshes. This can be use to improve performances.
  67785. * @see http://doc.babylonjs.com/how_to/multi_materials
  67786. * @param name Define the name in the scene
  67787. * @param scene Define the scene the material belongs to
  67788. */
  67789. function MultiMaterial(name, scene) {
  67790. var _this = _super.call(this, name, scene, true) || this;
  67791. scene.multiMaterials.push(_this);
  67792. _this.subMaterials = new Array();
  67793. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  67794. return _this;
  67795. }
  67796. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  67797. /**
  67798. * Gets or Sets the list of Materials used within the multi material.
  67799. * They need to be ordered according to the submeshes order in the associated mesh
  67800. */
  67801. get: function () {
  67802. return this._subMaterials;
  67803. },
  67804. set: function (value) {
  67805. this._subMaterials = value;
  67806. this._hookArray(value);
  67807. },
  67808. enumerable: true,
  67809. configurable: true
  67810. });
  67811. /**
  67812. * Function used to align with Node.getChildren()
  67813. * @returns the list of Materials used within the multi material
  67814. */
  67815. MultiMaterial.prototype.getChildren = function () {
  67816. return this.subMaterials;
  67817. };
  67818. MultiMaterial.prototype._hookArray = function (array) {
  67819. var _this = this;
  67820. var oldPush = array.push;
  67821. array.push = function () {
  67822. var items = [];
  67823. for (var _i = 0; _i < arguments.length; _i++) {
  67824. items[_i] = arguments[_i];
  67825. }
  67826. var result = oldPush.apply(array, items);
  67827. _this._markAllSubMeshesAsTexturesDirty();
  67828. return result;
  67829. };
  67830. var oldSplice = array.splice;
  67831. array.splice = function (index, deleteCount) {
  67832. var deleted = oldSplice.apply(array, [index, deleteCount]);
  67833. _this._markAllSubMeshesAsTexturesDirty();
  67834. return deleted;
  67835. };
  67836. };
  67837. /**
  67838. * Get one of the submaterial by its index in the submaterials array
  67839. * @param index The index to look the sub material at
  67840. * @returns The Material if the index has been defined
  67841. */
  67842. MultiMaterial.prototype.getSubMaterial = function (index) {
  67843. if (index < 0 || index >= this.subMaterials.length) {
  67844. return this.getScene().defaultMaterial;
  67845. }
  67846. return this.subMaterials[index];
  67847. };
  67848. /**
  67849. * Get the list of active textures for the whole sub materials list.
  67850. * @returns All the textures that will be used during the rendering
  67851. */
  67852. MultiMaterial.prototype.getActiveTextures = function () {
  67853. var _a;
  67854. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  67855. if (subMaterial) {
  67856. return subMaterial.getActiveTextures();
  67857. }
  67858. else {
  67859. return [];
  67860. }
  67861. }));
  67862. };
  67863. /**
  67864. * Gets the current class name of the material e.g. "MultiMaterial"
  67865. * Mainly use in serialization.
  67866. * @returns the class name
  67867. */
  67868. MultiMaterial.prototype.getClassName = function () {
  67869. return "MultiMaterial";
  67870. };
  67871. /**
  67872. * Checks if the material is ready to render the requested sub mesh
  67873. * @param mesh Define the mesh the submesh belongs to
  67874. * @param subMesh Define the sub mesh to look readyness for
  67875. * @param useInstances Define whether or not the material is used with instances
  67876. * @returns true if ready, otherwise false
  67877. */
  67878. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67879. for (var index = 0; index < this.subMaterials.length; index++) {
  67880. var subMaterial = this.subMaterials[index];
  67881. if (subMaterial) {
  67882. if (subMaterial._storeEffectOnSubMeshes) {
  67883. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  67884. return false;
  67885. }
  67886. continue;
  67887. }
  67888. if (!subMaterial.isReady(mesh)) {
  67889. return false;
  67890. }
  67891. }
  67892. }
  67893. return true;
  67894. };
  67895. /**
  67896. * Clones the current material and its related sub materials
  67897. * @param name Define the name of the newly cloned material
  67898. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67899. * @returns the cloned material
  67900. */
  67901. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  67902. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  67903. for (var index = 0; index < this.subMaterials.length; index++) {
  67904. var subMaterial = null;
  67905. var current = this.subMaterials[index];
  67906. if (cloneChildren && current) {
  67907. subMaterial = current.clone(name + "-" + current.name);
  67908. }
  67909. else {
  67910. subMaterial = this.subMaterials[index];
  67911. }
  67912. newMultiMaterial.subMaterials.push(subMaterial);
  67913. }
  67914. return newMultiMaterial;
  67915. };
  67916. /**
  67917. * Serializes the materials into a JSON representation.
  67918. * @returns the JSON representation
  67919. */
  67920. MultiMaterial.prototype.serialize = function () {
  67921. var serializationObject = {};
  67922. serializationObject.name = this.name;
  67923. serializationObject.id = this.id;
  67924. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  67925. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  67926. }
  67927. serializationObject.materials = [];
  67928. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  67929. var subMat = this.subMaterials[matIndex];
  67930. if (subMat) {
  67931. serializationObject.materials.push(subMat.id);
  67932. }
  67933. else {
  67934. serializationObject.materials.push(null);
  67935. }
  67936. }
  67937. return serializationObject;
  67938. };
  67939. /**
  67940. * Dispose the material and release its associated resources
  67941. * @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)
  67942. * @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)
  67943. * @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)
  67944. */
  67945. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  67946. var scene = this.getScene();
  67947. if (!scene) {
  67948. return;
  67949. }
  67950. if (forceDisposeChildren) {
  67951. for (var index = 0; index < this.subMaterials.length; index++) {
  67952. var subMaterial = this.subMaterials[index];
  67953. if (subMaterial) {
  67954. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  67955. }
  67956. }
  67957. }
  67958. var index = scene.multiMaterials.indexOf(this);
  67959. if (index >= 0) {
  67960. scene.multiMaterials.splice(index, 1);
  67961. }
  67962. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  67963. };
  67964. /**
  67965. * Creates a MultiMaterial from parsed MultiMaterial data.
  67966. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67967. * @param scene defines the hosting scene
  67968. * @returns a new MultiMaterial
  67969. */
  67970. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  67971. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  67972. multiMaterial.id = parsedMultiMaterial.id;
  67973. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  67974. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  67975. }
  67976. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  67977. var subMatId = parsedMultiMaterial.materials[matIndex];
  67978. if (subMatId) {
  67979. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  67980. }
  67981. else {
  67982. multiMaterial.subMaterials.push(null);
  67983. }
  67984. }
  67985. return multiMaterial;
  67986. };
  67987. return MultiMaterial;
  67988. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  67989. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  67990. /***/ }),
  67991. /***/ "./Materials/pushMaterial.ts":
  67992. /*!***********************************!*\
  67993. !*** ./Materials/pushMaterial.ts ***!
  67994. \***********************************/
  67995. /*! exports provided: PushMaterial */
  67996. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67997. "use strict";
  67998. __webpack_require__.r(__webpack_exports__);
  67999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  68000. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  68001. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  68002. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  68003. /**
  68004. * Base class of materials working in push mode in babylon JS
  68005. * @hidden
  68006. */
  68007. var PushMaterial = /** @class */ (function (_super) {
  68008. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  68009. function PushMaterial(name, scene) {
  68010. var _this = _super.call(this, name, scene) || this;
  68011. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  68012. /**
  68013. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  68014. * This means that the material can keep using a previous shader while a new one is being compiled.
  68015. * This is mostly used when shader parallel compilation is supported (true by default)
  68016. */
  68017. _this.allowShaderHotSwapping = true;
  68018. _this._storeEffectOnSubMeshes = true;
  68019. return _this;
  68020. }
  68021. PushMaterial.prototype.getEffect = function () {
  68022. return this._activeEffect;
  68023. };
  68024. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  68025. if (!mesh) {
  68026. return false;
  68027. }
  68028. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  68029. return true;
  68030. }
  68031. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  68032. };
  68033. /**
  68034. * Binds the given world matrix to the active effect
  68035. *
  68036. * @param world the matrix to bind
  68037. */
  68038. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  68039. this._activeEffect.setMatrix("world", world);
  68040. };
  68041. /**
  68042. * Binds the given normal matrix to the active effect
  68043. *
  68044. * @param normalMatrix the matrix to bind
  68045. */
  68046. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  68047. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  68048. };
  68049. PushMaterial.prototype.bind = function (world, mesh) {
  68050. if (!mesh) {
  68051. return;
  68052. }
  68053. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  68054. };
  68055. PushMaterial.prototype._afterBind = function (mesh, effect) {
  68056. if (effect === void 0) { effect = null; }
  68057. _super.prototype._afterBind.call(this, mesh);
  68058. this.getScene()._cachedEffect = effect;
  68059. };
  68060. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  68061. if (visibility === void 0) { visibility = 1; }
  68062. return scene.isCachedMaterialInvalid(this, effect, visibility);
  68063. };
  68064. return PushMaterial;
  68065. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  68066. /***/ }),
  68067. /***/ "./Materials/shaderMaterial.ts":
  68068. /*!*************************************!*\
  68069. !*** ./Materials/shaderMaterial.ts ***!
  68070. \*************************************/
  68071. /*! exports provided: ShaderMaterial */
  68072. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68073. "use strict";
  68074. __webpack_require__.r(__webpack_exports__);
  68075. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  68076. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  68077. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  68078. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  68079. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  68080. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  68081. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  68082. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  68083. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  68084. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  68085. /**
  68086. * 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.
  68087. *
  68088. * This returned material effects how the mesh will look based on the code in the shaders.
  68089. *
  68090. * @see http://doc.babylonjs.com/how_to/shader_material
  68091. */
  68092. var ShaderMaterial = /** @class */ (function (_super) {
  68093. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  68094. /**
  68095. * Instantiate a new shader material.
  68096. * 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.
  68097. * This returned material effects how the mesh will look based on the code in the shaders.
  68098. * @see http://doc.babylonjs.com/how_to/shader_material
  68099. * @param name Define the name of the material in the scene
  68100. * @param scene Define the scene the material belongs to
  68101. * @param shaderPath Defines the route to the shader code in one of three ways:
  68102. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  68103. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  68104. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  68105. * @param options Define the options used to create the shader
  68106. */
  68107. function ShaderMaterial(name, scene, shaderPath, options) {
  68108. if (options === void 0) { options = {}; }
  68109. var _this = _super.call(this, name, scene) || this;
  68110. _this._textures = {};
  68111. _this._textureArrays = {};
  68112. _this._floats = {};
  68113. _this._ints = {};
  68114. _this._floatsArrays = {};
  68115. _this._colors3 = {};
  68116. _this._colors3Arrays = {};
  68117. _this._colors4 = {};
  68118. _this._vectors2 = {};
  68119. _this._vectors3 = {};
  68120. _this._vectors4 = {};
  68121. _this._matrices = {};
  68122. _this._matrices3x3 = {};
  68123. _this._matrices2x2 = {};
  68124. _this._vectors2Arrays = {};
  68125. _this._vectors3Arrays = {};
  68126. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  68127. _this._shaderPath = shaderPath;
  68128. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  68129. return _this;
  68130. }
  68131. Object.defineProperty(ShaderMaterial.prototype, "options", {
  68132. /**
  68133. * Gets the options used to compile the shader.
  68134. * They can be modified to trigger a new compilation
  68135. */
  68136. get: function () {
  68137. return this._options;
  68138. },
  68139. enumerable: true,
  68140. configurable: true
  68141. });
  68142. /**
  68143. * Gets the current class name of the material e.g. "ShaderMaterial"
  68144. * Mainly use in serialization.
  68145. * @returns the class name
  68146. */
  68147. ShaderMaterial.prototype.getClassName = function () {
  68148. return "ShaderMaterial";
  68149. };
  68150. /**
  68151. * Specifies if the material will require alpha blending
  68152. * @returns a boolean specifying if alpha blending is needed
  68153. */
  68154. ShaderMaterial.prototype.needAlphaBlending = function () {
  68155. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  68156. };
  68157. /**
  68158. * Specifies if this material should be rendered in alpha test mode
  68159. * @returns a boolean specifying if an alpha test is needed.
  68160. */
  68161. ShaderMaterial.prototype.needAlphaTesting = function () {
  68162. return this._options.needAlphaTesting;
  68163. };
  68164. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  68165. if (this._options.uniforms.indexOf(uniformName) === -1) {
  68166. this._options.uniforms.push(uniformName);
  68167. }
  68168. };
  68169. /**
  68170. * Set a texture in the shader.
  68171. * @param name Define the name of the uniform samplers as defined in the shader
  68172. * @param texture Define the texture to bind to this sampler
  68173. * @return the material itself allowing "fluent" like uniform updates
  68174. */
  68175. ShaderMaterial.prototype.setTexture = function (name, texture) {
  68176. if (this._options.samplers.indexOf(name) === -1) {
  68177. this._options.samplers.push(name);
  68178. }
  68179. this._textures[name] = texture;
  68180. return this;
  68181. };
  68182. /**
  68183. * Set a texture array in the shader.
  68184. * @param name Define the name of the uniform sampler array as defined in the shader
  68185. * @param textures Define the list of textures to bind to this sampler
  68186. * @return the material itself allowing "fluent" like uniform updates
  68187. */
  68188. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  68189. if (this._options.samplers.indexOf(name) === -1) {
  68190. this._options.samplers.push(name);
  68191. }
  68192. this._checkUniform(name);
  68193. this._textureArrays[name] = textures;
  68194. return this;
  68195. };
  68196. /**
  68197. * Set a float in the shader.
  68198. * @param name Define the name of the uniform as defined in the shader
  68199. * @param value Define the value to give to the uniform
  68200. * @return the material itself allowing "fluent" like uniform updates
  68201. */
  68202. ShaderMaterial.prototype.setFloat = function (name, value) {
  68203. this._checkUniform(name);
  68204. this._floats[name] = value;
  68205. return this;
  68206. };
  68207. /**
  68208. * Set a int in the shader.
  68209. * @param name Define the name of the uniform as defined in the shader
  68210. * @param value Define the value to give to the uniform
  68211. * @return the material itself allowing "fluent" like uniform updates
  68212. */
  68213. ShaderMaterial.prototype.setInt = function (name, value) {
  68214. this._checkUniform(name);
  68215. this._ints[name] = value;
  68216. return this;
  68217. };
  68218. /**
  68219. * Set an array of floats in the shader.
  68220. * @param name Define the name of the uniform as defined in the shader
  68221. * @param value Define the value to give to the uniform
  68222. * @return the material itself allowing "fluent" like uniform updates
  68223. */
  68224. ShaderMaterial.prototype.setFloats = function (name, value) {
  68225. this._checkUniform(name);
  68226. this._floatsArrays[name] = value;
  68227. return this;
  68228. };
  68229. /**
  68230. * Set a vec3 in the shader from a Color3.
  68231. * @param name Define the name of the uniform as defined in the shader
  68232. * @param value Define the value to give to the uniform
  68233. * @return the material itself allowing "fluent" like uniform updates
  68234. */
  68235. ShaderMaterial.prototype.setColor3 = function (name, value) {
  68236. this._checkUniform(name);
  68237. this._colors3[name] = value;
  68238. return this;
  68239. };
  68240. /**
  68241. * Set a vec3 array in the shader from a Color3 array.
  68242. * @param name Define the name of the uniform as defined in the shader
  68243. * @param value Define the value to give to the uniform
  68244. * @return the material itself allowing "fluent" like uniform updates
  68245. */
  68246. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  68247. this._checkUniform(name);
  68248. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  68249. color.toArray(arr, arr.length);
  68250. return arr;
  68251. }, []);
  68252. return this;
  68253. };
  68254. /**
  68255. * Set a vec4 in the shader from a Color4.
  68256. * @param name Define the name of the uniform as defined in the shader
  68257. * @param value Define the value to give to the uniform
  68258. * @return the material itself allowing "fluent" like uniform updates
  68259. */
  68260. ShaderMaterial.prototype.setColor4 = function (name, value) {
  68261. this._checkUniform(name);
  68262. this._colors4[name] = value;
  68263. return this;
  68264. };
  68265. /**
  68266. * Set a vec2 in the shader from a Vector2.
  68267. * @param name Define the name of the uniform as defined in the shader
  68268. * @param value Define the value to give to the uniform
  68269. * @return the material itself allowing "fluent" like uniform updates
  68270. */
  68271. ShaderMaterial.prototype.setVector2 = function (name, value) {
  68272. this._checkUniform(name);
  68273. this._vectors2[name] = value;
  68274. return this;
  68275. };
  68276. /**
  68277. * Set a vec3 in the shader from a Vector3.
  68278. * @param name Define the name of the uniform as defined in the shader
  68279. * @param value Define the value to give to the uniform
  68280. * @return the material itself allowing "fluent" like uniform updates
  68281. */
  68282. ShaderMaterial.prototype.setVector3 = function (name, value) {
  68283. this._checkUniform(name);
  68284. this._vectors3[name] = value;
  68285. return this;
  68286. };
  68287. /**
  68288. * Set a vec4 in the shader from a Vector4.
  68289. * @param name Define the name of the uniform as defined in the shader
  68290. * @param value Define the value to give to the uniform
  68291. * @return the material itself allowing "fluent" like uniform updates
  68292. */
  68293. ShaderMaterial.prototype.setVector4 = function (name, value) {
  68294. this._checkUniform(name);
  68295. this._vectors4[name] = value;
  68296. return this;
  68297. };
  68298. /**
  68299. * Set a mat4 in the shader from a Matrix.
  68300. * @param name Define the name of the uniform as defined in the shader
  68301. * @param value Define the value to give to the uniform
  68302. * @return the material itself allowing "fluent" like uniform updates
  68303. */
  68304. ShaderMaterial.prototype.setMatrix = function (name, value) {
  68305. this._checkUniform(name);
  68306. this._matrices[name] = value;
  68307. return this;
  68308. };
  68309. /**
  68310. * Set a mat3 in the shader from a Float32Array.
  68311. * @param name Define the name of the uniform as defined in the shader
  68312. * @param value Define the value to give to the uniform
  68313. * @return the material itself allowing "fluent" like uniform updates
  68314. */
  68315. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  68316. this._checkUniform(name);
  68317. this._matrices3x3[name] = value;
  68318. return this;
  68319. };
  68320. /**
  68321. * Set a mat2 in the shader from a Float32Array.
  68322. * @param name Define the name of the uniform as defined in the shader
  68323. * @param value Define the value to give to the uniform
  68324. * @return the material itself allowing "fluent" like uniform updates
  68325. */
  68326. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  68327. this._checkUniform(name);
  68328. this._matrices2x2[name] = value;
  68329. return this;
  68330. };
  68331. /**
  68332. * Set a vec2 array in the shader from a number array.
  68333. * @param name Define the name of the uniform as defined in the shader
  68334. * @param value Define the value to give to the uniform
  68335. * @return the material itself allowing "fluent" like uniform updates
  68336. */
  68337. ShaderMaterial.prototype.setArray2 = function (name, value) {
  68338. this._checkUniform(name);
  68339. this._vectors2Arrays[name] = value;
  68340. return this;
  68341. };
  68342. /**
  68343. * Set a vec3 array in the shader from a number array.
  68344. * @param name Define the name of the uniform as defined in the shader
  68345. * @param value Define the value to give to the uniform
  68346. * @return the material itself allowing "fluent" like uniform updates
  68347. */
  68348. ShaderMaterial.prototype.setArray3 = function (name, value) {
  68349. this._checkUniform(name);
  68350. this._vectors3Arrays[name] = value;
  68351. return this;
  68352. };
  68353. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  68354. if (!mesh) {
  68355. return true;
  68356. }
  68357. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  68358. return false;
  68359. }
  68360. return false;
  68361. };
  68362. /**
  68363. * Specifies that the submesh is ready to be used
  68364. * @param mesh defines the mesh to check
  68365. * @param subMesh defines which submesh to check
  68366. * @param useInstances specifies that instances should be used
  68367. * @returns a boolean indicating that the submesh is ready or not
  68368. */
  68369. ShaderMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  68370. return this.isReady(mesh, useInstances);
  68371. };
  68372. /**
  68373. * Checks if the material is ready to render the requested mesh
  68374. * @param mesh Define the mesh to render
  68375. * @param useInstances Define whether or not the material is used with instances
  68376. * @returns true if ready, otherwise false
  68377. */
  68378. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  68379. var scene = this.getScene();
  68380. var engine = scene.getEngine();
  68381. if (!this.checkReadyOnEveryCall) {
  68382. if (this._renderId === scene.getRenderId()) {
  68383. if (this._checkCache(mesh, useInstances)) {
  68384. return true;
  68385. }
  68386. }
  68387. }
  68388. // Instances
  68389. var defines = [];
  68390. var attribs = [];
  68391. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  68392. for (var index = 0; index < this._options.defines.length; index++) {
  68393. defines.push(this._options.defines[index]);
  68394. }
  68395. for (var index = 0; index < this._options.attributes.length; index++) {
  68396. attribs.push(this._options.attributes[index]);
  68397. }
  68398. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  68399. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  68400. defines.push("#define VERTEXCOLOR");
  68401. }
  68402. if (useInstances) {
  68403. defines.push("#define INSTANCES");
  68404. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  68405. }
  68406. // Bones
  68407. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  68408. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  68409. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  68410. if (mesh.numBoneInfluencers > 4) {
  68411. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  68412. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  68413. }
  68414. var skeleton = mesh.skeleton;
  68415. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  68416. fallbacks.addCPUSkinningFallback(0, mesh);
  68417. if (skeleton.isUsingTextureForMatrices) {
  68418. defines.push("#define BONETEXTURE");
  68419. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  68420. this._options.uniforms.push("boneTextureWidth");
  68421. }
  68422. if (this._options.samplers.indexOf("boneSampler") === -1) {
  68423. this._options.samplers.push("boneSampler");
  68424. }
  68425. }
  68426. else {
  68427. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  68428. if (this._options.uniforms.indexOf("mBones") === -1) {
  68429. this._options.uniforms.push("mBones");
  68430. }
  68431. }
  68432. }
  68433. else {
  68434. defines.push("#define NUM_BONE_INFLUENCERS 0");
  68435. }
  68436. // Textures
  68437. for (var name in this._textures) {
  68438. if (!this._textures[name].isReady()) {
  68439. return false;
  68440. }
  68441. }
  68442. // Alpha test
  68443. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  68444. defines.push("#define ALPHATEST");
  68445. }
  68446. var previousEffect = this._effect;
  68447. var join = defines.join("\n");
  68448. this._effect = engine.createEffect(this._shaderPath, {
  68449. attributes: attribs,
  68450. uniformsNames: this._options.uniforms,
  68451. uniformBuffersNames: this._options.uniformBuffers,
  68452. samplers: this._options.samplers,
  68453. defines: join,
  68454. fallbacks: fallbacks,
  68455. onCompiled: this.onCompiled,
  68456. onError: this.onError
  68457. }, engine);
  68458. if (!this._effect.isReady()) {
  68459. return false;
  68460. }
  68461. if (previousEffect !== this._effect) {
  68462. scene.resetCachedMaterial();
  68463. }
  68464. this._renderId = scene.getRenderId();
  68465. return true;
  68466. };
  68467. /**
  68468. * Binds the world matrix to the material
  68469. * @param world defines the world transformation matrix
  68470. */
  68471. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  68472. var scene = this.getScene();
  68473. if (!this._effect) {
  68474. return;
  68475. }
  68476. if (this._options.uniforms.indexOf("world") !== -1) {
  68477. this._effect.setMatrix("world", world);
  68478. }
  68479. if (this._options.uniforms.indexOf("worldView") !== -1) {
  68480. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  68481. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  68482. }
  68483. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  68484. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  68485. }
  68486. };
  68487. /**
  68488. * Binds the material to the mesh
  68489. * @param world defines the world transformation matrix
  68490. * @param mesh defines the mesh to bind the material to
  68491. */
  68492. ShaderMaterial.prototype.bind = function (world, mesh) {
  68493. // Std values
  68494. this.bindOnlyWorldMatrix(world);
  68495. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  68496. if (this._options.uniforms.indexOf("view") !== -1) {
  68497. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  68498. }
  68499. if (this._options.uniforms.indexOf("projection") !== -1) {
  68500. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  68501. }
  68502. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  68503. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  68504. }
  68505. // Bones
  68506. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  68507. var name;
  68508. // Texture
  68509. for (name in this._textures) {
  68510. this._effect.setTexture(name, this._textures[name]);
  68511. }
  68512. // Texture arrays
  68513. for (name in this._textureArrays) {
  68514. this._effect.setTextureArray(name, this._textureArrays[name]);
  68515. }
  68516. // Int
  68517. for (name in this._ints) {
  68518. this._effect.setInt(name, this._ints[name]);
  68519. }
  68520. // Float
  68521. for (name in this._floats) {
  68522. this._effect.setFloat(name, this._floats[name]);
  68523. }
  68524. // Floats
  68525. for (name in this._floatsArrays) {
  68526. this._effect.setArray(name, this._floatsArrays[name]);
  68527. }
  68528. // Color3
  68529. for (name in this._colors3) {
  68530. this._effect.setColor3(name, this._colors3[name]);
  68531. }
  68532. for (name in this._colors3Arrays) {
  68533. this._effect.setArray3(name, this._colors3Arrays[name]);
  68534. }
  68535. // Color4
  68536. for (name in this._colors4) {
  68537. var color = this._colors4[name];
  68538. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  68539. }
  68540. // Vector2
  68541. for (name in this._vectors2) {
  68542. this._effect.setVector2(name, this._vectors2[name]);
  68543. }
  68544. // Vector3
  68545. for (name in this._vectors3) {
  68546. this._effect.setVector3(name, this._vectors3[name]);
  68547. }
  68548. // Vector4
  68549. for (name in this._vectors4) {
  68550. this._effect.setVector4(name, this._vectors4[name]);
  68551. }
  68552. // Matrix
  68553. for (name in this._matrices) {
  68554. this._effect.setMatrix(name, this._matrices[name]);
  68555. }
  68556. // Matrix 3x3
  68557. for (name in this._matrices3x3) {
  68558. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  68559. }
  68560. // Matrix 2x2
  68561. for (name in this._matrices2x2) {
  68562. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  68563. }
  68564. // Vector2Array
  68565. for (name in this._vectors2Arrays) {
  68566. this._effect.setArray2(name, this._vectors2Arrays[name]);
  68567. }
  68568. // Vector3Array
  68569. for (name in this._vectors3Arrays) {
  68570. this._effect.setArray3(name, this._vectors3Arrays[name]);
  68571. }
  68572. }
  68573. this._afterBind(mesh);
  68574. };
  68575. /**
  68576. * Gets the active textures from the material
  68577. * @returns an array of textures
  68578. */
  68579. ShaderMaterial.prototype.getActiveTextures = function () {
  68580. var activeTextures = _super.prototype.getActiveTextures.call(this);
  68581. for (var name in this._textures) {
  68582. activeTextures.push(this._textures[name]);
  68583. }
  68584. for (var name in this._textureArrays) {
  68585. var array = this._textureArrays[name];
  68586. for (var index = 0; index < array.length; index++) {
  68587. activeTextures.push(array[index]);
  68588. }
  68589. }
  68590. return activeTextures;
  68591. };
  68592. /**
  68593. * Specifies if the material uses a texture
  68594. * @param texture defines the texture to check against the material
  68595. * @returns a boolean specifying if the material uses the texture
  68596. */
  68597. ShaderMaterial.prototype.hasTexture = function (texture) {
  68598. if (_super.prototype.hasTexture.call(this, texture)) {
  68599. return true;
  68600. }
  68601. for (var name in this._textures) {
  68602. if (this._textures[name] === texture) {
  68603. return true;
  68604. }
  68605. }
  68606. for (var name in this._textureArrays) {
  68607. var array = this._textureArrays[name];
  68608. for (var index = 0; index < array.length; index++) {
  68609. if (array[index] === texture) {
  68610. return true;
  68611. }
  68612. }
  68613. }
  68614. return false;
  68615. };
  68616. /**
  68617. * Makes a duplicate of the material, and gives it a new name
  68618. * @param name defines the new name for the duplicated material
  68619. * @returns the cloned material
  68620. */
  68621. ShaderMaterial.prototype.clone = function (name) {
  68622. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  68623. return newShaderMaterial;
  68624. };
  68625. /**
  68626. * Disposes the material
  68627. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68628. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  68629. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  68630. */
  68631. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  68632. if (forceDisposeTextures) {
  68633. var name;
  68634. for (name in this._textures) {
  68635. this._textures[name].dispose();
  68636. }
  68637. for (name in this._textureArrays) {
  68638. var array = this._textureArrays[name];
  68639. for (var index = 0; index < array.length; index++) {
  68640. array[index].dispose();
  68641. }
  68642. }
  68643. }
  68644. this._textures = {};
  68645. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  68646. };
  68647. /**
  68648. * Serializes this material in a JSON representation
  68649. * @returns the serialized material object
  68650. */
  68651. ShaderMaterial.prototype.serialize = function () {
  68652. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  68653. serializationObject.customType = "BABYLON.ShaderMaterial";
  68654. serializationObject.options = this._options;
  68655. serializationObject.shaderPath = this._shaderPath;
  68656. var name;
  68657. // Texture
  68658. serializationObject.textures = {};
  68659. for (name in this._textures) {
  68660. serializationObject.textures[name] = this._textures[name].serialize();
  68661. }
  68662. // Texture arrays
  68663. serializationObject.textureArrays = {};
  68664. for (name in this._textureArrays) {
  68665. serializationObject.textureArrays[name] = [];
  68666. var array = this._textureArrays[name];
  68667. for (var index = 0; index < array.length; index++) {
  68668. serializationObject.textureArrays[name].push(array[index].serialize());
  68669. }
  68670. }
  68671. // Float
  68672. serializationObject.floats = {};
  68673. for (name in this._floats) {
  68674. serializationObject.floats[name] = this._floats[name];
  68675. }
  68676. // Float s
  68677. serializationObject.FloatArrays = {};
  68678. for (name in this._floatsArrays) {
  68679. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  68680. }
  68681. // Color3
  68682. serializationObject.colors3 = {};
  68683. for (name in this._colors3) {
  68684. serializationObject.colors3[name] = this._colors3[name].asArray();
  68685. }
  68686. // Color3 array
  68687. serializationObject.colors3Arrays = {};
  68688. for (name in this._colors3Arrays) {
  68689. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  68690. }
  68691. // Color4
  68692. serializationObject.colors4 = {};
  68693. for (name in this._colors4) {
  68694. serializationObject.colors4[name] = this._colors4[name].asArray();
  68695. }
  68696. // Vector2
  68697. serializationObject.vectors2 = {};
  68698. for (name in this._vectors2) {
  68699. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  68700. }
  68701. // Vector3
  68702. serializationObject.vectors3 = {};
  68703. for (name in this._vectors3) {
  68704. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  68705. }
  68706. // Vector4
  68707. serializationObject.vectors4 = {};
  68708. for (name in this._vectors4) {
  68709. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  68710. }
  68711. // Matrix
  68712. serializationObject.matrices = {};
  68713. for (name in this._matrices) {
  68714. serializationObject.matrices[name] = this._matrices[name].asArray();
  68715. }
  68716. // Matrix 3x3
  68717. serializationObject.matrices3x3 = {};
  68718. for (name in this._matrices3x3) {
  68719. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  68720. }
  68721. // Matrix 2x2
  68722. serializationObject.matrices2x2 = {};
  68723. for (name in this._matrices2x2) {
  68724. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  68725. }
  68726. // Vector2Array
  68727. serializationObject.vectors2Arrays = {};
  68728. for (name in this._vectors2Arrays) {
  68729. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  68730. }
  68731. // Vector3Array
  68732. serializationObject.vectors3Arrays = {};
  68733. for (name in this._vectors3Arrays) {
  68734. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  68735. }
  68736. return serializationObject;
  68737. };
  68738. /**
  68739. * Creates a shader material from parsed shader material data
  68740. * @param source defines the JSON represnetation of the material
  68741. * @param scene defines the hosting scene
  68742. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68743. * @returns a new material
  68744. */
  68745. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  68746. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  68747. var name;
  68748. // Texture
  68749. for (name in source.textures) {
  68750. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  68751. }
  68752. // Texture arrays
  68753. for (name in source.textureArrays) {
  68754. var array = source.textureArrays[name];
  68755. var textureArray = new Array();
  68756. for (var index = 0; index < array.length; index++) {
  68757. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  68758. }
  68759. material.setTextureArray(name, textureArray);
  68760. }
  68761. // Float
  68762. for (name in source.floats) {
  68763. material.setFloat(name, source.floats[name]);
  68764. }
  68765. // Float s
  68766. for (name in source.floatsArrays) {
  68767. material.setFloats(name, source.floatsArrays[name]);
  68768. }
  68769. // Color3
  68770. for (name in source.colors3) {
  68771. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  68772. }
  68773. // Color3 arrays
  68774. for (name in source.colors3Arrays) {
  68775. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  68776. if (i % 3 === 0) {
  68777. arr.push([num]);
  68778. }
  68779. else {
  68780. arr[arr.length - 1].push(num);
  68781. }
  68782. return arr;
  68783. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  68784. material.setColor3Array(name, colors);
  68785. }
  68786. // Color4
  68787. for (name in source.colors4) {
  68788. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  68789. }
  68790. // Vector2
  68791. for (name in source.vectors2) {
  68792. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  68793. }
  68794. // Vector3
  68795. for (name in source.vectors3) {
  68796. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  68797. }
  68798. // Vector4
  68799. for (name in source.vectors4) {
  68800. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  68801. }
  68802. // Matrix
  68803. for (name in source.matrices) {
  68804. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  68805. }
  68806. // Matrix 3x3
  68807. for (name in source.matrices3x3) {
  68808. material.setMatrix3x3(name, source.matrices3x3[name]);
  68809. }
  68810. // Matrix 2x2
  68811. for (name in source.matrices2x2) {
  68812. material.setMatrix2x2(name, source.matrices2x2[name]);
  68813. }
  68814. // Vector2Array
  68815. for (name in source.vectors2Arrays) {
  68816. material.setArray2(name, source.vectors2Arrays[name]);
  68817. }
  68818. // Vector3Array
  68819. for (name in source.vectors3Arrays) {
  68820. material.setArray3(name, source.vectors3Arrays[name]);
  68821. }
  68822. return material;
  68823. };
  68824. return ShaderMaterial;
  68825. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  68826. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  68827. /***/ }),
  68828. /***/ "./Materials/standardMaterial.ts":
  68829. /*!***************************************!*\
  68830. !*** ./Materials/standardMaterial.ts ***!
  68831. \***************************************/
  68832. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  68833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68834. "use strict";
  68835. __webpack_require__.r(__webpack_exports__);
  68836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  68837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  68838. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  68839. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  68840. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  68841. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  68842. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  68843. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  68844. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  68845. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  68846. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  68847. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  68848. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  68849. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  68850. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  68851. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  68852. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  68853. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  68854. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  68855. /** @hidden */
  68856. var StandardMaterialDefines = /** @class */ (function (_super) {
  68857. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  68858. function StandardMaterialDefines() {
  68859. var _this = _super.call(this) || this;
  68860. _this.MAINUV1 = false;
  68861. _this.MAINUV2 = false;
  68862. _this.DIFFUSE = false;
  68863. _this.DIFFUSEDIRECTUV = 0;
  68864. _this.AMBIENT = false;
  68865. _this.AMBIENTDIRECTUV = 0;
  68866. _this.OPACITY = false;
  68867. _this.OPACITYDIRECTUV = 0;
  68868. _this.OPACITYRGB = false;
  68869. _this.REFLECTION = false;
  68870. _this.EMISSIVE = false;
  68871. _this.EMISSIVEDIRECTUV = 0;
  68872. _this.SPECULAR = false;
  68873. _this.SPECULARDIRECTUV = 0;
  68874. _this.BUMP = false;
  68875. _this.BUMPDIRECTUV = 0;
  68876. _this.PARALLAX = false;
  68877. _this.PARALLAXOCCLUSION = false;
  68878. _this.SPECULAROVERALPHA = false;
  68879. _this.CLIPPLANE = false;
  68880. _this.CLIPPLANE2 = false;
  68881. _this.CLIPPLANE3 = false;
  68882. _this.CLIPPLANE4 = false;
  68883. _this.ALPHATEST = false;
  68884. _this.DEPTHPREPASS = false;
  68885. _this.ALPHAFROMDIFFUSE = false;
  68886. _this.POINTSIZE = false;
  68887. _this.FOG = false;
  68888. _this.SPECULARTERM = false;
  68889. _this.DIFFUSEFRESNEL = false;
  68890. _this.OPACITYFRESNEL = false;
  68891. _this.REFLECTIONFRESNEL = false;
  68892. _this.REFRACTIONFRESNEL = false;
  68893. _this.EMISSIVEFRESNEL = false;
  68894. _this.FRESNEL = false;
  68895. _this.NORMAL = false;
  68896. _this.UV1 = false;
  68897. _this.UV2 = false;
  68898. _this.VERTEXCOLOR = false;
  68899. _this.VERTEXALPHA = false;
  68900. _this.NUM_BONE_INFLUENCERS = 0;
  68901. _this.BonesPerMesh = 0;
  68902. _this.BONETEXTURE = false;
  68903. _this.INSTANCES = false;
  68904. _this.GLOSSINESS = false;
  68905. _this.ROUGHNESS = false;
  68906. _this.EMISSIVEASILLUMINATION = false;
  68907. _this.LINKEMISSIVEWITHDIFFUSE = false;
  68908. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  68909. _this.LIGHTMAP = false;
  68910. _this.LIGHTMAPDIRECTUV = 0;
  68911. _this.OBJECTSPACE_NORMALMAP = false;
  68912. _this.USELIGHTMAPASSHADOWMAP = false;
  68913. _this.REFLECTIONMAP_3D = false;
  68914. _this.REFLECTIONMAP_SPHERICAL = false;
  68915. _this.REFLECTIONMAP_PLANAR = false;
  68916. _this.REFLECTIONMAP_CUBIC = false;
  68917. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  68918. _this.REFLECTIONMAP_PROJECTION = false;
  68919. _this.REFLECTIONMAP_SKYBOX = false;
  68920. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  68921. _this.REFLECTIONMAP_EXPLICIT = false;
  68922. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  68923. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  68924. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  68925. _this.INVERTCUBICMAP = false;
  68926. _this.LOGARITHMICDEPTH = false;
  68927. _this.REFRACTION = false;
  68928. _this.REFRACTIONMAP_3D = false;
  68929. _this.REFLECTIONOVERALPHA = false;
  68930. _this.TWOSIDEDLIGHTING = false;
  68931. _this.SHADOWFLOAT = false;
  68932. _this.MORPHTARGETS = false;
  68933. _this.MORPHTARGETS_NORMAL = false;
  68934. _this.MORPHTARGETS_TANGENT = false;
  68935. _this.NUM_MORPH_INFLUENCERS = 0;
  68936. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  68937. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  68938. _this.IMAGEPROCESSING = false;
  68939. _this.VIGNETTE = false;
  68940. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  68941. _this.VIGNETTEBLENDMODEOPAQUE = false;
  68942. _this.TONEMAPPING = false;
  68943. _this.TONEMAPPING_ACES = false;
  68944. _this.CONTRAST = false;
  68945. _this.COLORCURVES = false;
  68946. _this.COLORGRADING = false;
  68947. _this.COLORGRADING3D = false;
  68948. _this.SAMPLER3DGREENDEPTH = false;
  68949. _this.SAMPLER3DBGRMAP = false;
  68950. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  68951. _this.MULTIVIEW = false;
  68952. /**
  68953. * If the reflection texture on this material is in linear color space
  68954. * @hidden
  68955. */
  68956. _this.IS_REFLECTION_LINEAR = false;
  68957. /**
  68958. * If the refraction texture on this material is in linear color space
  68959. * @hidden
  68960. */
  68961. _this.IS_REFRACTION_LINEAR = false;
  68962. _this.EXPOSURE = false;
  68963. _this.rebuild();
  68964. return _this;
  68965. }
  68966. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  68967. var modes = [
  68968. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  68969. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  68970. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  68971. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  68972. ];
  68973. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  68974. var mode = modes_1[_i];
  68975. this[mode] = (mode === modeToEnable);
  68976. }
  68977. };
  68978. return StandardMaterialDefines;
  68979. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  68980. /**
  68981. * This is the default material used in Babylon. It is the best trade off between quality
  68982. * and performances.
  68983. * @see http://doc.babylonjs.com/babylon101/materials
  68984. */
  68985. var StandardMaterial = /** @class */ (function (_super) {
  68986. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  68987. /**
  68988. * Instantiates a new standard material.
  68989. * This is the default material used in Babylon. It is the best trade off between quality
  68990. * and performances.
  68991. * @see http://doc.babylonjs.com/babylon101/materials
  68992. * @param name Define the name of the material in the scene
  68993. * @param scene Define the scene the material belong to
  68994. */
  68995. function StandardMaterial(name, scene) {
  68996. var _this = _super.call(this, name, scene) || this;
  68997. /**
  68998. * The color of the material lit by the environmental background lighting.
  68999. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  69000. */
  69001. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  69002. /**
  69003. * The basic color of the material as viewed under a light.
  69004. */
  69005. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  69006. /**
  69007. * Define how the color and intensity of the highlight given by the light in the material.
  69008. */
  69009. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  69010. /**
  69011. * Define the color of the material as if self lit.
  69012. * This will be mixed in the final result even in the absence of light.
  69013. */
  69014. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  69015. /**
  69016. * Defines how sharp are the highlights in the material.
  69017. * The bigger the value the sharper giving a more glossy feeling to the result.
  69018. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  69019. */
  69020. _this.specularPower = 64;
  69021. _this._useAlphaFromDiffuseTexture = false;
  69022. _this._useEmissiveAsIllumination = false;
  69023. _this._linkEmissiveWithDiffuse = false;
  69024. _this._useSpecularOverAlpha = false;
  69025. _this._useReflectionOverAlpha = false;
  69026. _this._disableLighting = false;
  69027. _this._useObjectSpaceNormalMap = false;
  69028. _this._useParallax = false;
  69029. _this._useParallaxOcclusion = false;
  69030. /**
  69031. * 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.
  69032. */
  69033. _this.parallaxScaleBias = 0.05;
  69034. _this._roughness = 0;
  69035. /**
  69036. * In case of refraction, define the value of the indice of refraction.
  69037. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  69038. */
  69039. _this.indexOfRefraction = 0.98;
  69040. /**
  69041. * Invert the refraction texture alongside the y axis.
  69042. * It can be useful with procedural textures or probe for instance.
  69043. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  69044. */
  69045. _this.invertRefractionY = true;
  69046. /**
  69047. * Defines the alpha limits in alpha test mode.
  69048. */
  69049. _this.alphaCutOff = 0.4;
  69050. _this._useLightmapAsShadowmap = false;
  69051. _this._useReflectionFresnelFromSpecular = false;
  69052. _this._useGlossinessFromSpecularMapAlpha = false;
  69053. _this._maxSimultaneousLights = 4;
  69054. _this._invertNormalMapX = false;
  69055. _this._invertNormalMapY = false;
  69056. _this._twoSidedLighting = false;
  69057. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  69058. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  69059. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  69060. // Setup the default processing configuration to the scene.
  69061. _this._attachImageProcessingConfiguration(null);
  69062. _this.getRenderTargetTextures = function () {
  69063. _this._renderTargets.reset();
  69064. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  69065. _this._renderTargets.push(_this._reflectionTexture);
  69066. }
  69067. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  69068. _this._renderTargets.push(_this._refractionTexture);
  69069. }
  69070. return _this._renderTargets;
  69071. };
  69072. return _this;
  69073. }
  69074. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  69075. /**
  69076. * Gets the image processing configuration used either in this material.
  69077. */
  69078. get: function () {
  69079. return this._imageProcessingConfiguration;
  69080. },
  69081. /**
  69082. * Sets the Default image processing configuration used either in the this material.
  69083. *
  69084. * If sets to null, the scene one is in use.
  69085. */
  69086. set: function (value) {
  69087. this._attachImageProcessingConfiguration(value);
  69088. // Ensure the effect will be rebuilt.
  69089. this._markAllSubMeshesAsTexturesDirty();
  69090. },
  69091. enumerable: true,
  69092. configurable: true
  69093. });
  69094. /**
  69095. * Attaches a new image processing configuration to the Standard Material.
  69096. * @param configuration
  69097. */
  69098. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  69099. var _this = this;
  69100. if (configuration === this._imageProcessingConfiguration) {
  69101. return;
  69102. }
  69103. // Detaches observer.
  69104. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  69105. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  69106. }
  69107. // Pick the scene configuration if needed.
  69108. if (!configuration) {
  69109. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  69110. }
  69111. else {
  69112. this._imageProcessingConfiguration = configuration;
  69113. }
  69114. // Attaches observer.
  69115. if (this._imageProcessingConfiguration) {
  69116. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  69117. _this._markAllSubMeshesAsImageProcessingDirty();
  69118. });
  69119. }
  69120. };
  69121. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  69122. /**
  69123. * Gets wether the color curves effect is enabled.
  69124. */
  69125. get: function () {
  69126. return this.imageProcessingConfiguration.colorCurvesEnabled;
  69127. },
  69128. /**
  69129. * Sets wether the color curves effect is enabled.
  69130. */
  69131. set: function (value) {
  69132. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  69133. },
  69134. enumerable: true,
  69135. configurable: true
  69136. });
  69137. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  69138. /**
  69139. * Gets wether the color grading effect is enabled.
  69140. */
  69141. get: function () {
  69142. return this.imageProcessingConfiguration.colorGradingEnabled;
  69143. },
  69144. /**
  69145. * Gets wether the color grading effect is enabled.
  69146. */
  69147. set: function (value) {
  69148. this.imageProcessingConfiguration.colorGradingEnabled = value;
  69149. },
  69150. enumerable: true,
  69151. configurable: true
  69152. });
  69153. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  69154. /**
  69155. * Gets wether tonemapping is enabled or not.
  69156. */
  69157. get: function () {
  69158. return this._imageProcessingConfiguration.toneMappingEnabled;
  69159. },
  69160. /**
  69161. * Sets wether tonemapping is enabled or not
  69162. */
  69163. set: function (value) {
  69164. this._imageProcessingConfiguration.toneMappingEnabled = value;
  69165. },
  69166. enumerable: true,
  69167. configurable: true
  69168. });
  69169. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  69170. /**
  69171. * The camera exposure used on this material.
  69172. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  69173. * This corresponds to a photographic exposure.
  69174. */
  69175. get: function () {
  69176. return this._imageProcessingConfiguration.exposure;
  69177. },
  69178. /**
  69179. * The camera exposure used on this material.
  69180. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  69181. * This corresponds to a photographic exposure.
  69182. */
  69183. set: function (value) {
  69184. this._imageProcessingConfiguration.exposure = value;
  69185. },
  69186. enumerable: true,
  69187. configurable: true
  69188. });
  69189. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  69190. /**
  69191. * Gets The camera contrast used on this material.
  69192. */
  69193. get: function () {
  69194. return this._imageProcessingConfiguration.contrast;
  69195. },
  69196. /**
  69197. * Sets The camera contrast used on this material.
  69198. */
  69199. set: function (value) {
  69200. this._imageProcessingConfiguration.contrast = value;
  69201. },
  69202. enumerable: true,
  69203. configurable: true
  69204. });
  69205. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  69206. /**
  69207. * Gets the Color Grading 2D Lookup Texture.
  69208. */
  69209. get: function () {
  69210. return this._imageProcessingConfiguration.colorGradingTexture;
  69211. },
  69212. /**
  69213. * Sets the Color Grading 2D Lookup Texture.
  69214. */
  69215. set: function (value) {
  69216. this._imageProcessingConfiguration.colorGradingTexture = value;
  69217. },
  69218. enumerable: true,
  69219. configurable: true
  69220. });
  69221. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  69222. /**
  69223. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  69224. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  69225. * 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;
  69226. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  69227. */
  69228. get: function () {
  69229. return this._imageProcessingConfiguration.colorCurves;
  69230. },
  69231. /**
  69232. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  69233. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  69234. * 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;
  69235. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  69236. */
  69237. set: function (value) {
  69238. this._imageProcessingConfiguration.colorCurves = value;
  69239. },
  69240. enumerable: true,
  69241. configurable: true
  69242. });
  69243. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  69244. /**
  69245. * Gets a boolean indicating that current material needs to register RTT
  69246. */
  69247. get: function () {
  69248. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  69249. return true;
  69250. }
  69251. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  69252. return true;
  69253. }
  69254. return false;
  69255. },
  69256. enumerable: true,
  69257. configurable: true
  69258. });
  69259. /**
  69260. * Gets the current class name of the material e.g. "StandardMaterial"
  69261. * Mainly use in serialization.
  69262. * @returns the class name
  69263. */
  69264. StandardMaterial.prototype.getClassName = function () {
  69265. return "StandardMaterial";
  69266. };
  69267. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  69268. /**
  69269. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  69270. * You can try switching to logarithmic depth.
  69271. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  69272. */
  69273. get: function () {
  69274. return this._useLogarithmicDepth;
  69275. },
  69276. set: function (value) {
  69277. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  69278. this._markAllSubMeshesAsMiscDirty();
  69279. },
  69280. enumerable: true,
  69281. configurable: true
  69282. });
  69283. /**
  69284. * Specifies if the material will require alpha blending
  69285. * @returns a boolean specifying if alpha blending is needed
  69286. */
  69287. StandardMaterial.prototype.needAlphaBlending = function () {
  69288. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  69289. };
  69290. /**
  69291. * Specifies if this material should be rendered in alpha test mode
  69292. * @returns a boolean specifying if an alpha test is needed.
  69293. */
  69294. StandardMaterial.prototype.needAlphaTesting = function () {
  69295. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  69296. };
  69297. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  69298. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  69299. };
  69300. /**
  69301. * Get the texture used for alpha test purpose.
  69302. * @returns the diffuse texture in case of the standard material.
  69303. */
  69304. StandardMaterial.prototype.getAlphaTestTexture = function () {
  69305. return this._diffuseTexture;
  69306. };
  69307. /**
  69308. * Get if the submesh is ready to be used and all its information available.
  69309. * Child classes can use it to update shaders
  69310. * @param mesh defines the mesh to check
  69311. * @param subMesh defines which submesh to check
  69312. * @param useInstances specifies that instances should be used
  69313. * @returns a boolean indicating that the submesh is ready or not
  69314. */
  69315. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  69316. if (useInstances === void 0) { useInstances = false; }
  69317. if (subMesh.effect && this.isFrozen) {
  69318. if (this._wasPreviouslyReady) {
  69319. return true;
  69320. }
  69321. }
  69322. if (!subMesh._materialDefines) {
  69323. subMesh._materialDefines = new StandardMaterialDefines();
  69324. }
  69325. var scene = this.getScene();
  69326. var defines = subMesh._materialDefines;
  69327. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  69328. if (defines._renderId === scene.getRenderId()) {
  69329. return true;
  69330. }
  69331. }
  69332. var engine = scene.getEngine();
  69333. // Lights
  69334. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  69335. // Multiview
  69336. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  69337. // Textures
  69338. if (defines._areTexturesDirty) {
  69339. defines._needUVs = false;
  69340. defines.MAINUV1 = false;
  69341. defines.MAINUV2 = false;
  69342. if (scene.texturesEnabled) {
  69343. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69344. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  69345. return false;
  69346. }
  69347. else {
  69348. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  69349. }
  69350. }
  69351. else {
  69352. defines.DIFFUSE = false;
  69353. }
  69354. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69355. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  69356. return false;
  69357. }
  69358. else {
  69359. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  69360. }
  69361. }
  69362. else {
  69363. defines.AMBIENT = false;
  69364. }
  69365. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69366. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  69367. return false;
  69368. }
  69369. else {
  69370. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  69371. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  69372. }
  69373. }
  69374. else {
  69375. defines.OPACITY = false;
  69376. }
  69377. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69378. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  69379. return false;
  69380. }
  69381. else {
  69382. defines._needNormals = true;
  69383. defines.REFLECTION = true;
  69384. defines.ROUGHNESS = (this._roughness > 0);
  69385. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  69386. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  69387. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  69388. switch (this._reflectionTexture.coordinatesMode) {
  69389. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  69390. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  69391. break;
  69392. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  69393. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  69394. break;
  69395. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  69396. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  69397. break;
  69398. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  69399. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  69400. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  69401. break;
  69402. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  69403. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  69404. break;
  69405. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  69406. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  69407. break;
  69408. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  69409. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  69410. break;
  69411. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  69412. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  69413. break;
  69414. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  69415. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  69416. default:
  69417. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  69418. break;
  69419. }
  69420. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  69421. }
  69422. }
  69423. else {
  69424. defines.REFLECTION = false;
  69425. }
  69426. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69427. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  69428. return false;
  69429. }
  69430. else {
  69431. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  69432. }
  69433. }
  69434. else {
  69435. defines.EMISSIVE = false;
  69436. }
  69437. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69438. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  69439. return false;
  69440. }
  69441. else {
  69442. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  69443. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  69444. }
  69445. }
  69446. else {
  69447. defines.LIGHTMAP = false;
  69448. }
  69449. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69450. if (!this._specularTexture.isReadyOrNotBlocking()) {
  69451. return false;
  69452. }
  69453. else {
  69454. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  69455. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  69456. }
  69457. }
  69458. else {
  69459. defines.SPECULAR = false;
  69460. }
  69461. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  69462. // Bump texure can not be not blocking.
  69463. if (!this._bumpTexture.isReady()) {
  69464. return false;
  69465. }
  69466. else {
  69467. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  69468. defines.PARALLAX = this._useParallax;
  69469. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  69470. }
  69471. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  69472. }
  69473. else {
  69474. defines.BUMP = false;
  69475. }
  69476. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69477. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  69478. return false;
  69479. }
  69480. else {
  69481. defines._needUVs = true;
  69482. defines.REFRACTION = true;
  69483. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  69484. }
  69485. }
  69486. else {
  69487. defines.REFRACTION = false;
  69488. }
  69489. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  69490. }
  69491. else {
  69492. defines.DIFFUSE = false;
  69493. defines.AMBIENT = false;
  69494. defines.OPACITY = false;
  69495. defines.REFLECTION = false;
  69496. defines.EMISSIVE = false;
  69497. defines.LIGHTMAP = false;
  69498. defines.BUMP = false;
  69499. defines.REFRACTION = false;
  69500. }
  69501. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  69502. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  69503. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  69504. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  69505. 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);
  69506. }
  69507. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  69508. if (!this._imageProcessingConfiguration.isReady()) {
  69509. return false;
  69510. }
  69511. this._imageProcessingConfiguration.prepareDefines(defines);
  69512. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  69513. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  69514. }
  69515. if (defines._areFresnelDirty) {
  69516. if (StandardMaterial.FresnelEnabled) {
  69517. // Fresnel
  69518. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  69519. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  69520. this._reflectionFresnelParameters) {
  69521. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  69522. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  69523. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  69524. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  69525. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  69526. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  69527. defines._needNormals = true;
  69528. defines.FRESNEL = true;
  69529. }
  69530. }
  69531. else {
  69532. defines.FRESNEL = false;
  69533. }
  69534. }
  69535. // Misc.
  69536. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  69537. // Attribs
  69538. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  69539. // Values that need to be evaluated on every frame
  69540. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  69541. // Get correct effect
  69542. if (defines.isDirty) {
  69543. defines.markAsProcessed();
  69544. // Fallbacks
  69545. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  69546. if (defines.REFLECTION) {
  69547. fallbacks.addFallback(0, "REFLECTION");
  69548. }
  69549. if (defines.SPECULAR) {
  69550. fallbacks.addFallback(0, "SPECULAR");
  69551. }
  69552. if (defines.BUMP) {
  69553. fallbacks.addFallback(0, "BUMP");
  69554. }
  69555. if (defines.PARALLAX) {
  69556. fallbacks.addFallback(1, "PARALLAX");
  69557. }
  69558. if (defines.PARALLAXOCCLUSION) {
  69559. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  69560. }
  69561. if (defines.SPECULAROVERALPHA) {
  69562. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  69563. }
  69564. if (defines.FOG) {
  69565. fallbacks.addFallback(1, "FOG");
  69566. }
  69567. if (defines.POINTSIZE) {
  69568. fallbacks.addFallback(0, "POINTSIZE");
  69569. }
  69570. if (defines.LOGARITHMICDEPTH) {
  69571. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  69572. }
  69573. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  69574. if (defines.SPECULARTERM) {
  69575. fallbacks.addFallback(0, "SPECULARTERM");
  69576. }
  69577. if (defines.DIFFUSEFRESNEL) {
  69578. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  69579. }
  69580. if (defines.OPACITYFRESNEL) {
  69581. fallbacks.addFallback(2, "OPACITYFRESNEL");
  69582. }
  69583. if (defines.REFLECTIONFRESNEL) {
  69584. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  69585. }
  69586. if (defines.EMISSIVEFRESNEL) {
  69587. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  69588. }
  69589. if (defines.FRESNEL) {
  69590. fallbacks.addFallback(4, "FRESNEL");
  69591. }
  69592. if (defines.MULTIVIEW) {
  69593. fallbacks.addFallback(0, "MULTIVIEW");
  69594. }
  69595. //Attributes
  69596. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  69597. if (defines.NORMAL) {
  69598. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  69599. }
  69600. if (defines.UV1) {
  69601. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  69602. }
  69603. if (defines.UV2) {
  69604. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  69605. }
  69606. if (defines.VERTEXCOLOR) {
  69607. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  69608. }
  69609. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  69610. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  69611. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  69612. var shaderName = "default";
  69613. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility",
  69614. "vFogInfos", "vFogColor", "pointSize",
  69615. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  69616. "mBones",
  69617. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  69618. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  69619. "vReflectionPosition", "vReflectionSize",
  69620. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  69621. ];
  69622. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  69623. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  69624. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  69625. var uniformBuffers = ["Material", "Scene"];
  69626. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  69627. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  69628. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  69629. }
  69630. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  69631. uniformsNames: uniforms,
  69632. uniformBuffersNames: uniformBuffers,
  69633. samplers: samplers,
  69634. defines: defines,
  69635. maxSimultaneousLights: this._maxSimultaneousLights
  69636. });
  69637. if (this.customShaderNameResolve) {
  69638. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  69639. }
  69640. var join = defines.toString();
  69641. var previousEffect = subMesh.effect;
  69642. var effect = scene.getEngine().createEffect(shaderName, {
  69643. attributes: attribs,
  69644. uniformsNames: uniforms,
  69645. uniformBuffersNames: uniformBuffers,
  69646. samplers: samplers,
  69647. defines: join,
  69648. fallbacks: fallbacks,
  69649. onCompiled: this.onCompiled,
  69650. onError: this.onError,
  69651. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  69652. }, engine);
  69653. if (effect) {
  69654. // Use previous effect while new one is compiling
  69655. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  69656. effect = previousEffect;
  69657. defines.markAsUnprocessed();
  69658. }
  69659. else {
  69660. scene.resetCachedMaterial();
  69661. subMesh.setEffect(effect, defines);
  69662. this.buildUniformLayout();
  69663. }
  69664. }
  69665. }
  69666. if (!subMesh.effect || !subMesh.effect.isReady()) {
  69667. return false;
  69668. }
  69669. defines._renderId = scene.getRenderId();
  69670. this._wasPreviouslyReady = true;
  69671. return true;
  69672. };
  69673. /**
  69674. * Builds the material UBO layouts.
  69675. * Used internally during the effect preparation.
  69676. */
  69677. StandardMaterial.prototype.buildUniformLayout = function () {
  69678. // Order is important !
  69679. var ubo = this._uniformBuffer;
  69680. ubo.addUniform("diffuseLeftColor", 4);
  69681. ubo.addUniform("diffuseRightColor", 4);
  69682. ubo.addUniform("opacityParts", 4);
  69683. ubo.addUniform("reflectionLeftColor", 4);
  69684. ubo.addUniform("reflectionRightColor", 4);
  69685. ubo.addUniform("refractionLeftColor", 4);
  69686. ubo.addUniform("refractionRightColor", 4);
  69687. ubo.addUniform("emissiveLeftColor", 4);
  69688. ubo.addUniform("emissiveRightColor", 4);
  69689. ubo.addUniform("vDiffuseInfos", 2);
  69690. ubo.addUniform("vAmbientInfos", 2);
  69691. ubo.addUniform("vOpacityInfos", 2);
  69692. ubo.addUniform("vReflectionInfos", 2);
  69693. ubo.addUniform("vReflectionPosition", 3);
  69694. ubo.addUniform("vReflectionSize", 3);
  69695. ubo.addUniform("vEmissiveInfos", 2);
  69696. ubo.addUniform("vLightmapInfos", 2);
  69697. ubo.addUniform("vSpecularInfos", 2);
  69698. ubo.addUniform("vBumpInfos", 3);
  69699. ubo.addUniform("diffuseMatrix", 16);
  69700. ubo.addUniform("ambientMatrix", 16);
  69701. ubo.addUniform("opacityMatrix", 16);
  69702. ubo.addUniform("reflectionMatrix", 16);
  69703. ubo.addUniform("emissiveMatrix", 16);
  69704. ubo.addUniform("lightmapMatrix", 16);
  69705. ubo.addUniform("specularMatrix", 16);
  69706. ubo.addUniform("bumpMatrix", 16);
  69707. ubo.addUniform("vTangentSpaceParams", 2);
  69708. ubo.addUniform("pointSize", 1);
  69709. ubo.addUniform("refractionMatrix", 16);
  69710. ubo.addUniform("vRefractionInfos", 4);
  69711. ubo.addUniform("vSpecularColor", 4);
  69712. ubo.addUniform("vEmissiveColor", 3);
  69713. ubo.addUniform("visibility", 1);
  69714. ubo.addUniform("vDiffuseColor", 4);
  69715. ubo.create();
  69716. };
  69717. /**
  69718. * Unbinds the material from the mesh
  69719. */
  69720. StandardMaterial.prototype.unbind = function () {
  69721. if (this._activeEffect) {
  69722. var needFlag = false;
  69723. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  69724. this._activeEffect.setTexture("reflection2DSampler", null);
  69725. needFlag = true;
  69726. }
  69727. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  69728. this._activeEffect.setTexture("refraction2DSampler", null);
  69729. needFlag = true;
  69730. }
  69731. if (needFlag) {
  69732. this._markAllSubMeshesAsTexturesDirty();
  69733. }
  69734. }
  69735. _super.prototype.unbind.call(this);
  69736. };
  69737. /**
  69738. * Binds the submesh to this material by preparing the effect and shader to draw
  69739. * @param world defines the world transformation matrix
  69740. * @param mesh defines the mesh containing the submesh
  69741. * @param subMesh defines the submesh to bind the material to
  69742. */
  69743. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  69744. var scene = this.getScene();
  69745. var defines = subMesh._materialDefines;
  69746. if (!defines) {
  69747. return;
  69748. }
  69749. var effect = subMesh.effect;
  69750. if (!effect) {
  69751. return;
  69752. }
  69753. this._activeEffect = effect;
  69754. // Matrices
  69755. if (!defines.INSTANCES) {
  69756. this.bindOnlyWorldMatrix(world);
  69757. }
  69758. // Normal Matrix
  69759. if (defines.OBJECTSPACE_NORMALMAP) {
  69760. world.toNormalMatrix(this._normalMatrix);
  69761. this.bindOnlyNormalMatrix(this._normalMatrix);
  69762. }
  69763. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  69764. // Bones
  69765. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  69766. var ubo = this._uniformBuffer;
  69767. if (mustRebind) {
  69768. ubo.bindToEffect(effect, "Material");
  69769. this.bindViewProjection(effect);
  69770. if (!ubo.useUbo || !this.isFrozen || !ubo.isSync) {
  69771. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  69772. // Fresnel
  69773. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  69774. ubo.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  69775. ubo.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  69776. }
  69777. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  69778. ubo.updateColor4("opacityParts", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power);
  69779. }
  69780. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  69781. ubo.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  69782. ubo.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  69783. }
  69784. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  69785. ubo.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  69786. ubo.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  69787. }
  69788. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  69789. ubo.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  69790. ubo.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  69791. }
  69792. }
  69793. // Textures
  69794. if (scene.texturesEnabled) {
  69795. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69796. ubo.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  69797. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, ubo, "diffuse");
  69798. if (this._diffuseTexture.hasAlpha) {
  69799. effect.setFloat("alphaCutOff", this.alphaCutOff);
  69800. }
  69801. }
  69802. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69803. ubo.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  69804. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, ubo, "ambient");
  69805. }
  69806. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69807. ubo.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  69808. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, ubo, "opacity");
  69809. }
  69810. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69811. ubo.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  69812. ubo.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  69813. if (this._reflectionTexture.boundingBoxSize) {
  69814. var cubeTexture = this._reflectionTexture;
  69815. ubo.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  69816. ubo.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  69817. }
  69818. }
  69819. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69820. ubo.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  69821. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, ubo, "emissive");
  69822. }
  69823. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69824. ubo.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  69825. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, ubo, "lightmap");
  69826. }
  69827. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69828. ubo.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  69829. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, ubo, "specular");
  69830. }
  69831. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  69832. ubo.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  69833. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, ubo, "bump");
  69834. if (scene._mirroredCameraPosition) {
  69835. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  69836. }
  69837. else {
  69838. ubo.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  69839. }
  69840. }
  69841. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69842. var depth = 1.0;
  69843. if (!this._refractionTexture.isCube) {
  69844. ubo.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  69845. if (this._refractionTexture.depth) {
  69846. depth = this._refractionTexture.depth;
  69847. }
  69848. }
  69849. ubo.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  69850. }
  69851. }
  69852. // Point size
  69853. if (this.pointsCloud) {
  69854. ubo.updateFloat("pointSize", this.pointSize);
  69855. }
  69856. if (defines.SPECULARTERM) {
  69857. ubo.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  69858. }
  69859. ubo.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  69860. // Visibility
  69861. ubo.updateFloat("visibility", mesh.visibility);
  69862. // Diffuse
  69863. ubo.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha);
  69864. }
  69865. // Textures
  69866. if (scene.texturesEnabled) {
  69867. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69868. effect.setTexture("diffuseSampler", this._diffuseTexture);
  69869. }
  69870. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69871. effect.setTexture("ambientSampler", this._ambientTexture);
  69872. }
  69873. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69874. effect.setTexture("opacitySampler", this._opacityTexture);
  69875. }
  69876. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69877. if (this._reflectionTexture.isCube) {
  69878. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  69879. }
  69880. else {
  69881. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  69882. }
  69883. }
  69884. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69885. effect.setTexture("emissiveSampler", this._emissiveTexture);
  69886. }
  69887. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69888. effect.setTexture("lightmapSampler", this._lightmapTexture);
  69889. }
  69890. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69891. effect.setTexture("specularSampler", this._specularTexture);
  69892. }
  69893. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  69894. effect.setTexture("bumpSampler", this._bumpTexture);
  69895. }
  69896. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69897. var depth = 1.0;
  69898. if (this._refractionTexture.isCube) {
  69899. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  69900. }
  69901. else {
  69902. effect.setTexture("refraction2DSampler", this._refractionTexture);
  69903. }
  69904. }
  69905. }
  69906. // Clip plane
  69907. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  69908. // Colors
  69909. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  69910. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  69911. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  69912. }
  69913. if (mustRebind || !this.isFrozen) {
  69914. // Lights
  69915. if (scene.lightsEnabled && !this._disableLighting) {
  69916. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  69917. }
  69918. // View
  69919. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  69920. this.bindView(effect);
  69921. }
  69922. // Fog
  69923. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  69924. // Morph targets
  69925. if (defines.NUM_MORPH_INFLUENCERS) {
  69926. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  69927. }
  69928. // Log. depth
  69929. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  69930. // image processing
  69931. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  69932. this._imageProcessingConfiguration.bind(this._activeEffect);
  69933. }
  69934. }
  69935. ubo.update();
  69936. this._afterBind(mesh, this._activeEffect);
  69937. };
  69938. /**
  69939. * Get the list of animatables in the material.
  69940. * @returns the list of animatables object used in the material
  69941. */
  69942. StandardMaterial.prototype.getAnimatables = function () {
  69943. var results = [];
  69944. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  69945. results.push(this._diffuseTexture);
  69946. }
  69947. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  69948. results.push(this._ambientTexture);
  69949. }
  69950. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  69951. results.push(this._opacityTexture);
  69952. }
  69953. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  69954. results.push(this._reflectionTexture);
  69955. }
  69956. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  69957. results.push(this._emissiveTexture);
  69958. }
  69959. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  69960. results.push(this._specularTexture);
  69961. }
  69962. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  69963. results.push(this._bumpTexture);
  69964. }
  69965. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  69966. results.push(this._lightmapTexture);
  69967. }
  69968. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  69969. results.push(this._refractionTexture);
  69970. }
  69971. return results;
  69972. };
  69973. /**
  69974. * Gets the active textures from the material
  69975. * @returns an array of textures
  69976. */
  69977. StandardMaterial.prototype.getActiveTextures = function () {
  69978. var activeTextures = _super.prototype.getActiveTextures.call(this);
  69979. if (this._diffuseTexture) {
  69980. activeTextures.push(this._diffuseTexture);
  69981. }
  69982. if (this._ambientTexture) {
  69983. activeTextures.push(this._ambientTexture);
  69984. }
  69985. if (this._opacityTexture) {
  69986. activeTextures.push(this._opacityTexture);
  69987. }
  69988. if (this._reflectionTexture) {
  69989. activeTextures.push(this._reflectionTexture);
  69990. }
  69991. if (this._emissiveTexture) {
  69992. activeTextures.push(this._emissiveTexture);
  69993. }
  69994. if (this._specularTexture) {
  69995. activeTextures.push(this._specularTexture);
  69996. }
  69997. if (this._bumpTexture) {
  69998. activeTextures.push(this._bumpTexture);
  69999. }
  70000. if (this._lightmapTexture) {
  70001. activeTextures.push(this._lightmapTexture);
  70002. }
  70003. if (this._refractionTexture) {
  70004. activeTextures.push(this._refractionTexture);
  70005. }
  70006. return activeTextures;
  70007. };
  70008. /**
  70009. * Specifies if the material uses a texture
  70010. * @param texture defines the texture to check against the material
  70011. * @returns a boolean specifying if the material uses the texture
  70012. */
  70013. StandardMaterial.prototype.hasTexture = function (texture) {
  70014. if (_super.prototype.hasTexture.call(this, texture)) {
  70015. return true;
  70016. }
  70017. if (this._diffuseTexture === texture) {
  70018. return true;
  70019. }
  70020. if (this._ambientTexture === texture) {
  70021. return true;
  70022. }
  70023. if (this._opacityTexture === texture) {
  70024. return true;
  70025. }
  70026. if (this._reflectionTexture === texture) {
  70027. return true;
  70028. }
  70029. if (this._emissiveTexture === texture) {
  70030. return true;
  70031. }
  70032. if (this._specularTexture === texture) {
  70033. return true;
  70034. }
  70035. if (this._bumpTexture === texture) {
  70036. return true;
  70037. }
  70038. if (this._lightmapTexture === texture) {
  70039. return true;
  70040. }
  70041. if (this._refractionTexture === texture) {
  70042. return true;
  70043. }
  70044. return false;
  70045. };
  70046. /**
  70047. * Disposes the material
  70048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  70049. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  70050. */
  70051. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  70052. if (forceDisposeTextures) {
  70053. if (this._diffuseTexture) {
  70054. this._diffuseTexture.dispose();
  70055. }
  70056. if (this._ambientTexture) {
  70057. this._ambientTexture.dispose();
  70058. }
  70059. if (this._opacityTexture) {
  70060. this._opacityTexture.dispose();
  70061. }
  70062. if (this._reflectionTexture) {
  70063. this._reflectionTexture.dispose();
  70064. }
  70065. if (this._emissiveTexture) {
  70066. this._emissiveTexture.dispose();
  70067. }
  70068. if (this._specularTexture) {
  70069. this._specularTexture.dispose();
  70070. }
  70071. if (this._bumpTexture) {
  70072. this._bumpTexture.dispose();
  70073. }
  70074. if (this._lightmapTexture) {
  70075. this._lightmapTexture.dispose();
  70076. }
  70077. if (this._refractionTexture) {
  70078. this._refractionTexture.dispose();
  70079. }
  70080. }
  70081. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  70082. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  70083. }
  70084. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  70085. };
  70086. /**
  70087. * Makes a duplicate of the material, and gives it a new name
  70088. * @param name defines the new name for the duplicated material
  70089. * @returns the cloned material
  70090. */
  70091. StandardMaterial.prototype.clone = function (name) {
  70092. var _this = this;
  70093. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  70094. result.name = name;
  70095. result.id = name;
  70096. return result;
  70097. };
  70098. /**
  70099. * Serializes this material in a JSON representation
  70100. * @returns the serialized material object
  70101. */
  70102. StandardMaterial.prototype.serialize = function () {
  70103. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  70104. };
  70105. /**
  70106. * Creates a standard material from parsed material data
  70107. * @param source defines the JSON representation of the material
  70108. * @param scene defines the hosting scene
  70109. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70110. * @returns a new standard material
  70111. */
  70112. StandardMaterial.Parse = function (source, scene, rootUrl) {
  70113. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  70114. };
  70115. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  70116. // Flags used to enable or disable a type of texture for all Standard Materials
  70117. /**
  70118. * Are diffuse textures enabled in the application.
  70119. */
  70120. get: function () {
  70121. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  70122. },
  70123. set: function (value) {
  70124. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  70125. },
  70126. enumerable: true,
  70127. configurable: true
  70128. });
  70129. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  70130. /**
  70131. * Are ambient textures enabled in the application.
  70132. */
  70133. get: function () {
  70134. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  70135. },
  70136. set: function (value) {
  70137. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  70138. },
  70139. enumerable: true,
  70140. configurable: true
  70141. });
  70142. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  70143. /**
  70144. * Are opacity textures enabled in the application.
  70145. */
  70146. get: function () {
  70147. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  70148. },
  70149. set: function (value) {
  70150. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  70151. },
  70152. enumerable: true,
  70153. configurable: true
  70154. });
  70155. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  70156. /**
  70157. * Are reflection textures enabled in the application.
  70158. */
  70159. get: function () {
  70160. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  70161. },
  70162. set: function (value) {
  70163. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  70164. },
  70165. enumerable: true,
  70166. configurable: true
  70167. });
  70168. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  70169. /**
  70170. * Are emissive textures enabled in the application.
  70171. */
  70172. get: function () {
  70173. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  70174. },
  70175. set: function (value) {
  70176. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  70177. },
  70178. enumerable: true,
  70179. configurable: true
  70180. });
  70181. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  70182. /**
  70183. * Are specular textures enabled in the application.
  70184. */
  70185. get: function () {
  70186. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  70187. },
  70188. set: function (value) {
  70189. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  70190. },
  70191. enumerable: true,
  70192. configurable: true
  70193. });
  70194. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  70195. /**
  70196. * Are bump textures enabled in the application.
  70197. */
  70198. get: function () {
  70199. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  70200. },
  70201. set: function (value) {
  70202. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  70203. },
  70204. enumerable: true,
  70205. configurable: true
  70206. });
  70207. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  70208. /**
  70209. * Are lightmap textures enabled in the application.
  70210. */
  70211. get: function () {
  70212. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  70213. },
  70214. set: function (value) {
  70215. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  70216. },
  70217. enumerable: true,
  70218. configurable: true
  70219. });
  70220. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  70221. /**
  70222. * Are refraction textures enabled in the application.
  70223. */
  70224. get: function () {
  70225. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  70226. },
  70227. set: function (value) {
  70228. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  70229. },
  70230. enumerable: true,
  70231. configurable: true
  70232. });
  70233. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  70234. /**
  70235. * Are color grading textures enabled in the application.
  70236. */
  70237. get: function () {
  70238. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  70239. },
  70240. set: function (value) {
  70241. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  70242. },
  70243. enumerable: true,
  70244. configurable: true
  70245. });
  70246. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  70247. /**
  70248. * Are fresnels enabled in the application.
  70249. */
  70250. get: function () {
  70251. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  70252. },
  70253. set: function (value) {
  70254. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  70255. },
  70256. enumerable: true,
  70257. configurable: true
  70258. });
  70259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  70261. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  70262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  70264. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  70265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  70267. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  70268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70270. ], StandardMaterial.prototype, "ambientTexture", void 0);
  70271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  70273. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  70274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  70276. ], StandardMaterial.prototype, "opacityTexture", void 0);
  70277. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  70279. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  70280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70282. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  70283. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70284. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  70285. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  70286. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70287. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70288. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  70289. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  70291. ], StandardMaterial.prototype, "_specularTexture", void 0);
  70292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70294. ], StandardMaterial.prototype, "specularTexture", void 0);
  70295. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70296. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  70297. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  70298. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70299. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70300. ], StandardMaterial.prototype, "bumpTexture", void 0);
  70301. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  70303. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  70304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70306. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  70307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  70309. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  70310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70312. ], StandardMaterial.prototype, "refractionTexture", void 0);
  70313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  70315. ], StandardMaterial.prototype, "ambientColor", void 0);
  70316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  70318. ], StandardMaterial.prototype, "diffuseColor", void 0);
  70319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  70321. ], StandardMaterial.prototype, "specularColor", void 0);
  70322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  70324. ], StandardMaterial.prototype, "emissiveColor", void 0);
  70325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70327. ], StandardMaterial.prototype, "specularPower", void 0);
  70328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  70330. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  70331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70333. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  70334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  70336. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  70337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70339. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  70340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  70342. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  70343. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70344. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70345. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  70346. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  70348. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  70349. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70351. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  70352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  70354. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  70355. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70356. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70357. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  70358. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70359. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  70360. ], StandardMaterial.prototype, "_disableLighting", void 0);
  70361. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70362. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  70363. ], StandardMaterial.prototype, "disableLighting", void 0);
  70364. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70365. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  70366. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  70367. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70368. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70369. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  70370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  70372. ], StandardMaterial.prototype, "_useParallax", void 0);
  70373. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70375. ], StandardMaterial.prototype, "useParallax", void 0);
  70376. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70377. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  70378. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  70379. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70380. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70381. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  70382. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70383. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70384. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  70385. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70386. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  70387. ], StandardMaterial.prototype, "_roughness", void 0);
  70388. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70389. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70390. ], StandardMaterial.prototype, "roughness", void 0);
  70391. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70392. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70393. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  70394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70395. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70396. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  70397. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70398. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70399. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  70400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  70402. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  70403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70405. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  70406. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70407. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  70408. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  70409. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70410. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70411. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  70412. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70413. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  70414. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  70415. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  70417. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  70418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  70420. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  70421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70423. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  70424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  70426. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  70427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70429. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  70430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  70432. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  70433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70435. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  70436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  70438. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  70439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70441. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  70442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  70444. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  70445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70447. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  70448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  70450. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  70451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  70453. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  70454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  70456. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  70457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70459. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  70460. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  70462. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  70463. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70464. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70465. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  70466. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70467. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  70468. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  70469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70471. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  70472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70474. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  70475. return StandardMaterial;
  70476. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  70477. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  70478. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  70479. return new StandardMaterial("default material", scene);
  70480. };
  70481. /***/ }),
  70482. /***/ "./Materials/uniformBuffer.ts":
  70483. /*!************************************!*\
  70484. !*** ./Materials/uniformBuffer.ts ***!
  70485. \************************************/
  70486. /*! exports provided: UniformBuffer */
  70487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70488. "use strict";
  70489. __webpack_require__.r(__webpack_exports__);
  70490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  70491. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  70492. /**
  70493. * Uniform buffer objects.
  70494. *
  70495. * Handles blocks of uniform on the GPU.
  70496. *
  70497. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  70498. *
  70499. * For more information, please refer to :
  70500. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  70501. */
  70502. var UniformBuffer = /** @class */ (function () {
  70503. /**
  70504. * Instantiates a new Uniform buffer objects.
  70505. *
  70506. * Handles blocks of uniform on the GPU.
  70507. *
  70508. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  70509. *
  70510. * For more information, please refer to :
  70511. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  70512. * @param engine Define the engine the buffer is associated with
  70513. * @param data Define the data contained in the buffer
  70514. * @param dynamic Define if the buffer is updatable
  70515. */
  70516. function UniformBuffer(engine, data, dynamic) {
  70517. this._engine = engine;
  70518. this._noUBO = !engine.supportsUniformBuffers;
  70519. this._dynamic = dynamic;
  70520. this._data = data || [];
  70521. this._uniformLocations = {};
  70522. this._uniformSizes = {};
  70523. this._uniformLocationPointer = 0;
  70524. this._needSync = false;
  70525. if (this._noUBO) {
  70526. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  70527. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  70528. this.updateFloat = this._updateFloatForEffect;
  70529. this.updateFloat2 = this._updateFloat2ForEffect;
  70530. this.updateFloat3 = this._updateFloat3ForEffect;
  70531. this.updateFloat4 = this._updateFloat4ForEffect;
  70532. this.updateMatrix = this._updateMatrixForEffect;
  70533. this.updateVector3 = this._updateVector3ForEffect;
  70534. this.updateVector4 = this._updateVector4ForEffect;
  70535. this.updateColor3 = this._updateColor3ForEffect;
  70536. this.updateColor4 = this._updateColor4ForEffect;
  70537. }
  70538. else {
  70539. this._engine._uniformBuffers.push(this);
  70540. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  70541. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  70542. this.updateFloat = this._updateFloatForUniform;
  70543. this.updateFloat2 = this._updateFloat2ForUniform;
  70544. this.updateFloat3 = this._updateFloat3ForUniform;
  70545. this.updateFloat4 = this._updateFloat4ForUniform;
  70546. this.updateMatrix = this._updateMatrixForUniform;
  70547. this.updateVector3 = this._updateVector3ForUniform;
  70548. this.updateVector4 = this._updateVector4ForUniform;
  70549. this.updateColor3 = this._updateColor3ForUniform;
  70550. this.updateColor4 = this._updateColor4ForUniform;
  70551. }
  70552. }
  70553. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  70554. /**
  70555. * Indicates if the buffer is using the WebGL2 UBO implementation,
  70556. * or just falling back on setUniformXXX calls.
  70557. */
  70558. get: function () {
  70559. return !this._noUBO;
  70560. },
  70561. enumerable: true,
  70562. configurable: true
  70563. });
  70564. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  70565. /**
  70566. * Indicates if the WebGL underlying uniform buffer is in sync
  70567. * with the javascript cache data.
  70568. */
  70569. get: function () {
  70570. return !this._needSync;
  70571. },
  70572. enumerable: true,
  70573. configurable: true
  70574. });
  70575. /**
  70576. * Indicates if the WebGL underlying uniform buffer is dynamic.
  70577. * Also, a dynamic UniformBuffer will disable cache verification and always
  70578. * update the underlying WebGL uniform buffer to the GPU.
  70579. * @returns if Dynamic, otherwise false
  70580. */
  70581. UniformBuffer.prototype.isDynamic = function () {
  70582. return this._dynamic !== undefined;
  70583. };
  70584. /**
  70585. * The data cache on JS side.
  70586. * @returns the underlying data as a float array
  70587. */
  70588. UniformBuffer.prototype.getData = function () {
  70589. return this._bufferData;
  70590. };
  70591. /**
  70592. * The underlying WebGL Uniform buffer.
  70593. * @returns the webgl buffer
  70594. */
  70595. UniformBuffer.prototype.getBuffer = function () {
  70596. return this._buffer;
  70597. };
  70598. /**
  70599. * std140 layout specifies how to align data within an UBO structure.
  70600. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  70601. * for specs.
  70602. */
  70603. UniformBuffer.prototype._fillAlignment = function (size) {
  70604. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  70605. // and 4x4 matrices
  70606. // TODO : change if other types are used
  70607. var alignment;
  70608. if (size <= 2) {
  70609. alignment = size;
  70610. }
  70611. else {
  70612. alignment = 4;
  70613. }
  70614. if ((this._uniformLocationPointer % alignment) !== 0) {
  70615. var oldPointer = this._uniformLocationPointer;
  70616. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  70617. var diff = this._uniformLocationPointer - oldPointer;
  70618. for (var i = 0; i < diff; i++) {
  70619. this._data.push(0);
  70620. }
  70621. }
  70622. };
  70623. /**
  70624. * Adds an uniform in the buffer.
  70625. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  70626. * for the layout to be correct !
  70627. * @param name Name of the uniform, as used in the uniform block in the shader.
  70628. * @param size Data size, or data directly.
  70629. */
  70630. UniformBuffer.prototype.addUniform = function (name, size) {
  70631. if (this._noUBO) {
  70632. return;
  70633. }
  70634. if (this._uniformLocations[name] !== undefined) {
  70635. // Already existing uniform
  70636. return;
  70637. }
  70638. // This function must be called in the order of the shader layout !
  70639. // size can be the size of the uniform, or data directly
  70640. var data;
  70641. if (size instanceof Array) {
  70642. data = size;
  70643. size = data.length;
  70644. }
  70645. else {
  70646. size = size;
  70647. data = [];
  70648. // Fill with zeros
  70649. for (var i = 0; i < size; i++) {
  70650. data.push(0);
  70651. }
  70652. }
  70653. this._fillAlignment(size);
  70654. this._uniformSizes[name] = size;
  70655. this._uniformLocations[name] = this._uniformLocationPointer;
  70656. this._uniformLocationPointer += size;
  70657. for (var i = 0; i < size; i++) {
  70658. this._data.push(data[i]);
  70659. }
  70660. this._needSync = true;
  70661. };
  70662. /**
  70663. * Adds a Matrix 4x4 to the uniform buffer.
  70664. * @param name Name of the uniform, as used in the uniform block in the shader.
  70665. * @param mat A 4x4 matrix.
  70666. */
  70667. UniformBuffer.prototype.addMatrix = function (name, mat) {
  70668. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  70669. };
  70670. /**
  70671. * Adds a vec2 to the uniform buffer.
  70672. * @param name Name of the uniform, as used in the uniform block in the shader.
  70673. * @param x Define the x component value of the vec2
  70674. * @param y Define the y component value of the vec2
  70675. */
  70676. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  70677. var temp = [x, y];
  70678. this.addUniform(name, temp);
  70679. };
  70680. /**
  70681. * Adds a vec3 to the uniform buffer.
  70682. * @param name Name of the uniform, as used in the uniform block in the shader.
  70683. * @param x Define the x component value of the vec3
  70684. * @param y Define the y component value of the vec3
  70685. * @param z Define the z component value of the vec3
  70686. */
  70687. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  70688. var temp = [x, y, z];
  70689. this.addUniform(name, temp);
  70690. };
  70691. /**
  70692. * Adds a vec3 to the uniform buffer.
  70693. * @param name Name of the uniform, as used in the uniform block in the shader.
  70694. * @param color Define the vec3 from a Color
  70695. */
  70696. UniformBuffer.prototype.addColor3 = function (name, color) {
  70697. var temp = new Array();
  70698. color.toArray(temp);
  70699. this.addUniform(name, temp);
  70700. };
  70701. /**
  70702. * Adds a vec4 to the uniform buffer.
  70703. * @param name Name of the uniform, as used in the uniform block in the shader.
  70704. * @param color Define the rgb components from a Color
  70705. * @param alpha Define the a component of the vec4
  70706. */
  70707. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  70708. var temp = new Array();
  70709. color.toArray(temp);
  70710. temp.push(alpha);
  70711. this.addUniform(name, temp);
  70712. };
  70713. /**
  70714. * Adds a vec3 to the uniform buffer.
  70715. * @param name Name of the uniform, as used in the uniform block in the shader.
  70716. * @param vector Define the vec3 components from a Vector
  70717. */
  70718. UniformBuffer.prototype.addVector3 = function (name, vector) {
  70719. var temp = new Array();
  70720. vector.toArray(temp);
  70721. this.addUniform(name, temp);
  70722. };
  70723. /**
  70724. * Adds a Matrix 3x3 to the uniform buffer.
  70725. * @param name Name of the uniform, as used in the uniform block in the shader.
  70726. */
  70727. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  70728. this.addUniform(name, 12);
  70729. };
  70730. /**
  70731. * Adds a Matrix 2x2 to the uniform buffer.
  70732. * @param name Name of the uniform, as used in the uniform block in the shader.
  70733. */
  70734. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  70735. this.addUniform(name, 8);
  70736. };
  70737. /**
  70738. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  70739. */
  70740. UniformBuffer.prototype.create = function () {
  70741. if (this._noUBO) {
  70742. return;
  70743. }
  70744. if (this._buffer) {
  70745. return; // nothing to do
  70746. }
  70747. // See spec, alignment must be filled as a vec4
  70748. this._fillAlignment(4);
  70749. this._bufferData = new Float32Array(this._data);
  70750. this._rebuild();
  70751. this._needSync = true;
  70752. };
  70753. /** @hidden */
  70754. UniformBuffer.prototype._rebuild = function () {
  70755. if (this._noUBO) {
  70756. return;
  70757. }
  70758. if (this._dynamic) {
  70759. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  70760. }
  70761. else {
  70762. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  70763. }
  70764. };
  70765. /**
  70766. * Updates the WebGL Uniform Buffer on the GPU.
  70767. * If the `dynamic` flag is set to true, no cache comparison is done.
  70768. * Otherwise, the buffer will be updated only if the cache differs.
  70769. */
  70770. UniformBuffer.prototype.update = function () {
  70771. if (!this._buffer) {
  70772. this.create();
  70773. return;
  70774. }
  70775. if (!this._dynamic && !this._needSync) {
  70776. return;
  70777. }
  70778. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  70779. this._needSync = false;
  70780. };
  70781. /**
  70782. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  70783. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  70784. * @param data Define the flattened data
  70785. * @param size Define the size of the data.
  70786. */
  70787. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  70788. var location = this._uniformLocations[uniformName];
  70789. if (location === undefined) {
  70790. if (this._buffer) {
  70791. // Cannot add an uniform if the buffer is already created
  70792. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  70793. return;
  70794. }
  70795. this.addUniform(uniformName, size);
  70796. location = this._uniformLocations[uniformName];
  70797. }
  70798. if (!this._buffer) {
  70799. this.create();
  70800. }
  70801. if (!this._dynamic) {
  70802. // Cache for static uniform buffers
  70803. var changed = false;
  70804. for (var i = 0; i < size; i++) {
  70805. if (this._bufferData[location + i] !== data[i]) {
  70806. changed = true;
  70807. this._bufferData[location + i] = data[i];
  70808. }
  70809. }
  70810. this._needSync = this._needSync || changed;
  70811. }
  70812. else {
  70813. // No cache for dynamic
  70814. for (var i = 0; i < size; i++) {
  70815. this._bufferData[location + i] = data[i];
  70816. }
  70817. }
  70818. };
  70819. // Update methods
  70820. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  70821. // To match std140, matrix must be realigned
  70822. for (var i = 0; i < 3; i++) {
  70823. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  70824. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  70825. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  70826. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  70827. }
  70828. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  70829. };
  70830. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  70831. this._currentEffect.setMatrix3x3(name, matrix);
  70832. };
  70833. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  70834. this._currentEffect.setMatrix2x2(name, matrix);
  70835. };
  70836. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  70837. // To match std140, matrix must be realigned
  70838. for (var i = 0; i < 2; i++) {
  70839. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  70840. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  70841. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  70842. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  70843. }
  70844. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  70845. };
  70846. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  70847. this._currentEffect.setFloat(name, x);
  70848. };
  70849. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  70850. UniformBuffer._tempBuffer[0] = x;
  70851. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  70852. };
  70853. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  70854. if (suffix === void 0) { suffix = ""; }
  70855. this._currentEffect.setFloat2(name + suffix, x, y);
  70856. };
  70857. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  70858. UniformBuffer._tempBuffer[0] = x;
  70859. UniformBuffer._tempBuffer[1] = y;
  70860. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  70861. };
  70862. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  70863. if (suffix === void 0) { suffix = ""; }
  70864. this._currentEffect.setFloat3(name + suffix, x, y, z);
  70865. };
  70866. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  70867. UniformBuffer._tempBuffer[0] = x;
  70868. UniformBuffer._tempBuffer[1] = y;
  70869. UniformBuffer._tempBuffer[2] = z;
  70870. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70871. };
  70872. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  70873. if (suffix === void 0) { suffix = ""; }
  70874. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  70875. };
  70876. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  70877. UniformBuffer._tempBuffer[0] = x;
  70878. UniformBuffer._tempBuffer[1] = y;
  70879. UniformBuffer._tempBuffer[2] = z;
  70880. UniformBuffer._tempBuffer[3] = w;
  70881. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70882. };
  70883. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  70884. this._currentEffect.setMatrix(name, mat);
  70885. };
  70886. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  70887. this.updateUniform(name, mat.toArray(), 16);
  70888. };
  70889. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  70890. this._currentEffect.setVector3(name, vector);
  70891. };
  70892. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  70893. vector.toArray(UniformBuffer._tempBuffer);
  70894. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70895. };
  70896. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  70897. this._currentEffect.setVector4(name, vector);
  70898. };
  70899. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  70900. vector.toArray(UniformBuffer._tempBuffer);
  70901. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70902. };
  70903. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  70904. if (suffix === void 0) { suffix = ""; }
  70905. this._currentEffect.setColor3(name + suffix, color);
  70906. };
  70907. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  70908. color.toArray(UniformBuffer._tempBuffer);
  70909. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70910. };
  70911. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  70912. if (suffix === void 0) { suffix = ""; }
  70913. this._currentEffect.setColor4(name + suffix, color, alpha);
  70914. };
  70915. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  70916. color.toArray(UniformBuffer._tempBuffer);
  70917. UniformBuffer._tempBuffer[3] = alpha;
  70918. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70919. };
  70920. /**
  70921. * Sets a sampler uniform on the effect.
  70922. * @param name Define the name of the sampler.
  70923. * @param texture Define the texture to set in the sampler
  70924. */
  70925. UniformBuffer.prototype.setTexture = function (name, texture) {
  70926. this._currentEffect.setTexture(name, texture);
  70927. };
  70928. /**
  70929. * Directly updates the value of the uniform in the cache AND on the GPU.
  70930. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  70931. * @param data Define the flattened data
  70932. */
  70933. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  70934. this.updateUniform(uniformName, data, data.length);
  70935. this.update();
  70936. };
  70937. /**
  70938. * Binds this uniform buffer to an effect.
  70939. * @param effect Define the effect to bind the buffer to
  70940. * @param name Name of the uniform block in the shader.
  70941. */
  70942. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  70943. this._currentEffect = effect;
  70944. if (this._noUBO || !this._buffer) {
  70945. return;
  70946. }
  70947. effect.bindUniformBuffer(this._buffer, name);
  70948. };
  70949. /**
  70950. * Disposes the uniform buffer.
  70951. */
  70952. UniformBuffer.prototype.dispose = function () {
  70953. if (this._noUBO) {
  70954. return;
  70955. }
  70956. var uniformBuffers = this._engine._uniformBuffers;
  70957. var index = uniformBuffers.indexOf(this);
  70958. if (index !== -1) {
  70959. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  70960. uniformBuffers.pop();
  70961. }
  70962. if (!this._buffer) {
  70963. return;
  70964. }
  70965. if (this._engine._releaseBuffer(this._buffer)) {
  70966. this._buffer = null;
  70967. }
  70968. };
  70969. // Pool for avoiding memory leaks
  70970. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  70971. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  70972. return UniformBuffer;
  70973. }());
  70974. /***/ }),
  70975. /***/ "./Maths/index.ts":
  70976. /*!************************!*\
  70977. !*** ./Maths/index.ts ***!
  70978. \************************/
  70979. /*! 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 */
  70980. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70981. "use strict";
  70982. __webpack_require__.r(__webpack_exports__);
  70983. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  70984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  70985. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  70986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  70987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  70988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  70989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  70990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  70991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  70992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  70993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  70994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  70995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  70996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  70997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  70998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  70999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  71000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  71001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  71002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  71003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  71004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  71005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  71006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  71007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  71008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  71009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  71010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  71011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  71012. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  71013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  71014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  71015. /***/ }),
  71016. /***/ "./Maths/math.scalar.ts":
  71017. /*!******************************!*\
  71018. !*** ./Maths/math.scalar.ts ***!
  71019. \******************************/
  71020. /*! exports provided: Scalar */
  71021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  71022. "use strict";
  71023. __webpack_require__.r(__webpack_exports__);
  71024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  71025. /**
  71026. * Scalar computation library
  71027. */
  71028. var Scalar = /** @class */ (function () {
  71029. function Scalar() {
  71030. }
  71031. /**
  71032. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  71033. * @param a number
  71034. * @param b number
  71035. * @param epsilon (default = 1.401298E-45)
  71036. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  71037. */
  71038. Scalar.WithinEpsilon = function (a, b, epsilon) {
  71039. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  71040. var num = a - b;
  71041. return -epsilon <= num && num <= epsilon;
  71042. };
  71043. /**
  71044. * Returns a string : the upper case translation of the number i to hexadecimal.
  71045. * @param i number
  71046. * @returns the upper case translation of the number i to hexadecimal.
  71047. */
  71048. Scalar.ToHex = function (i) {
  71049. var str = i.toString(16);
  71050. if (i <= 15) {
  71051. return ("0" + str).toUpperCase();
  71052. }
  71053. return str.toUpperCase();
  71054. };
  71055. /**
  71056. * Returns -1 if value is negative and +1 is value is positive.
  71057. * @param value the value
  71058. * @returns the value itself if it's equal to zero.
  71059. */
  71060. Scalar.Sign = function (value) {
  71061. value = +value; // convert to a number
  71062. if (value === 0 || isNaN(value)) {
  71063. return value;
  71064. }
  71065. return value > 0 ? 1 : -1;
  71066. };
  71067. /**
  71068. * Returns the value itself if it's between min and max.
  71069. * Returns min if the value is lower than min.
  71070. * Returns max if the value is greater than max.
  71071. * @param value the value to clmap
  71072. * @param min the min value to clamp to (default: 0)
  71073. * @param max the max value to clamp to (default: 1)
  71074. * @returns the clamped value
  71075. */
  71076. Scalar.Clamp = function (value, min, max) {
  71077. if (min === void 0) { min = 0; }
  71078. if (max === void 0) { max = 1; }
  71079. return Math.min(max, Math.max(min, value));
  71080. };
  71081. /**
  71082. * the log2 of value.
  71083. * @param value the value to compute log2 of
  71084. * @returns the log2 of value.
  71085. */
  71086. Scalar.Log2 = function (value) {
  71087. return Math.log(value) * Math.LOG2E;
  71088. };
  71089. /**
  71090. * Loops the value, so that it is never larger than length and never smaller than 0.
  71091. *
  71092. * This is similar to the modulo operator but it works with floating point numbers.
  71093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  71094. * With t = 5 and length = 2.5, the result would be 0.0.
  71095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  71096. * @param value the value
  71097. * @param length the length
  71098. * @returns the looped value
  71099. */
  71100. Scalar.Repeat = function (value, length) {
  71101. return value - Math.floor(value / length) * length;
  71102. };
  71103. /**
  71104. * Normalize the value between 0.0 and 1.0 using min and max values
  71105. * @param value value to normalize
  71106. * @param min max to normalize between
  71107. * @param max min to normalize between
  71108. * @returns the normalized value
  71109. */
  71110. Scalar.Normalize = function (value, min, max) {
  71111. return (value - min) / (max - min);
  71112. };
  71113. /**
  71114. * Denormalize the value from 0.0 and 1.0 using min and max values
  71115. * @param normalized value to denormalize
  71116. * @param min max to denormalize between
  71117. * @param max min to denormalize between
  71118. * @returns the denormalized value
  71119. */
  71120. Scalar.Denormalize = function (normalized, min, max) {
  71121. return (normalized * (max - min) + min);
  71122. };
  71123. /**
  71124. * Calculates the shortest difference between two given angles given in degrees.
  71125. * @param current current angle in degrees
  71126. * @param target target angle in degrees
  71127. * @returns the delta
  71128. */
  71129. Scalar.DeltaAngle = function (current, target) {
  71130. var num = Scalar.Repeat(target - current, 360.0);
  71131. if (num > 180.0) {
  71132. num -= 360.0;
  71133. }
  71134. return num;
  71135. };
  71136. /**
  71137. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  71138. * @param tx value
  71139. * @param length length
  71140. * @returns The returned value will move back and forth between 0 and length
  71141. */
  71142. Scalar.PingPong = function (tx, length) {
  71143. var t = Scalar.Repeat(tx, length * 2.0);
  71144. return length - Math.abs(t - length);
  71145. };
  71146. /**
  71147. * Interpolates between min and max with smoothing at the limits.
  71148. *
  71149. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  71150. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  71151. * @param from from
  71152. * @param to to
  71153. * @param tx value
  71154. * @returns the smooth stepped value
  71155. */
  71156. Scalar.SmoothStep = function (from, to, tx) {
  71157. var t = Scalar.Clamp(tx);
  71158. t = -2.0 * t * t * t + 3.0 * t * t;
  71159. return to * t + from * (1.0 - t);
  71160. };
  71161. /**
  71162. * Moves a value current towards target.
  71163. *
  71164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  71165. * Negative values of maxDelta pushes the value away from target.
  71166. * @param current current value
  71167. * @param target target value
  71168. * @param maxDelta max distance to move
  71169. * @returns resulting value
  71170. */
  71171. Scalar.MoveTowards = function (current, target, maxDelta) {
  71172. var result = 0;
  71173. if (Math.abs(target - current) <= maxDelta) {
  71174. result = target;
  71175. }
  71176. else {
  71177. result = current + Scalar.Sign(target - current) * maxDelta;
  71178. }
  71179. return result;
  71180. };
  71181. /**
  71182. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  71183. *
  71184. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  71185. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  71186. * @param current current value
  71187. * @param target target value
  71188. * @param maxDelta max distance to move
  71189. * @returns resulting angle
  71190. */
  71191. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  71192. var num = Scalar.DeltaAngle(current, target);
  71193. var result = 0;
  71194. if (-maxDelta < num && num < maxDelta) {
  71195. result = target;
  71196. }
  71197. else {
  71198. target = current + num;
  71199. result = Scalar.MoveTowards(current, target, maxDelta);
  71200. }
  71201. return result;
  71202. };
  71203. /**
  71204. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  71205. * @param start start value
  71206. * @param end target value
  71207. * @param amount amount to lerp between
  71208. * @returns the lerped value
  71209. */
  71210. Scalar.Lerp = function (start, end, amount) {
  71211. return start + ((end - start) * amount);
  71212. };
  71213. /**
  71214. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  71215. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  71216. * @param start start value
  71217. * @param end target value
  71218. * @param amount amount to lerp between
  71219. * @returns the lerped value
  71220. */
  71221. Scalar.LerpAngle = function (start, end, amount) {
  71222. var num = Scalar.Repeat(end - start, 360.0);
  71223. if (num > 180.0) {
  71224. num -= 360.0;
  71225. }
  71226. return start + num * Scalar.Clamp(amount);
  71227. };
  71228. /**
  71229. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  71230. * @param a start value
  71231. * @param b target value
  71232. * @param value value between a and b
  71233. * @returns the inverseLerp value
  71234. */
  71235. Scalar.InverseLerp = function (a, b, value) {
  71236. var result = 0;
  71237. if (a != b) {
  71238. result = Scalar.Clamp((value - a) / (b - a));
  71239. }
  71240. else {
  71241. result = 0.0;
  71242. }
  71243. return result;
  71244. };
  71245. /**
  71246. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  71247. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  71248. * @param value1 spline value
  71249. * @param tangent1 spline value
  71250. * @param value2 spline value
  71251. * @param tangent2 spline value
  71252. * @param amount input value
  71253. * @returns hermite result
  71254. */
  71255. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  71256. var squared = amount * amount;
  71257. var cubed = amount * squared;
  71258. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  71259. var part2 = (-2.0 * cubed) + (3.0 * squared);
  71260. var part3 = (cubed - (2.0 * squared)) + amount;
  71261. var part4 = cubed - squared;
  71262. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  71263. };
  71264. /**
  71265. * Returns a random float number between and min and max values
  71266. * @param min min value of random
  71267. * @param max max value of random
  71268. * @returns random value
  71269. */
  71270. Scalar.RandomRange = function (min, max) {
  71271. if (min === max) {
  71272. return min;
  71273. }
  71274. return ((Math.random() * (max - min)) + min);
  71275. };
  71276. /**
  71277. * This function returns percentage of a number in a given range.
  71278. *
  71279. * RangeToPercent(40,20,60) will return 0.5 (50%)
  71280. * RangeToPercent(34,0,100) will return 0.34 (34%)
  71281. * @param number to convert to percentage
  71282. * @param min min range
  71283. * @param max max range
  71284. * @returns the percentage
  71285. */
  71286. Scalar.RangeToPercent = function (number, min, max) {
  71287. return ((number - min) / (max - min));
  71288. };
  71289. /**
  71290. * This function returns number that corresponds to the percentage in a given range.
  71291. *
  71292. * PercentToRange(0.34,0,100) will return 34.
  71293. * @param percent to convert to number
  71294. * @param min min range
  71295. * @param max max range
  71296. * @returns the number
  71297. */
  71298. Scalar.PercentToRange = function (percent, min, max) {
  71299. return ((max - min) * percent + min);
  71300. };
  71301. /**
  71302. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  71303. * @param angle The angle to normalize in radian.
  71304. * @return The converted angle.
  71305. */
  71306. Scalar.NormalizeRadians = function (angle) {
  71307. // More precise but slower version kept for reference.
  71308. // angle = angle % Tools.TwoPi;
  71309. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  71310. //if (angle > Math.PI) {
  71311. // angle -= Tools.TwoPi;
  71312. //}
  71313. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  71314. return angle;
  71315. };
  71316. /**
  71317. * Two pi constants convenient for computation.
  71318. */
  71319. Scalar.TwoPi = Math.PI * 2;
  71320. return Scalar;
  71321. }());
  71322. /***/ }),
  71323. /***/ "./Maths/math.ts":
  71324. /*!***********************!*\
  71325. !*** ./Maths/math.ts ***!
  71326. \***********************/
  71327. /*! 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 */
  71328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  71329. "use strict";
  71330. __webpack_require__.r(__webpack_exports__);
  71331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  71332. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  71333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  71334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  71335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  71336. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  71337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  71338. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  71339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  71340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  71341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  71342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  71343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  71344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  71345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  71346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  71347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  71348. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  71349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  71350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  71351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  71352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  71353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  71354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  71355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  71356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  71357. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  71358. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  71359. /**
  71360. * Constant used to convert a value to gamma space
  71361. * @ignorenaming
  71362. */
  71363. var ToGammaSpace = 1 / 2.2;
  71364. /**
  71365. * Constant used to convert a value to linear space
  71366. * @ignorenaming
  71367. */
  71368. var ToLinearSpace = 2.2;
  71369. /**
  71370. * Constant used to define the minimal number value in Babylon.js
  71371. * @ignorenaming
  71372. */
  71373. var Epsilon = 0.001;
  71374. /**
  71375. * Class used to hold a RBG color
  71376. */
  71377. var Color3 = /** @class */ (function () {
  71378. /**
  71379. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  71380. * @param r defines the red component (between 0 and 1, default is 0)
  71381. * @param g defines the green component (between 0 and 1, default is 0)
  71382. * @param b defines the blue component (between 0 and 1, default is 0)
  71383. */
  71384. function Color3(
  71385. /**
  71386. * Defines the red component (between 0 and 1, default is 0)
  71387. */
  71388. r,
  71389. /**
  71390. * Defines the green component (between 0 and 1, default is 0)
  71391. */
  71392. g,
  71393. /**
  71394. * Defines the blue component (between 0 and 1, default is 0)
  71395. */
  71396. b) {
  71397. if (r === void 0) { r = 0; }
  71398. if (g === void 0) { g = 0; }
  71399. if (b === void 0) { b = 0; }
  71400. this.r = r;
  71401. this.g = g;
  71402. this.b = b;
  71403. }
  71404. /**
  71405. * Creates a string with the Color3 current values
  71406. * @returns the string representation of the Color3 object
  71407. */
  71408. Color3.prototype.toString = function () {
  71409. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  71410. };
  71411. /**
  71412. * Returns the string "Color3"
  71413. * @returns "Color3"
  71414. */
  71415. Color3.prototype.getClassName = function () {
  71416. return "Color3";
  71417. };
  71418. /**
  71419. * Compute the Color3 hash code
  71420. * @returns an unique number that can be used to hash Color3 objects
  71421. */
  71422. Color3.prototype.getHashCode = function () {
  71423. var hash = this.r || 0;
  71424. hash = (hash * 397) ^ (this.g || 0);
  71425. hash = (hash * 397) ^ (this.b || 0);
  71426. return hash;
  71427. };
  71428. // Operators
  71429. /**
  71430. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  71431. * @param array defines the array where to store the r,g,b components
  71432. * @param index defines an optional index in the target array to define where to start storing values
  71433. * @returns the current Color3 object
  71434. */
  71435. Color3.prototype.toArray = function (array, index) {
  71436. if (index === void 0) { index = 0; }
  71437. array[index] = this.r;
  71438. array[index + 1] = this.g;
  71439. array[index + 2] = this.b;
  71440. return this;
  71441. };
  71442. /**
  71443. * Returns a new Color4 object from the current Color3 and the given alpha
  71444. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  71445. * @returns a new Color4 object
  71446. */
  71447. Color3.prototype.toColor4 = function (alpha) {
  71448. if (alpha === void 0) { alpha = 1; }
  71449. return new Color4(this.r, this.g, this.b, alpha);
  71450. };
  71451. /**
  71452. * Returns a new array populated with 3 numeric elements : red, green and blue values
  71453. * @returns the new array
  71454. */
  71455. Color3.prototype.asArray = function () {
  71456. var result = new Array();
  71457. this.toArray(result, 0);
  71458. return result;
  71459. };
  71460. /**
  71461. * Returns the luminance value
  71462. * @returns a float value
  71463. */
  71464. Color3.prototype.toLuminance = function () {
  71465. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  71466. };
  71467. /**
  71468. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  71469. * @param otherColor defines the second operand
  71470. * @returns the new Color3 object
  71471. */
  71472. Color3.prototype.multiply = function (otherColor) {
  71473. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  71474. };
  71475. /**
  71476. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  71477. * @param otherColor defines the second operand
  71478. * @param result defines the Color3 object where to store the result
  71479. * @returns the current Color3
  71480. */
  71481. Color3.prototype.multiplyToRef = function (otherColor, result) {
  71482. result.r = this.r * otherColor.r;
  71483. result.g = this.g * otherColor.g;
  71484. result.b = this.b * otherColor.b;
  71485. return this;
  71486. };
  71487. /**
  71488. * Determines equality between Color3 objects
  71489. * @param otherColor defines the second operand
  71490. * @returns true if the rgb values are equal to the given ones
  71491. */
  71492. Color3.prototype.equals = function (otherColor) {
  71493. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  71494. };
  71495. /**
  71496. * Determines equality between the current Color3 object and a set of r,b,g values
  71497. * @param r defines the red component to check
  71498. * @param g defines the green component to check
  71499. * @param b defines the blue component to check
  71500. * @returns true if the rgb values are equal to the given ones
  71501. */
  71502. Color3.prototype.equalsFloats = function (r, g, b) {
  71503. return this.r === r && this.g === g && this.b === b;
  71504. };
  71505. /**
  71506. * Multiplies in place each rgb value by scale
  71507. * @param scale defines the scaling factor
  71508. * @returns the updated Color3
  71509. */
  71510. Color3.prototype.scale = function (scale) {
  71511. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  71512. };
  71513. /**
  71514. * Multiplies the rgb values by scale and stores the result into "result"
  71515. * @param scale defines the scaling factor
  71516. * @param result defines the Color3 object where to store the result
  71517. * @returns the unmodified current Color3
  71518. */
  71519. Color3.prototype.scaleToRef = function (scale, result) {
  71520. result.r = this.r * scale;
  71521. result.g = this.g * scale;
  71522. result.b = this.b * scale;
  71523. return this;
  71524. };
  71525. /**
  71526. * Scale the current Color3 values by a factor and add the result to a given Color3
  71527. * @param scale defines the scale factor
  71528. * @param result defines color to store the result into
  71529. * @returns the unmodified current Color3
  71530. */
  71531. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  71532. result.r += this.r * scale;
  71533. result.g += this.g * scale;
  71534. result.b += this.b * scale;
  71535. return this;
  71536. };
  71537. /**
  71538. * Clamps the rgb values by the min and max values and stores the result into "result"
  71539. * @param min defines minimum clamping value (default is 0)
  71540. * @param max defines maximum clamping value (default is 1)
  71541. * @param result defines color to store the result into
  71542. * @returns the original Color3
  71543. */
  71544. Color3.prototype.clampToRef = function (min, max, result) {
  71545. if (min === void 0) { min = 0; }
  71546. if (max === void 0) { max = 1; }
  71547. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  71548. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  71549. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  71550. return this;
  71551. };
  71552. /**
  71553. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  71554. * @param otherColor defines the second operand
  71555. * @returns the new Color3
  71556. */
  71557. Color3.prototype.add = function (otherColor) {
  71558. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  71559. };
  71560. /**
  71561. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  71562. * @param otherColor defines the second operand
  71563. * @param result defines Color3 object to store the result into
  71564. * @returns the unmodified current Color3
  71565. */
  71566. Color3.prototype.addToRef = function (otherColor, result) {
  71567. result.r = this.r + otherColor.r;
  71568. result.g = this.g + otherColor.g;
  71569. result.b = this.b + otherColor.b;
  71570. return this;
  71571. };
  71572. /**
  71573. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  71574. * @param otherColor defines the second operand
  71575. * @returns the new Color3
  71576. */
  71577. Color3.prototype.subtract = function (otherColor) {
  71578. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  71579. };
  71580. /**
  71581. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  71582. * @param otherColor defines the second operand
  71583. * @param result defines Color3 object to store the result into
  71584. * @returns the unmodified current Color3
  71585. */
  71586. Color3.prototype.subtractToRef = function (otherColor, result) {
  71587. result.r = this.r - otherColor.r;
  71588. result.g = this.g - otherColor.g;
  71589. result.b = this.b - otherColor.b;
  71590. return this;
  71591. };
  71592. /**
  71593. * Copy the current object
  71594. * @returns a new Color3 copied the current one
  71595. */
  71596. Color3.prototype.clone = function () {
  71597. return new Color3(this.r, this.g, this.b);
  71598. };
  71599. /**
  71600. * Copies the rgb values from the source in the current Color3
  71601. * @param source defines the source Color3 object
  71602. * @returns the updated Color3 object
  71603. */
  71604. Color3.prototype.copyFrom = function (source) {
  71605. this.r = source.r;
  71606. this.g = source.g;
  71607. this.b = source.b;
  71608. return this;
  71609. };
  71610. /**
  71611. * Updates the Color3 rgb values from the given floats
  71612. * @param r defines the red component to read from
  71613. * @param g defines the green component to read from
  71614. * @param b defines the blue component to read from
  71615. * @returns the current Color3 object
  71616. */
  71617. Color3.prototype.copyFromFloats = function (r, g, b) {
  71618. this.r = r;
  71619. this.g = g;
  71620. this.b = b;
  71621. return this;
  71622. };
  71623. /**
  71624. * Updates the Color3 rgb values from the given floats
  71625. * @param r defines the red component to read from
  71626. * @param g defines the green component to read from
  71627. * @param b defines the blue component to read from
  71628. * @returns the current Color3 object
  71629. */
  71630. Color3.prototype.set = function (r, g, b) {
  71631. return this.copyFromFloats(r, g, b);
  71632. };
  71633. /**
  71634. * Compute the Color3 hexadecimal code as a string
  71635. * @returns a string containing the hexadecimal representation of the Color3 object
  71636. */
  71637. Color3.prototype.toHexString = function () {
  71638. var intR = (this.r * 255) | 0;
  71639. var intG = (this.g * 255) | 0;
  71640. var intB = (this.b * 255) | 0;
  71641. 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);
  71642. };
  71643. /**
  71644. * Computes a new Color3 converted from the current one to linear space
  71645. * @returns a new Color3 object
  71646. */
  71647. Color3.prototype.toLinearSpace = function () {
  71648. var convertedColor = new Color3();
  71649. this.toLinearSpaceToRef(convertedColor);
  71650. return convertedColor;
  71651. };
  71652. /**
  71653. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  71654. * @param convertedColor defines the Color3 object where to store the linear space version
  71655. * @returns the unmodified Color3
  71656. */
  71657. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  71658. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  71659. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  71660. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  71661. return this;
  71662. };
  71663. /**
  71664. * Computes a new Color3 converted from the current one to gamma space
  71665. * @returns a new Color3 object
  71666. */
  71667. Color3.prototype.toGammaSpace = function () {
  71668. var convertedColor = new Color3();
  71669. this.toGammaSpaceToRef(convertedColor);
  71670. return convertedColor;
  71671. };
  71672. /**
  71673. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  71674. * @param convertedColor defines the Color3 object where to store the gamma space version
  71675. * @returns the unmodified Color3
  71676. */
  71677. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  71678. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  71679. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  71680. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  71681. return this;
  71682. };
  71683. /**
  71684. * Creates a new Color3 from the string containing valid hexadecimal values
  71685. * @param hex defines a string containing valid hexadecimal values
  71686. * @returns a new Color3 object
  71687. */
  71688. Color3.FromHexString = function (hex) {
  71689. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  71690. return new Color3(0, 0, 0);
  71691. }
  71692. var r = parseInt(hex.substring(1, 3), 16);
  71693. var g = parseInt(hex.substring(3, 5), 16);
  71694. var b = parseInt(hex.substring(5, 7), 16);
  71695. return Color3.FromInts(r, g, b);
  71696. };
  71697. /**
  71698. * Creates a new Color3 from the starting index of the given array
  71699. * @param array defines the source array
  71700. * @param offset defines an offset in the source array
  71701. * @returns a new Color3 object
  71702. */
  71703. Color3.FromArray = function (array, offset) {
  71704. if (offset === void 0) { offset = 0; }
  71705. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  71706. };
  71707. /**
  71708. * Creates a new Color3 from integer values (< 256)
  71709. * @param r defines the red component to read from (value between 0 and 255)
  71710. * @param g defines the green component to read from (value between 0 and 255)
  71711. * @param b defines the blue component to read from (value between 0 and 255)
  71712. * @returns a new Color3 object
  71713. */
  71714. Color3.FromInts = function (r, g, b) {
  71715. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  71716. };
  71717. /**
  71718. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  71719. * @param start defines the start Color3 value
  71720. * @param end defines the end Color3 value
  71721. * @param amount defines the gradient value between start and end
  71722. * @returns a new Color3 object
  71723. */
  71724. Color3.Lerp = function (start, end, amount) {
  71725. var result = new Color3(0.0, 0.0, 0.0);
  71726. Color3.LerpToRef(start, end, amount, result);
  71727. return result;
  71728. };
  71729. /**
  71730. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  71731. * @param left defines the start value
  71732. * @param right defines the end value
  71733. * @param amount defines the gradient factor
  71734. * @param result defines the Color3 object where to store the result
  71735. */
  71736. Color3.LerpToRef = function (left, right, amount, result) {
  71737. result.r = left.r + ((right.r - left.r) * amount);
  71738. result.g = left.g + ((right.g - left.g) * amount);
  71739. result.b = left.b + ((right.b - left.b) * amount);
  71740. };
  71741. /**
  71742. * Returns a Color3 value containing a red color
  71743. * @returns a new Color3 object
  71744. */
  71745. Color3.Red = function () { return new Color3(1, 0, 0); };
  71746. /**
  71747. * Returns a Color3 value containing a green color
  71748. * @returns a new Color3 object
  71749. */
  71750. Color3.Green = function () { return new Color3(0, 1, 0); };
  71751. /**
  71752. * Returns a Color3 value containing a blue color
  71753. * @returns a new Color3 object
  71754. */
  71755. Color3.Blue = function () { return new Color3(0, 0, 1); };
  71756. /**
  71757. * Returns a Color3 value containing a black color
  71758. * @returns a new Color3 object
  71759. */
  71760. Color3.Black = function () { return new Color3(0, 0, 0); };
  71761. Object.defineProperty(Color3, "BlackReadOnly", {
  71762. /**
  71763. * Gets a Color3 value containing a black color that must not be updated
  71764. */
  71765. get: function () {
  71766. return Color3._BlackReadOnly;
  71767. },
  71768. enumerable: true,
  71769. configurable: true
  71770. });
  71771. /**
  71772. * Returns a Color3 value containing a white color
  71773. * @returns a new Color3 object
  71774. */
  71775. Color3.White = function () { return new Color3(1, 1, 1); };
  71776. /**
  71777. * Returns a Color3 value containing a purple color
  71778. * @returns a new Color3 object
  71779. */
  71780. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  71781. /**
  71782. * Returns a Color3 value containing a magenta color
  71783. * @returns a new Color3 object
  71784. */
  71785. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  71786. /**
  71787. * Returns a Color3 value containing a yellow color
  71788. * @returns a new Color3 object
  71789. */
  71790. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  71791. /**
  71792. * Returns a Color3 value containing a gray color
  71793. * @returns a new Color3 object
  71794. */
  71795. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  71796. /**
  71797. * Returns a Color3 value containing a teal color
  71798. * @returns a new Color3 object
  71799. */
  71800. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  71801. /**
  71802. * Returns a Color3 value containing a random color
  71803. * @returns a new Color3 object
  71804. */
  71805. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  71806. // Statics
  71807. Color3._BlackReadOnly = Color3.Black();
  71808. return Color3;
  71809. }());
  71810. /**
  71811. * Class used to hold a RBGA color
  71812. */
  71813. var Color4 = /** @class */ (function () {
  71814. /**
  71815. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  71816. * @param r defines the red component (between 0 and 1, default is 0)
  71817. * @param g defines the green component (between 0 and 1, default is 0)
  71818. * @param b defines the blue component (between 0 and 1, default is 0)
  71819. * @param a defines the alpha component (between 0 and 1, default is 1)
  71820. */
  71821. function Color4(
  71822. /**
  71823. * Defines the red component (between 0 and 1, default is 0)
  71824. */
  71825. r,
  71826. /**
  71827. * Defines the green component (between 0 and 1, default is 0)
  71828. */
  71829. g,
  71830. /**
  71831. * Defines the blue component (between 0 and 1, default is 0)
  71832. */
  71833. b,
  71834. /**
  71835. * Defines the alpha component (between 0 and 1, default is 1)
  71836. */
  71837. a) {
  71838. if (r === void 0) { r = 0; }
  71839. if (g === void 0) { g = 0; }
  71840. if (b === void 0) { b = 0; }
  71841. if (a === void 0) { a = 1; }
  71842. this.r = r;
  71843. this.g = g;
  71844. this.b = b;
  71845. this.a = a;
  71846. }
  71847. // Operators
  71848. /**
  71849. * Adds in place the given Color4 values to the current Color4 object
  71850. * @param right defines the second operand
  71851. * @returns the current updated Color4 object
  71852. */
  71853. Color4.prototype.addInPlace = function (right) {
  71854. this.r += right.r;
  71855. this.g += right.g;
  71856. this.b += right.b;
  71857. this.a += right.a;
  71858. return this;
  71859. };
  71860. /**
  71861. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  71862. * @returns the new array
  71863. */
  71864. Color4.prototype.asArray = function () {
  71865. var result = new Array();
  71866. this.toArray(result, 0);
  71867. return result;
  71868. };
  71869. /**
  71870. * Stores from the starting index in the given array the Color4 successive values
  71871. * @param array defines the array where to store the r,g,b components
  71872. * @param index defines an optional index in the target array to define where to start storing values
  71873. * @returns the current Color4 object
  71874. */
  71875. Color4.prototype.toArray = function (array, index) {
  71876. if (index === void 0) { index = 0; }
  71877. array[index] = this.r;
  71878. array[index + 1] = this.g;
  71879. array[index + 2] = this.b;
  71880. array[index + 3] = this.a;
  71881. return this;
  71882. };
  71883. /**
  71884. * Determines equality between Color4 objects
  71885. * @param otherColor defines the second operand
  71886. * @returns true if the rgba values are equal to the given ones
  71887. */
  71888. Color4.prototype.equals = function (otherColor) {
  71889. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  71890. };
  71891. /**
  71892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  71893. * @param right defines the second operand
  71894. * @returns a new Color4 object
  71895. */
  71896. Color4.prototype.add = function (right) {
  71897. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  71898. };
  71899. /**
  71900. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  71901. * @param right defines the second operand
  71902. * @returns a new Color4 object
  71903. */
  71904. Color4.prototype.subtract = function (right) {
  71905. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  71906. };
  71907. /**
  71908. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  71909. * @param right defines the second operand
  71910. * @param result defines the Color4 object where to store the result
  71911. * @returns the current Color4 object
  71912. */
  71913. Color4.prototype.subtractToRef = function (right, result) {
  71914. result.r = this.r - right.r;
  71915. result.g = this.g - right.g;
  71916. result.b = this.b - right.b;
  71917. result.a = this.a - right.a;
  71918. return this;
  71919. };
  71920. /**
  71921. * Creates a new Color4 with the current Color4 values multiplied by scale
  71922. * @param scale defines the scaling factor to apply
  71923. * @returns a new Color4 object
  71924. */
  71925. Color4.prototype.scale = function (scale) {
  71926. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  71927. };
  71928. /**
  71929. * Multiplies the current Color4 values by scale and stores the result in "result"
  71930. * @param scale defines the scaling factor to apply
  71931. * @param result defines the Color4 object where to store the result
  71932. * @returns the current unmodified Color4
  71933. */
  71934. Color4.prototype.scaleToRef = function (scale, result) {
  71935. result.r = this.r * scale;
  71936. result.g = this.g * scale;
  71937. result.b = this.b * scale;
  71938. result.a = this.a * scale;
  71939. return this;
  71940. };
  71941. /**
  71942. * Scale the current Color4 values by a factor and add the result to a given Color4
  71943. * @param scale defines the scale factor
  71944. * @param result defines the Color4 object where to store the result
  71945. * @returns the unmodified current Color4
  71946. */
  71947. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  71948. result.r += this.r * scale;
  71949. result.g += this.g * scale;
  71950. result.b += this.b * scale;
  71951. result.a += this.a * scale;
  71952. return this;
  71953. };
  71954. /**
  71955. * Clamps the rgb values by the min and max values and stores the result into "result"
  71956. * @param min defines minimum clamping value (default is 0)
  71957. * @param max defines maximum clamping value (default is 1)
  71958. * @param result defines color to store the result into.
  71959. * @returns the cuurent Color4
  71960. */
  71961. Color4.prototype.clampToRef = function (min, max, result) {
  71962. if (min === void 0) { min = 0; }
  71963. if (max === void 0) { max = 1; }
  71964. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  71965. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  71966. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  71967. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  71968. return this;
  71969. };
  71970. /**
  71971. * Multipy an Color4 value by another and return a new Color4 object
  71972. * @param color defines the Color4 value to multiply by
  71973. * @returns a new Color4 object
  71974. */
  71975. Color4.prototype.multiply = function (color) {
  71976. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  71977. };
  71978. /**
  71979. * Multipy a Color4 value by another and push the result in a reference value
  71980. * @param color defines the Color4 value to multiply by
  71981. * @param result defines the Color4 to fill the result in
  71982. * @returns the result Color4
  71983. */
  71984. Color4.prototype.multiplyToRef = function (color, result) {
  71985. result.r = this.r * color.r;
  71986. result.g = this.g * color.g;
  71987. result.b = this.b * color.b;
  71988. result.a = this.a * color.a;
  71989. return result;
  71990. };
  71991. /**
  71992. * Creates a string with the Color4 current values
  71993. * @returns the string representation of the Color4 object
  71994. */
  71995. Color4.prototype.toString = function () {
  71996. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  71997. };
  71998. /**
  71999. * Returns the string "Color4"
  72000. * @returns "Color4"
  72001. */
  72002. Color4.prototype.getClassName = function () {
  72003. return "Color4";
  72004. };
  72005. /**
  72006. * Compute the Color4 hash code
  72007. * @returns an unique number that can be used to hash Color4 objects
  72008. */
  72009. Color4.prototype.getHashCode = function () {
  72010. var hash = this.r || 0;
  72011. hash = (hash * 397) ^ (this.g || 0);
  72012. hash = (hash * 397) ^ (this.b || 0);
  72013. hash = (hash * 397) ^ (this.a || 0);
  72014. return hash;
  72015. };
  72016. /**
  72017. * Creates a new Color4 copied from the current one
  72018. * @returns a new Color4 object
  72019. */
  72020. Color4.prototype.clone = function () {
  72021. return new Color4(this.r, this.g, this.b, this.a);
  72022. };
  72023. /**
  72024. * Copies the given Color4 values into the current one
  72025. * @param source defines the source Color4 object
  72026. * @returns the current updated Color4 object
  72027. */
  72028. Color4.prototype.copyFrom = function (source) {
  72029. this.r = source.r;
  72030. this.g = source.g;
  72031. this.b = source.b;
  72032. this.a = source.a;
  72033. return this;
  72034. };
  72035. /**
  72036. * Copies the given float values into the current one
  72037. * @param r defines the red component to read from
  72038. * @param g defines the green component to read from
  72039. * @param b defines the blue component to read from
  72040. * @param a defines the alpha component to read from
  72041. * @returns the current updated Color4 object
  72042. */
  72043. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  72044. this.r = r;
  72045. this.g = g;
  72046. this.b = b;
  72047. this.a = a;
  72048. return this;
  72049. };
  72050. /**
  72051. * Copies the given float values into the current one
  72052. * @param r defines the red component to read from
  72053. * @param g defines the green component to read from
  72054. * @param b defines the blue component to read from
  72055. * @param a defines the alpha component to read from
  72056. * @returns the current updated Color4 object
  72057. */
  72058. Color4.prototype.set = function (r, g, b, a) {
  72059. return this.copyFromFloats(r, g, b, a);
  72060. };
  72061. /**
  72062. * Compute the Color4 hexadecimal code as a string
  72063. * @returns a string containing the hexadecimal representation of the Color4 object
  72064. */
  72065. Color4.prototype.toHexString = function () {
  72066. var intR = (this.r * 255) | 0;
  72067. var intG = (this.g * 255) | 0;
  72068. var intB = (this.b * 255) | 0;
  72069. var intA = (this.a * 255) | 0;
  72070. 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);
  72071. };
  72072. /**
  72073. * Computes a new Color4 converted from the current one to linear space
  72074. * @returns a new Color4 object
  72075. */
  72076. Color4.prototype.toLinearSpace = function () {
  72077. var convertedColor = new Color4();
  72078. this.toLinearSpaceToRef(convertedColor);
  72079. return convertedColor;
  72080. };
  72081. /**
  72082. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72083. * @param convertedColor defines the Color4 object where to store the linear space version
  72084. * @returns the unmodified Color4
  72085. */
  72086. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  72087. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  72088. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  72089. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  72090. convertedColor.a = this.a;
  72091. return this;
  72092. };
  72093. /**
  72094. * Computes a new Color4 converted from the current one to gamma space
  72095. * @returns a new Color4 object
  72096. */
  72097. Color4.prototype.toGammaSpace = function () {
  72098. var convertedColor = new Color4();
  72099. this.toGammaSpaceToRef(convertedColor);
  72100. return convertedColor;
  72101. };
  72102. /**
  72103. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72104. * @param convertedColor defines the Color4 object where to store the gamma space version
  72105. * @returns the unmodified Color4
  72106. */
  72107. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  72108. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  72109. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  72110. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  72111. convertedColor.a = this.a;
  72112. return this;
  72113. };
  72114. // Statics
  72115. /**
  72116. * Creates a new Color4 from the string containing valid hexadecimal values
  72117. * @param hex defines a string containing valid hexadecimal values
  72118. * @returns a new Color4 object
  72119. */
  72120. Color4.FromHexString = function (hex) {
  72121. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  72122. return new Color4(0.0, 0.0, 0.0, 0.0);
  72123. }
  72124. var r = parseInt(hex.substring(1, 3), 16);
  72125. var g = parseInt(hex.substring(3, 5), 16);
  72126. var b = parseInt(hex.substring(5, 7), 16);
  72127. var a = parseInt(hex.substring(7, 9), 16);
  72128. return Color4.FromInts(r, g, b, a);
  72129. };
  72130. /**
  72131. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72132. * @param left defines the start value
  72133. * @param right defines the end value
  72134. * @param amount defines the gradient factor
  72135. * @returns a new Color4 object
  72136. */
  72137. Color4.Lerp = function (left, right, amount) {
  72138. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  72139. Color4.LerpToRef(left, right, amount, result);
  72140. return result;
  72141. };
  72142. /**
  72143. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72144. * @param left defines the start value
  72145. * @param right defines the end value
  72146. * @param amount defines the gradient factor
  72147. * @param result defines the Color4 object where to store data
  72148. */
  72149. Color4.LerpToRef = function (left, right, amount, result) {
  72150. result.r = left.r + (right.r - left.r) * amount;
  72151. result.g = left.g + (right.g - left.g) * amount;
  72152. result.b = left.b + (right.b - left.b) * amount;
  72153. result.a = left.a + (right.a - left.a) * amount;
  72154. };
  72155. /**
  72156. * Creates a new Color4 from a Color3 and an alpha value
  72157. * @param color3 defines the source Color3 to read from
  72158. * @param alpha defines the alpha component (1.0 by default)
  72159. * @returns a new Color4 object
  72160. */
  72161. Color4.FromColor3 = function (color3, alpha) {
  72162. if (alpha === void 0) { alpha = 1.0; }
  72163. return new Color4(color3.r, color3.g, color3.b, alpha);
  72164. };
  72165. /**
  72166. * Creates a new Color4 from the starting index element of the given array
  72167. * @param array defines the source array to read from
  72168. * @param offset defines the offset in the source array
  72169. * @returns a new Color4 object
  72170. */
  72171. Color4.FromArray = function (array, offset) {
  72172. if (offset === void 0) { offset = 0; }
  72173. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  72174. };
  72175. /**
  72176. * Creates a new Color3 from integer values (< 256)
  72177. * @param r defines the red component to read from (value between 0 and 255)
  72178. * @param g defines the green component to read from (value between 0 and 255)
  72179. * @param b defines the blue component to read from (value between 0 and 255)
  72180. * @param a defines the alpha component to read from (value between 0 and 255)
  72181. * @returns a new Color3 object
  72182. */
  72183. Color4.FromInts = function (r, g, b, a) {
  72184. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  72185. };
  72186. /**
  72187. * Check the content of a given array and convert it to an array containing RGBA data
  72188. * If the original array was already containing count * 4 values then it is returned directly
  72189. * @param colors defines the array to check
  72190. * @param count defines the number of RGBA data to expect
  72191. * @returns an array containing count * 4 values (RGBA)
  72192. */
  72193. Color4.CheckColors4 = function (colors, count) {
  72194. // Check if color3 was used
  72195. if (colors.length === count * 3) {
  72196. var colors4 = [];
  72197. for (var index = 0; index < colors.length; index += 3) {
  72198. var newIndex = (index / 3) * 4;
  72199. colors4[newIndex] = colors[index];
  72200. colors4[newIndex + 1] = colors[index + 1];
  72201. colors4[newIndex + 2] = colors[index + 2];
  72202. colors4[newIndex + 3] = 1.0;
  72203. }
  72204. return colors4;
  72205. }
  72206. return colors;
  72207. };
  72208. return Color4;
  72209. }());
  72210. /**
  72211. * Class representing a vector containing 2 coordinates
  72212. */
  72213. var Vector2 = /** @class */ (function () {
  72214. /**
  72215. * Creates a new Vector2 from the given x and y coordinates
  72216. * @param x defines the first coordinate
  72217. * @param y defines the second coordinate
  72218. */
  72219. function Vector2(
  72220. /** defines the first coordinate */
  72221. x,
  72222. /** defines the second coordinate */
  72223. y) {
  72224. if (x === void 0) { x = 0; }
  72225. if (y === void 0) { y = 0; }
  72226. this.x = x;
  72227. this.y = y;
  72228. }
  72229. /**
  72230. * Gets a string with the Vector2 coordinates
  72231. * @returns a string with the Vector2 coordinates
  72232. */
  72233. Vector2.prototype.toString = function () {
  72234. return "{X: " + this.x + " Y:" + this.y + "}";
  72235. };
  72236. /**
  72237. * Gets class name
  72238. * @returns the string "Vector2"
  72239. */
  72240. Vector2.prototype.getClassName = function () {
  72241. return "Vector2";
  72242. };
  72243. /**
  72244. * Gets current vector hash code
  72245. * @returns the Vector2 hash code as a number
  72246. */
  72247. Vector2.prototype.getHashCode = function () {
  72248. var hash = this.x || 0;
  72249. hash = (hash * 397) ^ (this.y || 0);
  72250. return hash;
  72251. };
  72252. // Operators
  72253. /**
  72254. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  72255. * @param array defines the source array
  72256. * @param index defines the offset in source array
  72257. * @returns the current Vector2
  72258. */
  72259. Vector2.prototype.toArray = function (array, index) {
  72260. if (index === void 0) { index = 0; }
  72261. array[index] = this.x;
  72262. array[index + 1] = this.y;
  72263. return this;
  72264. };
  72265. /**
  72266. * Copy the current vector to an array
  72267. * @returns a new array with 2 elements: the Vector2 coordinates.
  72268. */
  72269. Vector2.prototype.asArray = function () {
  72270. var result = new Array();
  72271. this.toArray(result, 0);
  72272. return result;
  72273. };
  72274. /**
  72275. * Sets the Vector2 coordinates with the given Vector2 coordinates
  72276. * @param source defines the source Vector2
  72277. * @returns the current updated Vector2
  72278. */
  72279. Vector2.prototype.copyFrom = function (source) {
  72280. this.x = source.x;
  72281. this.y = source.y;
  72282. return this;
  72283. };
  72284. /**
  72285. * Sets the Vector2 coordinates with the given floats
  72286. * @param x defines the first coordinate
  72287. * @param y defines the second coordinate
  72288. * @returns the current updated Vector2
  72289. */
  72290. Vector2.prototype.copyFromFloats = function (x, y) {
  72291. this.x = x;
  72292. this.y = y;
  72293. return this;
  72294. };
  72295. /**
  72296. * Sets the Vector2 coordinates with the given floats
  72297. * @param x defines the first coordinate
  72298. * @param y defines the second coordinate
  72299. * @returns the current updated Vector2
  72300. */
  72301. Vector2.prototype.set = function (x, y) {
  72302. return this.copyFromFloats(x, y);
  72303. };
  72304. /**
  72305. * Add another vector with the current one
  72306. * @param otherVector defines the other vector
  72307. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72308. */
  72309. Vector2.prototype.add = function (otherVector) {
  72310. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  72311. };
  72312. /**
  72313. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72314. * @param otherVector defines the other vector
  72315. * @param result defines the target vector
  72316. * @returns the unmodified current Vector2
  72317. */
  72318. Vector2.prototype.addToRef = function (otherVector, result) {
  72319. result.x = this.x + otherVector.x;
  72320. result.y = this.y + otherVector.y;
  72321. return this;
  72322. };
  72323. /**
  72324. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72325. * @param otherVector defines the other vector
  72326. * @returns the current updated Vector2
  72327. */
  72328. Vector2.prototype.addInPlace = function (otherVector) {
  72329. this.x += otherVector.x;
  72330. this.y += otherVector.y;
  72331. return this;
  72332. };
  72333. /**
  72334. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72335. * @param otherVector defines the other vector
  72336. * @returns a new Vector2
  72337. */
  72338. Vector2.prototype.addVector3 = function (otherVector) {
  72339. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  72340. };
  72341. /**
  72342. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72343. * @param otherVector defines the other vector
  72344. * @returns a new Vector2
  72345. */
  72346. Vector2.prototype.subtract = function (otherVector) {
  72347. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  72348. };
  72349. /**
  72350. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72351. * @param otherVector defines the other vector
  72352. * @param result defines the target vector
  72353. * @returns the unmodified current Vector2
  72354. */
  72355. Vector2.prototype.subtractToRef = function (otherVector, result) {
  72356. result.x = this.x - otherVector.x;
  72357. result.y = this.y - otherVector.y;
  72358. return this;
  72359. };
  72360. /**
  72361. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72362. * @param otherVector defines the other vector
  72363. * @returns the current updated Vector2
  72364. */
  72365. Vector2.prototype.subtractInPlace = function (otherVector) {
  72366. this.x -= otherVector.x;
  72367. this.y -= otherVector.y;
  72368. return this;
  72369. };
  72370. /**
  72371. * Multiplies in place the current Vector2 coordinates by the given ones
  72372. * @param otherVector defines the other vector
  72373. * @returns the current updated Vector2
  72374. */
  72375. Vector2.prototype.multiplyInPlace = function (otherVector) {
  72376. this.x *= otherVector.x;
  72377. this.y *= otherVector.y;
  72378. return this;
  72379. };
  72380. /**
  72381. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72382. * @param otherVector defines the other vector
  72383. * @returns a new Vector2
  72384. */
  72385. Vector2.prototype.multiply = function (otherVector) {
  72386. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  72387. };
  72388. /**
  72389. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72390. * @param otherVector defines the other vector
  72391. * @param result defines the target vector
  72392. * @returns the unmodified current Vector2
  72393. */
  72394. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  72395. result.x = this.x * otherVector.x;
  72396. result.y = this.y * otherVector.y;
  72397. return this;
  72398. };
  72399. /**
  72400. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72401. * @param x defines the first coordinate
  72402. * @param y defines the second coordinate
  72403. * @returns a new Vector2
  72404. */
  72405. Vector2.prototype.multiplyByFloats = function (x, y) {
  72406. return new Vector2(this.x * x, this.y * y);
  72407. };
  72408. /**
  72409. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72410. * @param otherVector defines the other vector
  72411. * @returns a new Vector2
  72412. */
  72413. Vector2.prototype.divide = function (otherVector) {
  72414. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  72415. };
  72416. /**
  72417. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72418. * @param otherVector defines the other vector
  72419. * @param result defines the target vector
  72420. * @returns the unmodified current Vector2
  72421. */
  72422. Vector2.prototype.divideToRef = function (otherVector, result) {
  72423. result.x = this.x / otherVector.x;
  72424. result.y = this.y / otherVector.y;
  72425. return this;
  72426. };
  72427. /**
  72428. * Divides the current Vector2 coordinates by the given ones
  72429. * @param otherVector defines the other vector
  72430. * @returns the current updated Vector2
  72431. */
  72432. Vector2.prototype.divideInPlace = function (otherVector) {
  72433. return this.divideToRef(otherVector, this);
  72434. };
  72435. /**
  72436. * Gets a new Vector2 with current Vector2 negated coordinates
  72437. * @returns a new Vector2
  72438. */
  72439. Vector2.prototype.negate = function () {
  72440. return new Vector2(-this.x, -this.y);
  72441. };
  72442. /**
  72443. * Multiply the Vector2 coordinates by scale
  72444. * @param scale defines the scaling factor
  72445. * @returns the current updated Vector2
  72446. */
  72447. Vector2.prototype.scaleInPlace = function (scale) {
  72448. this.x *= scale;
  72449. this.y *= scale;
  72450. return this;
  72451. };
  72452. /**
  72453. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72454. * @param scale defines the scaling factor
  72455. * @returns a new Vector2
  72456. */
  72457. Vector2.prototype.scale = function (scale) {
  72458. var result = new Vector2(0, 0);
  72459. this.scaleToRef(scale, result);
  72460. return result;
  72461. };
  72462. /**
  72463. * Scale the current Vector2 values by a factor to a given Vector2
  72464. * @param scale defines the scale factor
  72465. * @param result defines the Vector2 object where to store the result
  72466. * @returns the unmodified current Vector2
  72467. */
  72468. Vector2.prototype.scaleToRef = function (scale, result) {
  72469. result.x = this.x * scale;
  72470. result.y = this.y * scale;
  72471. return this;
  72472. };
  72473. /**
  72474. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72475. * @param scale defines the scale factor
  72476. * @param result defines the Vector2 object where to store the result
  72477. * @returns the unmodified current Vector2
  72478. */
  72479. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  72480. result.x += this.x * scale;
  72481. result.y += this.y * scale;
  72482. return this;
  72483. };
  72484. /**
  72485. * Gets a boolean if two vectors are equals
  72486. * @param otherVector defines the other vector
  72487. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72488. */
  72489. Vector2.prototype.equals = function (otherVector) {
  72490. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  72491. };
  72492. /**
  72493. * Gets a boolean if two vectors are equals (using an epsilon value)
  72494. * @param otherVector defines the other vector
  72495. * @param epsilon defines the minimal distance to consider equality
  72496. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72497. */
  72498. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  72499. if (epsilon === void 0) { epsilon = Epsilon; }
  72500. 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);
  72501. };
  72502. /**
  72503. * Gets a new Vector2 from current Vector2 floored values
  72504. * @returns a new Vector2
  72505. */
  72506. Vector2.prototype.floor = function () {
  72507. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  72508. };
  72509. /**
  72510. * Gets a new Vector2 from current Vector2 floored values
  72511. * @returns a new Vector2
  72512. */
  72513. Vector2.prototype.fract = function () {
  72514. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  72515. };
  72516. // Properties
  72517. /**
  72518. * Gets the length of the vector
  72519. * @returns the vector length (float)
  72520. */
  72521. Vector2.prototype.length = function () {
  72522. return Math.sqrt(this.x * this.x + this.y * this.y);
  72523. };
  72524. /**
  72525. * Gets the vector squared length
  72526. * @returns the vector squared length (float)
  72527. */
  72528. Vector2.prototype.lengthSquared = function () {
  72529. return (this.x * this.x + this.y * this.y);
  72530. };
  72531. // Methods
  72532. /**
  72533. * Normalize the vector
  72534. * @returns the current updated Vector2
  72535. */
  72536. Vector2.prototype.normalize = function () {
  72537. var len = this.length();
  72538. if (len === 0) {
  72539. return this;
  72540. }
  72541. var num = 1.0 / len;
  72542. this.x *= num;
  72543. this.y *= num;
  72544. return this;
  72545. };
  72546. /**
  72547. * Gets a new Vector2 copied from the Vector2
  72548. * @returns a new Vector2
  72549. */
  72550. Vector2.prototype.clone = function () {
  72551. return new Vector2(this.x, this.y);
  72552. };
  72553. // Statics
  72554. /**
  72555. * Gets a new Vector2(0, 0)
  72556. * @returns a new Vector2
  72557. */
  72558. Vector2.Zero = function () {
  72559. return new Vector2(0, 0);
  72560. };
  72561. /**
  72562. * Gets a new Vector2(1, 1)
  72563. * @returns a new Vector2
  72564. */
  72565. Vector2.One = function () {
  72566. return new Vector2(1, 1);
  72567. };
  72568. /**
  72569. * Gets a new Vector2 set from the given index element of the given array
  72570. * @param array defines the data source
  72571. * @param offset defines the offset in the data source
  72572. * @returns a new Vector2
  72573. */
  72574. Vector2.FromArray = function (array, offset) {
  72575. if (offset === void 0) { offset = 0; }
  72576. return new Vector2(array[offset], array[offset + 1]);
  72577. };
  72578. /**
  72579. * Sets "result" from the given index element of the given array
  72580. * @param array defines the data source
  72581. * @param offset defines the offset in the data source
  72582. * @param result defines the target vector
  72583. */
  72584. Vector2.FromArrayToRef = function (array, offset, result) {
  72585. result.x = array[offset];
  72586. result.y = array[offset + 1];
  72587. };
  72588. /**
  72589. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72590. * @param value1 defines 1st point of control
  72591. * @param value2 defines 2nd point of control
  72592. * @param value3 defines 3rd point of control
  72593. * @param value4 defines 4th point of control
  72594. * @param amount defines the interpolation factor
  72595. * @returns a new Vector2
  72596. */
  72597. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  72598. var squared = amount * amount;
  72599. var cubed = amount * squared;
  72600. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  72601. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  72602. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  72603. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  72604. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  72605. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  72606. return new Vector2(x, y);
  72607. };
  72608. /**
  72609. * 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".
  72610. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72611. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72612. * @param value defines the value to clamp
  72613. * @param min defines the lower limit
  72614. * @param max defines the upper limit
  72615. * @returns a new Vector2
  72616. */
  72617. Vector2.Clamp = function (value, min, max) {
  72618. var x = value.x;
  72619. x = (x > max.x) ? max.x : x;
  72620. x = (x < min.x) ? min.x : x;
  72621. var y = value.y;
  72622. y = (y > max.y) ? max.y : y;
  72623. y = (y < min.y) ? min.y : y;
  72624. return new Vector2(x, y);
  72625. };
  72626. /**
  72627. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72628. * @param value1 defines the 1st control point
  72629. * @param tangent1 defines the outgoing tangent
  72630. * @param value2 defines the 2nd control point
  72631. * @param tangent2 defines the incoming tangent
  72632. * @param amount defines the interpolation factor
  72633. * @returns a new Vector2
  72634. */
  72635. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  72636. var squared = amount * amount;
  72637. var cubed = amount * squared;
  72638. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  72639. var part2 = (-2.0 * cubed) + (3.0 * squared);
  72640. var part3 = (cubed - (2.0 * squared)) + amount;
  72641. var part4 = cubed - squared;
  72642. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  72643. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  72644. return new Vector2(x, y);
  72645. };
  72646. /**
  72647. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72648. * @param start defines the start vector
  72649. * @param end defines the end vector
  72650. * @param amount defines the interpolation factor
  72651. * @returns a new Vector2
  72652. */
  72653. Vector2.Lerp = function (start, end, amount) {
  72654. var x = start.x + ((end.x - start.x) * amount);
  72655. var y = start.y + ((end.y - start.y) * amount);
  72656. return new Vector2(x, y);
  72657. };
  72658. /**
  72659. * Gets the dot product of the vector "left" and the vector "right"
  72660. * @param left defines first vector
  72661. * @param right defines second vector
  72662. * @returns the dot product (float)
  72663. */
  72664. Vector2.Dot = function (left, right) {
  72665. return left.x * right.x + left.y * right.y;
  72666. };
  72667. /**
  72668. * Returns a new Vector2 equal to the normalized given vector
  72669. * @param vector defines the vector to normalize
  72670. * @returns a new Vector2
  72671. */
  72672. Vector2.Normalize = function (vector) {
  72673. var newVector = vector.clone();
  72674. newVector.normalize();
  72675. return newVector;
  72676. };
  72677. /**
  72678. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72679. * @param left defines 1st vector
  72680. * @param right defines 2nd vector
  72681. * @returns a new Vector2
  72682. */
  72683. Vector2.Minimize = function (left, right) {
  72684. var x = (left.x < right.x) ? left.x : right.x;
  72685. var y = (left.y < right.y) ? left.y : right.y;
  72686. return new Vector2(x, y);
  72687. };
  72688. /**
  72689. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72690. * @param left defines 1st vector
  72691. * @param right defines 2nd vector
  72692. * @returns a new Vector2
  72693. */
  72694. Vector2.Maximize = function (left, right) {
  72695. var x = (left.x > right.x) ? left.x : right.x;
  72696. var y = (left.y > right.y) ? left.y : right.y;
  72697. return new Vector2(x, y);
  72698. };
  72699. /**
  72700. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72701. * @param vector defines the vector to transform
  72702. * @param transformation defines the matrix to apply
  72703. * @returns a new Vector2
  72704. */
  72705. Vector2.Transform = function (vector, transformation) {
  72706. var r = Vector2.Zero();
  72707. Vector2.TransformToRef(vector, transformation, r);
  72708. return r;
  72709. };
  72710. /**
  72711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72712. * @param vector defines the vector to transform
  72713. * @param transformation defines the matrix to apply
  72714. * @param result defines the target vector
  72715. */
  72716. Vector2.TransformToRef = function (vector, transformation, result) {
  72717. var m = transformation.m;
  72718. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  72719. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  72720. result.x = x;
  72721. result.y = y;
  72722. };
  72723. /**
  72724. * Determines if a given vector is included in a triangle
  72725. * @param p defines the vector to test
  72726. * @param p0 defines 1st triangle point
  72727. * @param p1 defines 2nd triangle point
  72728. * @param p2 defines 3rd triangle point
  72729. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72730. */
  72731. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  72732. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  72733. var sign = a < 0 ? -1 : 1;
  72734. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  72735. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  72736. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  72737. };
  72738. /**
  72739. * Gets the distance between the vectors "value1" and "value2"
  72740. * @param value1 defines first vector
  72741. * @param value2 defines second vector
  72742. * @returns the distance between vectors
  72743. */
  72744. Vector2.Distance = function (value1, value2) {
  72745. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  72746. };
  72747. /**
  72748. * Returns the squared distance between the vectors "value1" and "value2"
  72749. * @param value1 defines first vector
  72750. * @param value2 defines second vector
  72751. * @returns the squared distance between vectors
  72752. */
  72753. Vector2.DistanceSquared = function (value1, value2) {
  72754. var x = value1.x - value2.x;
  72755. var y = value1.y - value2.y;
  72756. return (x * x) + (y * y);
  72757. };
  72758. /**
  72759. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72760. * @param value1 defines first vector
  72761. * @param value2 defines second vector
  72762. * @returns a new Vector2
  72763. */
  72764. Vector2.Center = function (value1, value2) {
  72765. var center = value1.add(value2);
  72766. center.scaleInPlace(0.5);
  72767. return center;
  72768. };
  72769. /**
  72770. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72771. * @param p defines the middle point
  72772. * @param segA defines one point of the segment
  72773. * @param segB defines the other point of the segment
  72774. * @returns the shortest distance
  72775. */
  72776. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  72777. var l2 = Vector2.DistanceSquared(segA, segB);
  72778. if (l2 === 0.0) {
  72779. return Vector2.Distance(p, segA);
  72780. }
  72781. var v = segB.subtract(segA);
  72782. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  72783. var proj = segA.add(v.multiplyByFloats(t, t));
  72784. return Vector2.Distance(p, proj);
  72785. };
  72786. return Vector2;
  72787. }());
  72788. /**
  72789. * Classed used to store (x,y,z) vector representation
  72790. * A Vector3 is the main object used in 3D geometry
  72791. * It can represent etiher the coordinates of a point the space, either a direction
  72792. * Reminder: js uses a left handed forward facing system
  72793. */
  72794. var Vector3 = /** @class */ (function () {
  72795. /**
  72796. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72797. * @param x defines the first coordinates (on X axis)
  72798. * @param y defines the second coordinates (on Y axis)
  72799. * @param z defines the third coordinates (on Z axis)
  72800. */
  72801. function Vector3(
  72802. /**
  72803. * Defines the first coordinates (on X axis)
  72804. */
  72805. x,
  72806. /**
  72807. * Defines the second coordinates (on Y axis)
  72808. */
  72809. y,
  72810. /**
  72811. * Defines the third coordinates (on Z axis)
  72812. */
  72813. z) {
  72814. if (x === void 0) { x = 0; }
  72815. if (y === void 0) { y = 0; }
  72816. if (z === void 0) { z = 0; }
  72817. this.x = x;
  72818. this.y = y;
  72819. this.z = z;
  72820. }
  72821. /**
  72822. * Creates a string representation of the Vector3
  72823. * @returns a string with the Vector3 coordinates.
  72824. */
  72825. Vector3.prototype.toString = function () {
  72826. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  72827. };
  72828. /**
  72829. * Gets the class name
  72830. * @returns the string "Vector3"
  72831. */
  72832. Vector3.prototype.getClassName = function () {
  72833. return "Vector3";
  72834. };
  72835. /**
  72836. * Creates the Vector3 hash code
  72837. * @returns a number which tends to be unique between Vector3 instances
  72838. */
  72839. Vector3.prototype.getHashCode = function () {
  72840. var hash = this.x || 0;
  72841. hash = (hash * 397) ^ (this.y || 0);
  72842. hash = (hash * 397) ^ (this.z || 0);
  72843. return hash;
  72844. };
  72845. // Operators
  72846. /**
  72847. * Creates an array containing three elements : the coordinates of the Vector3
  72848. * @returns a new array of numbers
  72849. */
  72850. Vector3.prototype.asArray = function () {
  72851. var result = [];
  72852. this.toArray(result, 0);
  72853. return result;
  72854. };
  72855. /**
  72856. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  72857. * @param array defines the destination array
  72858. * @param index defines the offset in the destination array
  72859. * @returns the current Vector3
  72860. */
  72861. Vector3.prototype.toArray = function (array, index) {
  72862. if (index === void 0) { index = 0; }
  72863. array[index] = this.x;
  72864. array[index + 1] = this.y;
  72865. array[index + 2] = this.z;
  72866. return this;
  72867. };
  72868. /**
  72869. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  72870. * @returns a new Quaternion object, computed from the Vector3 coordinates
  72871. */
  72872. Vector3.prototype.toQuaternion = function () {
  72873. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  72874. };
  72875. /**
  72876. * Adds the given vector to the current Vector3
  72877. * @param otherVector defines the second operand
  72878. * @returns the current updated Vector3
  72879. */
  72880. Vector3.prototype.addInPlace = function (otherVector) {
  72881. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  72882. };
  72883. /**
  72884. * Adds the given coordinates to the current Vector3
  72885. * @param x defines the x coordinate of the operand
  72886. * @param y defines the y coordinate of the operand
  72887. * @param z defines the z coordinate of the operand
  72888. * @returns the current updated Vector3
  72889. */
  72890. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  72891. this.x += x;
  72892. this.y += y;
  72893. this.z += z;
  72894. return this;
  72895. };
  72896. /**
  72897. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  72898. * @param otherVector defines the second operand
  72899. * @returns the resulting Vector3
  72900. */
  72901. Vector3.prototype.add = function (otherVector) {
  72902. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  72903. };
  72904. /**
  72905. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  72906. * @param otherVector defines the second operand
  72907. * @param result defines the Vector3 object where to store the result
  72908. * @returns the current Vector3
  72909. */
  72910. Vector3.prototype.addToRef = function (otherVector, result) {
  72911. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  72912. };
  72913. /**
  72914. * Subtract the given vector from the current Vector3
  72915. * @param otherVector defines the second operand
  72916. * @returns the current updated Vector3
  72917. */
  72918. Vector3.prototype.subtractInPlace = function (otherVector) {
  72919. this.x -= otherVector.x;
  72920. this.y -= otherVector.y;
  72921. this.z -= otherVector.z;
  72922. return this;
  72923. };
  72924. /**
  72925. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  72926. * @param otherVector defines the second operand
  72927. * @returns the resulting Vector3
  72928. */
  72929. Vector3.prototype.subtract = function (otherVector) {
  72930. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  72931. };
  72932. /**
  72933. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  72934. * @param otherVector defines the second operand
  72935. * @param result defines the Vector3 object where to store the result
  72936. * @returns the current Vector3
  72937. */
  72938. Vector3.prototype.subtractToRef = function (otherVector, result) {
  72939. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  72940. };
  72941. /**
  72942. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  72943. * @param x defines the x coordinate of the operand
  72944. * @param y defines the y coordinate of the operand
  72945. * @param z defines the z coordinate of the operand
  72946. * @returns the resulting Vector3
  72947. */
  72948. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  72949. return new Vector3(this.x - x, this.y - y, this.z - z);
  72950. };
  72951. /**
  72952. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  72953. * @param x defines the x coordinate of the operand
  72954. * @param y defines the y coordinate of the operand
  72955. * @param z defines the z coordinate of the operand
  72956. * @param result defines the Vector3 object where to store the result
  72957. * @returns the current Vector3
  72958. */
  72959. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  72960. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  72961. };
  72962. /**
  72963. * Gets a new Vector3 set with the current Vector3 negated coordinates
  72964. * @returns a new Vector3
  72965. */
  72966. Vector3.prototype.negate = function () {
  72967. return new Vector3(-this.x, -this.y, -this.z);
  72968. };
  72969. /**
  72970. * Multiplies the Vector3 coordinates by the float "scale"
  72971. * @param scale defines the multiplier factor
  72972. * @returns the current updated Vector3
  72973. */
  72974. Vector3.prototype.scaleInPlace = function (scale) {
  72975. this.x *= scale;
  72976. this.y *= scale;
  72977. this.z *= scale;
  72978. return this;
  72979. };
  72980. /**
  72981. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  72982. * @param scale defines the multiplier factor
  72983. * @returns a new Vector3
  72984. */
  72985. Vector3.prototype.scale = function (scale) {
  72986. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  72987. };
  72988. /**
  72989. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  72990. * @param scale defines the multiplier factor
  72991. * @param result defines the Vector3 object where to store the result
  72992. * @returns the current Vector3
  72993. */
  72994. Vector3.prototype.scaleToRef = function (scale, result) {
  72995. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  72996. };
  72997. /**
  72998. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  72999. * @param scale defines the scale factor
  73000. * @param result defines the Vector3 object where to store the result
  73001. * @returns the unmodified current Vector3
  73002. */
  73003. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  73004. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  73005. };
  73006. /**
  73007. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73008. * @param otherVector defines the second operand
  73009. * @returns true if both vectors are equals
  73010. */
  73011. Vector3.prototype.equals = function (otherVector) {
  73012. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  73013. };
  73014. /**
  73015. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73016. * @param otherVector defines the second operand
  73017. * @param epsilon defines the minimal distance to define values as equals
  73018. * @returns true if both vectors are distant less than epsilon
  73019. */
  73020. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  73021. if (epsilon === void 0) { epsilon = Epsilon; }
  73022. 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);
  73023. };
  73024. /**
  73025. * Returns true if the current Vector3 coordinates equals the given floats
  73026. * @param x defines the x coordinate of the operand
  73027. * @param y defines the y coordinate of the operand
  73028. * @param z defines the z coordinate of the operand
  73029. * @returns true if both vectors are equals
  73030. */
  73031. Vector3.prototype.equalsToFloats = function (x, y, z) {
  73032. return this.x === x && this.y === y && this.z === z;
  73033. };
  73034. /**
  73035. * Multiplies the current Vector3 coordinates by the given ones
  73036. * @param otherVector defines the second operand
  73037. * @returns the current updated Vector3
  73038. */
  73039. Vector3.prototype.multiplyInPlace = function (otherVector) {
  73040. this.x *= otherVector.x;
  73041. this.y *= otherVector.y;
  73042. this.z *= otherVector.z;
  73043. return this;
  73044. };
  73045. /**
  73046. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73047. * @param otherVector defines the second operand
  73048. * @returns the new Vector3
  73049. */
  73050. Vector3.prototype.multiply = function (otherVector) {
  73051. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  73052. };
  73053. /**
  73054. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73055. * @param otherVector defines the second operand
  73056. * @param result defines the Vector3 object where to store the result
  73057. * @returns the current Vector3
  73058. */
  73059. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  73060. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  73061. };
  73062. /**
  73063. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73064. * @param x defines the x coordinate of the operand
  73065. * @param y defines the y coordinate of the operand
  73066. * @param z defines the z coordinate of the operand
  73067. * @returns the new Vector3
  73068. */
  73069. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  73070. return new Vector3(this.x * x, this.y * y, this.z * z);
  73071. };
  73072. /**
  73073. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73074. * @param otherVector defines the second operand
  73075. * @returns the new Vector3
  73076. */
  73077. Vector3.prototype.divide = function (otherVector) {
  73078. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  73079. };
  73080. /**
  73081. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73082. * @param otherVector defines the second operand
  73083. * @param result defines the Vector3 object where to store the result
  73084. * @returns the current Vector3
  73085. */
  73086. Vector3.prototype.divideToRef = function (otherVector, result) {
  73087. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  73088. };
  73089. /**
  73090. * Divides the current Vector3 coordinates by the given ones.
  73091. * @param otherVector defines the second operand
  73092. * @returns the current updated Vector3
  73093. */
  73094. Vector3.prototype.divideInPlace = function (otherVector) {
  73095. return this.divideToRef(otherVector, this);
  73096. };
  73097. /**
  73098. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73099. * @param other defines the second operand
  73100. * @returns the current updated Vector3
  73101. */
  73102. Vector3.prototype.minimizeInPlace = function (other) {
  73103. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  73104. };
  73105. /**
  73106. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73107. * @param other defines the second operand
  73108. * @returns the current updated Vector3
  73109. */
  73110. Vector3.prototype.maximizeInPlace = function (other) {
  73111. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  73112. };
  73113. /**
  73114. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73115. * @param x defines the x coordinate of the operand
  73116. * @param y defines the y coordinate of the operand
  73117. * @param z defines the z coordinate of the operand
  73118. * @returns the current updated Vector3
  73119. */
  73120. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  73121. if (x < this.x) {
  73122. this.x = x;
  73123. }
  73124. if (y < this.y) {
  73125. this.y = y;
  73126. }
  73127. if (z < this.z) {
  73128. this.z = z;
  73129. }
  73130. return this;
  73131. };
  73132. /**
  73133. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73134. * @param x defines the x coordinate of the operand
  73135. * @param y defines the y coordinate of the operand
  73136. * @param z defines the z coordinate of the operand
  73137. * @returns the current updated Vector3
  73138. */
  73139. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  73140. if (x > this.x) {
  73141. this.x = x;
  73142. }
  73143. if (y > this.y) {
  73144. this.y = y;
  73145. }
  73146. if (z > this.z) {
  73147. this.z = z;
  73148. }
  73149. return this;
  73150. };
  73151. /**
  73152. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73153. * Check if is non uniform within a certain amount of decimal places to account for this
  73154. * @param epsilon the amount the values can differ
  73155. * @returns if the the vector is non uniform to a certain number of decimal places
  73156. */
  73157. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  73158. var absX = Math.abs(this.x);
  73159. var absY = Math.abs(this.y);
  73160. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  73161. return true;
  73162. }
  73163. var absZ = Math.abs(this.z);
  73164. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  73165. return true;
  73166. }
  73167. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  73168. return true;
  73169. }
  73170. return false;
  73171. };
  73172. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  73173. /**
  73174. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73175. */
  73176. get: function () {
  73177. var absX = Math.abs(this.x);
  73178. var absY = Math.abs(this.y);
  73179. if (absX !== absY) {
  73180. return true;
  73181. }
  73182. var absZ = Math.abs(this.z);
  73183. if (absX !== absZ) {
  73184. return true;
  73185. }
  73186. if (absY !== absZ) {
  73187. return true;
  73188. }
  73189. return false;
  73190. },
  73191. enumerable: true,
  73192. configurable: true
  73193. });
  73194. /**
  73195. * Gets a new Vector3 from current Vector3 floored values
  73196. * @returns a new Vector3
  73197. */
  73198. Vector3.prototype.floor = function () {
  73199. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  73200. };
  73201. /**
  73202. * Gets a new Vector3 from current Vector3 floored values
  73203. * @returns a new Vector3
  73204. */
  73205. Vector3.prototype.fract = function () {
  73206. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  73207. };
  73208. // Properties
  73209. /**
  73210. * Gets the length of the Vector3
  73211. * @returns the length of the Vecto3
  73212. */
  73213. Vector3.prototype.length = function () {
  73214. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  73215. };
  73216. /**
  73217. * Gets the squared length of the Vector3
  73218. * @returns squared length of the Vector3
  73219. */
  73220. Vector3.prototype.lengthSquared = function () {
  73221. return (this.x * this.x + this.y * this.y + this.z * this.z);
  73222. };
  73223. /**
  73224. * Normalize the current Vector3.
  73225. * Please note that this is an in place operation.
  73226. * @returns the current updated Vector3
  73227. */
  73228. Vector3.prototype.normalize = function () {
  73229. return this.normalizeFromLength(this.length());
  73230. };
  73231. /**
  73232. * Reorders the x y z properties of the vector in place
  73233. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73234. * @returns the current updated vector
  73235. */
  73236. Vector3.prototype.reorderInPlace = function (order) {
  73237. var _this = this;
  73238. order = order.toLowerCase();
  73239. if (order === "xyz") {
  73240. return this;
  73241. }
  73242. MathTmp.Vector3[0].copyFrom(this);
  73243. ["x", "y", "z"].forEach(function (val, i) {
  73244. _this[val] = MathTmp.Vector3[0][order[i]];
  73245. });
  73246. return this;
  73247. };
  73248. /**
  73249. * Rotates the vector around 0,0,0 by a quaternion
  73250. * @param quaternion the rotation quaternion
  73251. * @param result vector to store the result
  73252. * @returns the resulting vector
  73253. */
  73254. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  73255. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  73256. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  73257. return result;
  73258. };
  73259. /**
  73260. * Rotates a vector around a given point
  73261. * @param quaternion the rotation quaternion
  73262. * @param point the point to rotate around
  73263. * @param result vector to store the result
  73264. * @returns the resulting vector
  73265. */
  73266. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  73267. this.subtractToRef(point, MathTmp.Vector3[0]);
  73268. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  73269. point.addToRef(MathTmp.Vector3[0], result);
  73270. return result;
  73271. };
  73272. /**
  73273. * Normalize the current Vector3 with the given input length.
  73274. * Please note that this is an in place operation.
  73275. * @param len the length of the vector
  73276. * @returns the current updated Vector3
  73277. */
  73278. Vector3.prototype.normalizeFromLength = function (len) {
  73279. if (len === 0 || len === 1.0) {
  73280. return this;
  73281. }
  73282. return this.scaleInPlace(1.0 / len);
  73283. };
  73284. /**
  73285. * Normalize the current Vector3 to a new vector
  73286. * @returns the new Vector3
  73287. */
  73288. Vector3.prototype.normalizeToNew = function () {
  73289. var normalized = new Vector3(0, 0, 0);
  73290. this.normalizeToRef(normalized);
  73291. return normalized;
  73292. };
  73293. /**
  73294. * Normalize the current Vector3 to the reference
  73295. * @param reference define the Vector3 to update
  73296. * @returns the updated Vector3
  73297. */
  73298. Vector3.prototype.normalizeToRef = function (reference) {
  73299. var len = this.length();
  73300. if (len === 0 || len === 1.0) {
  73301. return reference.copyFromFloats(this.x, this.y, this.z);
  73302. }
  73303. return this.scaleToRef(1.0 / len, reference);
  73304. };
  73305. /**
  73306. * Creates a new Vector3 copied from the current Vector3
  73307. * @returns the new Vector3
  73308. */
  73309. Vector3.prototype.clone = function () {
  73310. return new Vector3(this.x, this.y, this.z);
  73311. };
  73312. /**
  73313. * Copies the given vector coordinates to the current Vector3 ones
  73314. * @param source defines the source Vector3
  73315. * @returns the current updated Vector3
  73316. */
  73317. Vector3.prototype.copyFrom = function (source) {
  73318. return this.copyFromFloats(source.x, source.y, source.z);
  73319. };
  73320. /**
  73321. * Copies the given floats to the current Vector3 coordinates
  73322. * @param x defines the x coordinate of the operand
  73323. * @param y defines the y coordinate of the operand
  73324. * @param z defines the z coordinate of the operand
  73325. * @returns the current updated Vector3
  73326. */
  73327. Vector3.prototype.copyFromFloats = function (x, y, z) {
  73328. this.x = x;
  73329. this.y = y;
  73330. this.z = z;
  73331. return this;
  73332. };
  73333. /**
  73334. * Copies the given floats to the current Vector3 coordinates
  73335. * @param x defines the x coordinate of the operand
  73336. * @param y defines the y coordinate of the operand
  73337. * @param z defines the z coordinate of the operand
  73338. * @returns the current updated Vector3
  73339. */
  73340. Vector3.prototype.set = function (x, y, z) {
  73341. return this.copyFromFloats(x, y, z);
  73342. };
  73343. /**
  73344. * Copies the given float to the current Vector3 coordinates
  73345. * @param v defines the x, y and z coordinates of the operand
  73346. * @returns the current updated Vector3
  73347. */
  73348. Vector3.prototype.setAll = function (v) {
  73349. this.x = this.y = this.z = v;
  73350. return this;
  73351. };
  73352. // Statics
  73353. /**
  73354. * Get the clip factor between two vectors
  73355. * @param vector0 defines the first operand
  73356. * @param vector1 defines the second operand
  73357. * @param axis defines the axis to use
  73358. * @param size defines the size along the axis
  73359. * @returns the clip factor
  73360. */
  73361. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  73362. var d0 = Vector3.Dot(vector0, axis) - size;
  73363. var d1 = Vector3.Dot(vector1, axis) - size;
  73364. var s = d0 / (d0 - d1);
  73365. return s;
  73366. };
  73367. /**
  73368. * Get angle between two vectors
  73369. * @param vector0 angle between vector0 and vector1
  73370. * @param vector1 angle between vector0 and vector1
  73371. * @param normal direction of the normal
  73372. * @return the angle between vector0 and vector1
  73373. */
  73374. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  73375. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  73376. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  73377. var dot = Vector3.Dot(v0, v1);
  73378. var n = MathTmp.Vector3[3];
  73379. Vector3.CrossToRef(v0, v1, n);
  73380. if (Vector3.Dot(n, normal) > 0) {
  73381. return Math.acos(dot);
  73382. }
  73383. return -Math.acos(dot);
  73384. };
  73385. /**
  73386. * Returns a new Vector3 set from the index "offset" of the given array
  73387. * @param array defines the source array
  73388. * @param offset defines the offset in the source array
  73389. * @returns the new Vector3
  73390. */
  73391. Vector3.FromArray = function (array, offset) {
  73392. if (offset === void 0) { offset = 0; }
  73393. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  73394. };
  73395. /**
  73396. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73397. * This function is deprecated. Use FromArray instead
  73398. * @param array defines the source array
  73399. * @param offset defines the offset in the source array
  73400. * @returns the new Vector3
  73401. */
  73402. Vector3.FromFloatArray = function (array, offset) {
  73403. return Vector3.FromArray(array, offset);
  73404. };
  73405. /**
  73406. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73407. * @param array defines the source array
  73408. * @param offset defines the offset in the source array
  73409. * @param result defines the Vector3 where to store the result
  73410. */
  73411. Vector3.FromArrayToRef = function (array, offset, result) {
  73412. result.x = array[offset];
  73413. result.y = array[offset + 1];
  73414. result.z = array[offset + 2];
  73415. };
  73416. /**
  73417. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73418. * This function is deprecated. Use FromArrayToRef instead.
  73419. * @param array defines the source array
  73420. * @param offset defines the offset in the source array
  73421. * @param result defines the Vector3 where to store the result
  73422. */
  73423. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  73424. return Vector3.FromArrayToRef(array, offset, result);
  73425. };
  73426. /**
  73427. * Sets the given vector "result" with the given floats.
  73428. * @param x defines the x coordinate of the source
  73429. * @param y defines the y coordinate of the source
  73430. * @param z defines the z coordinate of the source
  73431. * @param result defines the Vector3 where to store the result
  73432. */
  73433. Vector3.FromFloatsToRef = function (x, y, z, result) {
  73434. result.copyFromFloats(x, y, z);
  73435. };
  73436. /**
  73437. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73438. * @returns a new empty Vector3
  73439. */
  73440. Vector3.Zero = function () {
  73441. return new Vector3(0.0, 0.0, 0.0);
  73442. };
  73443. /**
  73444. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73445. * @returns a new unit Vector3
  73446. */
  73447. Vector3.One = function () {
  73448. return new Vector3(1.0, 1.0, 1.0);
  73449. };
  73450. /**
  73451. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73452. * @returns a new up Vector3
  73453. */
  73454. Vector3.Up = function () {
  73455. return new Vector3(0.0, 1.0, 0.0);
  73456. };
  73457. Object.defineProperty(Vector3, "UpReadOnly", {
  73458. /**
  73459. * Gets a up Vector3 that must not be updated
  73460. */
  73461. get: function () {
  73462. return Vector3._UpReadOnly;
  73463. },
  73464. enumerable: true,
  73465. configurable: true
  73466. });
  73467. /**
  73468. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73469. * @returns a new down Vector3
  73470. */
  73471. Vector3.Down = function () {
  73472. return new Vector3(0.0, -1.0, 0.0);
  73473. };
  73474. /**
  73475. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73476. * @returns a new forward Vector3
  73477. */
  73478. Vector3.Forward = function () {
  73479. return new Vector3(0.0, 0.0, 1.0);
  73480. };
  73481. /**
  73482. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73483. * @returns a new forward Vector3
  73484. */
  73485. Vector3.Backward = function () {
  73486. return new Vector3(0.0, 0.0, -1.0);
  73487. };
  73488. /**
  73489. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73490. * @returns a new right Vector3
  73491. */
  73492. Vector3.Right = function () {
  73493. return new Vector3(1.0, 0.0, 0.0);
  73494. };
  73495. /**
  73496. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73497. * @returns a new left Vector3
  73498. */
  73499. Vector3.Left = function () {
  73500. return new Vector3(-1.0, 0.0, 0.0);
  73501. };
  73502. /**
  73503. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73504. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73505. * @param vector defines the Vector3 to transform
  73506. * @param transformation defines the transformation matrix
  73507. * @returns the transformed Vector3
  73508. */
  73509. Vector3.TransformCoordinates = function (vector, transformation) {
  73510. var result = Vector3.Zero();
  73511. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  73512. return result;
  73513. };
  73514. /**
  73515. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73516. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73517. * @param vector defines the Vector3 to transform
  73518. * @param transformation defines the transformation matrix
  73519. * @param result defines the Vector3 where to store the result
  73520. */
  73521. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  73522. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  73523. };
  73524. /**
  73525. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73526. * This method computes tranformed coordinates only, not transformed direction vectors
  73527. * @param x define the x coordinate of the source vector
  73528. * @param y define the y coordinate of the source vector
  73529. * @param z define the z coordinate of the source vector
  73530. * @param transformation defines the transformation matrix
  73531. * @param result defines the Vector3 where to store the result
  73532. */
  73533. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  73534. var m = transformation.m;
  73535. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  73536. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  73537. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  73538. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  73539. result.x = rx * rw;
  73540. result.y = ry * rw;
  73541. result.z = rz * rw;
  73542. };
  73543. /**
  73544. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73545. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73546. * @param vector defines the Vector3 to transform
  73547. * @param transformation defines the transformation matrix
  73548. * @returns the new Vector3
  73549. */
  73550. Vector3.TransformNormal = function (vector, transformation) {
  73551. var result = Vector3.Zero();
  73552. Vector3.TransformNormalToRef(vector, transformation, result);
  73553. return result;
  73554. };
  73555. /**
  73556. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73557. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73558. * @param vector defines the Vector3 to transform
  73559. * @param transformation defines the transformation matrix
  73560. * @param result defines the Vector3 where to store the result
  73561. */
  73562. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  73563. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  73564. };
  73565. /**
  73566. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73567. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73568. * @param x define the x coordinate of the source vector
  73569. * @param y define the y coordinate of the source vector
  73570. * @param z define the z coordinate of the source vector
  73571. * @param transformation defines the transformation matrix
  73572. * @param result defines the Vector3 where to store the result
  73573. */
  73574. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  73575. var m = transformation.m;
  73576. result.x = x * m[0] + y * m[4] + z * m[8];
  73577. result.y = x * m[1] + y * m[5] + z * m[9];
  73578. result.z = x * m[2] + y * m[6] + z * m[10];
  73579. };
  73580. /**
  73581. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73582. * @param value1 defines the first control point
  73583. * @param value2 defines the second control point
  73584. * @param value3 defines the third control point
  73585. * @param value4 defines the fourth control point
  73586. * @param amount defines the amount on the spline to use
  73587. * @returns the new Vector3
  73588. */
  73589. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  73590. var squared = amount * amount;
  73591. var cubed = amount * squared;
  73592. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  73593. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  73594. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  73595. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  73596. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  73597. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  73598. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  73599. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  73600. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  73601. return new Vector3(x, y, z);
  73602. };
  73603. /**
  73604. * 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"
  73605. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73606. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73607. * @param value defines the current value
  73608. * @param min defines the lower range value
  73609. * @param max defines the upper range value
  73610. * @returns the new Vector3
  73611. */
  73612. Vector3.Clamp = function (value, min, max) {
  73613. var v = new Vector3();
  73614. Vector3.ClampToRef(value, min, max, v);
  73615. return v;
  73616. };
  73617. /**
  73618. * 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"
  73619. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73620. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73621. * @param value defines the current value
  73622. * @param min defines the lower range value
  73623. * @param max defines the upper range value
  73624. * @param result defines the Vector3 where to store the result
  73625. */
  73626. Vector3.ClampToRef = function (value, min, max, result) {
  73627. var x = value.x;
  73628. x = (x > max.x) ? max.x : x;
  73629. x = (x < min.x) ? min.x : x;
  73630. var y = value.y;
  73631. y = (y > max.y) ? max.y : y;
  73632. y = (y < min.y) ? min.y : y;
  73633. var z = value.z;
  73634. z = (z > max.z) ? max.z : z;
  73635. z = (z < min.z) ? min.z : z;
  73636. result.copyFromFloats(x, y, z);
  73637. };
  73638. /**
  73639. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73640. * @param value1 defines the first control point
  73641. * @param tangent1 defines the first tangent vector
  73642. * @param value2 defines the second control point
  73643. * @param tangent2 defines the second tangent vector
  73644. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73645. * @returns the new Vector3
  73646. */
  73647. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  73648. var squared = amount * amount;
  73649. var cubed = amount * squared;
  73650. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  73651. var part2 = (-2.0 * cubed) + (3.0 * squared);
  73652. var part3 = (cubed - (2.0 * squared)) + amount;
  73653. var part4 = cubed - squared;
  73654. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  73655. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  73656. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  73657. return new Vector3(x, y, z);
  73658. };
  73659. /**
  73660. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73661. * @param start defines the start value
  73662. * @param end defines the end value
  73663. * @param amount max defines amount between both (between 0 and 1)
  73664. * @returns the new Vector3
  73665. */
  73666. Vector3.Lerp = function (start, end, amount) {
  73667. var result = new Vector3(0, 0, 0);
  73668. Vector3.LerpToRef(start, end, amount, result);
  73669. return result;
  73670. };
  73671. /**
  73672. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73673. * @param start defines the start value
  73674. * @param end defines the end value
  73675. * @param amount max defines amount between both (between 0 and 1)
  73676. * @param result defines the Vector3 where to store the result
  73677. */
  73678. Vector3.LerpToRef = function (start, end, amount, result) {
  73679. result.x = start.x + ((end.x - start.x) * amount);
  73680. result.y = start.y + ((end.y - start.y) * amount);
  73681. result.z = start.z + ((end.z - start.z) * amount);
  73682. };
  73683. /**
  73684. * Returns the dot product (float) between the vectors "left" and "right"
  73685. * @param left defines the left operand
  73686. * @param right defines the right operand
  73687. * @returns the dot product
  73688. */
  73689. Vector3.Dot = function (left, right) {
  73690. return (left.x * right.x + left.y * right.y + left.z * right.z);
  73691. };
  73692. /**
  73693. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73694. * The cross product is then orthogonal to both "left" and "right"
  73695. * @param left defines the left operand
  73696. * @param right defines the right operand
  73697. * @returns the cross product
  73698. */
  73699. Vector3.Cross = function (left, right) {
  73700. var result = Vector3.Zero();
  73701. Vector3.CrossToRef(left, right, result);
  73702. return result;
  73703. };
  73704. /**
  73705. * Sets the given vector "result" with the cross product of "left" and "right"
  73706. * The cross product is then orthogonal to both "left" and "right"
  73707. * @param left defines the left operand
  73708. * @param right defines the right operand
  73709. * @param result defines the Vector3 where to store the result
  73710. */
  73711. Vector3.CrossToRef = function (left, right, result) {
  73712. var x = left.y * right.z - left.z * right.y;
  73713. var y = left.z * right.x - left.x * right.z;
  73714. var z = left.x * right.y - left.y * right.x;
  73715. result.copyFromFloats(x, y, z);
  73716. };
  73717. /**
  73718. * Returns a new Vector3 as the normalization of the given vector
  73719. * @param vector defines the Vector3 to normalize
  73720. * @returns the new Vector3
  73721. */
  73722. Vector3.Normalize = function (vector) {
  73723. var result = Vector3.Zero();
  73724. Vector3.NormalizeToRef(vector, result);
  73725. return result;
  73726. };
  73727. /**
  73728. * Sets the given vector "result" with the normalization of the given first vector
  73729. * @param vector defines the Vector3 to normalize
  73730. * @param result defines the Vector3 where to store the result
  73731. */
  73732. Vector3.NormalizeToRef = function (vector, result) {
  73733. vector.normalizeToRef(result);
  73734. };
  73735. /**
  73736. * Project a Vector3 onto screen space
  73737. * @param vector defines the Vector3 to project
  73738. * @param world defines the world matrix to use
  73739. * @param transform defines the transform (view x projection) matrix to use
  73740. * @param viewport defines the screen viewport to use
  73741. * @returns the new Vector3
  73742. */
  73743. Vector3.Project = function (vector, world, transform, viewport) {
  73744. var cw = viewport.width;
  73745. var ch = viewport.height;
  73746. var cx = viewport.x;
  73747. var cy = viewport.y;
  73748. var viewportMatrix = MathTmp.Matrix[1];
  73749. 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);
  73750. var matrix = MathTmp.Matrix[0];
  73751. world.multiplyToRef(transform, matrix);
  73752. matrix.multiplyToRef(viewportMatrix, matrix);
  73753. return Vector3.TransformCoordinates(vector, matrix);
  73754. };
  73755. /** @hidden */
  73756. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  73757. Vector3.TransformCoordinatesToRef(source, matrix, result);
  73758. var m = matrix.m;
  73759. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  73760. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  73761. result.scaleInPlace(1.0 / num);
  73762. }
  73763. };
  73764. /**
  73765. * Unproject from screen space to object space
  73766. * @param source defines the screen space Vector3 to use
  73767. * @param viewportWidth defines the current width of the viewport
  73768. * @param viewportHeight defines the current height of the viewport
  73769. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73770. * @param transform defines the transform (view x projection) matrix to use
  73771. * @returns the new Vector3
  73772. */
  73773. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  73774. var matrix = MathTmp.Matrix[0];
  73775. world.multiplyToRef(transform, matrix);
  73776. matrix.invert();
  73777. source.x = source.x / viewportWidth * 2 - 1;
  73778. source.y = -(source.y / viewportHeight * 2 - 1);
  73779. var vector = new Vector3();
  73780. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  73781. return vector;
  73782. };
  73783. /**
  73784. * Unproject from screen space to object space
  73785. * @param source defines the screen space Vector3 to use
  73786. * @param viewportWidth defines the current width of the viewport
  73787. * @param viewportHeight defines the current height of the viewport
  73788. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73789. * @param view defines the view matrix to use
  73790. * @param projection defines the projection matrix to use
  73791. * @returns the new Vector3
  73792. */
  73793. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  73794. var result = Vector3.Zero();
  73795. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  73796. return result;
  73797. };
  73798. /**
  73799. * Unproject from screen space to object space
  73800. * @param source defines the screen space Vector3 to use
  73801. * @param viewportWidth defines the current width of the viewport
  73802. * @param viewportHeight defines the current height of the viewport
  73803. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73804. * @param view defines the view matrix to use
  73805. * @param projection defines the projection matrix to use
  73806. * @param result defines the Vector3 where to store the result
  73807. */
  73808. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  73809. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  73810. };
  73811. /**
  73812. * Unproject from screen space to object space
  73813. * @param sourceX defines the screen space x coordinate to use
  73814. * @param sourceY defines the screen space y coordinate to use
  73815. * @param sourceZ defines the screen space z coordinate to use
  73816. * @param viewportWidth defines the current width of the viewport
  73817. * @param viewportHeight defines the current height of the viewport
  73818. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73819. * @param view defines the view matrix to use
  73820. * @param projection defines the projection matrix to use
  73821. * @param result defines the Vector3 where to store the result
  73822. */
  73823. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  73824. var matrix = MathTmp.Matrix[0];
  73825. world.multiplyToRef(view, matrix);
  73826. matrix.multiplyToRef(projection, matrix);
  73827. matrix.invert();
  73828. var screenSource = MathTmp.Vector3[0];
  73829. screenSource.x = sourceX / viewportWidth * 2 - 1;
  73830. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  73831. screenSource.z = 2 * sourceZ - 1.0;
  73832. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  73833. };
  73834. /**
  73835. * Gets the minimal coordinate values between two Vector3
  73836. * @param left defines the first operand
  73837. * @param right defines the second operand
  73838. * @returns the new Vector3
  73839. */
  73840. Vector3.Minimize = function (left, right) {
  73841. var min = left.clone();
  73842. min.minimizeInPlace(right);
  73843. return min;
  73844. };
  73845. /**
  73846. * Gets the maximal coordinate values between two Vector3
  73847. * @param left defines the first operand
  73848. * @param right defines the second operand
  73849. * @returns the new Vector3
  73850. */
  73851. Vector3.Maximize = function (left, right) {
  73852. var max = left.clone();
  73853. max.maximizeInPlace(right);
  73854. return max;
  73855. };
  73856. /**
  73857. * Returns the distance between the vectors "value1" and "value2"
  73858. * @param value1 defines the first operand
  73859. * @param value2 defines the second operand
  73860. * @returns the distance
  73861. */
  73862. Vector3.Distance = function (value1, value2) {
  73863. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  73864. };
  73865. /**
  73866. * Returns the squared distance between the vectors "value1" and "value2"
  73867. * @param value1 defines the first operand
  73868. * @param value2 defines the second operand
  73869. * @returns the squared distance
  73870. */
  73871. Vector3.DistanceSquared = function (value1, value2) {
  73872. var x = value1.x - value2.x;
  73873. var y = value1.y - value2.y;
  73874. var z = value1.z - value2.z;
  73875. return (x * x) + (y * y) + (z * z);
  73876. };
  73877. /**
  73878. * Returns a new Vector3 located at the center between "value1" and "value2"
  73879. * @param value1 defines the first operand
  73880. * @param value2 defines the second operand
  73881. * @returns the new Vector3
  73882. */
  73883. Vector3.Center = function (value1, value2) {
  73884. var center = value1.add(value2);
  73885. center.scaleInPlace(0.5);
  73886. return center;
  73887. };
  73888. /**
  73889. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73890. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73891. * to something in order to rotate it from its local system to the given target system
  73892. * Note: axis1, axis2 and axis3 are normalized during this operation
  73893. * @param axis1 defines the first axis
  73894. * @param axis2 defines the second axis
  73895. * @param axis3 defines the third axis
  73896. * @returns a new Vector3
  73897. */
  73898. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  73899. var rotation = Vector3.Zero();
  73900. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  73901. return rotation;
  73902. };
  73903. /**
  73904. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73905. * @param axis1 defines the first axis
  73906. * @param axis2 defines the second axis
  73907. * @param axis3 defines the third axis
  73908. * @param ref defines the Vector3 where to store the result
  73909. */
  73910. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  73911. var quat = MathTmp.Quaternion[0];
  73912. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  73913. quat.toEulerAnglesToRef(ref);
  73914. };
  73915. Vector3._UpReadOnly = Vector3.Up();
  73916. return Vector3;
  73917. }());
  73918. /**
  73919. * Vector4 class created for EulerAngle class conversion to Quaternion
  73920. */
  73921. var Vector4 = /** @class */ (function () {
  73922. /**
  73923. * Creates a Vector4 object from the given floats.
  73924. * @param x x value of the vector
  73925. * @param y y value of the vector
  73926. * @param z z value of the vector
  73927. * @param w w value of the vector
  73928. */
  73929. function Vector4(
  73930. /** x value of the vector */
  73931. x,
  73932. /** y value of the vector */
  73933. y,
  73934. /** z value of the vector */
  73935. z,
  73936. /** w value of the vector */
  73937. w) {
  73938. this.x = x;
  73939. this.y = y;
  73940. this.z = z;
  73941. this.w = w;
  73942. }
  73943. /**
  73944. * Returns the string with the Vector4 coordinates.
  73945. * @returns a string containing all the vector values
  73946. */
  73947. Vector4.prototype.toString = function () {
  73948. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  73949. };
  73950. /**
  73951. * Returns the string "Vector4".
  73952. * @returns "Vector4"
  73953. */
  73954. Vector4.prototype.getClassName = function () {
  73955. return "Vector4";
  73956. };
  73957. /**
  73958. * Returns the Vector4 hash code.
  73959. * @returns a unique hash code
  73960. */
  73961. Vector4.prototype.getHashCode = function () {
  73962. var hash = this.x || 0;
  73963. hash = (hash * 397) ^ (this.y || 0);
  73964. hash = (hash * 397) ^ (this.z || 0);
  73965. hash = (hash * 397) ^ (this.w || 0);
  73966. return hash;
  73967. };
  73968. // Operators
  73969. /**
  73970. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73971. * @returns the resulting array
  73972. */
  73973. Vector4.prototype.asArray = function () {
  73974. var result = new Array();
  73975. this.toArray(result, 0);
  73976. return result;
  73977. };
  73978. /**
  73979. * Populates the given array from the given index with the Vector4 coordinates.
  73980. * @param array array to populate
  73981. * @param index index of the array to start at (default: 0)
  73982. * @returns the Vector4.
  73983. */
  73984. Vector4.prototype.toArray = function (array, index) {
  73985. if (index === undefined) {
  73986. index = 0;
  73987. }
  73988. array[index] = this.x;
  73989. array[index + 1] = this.y;
  73990. array[index + 2] = this.z;
  73991. array[index + 3] = this.w;
  73992. return this;
  73993. };
  73994. /**
  73995. * Adds the given vector to the current Vector4.
  73996. * @param otherVector the vector to add
  73997. * @returns the updated Vector4.
  73998. */
  73999. Vector4.prototype.addInPlace = function (otherVector) {
  74000. this.x += otherVector.x;
  74001. this.y += otherVector.y;
  74002. this.z += otherVector.z;
  74003. this.w += otherVector.w;
  74004. return this;
  74005. };
  74006. /**
  74007. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  74008. * @param otherVector the vector to add
  74009. * @returns the resulting vector
  74010. */
  74011. Vector4.prototype.add = function (otherVector) {
  74012. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  74013. };
  74014. /**
  74015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  74016. * @param otherVector the vector to add
  74017. * @param result the vector to store the result
  74018. * @returns the current Vector4.
  74019. */
  74020. Vector4.prototype.addToRef = function (otherVector, result) {
  74021. result.x = this.x + otherVector.x;
  74022. result.y = this.y + otherVector.y;
  74023. result.z = this.z + otherVector.z;
  74024. result.w = this.w + otherVector.w;
  74025. return this;
  74026. };
  74027. /**
  74028. * Subtract in place the given vector from the current Vector4.
  74029. * @param otherVector the vector to subtract
  74030. * @returns the updated Vector4.
  74031. */
  74032. Vector4.prototype.subtractInPlace = function (otherVector) {
  74033. this.x -= otherVector.x;
  74034. this.y -= otherVector.y;
  74035. this.z -= otherVector.z;
  74036. this.w -= otherVector.w;
  74037. return this;
  74038. };
  74039. /**
  74040. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  74041. * @param otherVector the vector to add
  74042. * @returns the new vector with the result
  74043. */
  74044. Vector4.prototype.subtract = function (otherVector) {
  74045. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  74046. };
  74047. /**
  74048. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  74049. * @param otherVector the vector to subtract
  74050. * @param result the vector to store the result
  74051. * @returns the current Vector4.
  74052. */
  74053. Vector4.prototype.subtractToRef = function (otherVector, result) {
  74054. result.x = this.x - otherVector.x;
  74055. result.y = this.y - otherVector.y;
  74056. result.z = this.z - otherVector.z;
  74057. result.w = this.w - otherVector.w;
  74058. return this;
  74059. };
  74060. /**
  74061. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74062. */
  74063. /**
  74064. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74065. * @param x value to subtract
  74066. * @param y value to subtract
  74067. * @param z value to subtract
  74068. * @param w value to subtract
  74069. * @returns new vector containing the result
  74070. */
  74071. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  74072. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  74073. };
  74074. /**
  74075. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74076. * @param x value to subtract
  74077. * @param y value to subtract
  74078. * @param z value to subtract
  74079. * @param w value to subtract
  74080. * @param result the vector to store the result in
  74081. * @returns the current Vector4.
  74082. */
  74083. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  74084. result.x = this.x - x;
  74085. result.y = this.y - y;
  74086. result.z = this.z - z;
  74087. result.w = this.w - w;
  74088. return this;
  74089. };
  74090. /**
  74091. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  74092. * @returns a new vector with the negated values
  74093. */
  74094. Vector4.prototype.negate = function () {
  74095. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  74096. };
  74097. /**
  74098. * Multiplies the current Vector4 coordinates by scale (float).
  74099. * @param scale the number to scale with
  74100. * @returns the updated Vector4.
  74101. */
  74102. Vector4.prototype.scaleInPlace = function (scale) {
  74103. this.x *= scale;
  74104. this.y *= scale;
  74105. this.z *= scale;
  74106. this.w *= scale;
  74107. return this;
  74108. };
  74109. /**
  74110. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  74111. * @param scale the number to scale with
  74112. * @returns a new vector with the result
  74113. */
  74114. Vector4.prototype.scale = function (scale) {
  74115. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  74116. };
  74117. /**
  74118. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  74119. * @param scale the number to scale with
  74120. * @param result a vector to store the result in
  74121. * @returns the current Vector4.
  74122. */
  74123. Vector4.prototype.scaleToRef = function (scale, result) {
  74124. result.x = this.x * scale;
  74125. result.y = this.y * scale;
  74126. result.z = this.z * scale;
  74127. result.w = this.w * scale;
  74128. return this;
  74129. };
  74130. /**
  74131. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  74132. * @param scale defines the scale factor
  74133. * @param result defines the Vector4 object where to store the result
  74134. * @returns the unmodified current Vector4
  74135. */
  74136. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  74137. result.x += this.x * scale;
  74138. result.y += this.y * scale;
  74139. result.z += this.z * scale;
  74140. result.w += this.w * scale;
  74141. return this;
  74142. };
  74143. /**
  74144. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  74145. * @param otherVector the vector to compare against
  74146. * @returns true if they are equal
  74147. */
  74148. Vector4.prototype.equals = function (otherVector) {
  74149. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  74150. };
  74151. /**
  74152. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  74153. * @param otherVector vector to compare against
  74154. * @param epsilon (Default: very small number)
  74155. * @returns true if they are equal
  74156. */
  74157. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  74158. if (epsilon === void 0) { epsilon = Epsilon; }
  74159. return otherVector
  74160. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  74161. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  74162. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  74163. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  74164. };
  74165. /**
  74166. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  74167. * @param x x value to compare against
  74168. * @param y y value to compare against
  74169. * @param z z value to compare against
  74170. * @param w w value to compare against
  74171. * @returns true if equal
  74172. */
  74173. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  74174. return this.x === x && this.y === y && this.z === z && this.w === w;
  74175. };
  74176. /**
  74177. * Multiplies in place the current Vector4 by the given one.
  74178. * @param otherVector vector to multiple with
  74179. * @returns the updated Vector4.
  74180. */
  74181. Vector4.prototype.multiplyInPlace = function (otherVector) {
  74182. this.x *= otherVector.x;
  74183. this.y *= otherVector.y;
  74184. this.z *= otherVector.z;
  74185. this.w *= otherVector.w;
  74186. return this;
  74187. };
  74188. /**
  74189. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  74190. * @param otherVector vector to multiple with
  74191. * @returns resulting new vector
  74192. */
  74193. Vector4.prototype.multiply = function (otherVector) {
  74194. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  74195. };
  74196. /**
  74197. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  74198. * @param otherVector vector to multiple with
  74199. * @param result vector to store the result
  74200. * @returns the current Vector4.
  74201. */
  74202. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  74203. result.x = this.x * otherVector.x;
  74204. result.y = this.y * otherVector.y;
  74205. result.z = this.z * otherVector.z;
  74206. result.w = this.w * otherVector.w;
  74207. return this;
  74208. };
  74209. /**
  74210. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  74211. * @param x x value multiply with
  74212. * @param y y value multiply with
  74213. * @param z z value multiply with
  74214. * @param w w value multiply with
  74215. * @returns resulting new vector
  74216. */
  74217. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  74218. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  74219. };
  74220. /**
  74221. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  74222. * @param otherVector vector to devide with
  74223. * @returns resulting new vector
  74224. */
  74225. Vector4.prototype.divide = function (otherVector) {
  74226. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  74227. };
  74228. /**
  74229. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  74230. * @param otherVector vector to devide with
  74231. * @param result vector to store the result
  74232. * @returns the current Vector4.
  74233. */
  74234. Vector4.prototype.divideToRef = function (otherVector, result) {
  74235. result.x = this.x / otherVector.x;
  74236. result.y = this.y / otherVector.y;
  74237. result.z = this.z / otherVector.z;
  74238. result.w = this.w / otherVector.w;
  74239. return this;
  74240. };
  74241. /**
  74242. * Divides the current Vector3 coordinates by the given ones.
  74243. * @param otherVector vector to devide with
  74244. * @returns the updated Vector3.
  74245. */
  74246. Vector4.prototype.divideInPlace = function (otherVector) {
  74247. return this.divideToRef(otherVector, this);
  74248. };
  74249. /**
  74250. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  74251. * @param other defines the second operand
  74252. * @returns the current updated Vector4
  74253. */
  74254. Vector4.prototype.minimizeInPlace = function (other) {
  74255. if (other.x < this.x) {
  74256. this.x = other.x;
  74257. }
  74258. if (other.y < this.y) {
  74259. this.y = other.y;
  74260. }
  74261. if (other.z < this.z) {
  74262. this.z = other.z;
  74263. }
  74264. if (other.w < this.w) {
  74265. this.w = other.w;
  74266. }
  74267. return this;
  74268. };
  74269. /**
  74270. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  74271. * @param other defines the second operand
  74272. * @returns the current updated Vector4
  74273. */
  74274. Vector4.prototype.maximizeInPlace = function (other) {
  74275. if (other.x > this.x) {
  74276. this.x = other.x;
  74277. }
  74278. if (other.y > this.y) {
  74279. this.y = other.y;
  74280. }
  74281. if (other.z > this.z) {
  74282. this.z = other.z;
  74283. }
  74284. if (other.w > this.w) {
  74285. this.w = other.w;
  74286. }
  74287. return this;
  74288. };
  74289. /**
  74290. * Gets a new Vector4 from current Vector4 floored values
  74291. * @returns a new Vector4
  74292. */
  74293. Vector4.prototype.floor = function () {
  74294. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  74295. };
  74296. /**
  74297. * Gets a new Vector4 from current Vector3 floored values
  74298. * @returns a new Vector4
  74299. */
  74300. Vector4.prototype.fract = function () {
  74301. 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));
  74302. };
  74303. // Properties
  74304. /**
  74305. * Returns the Vector4 length (float).
  74306. * @returns the length
  74307. */
  74308. Vector4.prototype.length = function () {
  74309. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  74310. };
  74311. /**
  74312. * Returns the Vector4 squared length (float).
  74313. * @returns the length squared
  74314. */
  74315. Vector4.prototype.lengthSquared = function () {
  74316. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  74317. };
  74318. // Methods
  74319. /**
  74320. * Normalizes in place the Vector4.
  74321. * @returns the updated Vector4.
  74322. */
  74323. Vector4.prototype.normalize = function () {
  74324. var len = this.length();
  74325. if (len === 0) {
  74326. return this;
  74327. }
  74328. return this.scaleInPlace(1.0 / len);
  74329. };
  74330. /**
  74331. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  74332. * @returns this converted to a new vector3
  74333. */
  74334. Vector4.prototype.toVector3 = function () {
  74335. return new Vector3(this.x, this.y, this.z);
  74336. };
  74337. /**
  74338. * Returns a new Vector4 copied from the current one.
  74339. * @returns the new cloned vector
  74340. */
  74341. Vector4.prototype.clone = function () {
  74342. return new Vector4(this.x, this.y, this.z, this.w);
  74343. };
  74344. /**
  74345. * Updates the current Vector4 with the given one coordinates.
  74346. * @param source the source vector to copy from
  74347. * @returns the updated Vector4.
  74348. */
  74349. Vector4.prototype.copyFrom = function (source) {
  74350. this.x = source.x;
  74351. this.y = source.y;
  74352. this.z = source.z;
  74353. this.w = source.w;
  74354. return this;
  74355. };
  74356. /**
  74357. * Updates the current Vector4 coordinates with the given floats.
  74358. * @param x float to copy from
  74359. * @param y float to copy from
  74360. * @param z float to copy from
  74361. * @param w float to copy from
  74362. * @returns the updated Vector4.
  74363. */
  74364. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  74365. this.x = x;
  74366. this.y = y;
  74367. this.z = z;
  74368. this.w = w;
  74369. return this;
  74370. };
  74371. /**
  74372. * Updates the current Vector4 coordinates with the given floats.
  74373. * @param x float to set from
  74374. * @param y float to set from
  74375. * @param z float to set from
  74376. * @param w float to set from
  74377. * @returns the updated Vector4.
  74378. */
  74379. Vector4.prototype.set = function (x, y, z, w) {
  74380. return this.copyFromFloats(x, y, z, w);
  74381. };
  74382. /**
  74383. * Copies the given float to the current Vector3 coordinates
  74384. * @param v defines the x, y, z and w coordinates of the operand
  74385. * @returns the current updated Vector3
  74386. */
  74387. Vector4.prototype.setAll = function (v) {
  74388. this.x = this.y = this.z = this.w = v;
  74389. return this;
  74390. };
  74391. // Statics
  74392. /**
  74393. * Returns a new Vector4 set from the starting index of the given array.
  74394. * @param array the array to pull values from
  74395. * @param offset the offset into the array to start at
  74396. * @returns the new vector
  74397. */
  74398. Vector4.FromArray = function (array, offset) {
  74399. if (!offset) {
  74400. offset = 0;
  74401. }
  74402. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  74403. };
  74404. /**
  74405. * Updates the given vector "result" from the starting index of the given array.
  74406. * @param array the array to pull values from
  74407. * @param offset the offset into the array to start at
  74408. * @param result the vector to store the result in
  74409. */
  74410. Vector4.FromArrayToRef = function (array, offset, result) {
  74411. result.x = array[offset];
  74412. result.y = array[offset + 1];
  74413. result.z = array[offset + 2];
  74414. result.w = array[offset + 3];
  74415. };
  74416. /**
  74417. * Updates the given vector "result" from the starting index of the given Float32Array.
  74418. * @param array the array to pull values from
  74419. * @param offset the offset into the array to start at
  74420. * @param result the vector to store the result in
  74421. */
  74422. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  74423. Vector4.FromArrayToRef(array, offset, result);
  74424. };
  74425. /**
  74426. * Updates the given vector "result" coordinates from the given floats.
  74427. * @param x float to set from
  74428. * @param y float to set from
  74429. * @param z float to set from
  74430. * @param w float to set from
  74431. * @param result the vector to the floats in
  74432. */
  74433. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  74434. result.x = x;
  74435. result.y = y;
  74436. result.z = z;
  74437. result.w = w;
  74438. };
  74439. /**
  74440. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74441. * @returns the new vector
  74442. */
  74443. Vector4.Zero = function () {
  74444. return new Vector4(0.0, 0.0, 0.0, 0.0);
  74445. };
  74446. /**
  74447. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74448. * @returns the new vector
  74449. */
  74450. Vector4.One = function () {
  74451. return new Vector4(1.0, 1.0, 1.0, 1.0);
  74452. };
  74453. /**
  74454. * Returns a new normalized Vector4 from the given one.
  74455. * @param vector the vector to normalize
  74456. * @returns the vector
  74457. */
  74458. Vector4.Normalize = function (vector) {
  74459. var result = Vector4.Zero();
  74460. Vector4.NormalizeToRef(vector, result);
  74461. return result;
  74462. };
  74463. /**
  74464. * Updates the given vector "result" from the normalization of the given one.
  74465. * @param vector the vector to normalize
  74466. * @param result the vector to store the result in
  74467. */
  74468. Vector4.NormalizeToRef = function (vector, result) {
  74469. result.copyFrom(vector);
  74470. result.normalize();
  74471. };
  74472. /**
  74473. * Returns a vector with the minimum values from the left and right vectors
  74474. * @param left left vector to minimize
  74475. * @param right right vector to minimize
  74476. * @returns a new vector with the minimum of the left and right vector values
  74477. */
  74478. Vector4.Minimize = function (left, right) {
  74479. var min = left.clone();
  74480. min.minimizeInPlace(right);
  74481. return min;
  74482. };
  74483. /**
  74484. * Returns a vector with the maximum values from the left and right vectors
  74485. * @param left left vector to maximize
  74486. * @param right right vector to maximize
  74487. * @returns a new vector with the maximum of the left and right vector values
  74488. */
  74489. Vector4.Maximize = function (left, right) {
  74490. var max = left.clone();
  74491. max.maximizeInPlace(right);
  74492. return max;
  74493. };
  74494. /**
  74495. * Returns the distance (float) between the vectors "value1" and "value2".
  74496. * @param value1 value to calulate the distance between
  74497. * @param value2 value to calulate the distance between
  74498. * @return the distance between the two vectors
  74499. */
  74500. Vector4.Distance = function (value1, value2) {
  74501. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  74502. };
  74503. /**
  74504. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74505. * @param value1 value to calulate the distance between
  74506. * @param value2 value to calulate the distance between
  74507. * @return the distance between the two vectors squared
  74508. */
  74509. Vector4.DistanceSquared = function (value1, value2) {
  74510. var x = value1.x - value2.x;
  74511. var y = value1.y - value2.y;
  74512. var z = value1.z - value2.z;
  74513. var w = value1.w - value2.w;
  74514. return (x * x) + (y * y) + (z * z) + (w * w);
  74515. };
  74516. /**
  74517. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74518. * @param value1 value to calulate the center between
  74519. * @param value2 value to calulate the center between
  74520. * @return the center between the two vectors
  74521. */
  74522. Vector4.Center = function (value1, value2) {
  74523. var center = value1.add(value2);
  74524. center.scaleInPlace(0.5);
  74525. return center;
  74526. };
  74527. /**
  74528. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74529. * This methods computes transformed normalized direction vectors only.
  74530. * @param vector the vector to transform
  74531. * @param transformation the transformation matrix to apply
  74532. * @returns the new vector
  74533. */
  74534. Vector4.TransformNormal = function (vector, transformation) {
  74535. var result = Vector4.Zero();
  74536. Vector4.TransformNormalToRef(vector, transformation, result);
  74537. return result;
  74538. };
  74539. /**
  74540. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74541. * This methods computes transformed normalized direction vectors only.
  74542. * @param vector the vector to transform
  74543. * @param transformation the transformation matrix to apply
  74544. * @param result the vector to store the result in
  74545. */
  74546. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  74547. var m = transformation.m;
  74548. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  74549. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  74550. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  74551. result.x = x;
  74552. result.y = y;
  74553. result.z = z;
  74554. result.w = vector.w;
  74555. };
  74556. /**
  74557. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74558. * This methods computes transformed normalized direction vectors only.
  74559. * @param x value to transform
  74560. * @param y value to transform
  74561. * @param z value to transform
  74562. * @param w value to transform
  74563. * @param transformation the transformation matrix to apply
  74564. * @param result the vector to store the results in
  74565. */
  74566. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  74567. var m = transformation.m;
  74568. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  74569. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  74570. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  74571. result.w = w;
  74572. };
  74573. /**
  74574. * Creates a new Vector4 from a Vector3
  74575. * @param source defines the source data
  74576. * @param w defines the 4th component (default is 0)
  74577. * @returns a new Vector4
  74578. */
  74579. Vector4.FromVector3 = function (source, w) {
  74580. if (w === void 0) { w = 0; }
  74581. return new Vector4(source.x, source.y, source.z, w);
  74582. };
  74583. return Vector4;
  74584. }());
  74585. /**
  74586. * Size containing widht and height
  74587. */
  74588. var Size = /** @class */ (function () {
  74589. /**
  74590. * Creates a Size object from the given width and height (floats).
  74591. * @param width width of the new size
  74592. * @param height height of the new size
  74593. */
  74594. function Size(width, height) {
  74595. this.width = width;
  74596. this.height = height;
  74597. }
  74598. /**
  74599. * Returns a string with the Size width and height
  74600. * @returns a string with the Size width and height
  74601. */
  74602. Size.prototype.toString = function () {
  74603. return "{W: " + this.width + ", H: " + this.height + "}";
  74604. };
  74605. /**
  74606. * "Size"
  74607. * @returns the string "Size"
  74608. */
  74609. Size.prototype.getClassName = function () {
  74610. return "Size";
  74611. };
  74612. /**
  74613. * Returns the Size hash code.
  74614. * @returns a hash code for a unique width and height
  74615. */
  74616. Size.prototype.getHashCode = function () {
  74617. var hash = this.width || 0;
  74618. hash = (hash * 397) ^ (this.height || 0);
  74619. return hash;
  74620. };
  74621. /**
  74622. * Updates the current size from the given one.
  74623. * @param src the given size
  74624. */
  74625. Size.prototype.copyFrom = function (src) {
  74626. this.width = src.width;
  74627. this.height = src.height;
  74628. };
  74629. /**
  74630. * Updates in place the current Size from the given floats.
  74631. * @param width width of the new size
  74632. * @param height height of the new size
  74633. * @returns the updated Size.
  74634. */
  74635. Size.prototype.copyFromFloats = function (width, height) {
  74636. this.width = width;
  74637. this.height = height;
  74638. return this;
  74639. };
  74640. /**
  74641. * Updates in place the current Size from the given floats.
  74642. * @param width width to set
  74643. * @param height height to set
  74644. * @returns the updated Size.
  74645. */
  74646. Size.prototype.set = function (width, height) {
  74647. return this.copyFromFloats(width, height);
  74648. };
  74649. /**
  74650. * Multiplies the width and height by numbers
  74651. * @param w factor to multiple the width by
  74652. * @param h factor to multiple the height by
  74653. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  74654. */
  74655. Size.prototype.multiplyByFloats = function (w, h) {
  74656. return new Size(this.width * w, this.height * h);
  74657. };
  74658. /**
  74659. * Clones the size
  74660. * @returns a new Size copied from the given one.
  74661. */
  74662. Size.prototype.clone = function () {
  74663. return new Size(this.width, this.height);
  74664. };
  74665. /**
  74666. * True if the current Size and the given one width and height are strictly equal.
  74667. * @param other the other size to compare against
  74668. * @returns True if the current Size and the given one width and height are strictly equal.
  74669. */
  74670. Size.prototype.equals = function (other) {
  74671. if (!other) {
  74672. return false;
  74673. }
  74674. return (this.width === other.width) && (this.height === other.height);
  74675. };
  74676. Object.defineProperty(Size.prototype, "surface", {
  74677. /**
  74678. * The surface of the Size : width * height (float).
  74679. */
  74680. get: function () {
  74681. return this.width * this.height;
  74682. },
  74683. enumerable: true,
  74684. configurable: true
  74685. });
  74686. /**
  74687. * Create a new size of zero
  74688. * @returns a new Size set to (0.0, 0.0)
  74689. */
  74690. Size.Zero = function () {
  74691. return new Size(0.0, 0.0);
  74692. };
  74693. /**
  74694. * Sums the width and height of two sizes
  74695. * @param otherSize size to add to this size
  74696. * @returns a new Size set as the addition result of the current Size and the given one.
  74697. */
  74698. Size.prototype.add = function (otherSize) {
  74699. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  74700. return r;
  74701. };
  74702. /**
  74703. * Subtracts the width and height of two
  74704. * @param otherSize size to subtract to this size
  74705. * @returns a new Size set as the subtraction result of the given one from the current Size.
  74706. */
  74707. Size.prototype.subtract = function (otherSize) {
  74708. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  74709. return r;
  74710. };
  74711. /**
  74712. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  74713. * @param start starting size to lerp between
  74714. * @param end end size to lerp between
  74715. * @param amount amount to lerp between the start and end values
  74716. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  74717. */
  74718. Size.Lerp = function (start, end, amount) {
  74719. var w = start.width + ((end.width - start.width) * amount);
  74720. var h = start.height + ((end.height - start.height) * amount);
  74721. return new Size(w, h);
  74722. };
  74723. return Size;
  74724. }());
  74725. /**
  74726. * Class used to store quaternion data
  74727. * @see https://en.wikipedia.org/wiki/Quaternion
  74728. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74729. */
  74730. var Quaternion = /** @class */ (function () {
  74731. /**
  74732. * Creates a new Quaternion from the given floats
  74733. * @param x defines the first component (0 by default)
  74734. * @param y defines the second component (0 by default)
  74735. * @param z defines the third component (0 by default)
  74736. * @param w defines the fourth component (1.0 by default)
  74737. */
  74738. function Quaternion(
  74739. /** defines the first component (0 by default) */
  74740. x,
  74741. /** defines the second component (0 by default) */
  74742. y,
  74743. /** defines the third component (0 by default) */
  74744. z,
  74745. /** defines the fourth component (1.0 by default) */
  74746. w) {
  74747. if (x === void 0) { x = 0.0; }
  74748. if (y === void 0) { y = 0.0; }
  74749. if (z === void 0) { z = 0.0; }
  74750. if (w === void 0) { w = 1.0; }
  74751. this.x = x;
  74752. this.y = y;
  74753. this.z = z;
  74754. this.w = w;
  74755. }
  74756. /**
  74757. * Gets a string representation for the current quaternion
  74758. * @returns a string with the Quaternion coordinates
  74759. */
  74760. Quaternion.prototype.toString = function () {
  74761. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  74762. };
  74763. /**
  74764. * Gets the class name of the quaternion
  74765. * @returns the string "Quaternion"
  74766. */
  74767. Quaternion.prototype.getClassName = function () {
  74768. return "Quaternion";
  74769. };
  74770. /**
  74771. * Gets a hash code for this quaternion
  74772. * @returns the quaternion hash code
  74773. */
  74774. Quaternion.prototype.getHashCode = function () {
  74775. var hash = this.x || 0;
  74776. hash = (hash * 397) ^ (this.y || 0);
  74777. hash = (hash * 397) ^ (this.z || 0);
  74778. hash = (hash * 397) ^ (this.w || 0);
  74779. return hash;
  74780. };
  74781. /**
  74782. * Copy the quaternion to an array
  74783. * @returns a new array populated with 4 elements from the quaternion coordinates
  74784. */
  74785. Quaternion.prototype.asArray = function () {
  74786. return [this.x, this.y, this.z, this.w];
  74787. };
  74788. /**
  74789. * Check if two quaternions are equals
  74790. * @param otherQuaternion defines the second operand
  74791. * @return true if the current quaternion and the given one coordinates are strictly equals
  74792. */
  74793. Quaternion.prototype.equals = function (otherQuaternion) {
  74794. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  74795. };
  74796. /**
  74797. * Clone the current quaternion
  74798. * @returns a new quaternion copied from the current one
  74799. */
  74800. Quaternion.prototype.clone = function () {
  74801. return new Quaternion(this.x, this.y, this.z, this.w);
  74802. };
  74803. /**
  74804. * Copy a quaternion to the current one
  74805. * @param other defines the other quaternion
  74806. * @returns the updated current quaternion
  74807. */
  74808. Quaternion.prototype.copyFrom = function (other) {
  74809. this.x = other.x;
  74810. this.y = other.y;
  74811. this.z = other.z;
  74812. this.w = other.w;
  74813. return this;
  74814. };
  74815. /**
  74816. * Updates the current quaternion with the given float coordinates
  74817. * @param x defines the x coordinate
  74818. * @param y defines the y coordinate
  74819. * @param z defines the z coordinate
  74820. * @param w defines the w coordinate
  74821. * @returns the updated current quaternion
  74822. */
  74823. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  74824. this.x = x;
  74825. this.y = y;
  74826. this.z = z;
  74827. this.w = w;
  74828. return this;
  74829. };
  74830. /**
  74831. * Updates the current quaternion from the given float coordinates
  74832. * @param x defines the x coordinate
  74833. * @param y defines the y coordinate
  74834. * @param z defines the z coordinate
  74835. * @param w defines the w coordinate
  74836. * @returns the updated current quaternion
  74837. */
  74838. Quaternion.prototype.set = function (x, y, z, w) {
  74839. return this.copyFromFloats(x, y, z, w);
  74840. };
  74841. /**
  74842. * Adds two quaternions
  74843. * @param other defines the second operand
  74844. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74845. */
  74846. Quaternion.prototype.add = function (other) {
  74847. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  74848. };
  74849. /**
  74850. * Add a quaternion to the current one
  74851. * @param other defines the quaternion to add
  74852. * @returns the current quaternion
  74853. */
  74854. Quaternion.prototype.addInPlace = function (other) {
  74855. this.x += other.x;
  74856. this.y += other.y;
  74857. this.z += other.z;
  74858. this.w += other.w;
  74859. return this;
  74860. };
  74861. /**
  74862. * Subtract two quaternions
  74863. * @param other defines the second operand
  74864. * @returns a new quaternion as the subtraction result of the given one from the current one
  74865. */
  74866. Quaternion.prototype.subtract = function (other) {
  74867. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  74868. };
  74869. /**
  74870. * Multiplies the current quaternion by a scale factor
  74871. * @param value defines the scale factor
  74872. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74873. */
  74874. Quaternion.prototype.scale = function (value) {
  74875. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  74876. };
  74877. /**
  74878. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74879. * @param scale defines the scale factor
  74880. * @param result defines the Quaternion object where to store the result
  74881. * @returns the unmodified current quaternion
  74882. */
  74883. Quaternion.prototype.scaleToRef = function (scale, result) {
  74884. result.x = this.x * scale;
  74885. result.y = this.y * scale;
  74886. result.z = this.z * scale;
  74887. result.w = this.w * scale;
  74888. return this;
  74889. };
  74890. /**
  74891. * Multiplies in place the current quaternion by a scale factor
  74892. * @param value defines the scale factor
  74893. * @returns the current modified quaternion
  74894. */
  74895. Quaternion.prototype.scaleInPlace = function (value) {
  74896. this.x *= value;
  74897. this.y *= value;
  74898. this.z *= value;
  74899. this.w *= value;
  74900. return this;
  74901. };
  74902. /**
  74903. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74904. * @param scale defines the scale factor
  74905. * @param result defines the Quaternion object where to store the result
  74906. * @returns the unmodified current quaternion
  74907. */
  74908. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  74909. result.x += this.x * scale;
  74910. result.y += this.y * scale;
  74911. result.z += this.z * scale;
  74912. result.w += this.w * scale;
  74913. return this;
  74914. };
  74915. /**
  74916. * Multiplies two quaternions
  74917. * @param q1 defines the second operand
  74918. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74919. */
  74920. Quaternion.prototype.multiply = function (q1) {
  74921. var result = new Quaternion(0, 0, 0, 1.0);
  74922. this.multiplyToRef(q1, result);
  74923. return result;
  74924. };
  74925. /**
  74926. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74927. * @param q1 defines the second operand
  74928. * @param result defines the target quaternion
  74929. * @returns the current quaternion
  74930. */
  74931. Quaternion.prototype.multiplyToRef = function (q1, result) {
  74932. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  74933. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  74934. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  74935. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  74936. result.copyFromFloats(x, y, z, w);
  74937. return this;
  74938. };
  74939. /**
  74940. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74941. * @param q1 defines the second operand
  74942. * @returns the currentupdated quaternion
  74943. */
  74944. Quaternion.prototype.multiplyInPlace = function (q1) {
  74945. this.multiplyToRef(q1, this);
  74946. return this;
  74947. };
  74948. /**
  74949. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74950. * @param ref defines the target quaternion
  74951. * @returns the current quaternion
  74952. */
  74953. Quaternion.prototype.conjugateToRef = function (ref) {
  74954. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  74955. return this;
  74956. };
  74957. /**
  74958. * Conjugates in place (1-q) the current quaternion
  74959. * @returns the current updated quaternion
  74960. */
  74961. Quaternion.prototype.conjugateInPlace = function () {
  74962. this.x *= -1;
  74963. this.y *= -1;
  74964. this.z *= -1;
  74965. return this;
  74966. };
  74967. /**
  74968. * Conjugates in place (1-q) the current quaternion
  74969. * @returns a new quaternion
  74970. */
  74971. Quaternion.prototype.conjugate = function () {
  74972. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  74973. return result;
  74974. };
  74975. /**
  74976. * Gets length of current quaternion
  74977. * @returns the quaternion length (float)
  74978. */
  74979. Quaternion.prototype.length = function () {
  74980. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  74981. };
  74982. /**
  74983. * Normalize in place the current quaternion
  74984. * @returns the current updated quaternion
  74985. */
  74986. Quaternion.prototype.normalize = function () {
  74987. var len = this.length();
  74988. if (len === 0) {
  74989. return this;
  74990. }
  74991. var inv = 1.0 / len;
  74992. this.x *= inv;
  74993. this.y *= inv;
  74994. this.z *= inv;
  74995. this.w *= inv;
  74996. return this;
  74997. };
  74998. /**
  74999. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  75000. * @param order is a reserved parameter and is ignore for now
  75001. * @returns a new Vector3 containing the Euler angles
  75002. */
  75003. Quaternion.prototype.toEulerAngles = function (order) {
  75004. if (order === void 0) { order = "YZX"; }
  75005. var result = Vector3.Zero();
  75006. this.toEulerAnglesToRef(result);
  75007. return result;
  75008. };
  75009. /**
  75010. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  75011. * @param result defines the vector which will be filled with the Euler angles
  75012. * @param order is a reserved parameter and is ignore for now
  75013. * @returns the current unchanged quaternion
  75014. */
  75015. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  75016. var qz = this.z;
  75017. var qx = this.x;
  75018. var qy = this.y;
  75019. var qw = this.w;
  75020. var sqw = qw * qw;
  75021. var sqz = qz * qz;
  75022. var sqx = qx * qx;
  75023. var sqy = qy * qy;
  75024. var zAxisY = qy * qz - qx * qw;
  75025. var limit = .4999999;
  75026. if (zAxisY < -limit) {
  75027. result.y = 2 * Math.atan2(qy, qw);
  75028. result.x = Math.PI / 2;
  75029. result.z = 0;
  75030. }
  75031. else if (zAxisY > limit) {
  75032. result.y = 2 * Math.atan2(qy, qw);
  75033. result.x = -Math.PI / 2;
  75034. result.z = 0;
  75035. }
  75036. else {
  75037. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  75038. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  75039. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  75040. }
  75041. return this;
  75042. };
  75043. /**
  75044. * Updates the given rotation matrix with the current quaternion values
  75045. * @param result defines the target matrix
  75046. * @returns the current unchanged quaternion
  75047. */
  75048. Quaternion.prototype.toRotationMatrix = function (result) {
  75049. Matrix.FromQuaternionToRef(this, result);
  75050. return this;
  75051. };
  75052. /**
  75053. * Updates the current quaternion from the given rotation matrix values
  75054. * @param matrix defines the source matrix
  75055. * @returns the current updated quaternion
  75056. */
  75057. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  75058. Quaternion.FromRotationMatrixToRef(matrix, this);
  75059. return this;
  75060. };
  75061. // Statics
  75062. /**
  75063. * Creates a new quaternion from a rotation matrix
  75064. * @param matrix defines the source matrix
  75065. * @returns a new quaternion created from the given rotation matrix values
  75066. */
  75067. Quaternion.FromRotationMatrix = function (matrix) {
  75068. var result = new Quaternion();
  75069. Quaternion.FromRotationMatrixToRef(matrix, result);
  75070. return result;
  75071. };
  75072. /**
  75073. * Updates the given quaternion with the given rotation matrix values
  75074. * @param matrix defines the source matrix
  75075. * @param result defines the target quaternion
  75076. */
  75077. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  75078. var data = matrix.m;
  75079. var m11 = data[0], m12 = data[4], m13 = data[8];
  75080. var m21 = data[1], m22 = data[5], m23 = data[9];
  75081. var m31 = data[2], m32 = data[6], m33 = data[10];
  75082. var trace = m11 + m22 + m33;
  75083. var s;
  75084. if (trace > 0) {
  75085. s = 0.5 / Math.sqrt(trace + 1.0);
  75086. result.w = 0.25 / s;
  75087. result.x = (m32 - m23) * s;
  75088. result.y = (m13 - m31) * s;
  75089. result.z = (m21 - m12) * s;
  75090. }
  75091. else if (m11 > m22 && m11 > m33) {
  75092. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  75093. result.w = (m32 - m23) / s;
  75094. result.x = 0.25 * s;
  75095. result.y = (m12 + m21) / s;
  75096. result.z = (m13 + m31) / s;
  75097. }
  75098. else if (m22 > m33) {
  75099. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  75100. result.w = (m13 - m31) / s;
  75101. result.x = (m12 + m21) / s;
  75102. result.y = 0.25 * s;
  75103. result.z = (m23 + m32) / s;
  75104. }
  75105. else {
  75106. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  75107. result.w = (m21 - m12) / s;
  75108. result.x = (m13 + m31) / s;
  75109. result.y = (m23 + m32) / s;
  75110. result.z = 0.25 * s;
  75111. }
  75112. };
  75113. /**
  75114. * Returns the dot product (float) between the quaternions "left" and "right"
  75115. * @param left defines the left operand
  75116. * @param right defines the right operand
  75117. * @returns the dot product
  75118. */
  75119. Quaternion.Dot = function (left, right) {
  75120. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  75121. };
  75122. /**
  75123. * Checks if the two quaternions are close to each other
  75124. * @param quat0 defines the first quaternion to check
  75125. * @param quat1 defines the second quaternion to check
  75126. * @returns true if the two quaternions are close to each other
  75127. */
  75128. Quaternion.AreClose = function (quat0, quat1) {
  75129. var dot = Quaternion.Dot(quat0, quat1);
  75130. return dot >= 0;
  75131. };
  75132. /**
  75133. * Creates an empty quaternion
  75134. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  75135. */
  75136. Quaternion.Zero = function () {
  75137. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  75138. };
  75139. /**
  75140. * Inverse a given quaternion
  75141. * @param q defines the source quaternion
  75142. * @returns a new quaternion as the inverted current quaternion
  75143. */
  75144. Quaternion.Inverse = function (q) {
  75145. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  75146. };
  75147. /**
  75148. * Inverse a given quaternion
  75149. * @param q defines the source quaternion
  75150. * @param result the quaternion the result will be stored in
  75151. * @returns the result quaternion
  75152. */
  75153. Quaternion.InverseToRef = function (q, result) {
  75154. result.set(-q.x, -q.y, -q.z, q.w);
  75155. return result;
  75156. };
  75157. /**
  75158. * Creates an identity quaternion
  75159. * @returns the identity quaternion
  75160. */
  75161. Quaternion.Identity = function () {
  75162. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  75163. };
  75164. /**
  75165. * Gets a boolean indicating if the given quaternion is identity
  75166. * @param quaternion defines the quaternion to check
  75167. * @returns true if the quaternion is identity
  75168. */
  75169. Quaternion.IsIdentity = function (quaternion) {
  75170. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  75171. };
  75172. /**
  75173. * Creates a quaternion from a rotation around an axis
  75174. * @param axis defines the axis to use
  75175. * @param angle defines the angle to use
  75176. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  75177. */
  75178. Quaternion.RotationAxis = function (axis, angle) {
  75179. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  75180. };
  75181. /**
  75182. * Creates a rotation around an axis and stores it into the given quaternion
  75183. * @param axis defines the axis to use
  75184. * @param angle defines the angle to use
  75185. * @param result defines the target quaternion
  75186. * @returns the target quaternion
  75187. */
  75188. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  75189. var sin = Math.sin(angle / 2);
  75190. axis.normalize();
  75191. result.w = Math.cos(angle / 2);
  75192. result.x = axis.x * sin;
  75193. result.y = axis.y * sin;
  75194. result.z = axis.z * sin;
  75195. return result;
  75196. };
  75197. /**
  75198. * Creates a new quaternion from data stored into an array
  75199. * @param array defines the data source
  75200. * @param offset defines the offset in the source array where the data starts
  75201. * @returns a new quaternion
  75202. */
  75203. Quaternion.FromArray = function (array, offset) {
  75204. if (!offset) {
  75205. offset = 0;
  75206. }
  75207. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  75208. };
  75209. /**
  75210. * Create a quaternion from Euler rotation angles
  75211. * @param x Pitch
  75212. * @param y Yaw
  75213. * @param z Roll
  75214. * @returns the new Quaternion
  75215. */
  75216. Quaternion.FromEulerAngles = function (x, y, z) {
  75217. var q = new Quaternion();
  75218. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  75219. return q;
  75220. };
  75221. /**
  75222. * Updates a quaternion from Euler rotation angles
  75223. * @param x Pitch
  75224. * @param y Yaw
  75225. * @param z Roll
  75226. * @param result the quaternion to store the result
  75227. * @returns the updated quaternion
  75228. */
  75229. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  75230. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  75231. return result;
  75232. };
  75233. /**
  75234. * Create a quaternion from Euler rotation vector
  75235. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  75236. * @returns the new Quaternion
  75237. */
  75238. Quaternion.FromEulerVector = function (vec) {
  75239. var q = new Quaternion();
  75240. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  75241. return q;
  75242. };
  75243. /**
  75244. * Updates a quaternion from Euler rotation vector
  75245. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  75246. * @param result the quaternion to store the result
  75247. * @returns the updated quaternion
  75248. */
  75249. Quaternion.FromEulerVectorToRef = function (vec, result) {
  75250. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  75251. return result;
  75252. };
  75253. /**
  75254. * Creates a new quaternion from the given Euler float angles (y, x, z)
  75255. * @param yaw defines the rotation around Y axis
  75256. * @param pitch defines the rotation around X axis
  75257. * @param roll defines the rotation around Z axis
  75258. * @returns the new quaternion
  75259. */
  75260. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  75261. var q = new Quaternion();
  75262. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  75263. return q;
  75264. };
  75265. /**
  75266. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  75267. * @param yaw defines the rotation around Y axis
  75268. * @param pitch defines the rotation around X axis
  75269. * @param roll defines the rotation around Z axis
  75270. * @param result defines the target quaternion
  75271. */
  75272. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  75273. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  75274. var halfRoll = roll * 0.5;
  75275. var halfPitch = pitch * 0.5;
  75276. var halfYaw = yaw * 0.5;
  75277. var sinRoll = Math.sin(halfRoll);
  75278. var cosRoll = Math.cos(halfRoll);
  75279. var sinPitch = Math.sin(halfPitch);
  75280. var cosPitch = Math.cos(halfPitch);
  75281. var sinYaw = Math.sin(halfYaw);
  75282. var cosYaw = Math.cos(halfYaw);
  75283. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  75284. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  75285. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  75286. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  75287. };
  75288. /**
  75289. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  75290. * @param alpha defines the rotation around first axis
  75291. * @param beta defines the rotation around second axis
  75292. * @param gamma defines the rotation around third axis
  75293. * @returns the new quaternion
  75294. */
  75295. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  75296. var result = new Quaternion();
  75297. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  75298. return result;
  75299. };
  75300. /**
  75301. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  75302. * @param alpha defines the rotation around first axis
  75303. * @param beta defines the rotation around second axis
  75304. * @param gamma defines the rotation around third axis
  75305. * @param result defines the target quaternion
  75306. */
  75307. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  75308. // Produces a quaternion from Euler angles in the z-x-z orientation
  75309. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  75310. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  75311. var halfBeta = beta * 0.5;
  75312. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  75313. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  75314. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  75315. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  75316. };
  75317. /**
  75318. * 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)
  75319. * @param axis1 defines the first axis
  75320. * @param axis2 defines the second axis
  75321. * @param axis3 defines the third axis
  75322. * @returns the new quaternion
  75323. */
  75324. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  75325. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  75326. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  75327. return quat;
  75328. };
  75329. /**
  75330. * 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
  75331. * @param axis1 defines the first axis
  75332. * @param axis2 defines the second axis
  75333. * @param axis3 defines the third axis
  75334. * @param ref defines the target quaternion
  75335. */
  75336. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  75337. var rotMat = MathTmp.Matrix[0];
  75338. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  75339. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  75340. };
  75341. /**
  75342. * Interpolates between two quaternions
  75343. * @param left defines first quaternion
  75344. * @param right defines second quaternion
  75345. * @param amount defines the gradient to use
  75346. * @returns the new interpolated quaternion
  75347. */
  75348. Quaternion.Slerp = function (left, right, amount) {
  75349. var result = Quaternion.Identity();
  75350. Quaternion.SlerpToRef(left, right, amount, result);
  75351. return result;
  75352. };
  75353. /**
  75354. * Interpolates between two quaternions and stores it into a target quaternion
  75355. * @param left defines first quaternion
  75356. * @param right defines second quaternion
  75357. * @param amount defines the gradient to use
  75358. * @param result defines the target quaternion
  75359. */
  75360. Quaternion.SlerpToRef = function (left, right, amount, result) {
  75361. var num2;
  75362. var num3;
  75363. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  75364. var flag = false;
  75365. if (num4 < 0) {
  75366. flag = true;
  75367. num4 = -num4;
  75368. }
  75369. if (num4 > 0.999999) {
  75370. num3 = 1 - amount;
  75371. num2 = flag ? -amount : amount;
  75372. }
  75373. else {
  75374. var num5 = Math.acos(num4);
  75375. var num6 = (1.0 / Math.sin(num5));
  75376. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  75377. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  75378. }
  75379. result.x = (num3 * left.x) + (num2 * right.x);
  75380. result.y = (num3 * left.y) + (num2 * right.y);
  75381. result.z = (num3 * left.z) + (num2 * right.z);
  75382. result.w = (num3 * left.w) + (num2 * right.w);
  75383. };
  75384. /**
  75385. * Interpolate between two quaternions using Hermite interpolation
  75386. * @param value1 defines first quaternion
  75387. * @param tangent1 defines the incoming tangent
  75388. * @param value2 defines second quaternion
  75389. * @param tangent2 defines the outgoing tangent
  75390. * @param amount defines the target quaternion
  75391. * @returns the new interpolated quaternion
  75392. */
  75393. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  75394. var squared = amount * amount;
  75395. var cubed = amount * squared;
  75396. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  75397. var part2 = (-2.0 * cubed) + (3.0 * squared);
  75398. var part3 = (cubed - (2.0 * squared)) + amount;
  75399. var part4 = cubed - squared;
  75400. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  75401. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  75402. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  75403. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  75404. return new Quaternion(x, y, z, w);
  75405. };
  75406. return Quaternion;
  75407. }());
  75408. /**
  75409. * Class used to store matrix data (4x4)
  75410. */
  75411. var Matrix = /** @class */ (function () {
  75412. /**
  75413. * Creates an empty matrix (filled with zeros)
  75414. */
  75415. function Matrix() {
  75416. this._isIdentity = false;
  75417. this._isIdentityDirty = true;
  75418. this._isIdentity3x2 = true;
  75419. this._isIdentity3x2Dirty = true;
  75420. /**
  75421. * Gets the update flag of the matrix which is an unique number for the matrix.
  75422. * It will be incremented every time the matrix data change.
  75423. * You can use it to speed the comparison between two versions of the same matrix.
  75424. */
  75425. this.updateFlag = -1;
  75426. this._m = new Float32Array(16);
  75427. this._updateIdentityStatus(false);
  75428. }
  75429. Object.defineProperty(Matrix.prototype, "m", {
  75430. /**
  75431. * Gets the internal data of the matrix
  75432. */
  75433. get: function () { return this._m; },
  75434. enumerable: true,
  75435. configurable: true
  75436. });
  75437. /** @hidden */
  75438. Matrix.prototype._markAsUpdated = function () {
  75439. this.updateFlag = Matrix._updateFlagSeed++;
  75440. this._isIdentity = false;
  75441. this._isIdentity3x2 = false;
  75442. this._isIdentityDirty = true;
  75443. this._isIdentity3x2Dirty = true;
  75444. };
  75445. /** @hidden */
  75446. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  75447. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  75448. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  75449. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  75450. this.updateFlag = Matrix._updateFlagSeed++;
  75451. this._isIdentity = isIdentity;
  75452. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  75453. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  75454. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  75455. };
  75456. // Properties
  75457. /**
  75458. * Check if the current matrix is identity
  75459. * @returns true is the matrix is the identity matrix
  75460. */
  75461. Matrix.prototype.isIdentity = function () {
  75462. if (this._isIdentityDirty) {
  75463. this._isIdentityDirty = false;
  75464. var m = this._m;
  75465. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  75466. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  75467. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  75468. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  75469. }
  75470. return this._isIdentity;
  75471. };
  75472. /**
  75473. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  75474. * @returns true is the matrix is the identity matrix
  75475. */
  75476. Matrix.prototype.isIdentityAs3x2 = function () {
  75477. if (this._isIdentity3x2Dirty) {
  75478. this._isIdentity3x2Dirty = false;
  75479. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  75480. this._isIdentity3x2 = false;
  75481. }
  75482. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  75483. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  75484. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  75485. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  75486. this._isIdentity3x2 = false;
  75487. }
  75488. else {
  75489. this._isIdentity3x2 = true;
  75490. }
  75491. }
  75492. return this._isIdentity3x2;
  75493. };
  75494. /**
  75495. * Gets the determinant of the matrix
  75496. * @returns the matrix determinant
  75497. */
  75498. Matrix.prototype.determinant = function () {
  75499. if (this._isIdentity === true) {
  75500. return 1;
  75501. }
  75502. var m = this._m;
  75503. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  75504. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  75505. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  75506. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  75507. // https://en.wikipedia.org/wiki/Laplace_expansion
  75508. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  75509. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  75510. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  75511. // where
  75512. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  75513. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  75514. //
  75515. // Here we do that for the 1st row.
  75516. var det_22_33 = m22 * m33 - m32 * m23;
  75517. var det_21_33 = m21 * m33 - m31 * m23;
  75518. var det_21_32 = m21 * m32 - m31 * m22;
  75519. var det_20_33 = m20 * m33 - m30 * m23;
  75520. var det_20_32 = m20 * m32 - m22 * m30;
  75521. var det_20_31 = m20 * m31 - m30 * m21;
  75522. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  75523. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  75524. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  75525. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  75526. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  75527. };
  75528. // Methods
  75529. /**
  75530. * Returns the matrix as a Float32Array
  75531. * @returns the matrix underlying array
  75532. */
  75533. Matrix.prototype.toArray = function () {
  75534. return this._m;
  75535. };
  75536. /**
  75537. * Returns the matrix as a Float32Array
  75538. * @returns the matrix underlying array.
  75539. */
  75540. Matrix.prototype.asArray = function () {
  75541. return this._m;
  75542. };
  75543. /**
  75544. * Inverts the current matrix in place
  75545. * @returns the current inverted matrix
  75546. */
  75547. Matrix.prototype.invert = function () {
  75548. this.invertToRef(this);
  75549. return this;
  75550. };
  75551. /**
  75552. * Sets all the matrix elements to zero
  75553. * @returns the current matrix
  75554. */
  75555. Matrix.prototype.reset = function () {
  75556. 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);
  75557. this._updateIdentityStatus(false);
  75558. return this;
  75559. };
  75560. /**
  75561. * Adds the current matrix with a second one
  75562. * @param other defines the matrix to add
  75563. * @returns a new matrix as the addition of the current matrix and the given one
  75564. */
  75565. Matrix.prototype.add = function (other) {
  75566. var result = new Matrix();
  75567. this.addToRef(other, result);
  75568. return result;
  75569. };
  75570. /**
  75571. * Sets the given matrix "result" to the addition of the current matrix and the given one
  75572. * @param other defines the matrix to add
  75573. * @param result defines the target matrix
  75574. * @returns the current matrix
  75575. */
  75576. Matrix.prototype.addToRef = function (other, result) {
  75577. var m = this._m;
  75578. var resultM = result._m;
  75579. var otherM = other.m;
  75580. for (var index = 0; index < 16; index++) {
  75581. resultM[index] = m[index] + otherM[index];
  75582. }
  75583. result._markAsUpdated();
  75584. return this;
  75585. };
  75586. /**
  75587. * Adds in place the given matrix to the current matrix
  75588. * @param other defines the second operand
  75589. * @returns the current updated matrix
  75590. */
  75591. Matrix.prototype.addToSelf = function (other) {
  75592. var m = this._m;
  75593. var otherM = other.m;
  75594. for (var index = 0; index < 16; index++) {
  75595. m[index] += otherM[index];
  75596. }
  75597. this._markAsUpdated();
  75598. return this;
  75599. };
  75600. /**
  75601. * Sets the given matrix to the current inverted Matrix
  75602. * @param other defines the target matrix
  75603. * @returns the unmodified current matrix
  75604. */
  75605. Matrix.prototype.invertToRef = function (other) {
  75606. if (this._isIdentity === true) {
  75607. Matrix.IdentityToRef(other);
  75608. return this;
  75609. }
  75610. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  75611. var m = this._m;
  75612. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  75613. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  75614. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  75615. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  75616. var det_22_33 = m22 * m33 - m32 * m23;
  75617. var det_21_33 = m21 * m33 - m31 * m23;
  75618. var det_21_32 = m21 * m32 - m31 * m22;
  75619. var det_20_33 = m20 * m33 - m30 * m23;
  75620. var det_20_32 = m20 * m32 - m22 * m30;
  75621. var det_20_31 = m20 * m31 - m30 * m21;
  75622. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  75623. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  75624. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  75625. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  75626. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  75627. if (det === 0) {
  75628. // not invertible
  75629. other.copyFrom(this);
  75630. return this;
  75631. }
  75632. var detInv = 1 / det;
  75633. var det_12_33 = m12 * m33 - m32 * m13;
  75634. var det_11_33 = m11 * m33 - m31 * m13;
  75635. var det_11_32 = m11 * m32 - m31 * m12;
  75636. var det_10_33 = m10 * m33 - m30 * m13;
  75637. var det_10_32 = m10 * m32 - m30 * m12;
  75638. var det_10_31 = m10 * m31 - m30 * m11;
  75639. var det_12_23 = m12 * m23 - m22 * m13;
  75640. var det_11_23 = m11 * m23 - m21 * m13;
  75641. var det_11_22 = m11 * m22 - m21 * m12;
  75642. var det_10_23 = m10 * m23 - m20 * m13;
  75643. var det_10_22 = m10 * m22 - m20 * m12;
  75644. var det_10_21 = m10 * m21 - m20 * m11;
  75645. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  75646. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  75647. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  75648. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  75649. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  75650. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  75651. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  75652. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  75653. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  75654. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  75655. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  75656. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  75657. 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);
  75658. return this;
  75659. };
  75660. /**
  75661. * add a value at the specified position in the current Matrix
  75662. * @param index the index of the value within the matrix. between 0 and 15.
  75663. * @param value the value to be added
  75664. * @returns the current updated matrix
  75665. */
  75666. Matrix.prototype.addAtIndex = function (index, value) {
  75667. this._m[index] += value;
  75668. this._markAsUpdated();
  75669. return this;
  75670. };
  75671. /**
  75672. * mutiply the specified position in the current Matrix by a value
  75673. * @param index the index of the value within the matrix. between 0 and 15.
  75674. * @param value the value to be added
  75675. * @returns the current updated matrix
  75676. */
  75677. Matrix.prototype.multiplyAtIndex = function (index, value) {
  75678. this._m[index] *= value;
  75679. this._markAsUpdated();
  75680. return this;
  75681. };
  75682. /**
  75683. * Inserts the translation vector (using 3 floats) in the current matrix
  75684. * @param x defines the 1st component of the translation
  75685. * @param y defines the 2nd component of the translation
  75686. * @param z defines the 3rd component of the translation
  75687. * @returns the current updated matrix
  75688. */
  75689. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  75690. this._m[12] = x;
  75691. this._m[13] = y;
  75692. this._m[14] = z;
  75693. this._markAsUpdated();
  75694. return this;
  75695. };
  75696. /**
  75697. * Adds the translation vector (using 3 floats) in the current matrix
  75698. * @param x defines the 1st component of the translation
  75699. * @param y defines the 2nd component of the translation
  75700. * @param z defines the 3rd component of the translation
  75701. * @returns the current updated matrix
  75702. */
  75703. Matrix.prototype.addTranslationFromFloats = function (x, y, z) {
  75704. this._m[12] += x;
  75705. this._m[13] += y;
  75706. this._m[14] += z;
  75707. this._markAsUpdated();
  75708. return this;
  75709. };
  75710. /**
  75711. * Inserts the translation vector in the current matrix
  75712. * @param vector3 defines the translation to insert
  75713. * @returns the current updated matrix
  75714. */
  75715. Matrix.prototype.setTranslation = function (vector3) {
  75716. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  75717. };
  75718. /**
  75719. * Gets the translation value of the current matrix
  75720. * @returns a new Vector3 as the extracted translation from the matrix
  75721. */
  75722. Matrix.prototype.getTranslation = function () {
  75723. return new Vector3(this._m[12], this._m[13], this._m[14]);
  75724. };
  75725. /**
  75726. * Fill a Vector3 with the extracted translation from the matrix
  75727. * @param result defines the Vector3 where to store the translation
  75728. * @returns the current matrix
  75729. */
  75730. Matrix.prototype.getTranslationToRef = function (result) {
  75731. result.x = this._m[12];
  75732. result.y = this._m[13];
  75733. result.z = this._m[14];
  75734. return this;
  75735. };
  75736. /**
  75737. * Remove rotation and scaling part from the matrix
  75738. * @returns the updated matrix
  75739. */
  75740. Matrix.prototype.removeRotationAndScaling = function () {
  75741. var m = this.m;
  75742. 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);
  75743. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  75744. return this;
  75745. };
  75746. /**
  75747. * Multiply two matrices
  75748. * @param other defines the second operand
  75749. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  75750. */
  75751. Matrix.prototype.multiply = function (other) {
  75752. var result = new Matrix();
  75753. this.multiplyToRef(other, result);
  75754. return result;
  75755. };
  75756. /**
  75757. * Copy the current matrix from the given one
  75758. * @param other defines the source matrix
  75759. * @returns the current updated matrix
  75760. */
  75761. Matrix.prototype.copyFrom = function (other) {
  75762. other.copyToArray(this._m);
  75763. var o = other;
  75764. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  75765. return this;
  75766. };
  75767. /**
  75768. * Populates the given array from the starting index with the current matrix values
  75769. * @param array defines the target array
  75770. * @param offset defines the offset in the target array where to start storing values
  75771. * @returns the current matrix
  75772. */
  75773. Matrix.prototype.copyToArray = function (array, offset) {
  75774. if (offset === void 0) { offset = 0; }
  75775. for (var index = 0; index < 16; index++) {
  75776. array[offset + index] = this._m[index];
  75777. }
  75778. return this;
  75779. };
  75780. /**
  75781. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  75782. * @param other defines the second operand
  75783. * @param result defines the matrix where to store the multiplication
  75784. * @returns the current matrix
  75785. */
  75786. Matrix.prototype.multiplyToRef = function (other, result) {
  75787. if (this._isIdentity) {
  75788. result.copyFrom(other);
  75789. return this;
  75790. }
  75791. if (other._isIdentity) {
  75792. result.copyFrom(this);
  75793. return this;
  75794. }
  75795. this.multiplyToArray(other, result._m, 0);
  75796. result._markAsUpdated();
  75797. return this;
  75798. };
  75799. /**
  75800. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  75801. * @param other defines the second operand
  75802. * @param result defines the array where to store the multiplication
  75803. * @param offset defines the offset in the target array where to start storing values
  75804. * @returns the current matrix
  75805. */
  75806. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  75807. var m = this._m;
  75808. var otherM = other.m;
  75809. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  75810. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  75811. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  75812. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  75813. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  75814. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  75815. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  75816. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  75817. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  75818. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  75819. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  75820. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  75821. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  75822. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  75823. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  75824. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  75825. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  75826. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  75827. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  75828. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  75829. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  75830. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  75831. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  75832. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  75833. return this;
  75834. };
  75835. /**
  75836. * Check equality between this matrix and a second one
  75837. * @param value defines the second matrix to compare
  75838. * @returns true is the current matrix and the given one values are strictly equal
  75839. */
  75840. Matrix.prototype.equals = function (value) {
  75841. var other = value;
  75842. if (!other) {
  75843. return false;
  75844. }
  75845. if (this._isIdentity || other._isIdentity) {
  75846. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  75847. return this._isIdentity && other._isIdentity;
  75848. }
  75849. }
  75850. var m = this.m;
  75851. var om = other.m;
  75852. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  75853. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  75854. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  75855. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  75856. };
  75857. /**
  75858. * Clone the current matrix
  75859. * @returns a new matrix from the current matrix
  75860. */
  75861. Matrix.prototype.clone = function () {
  75862. var matrix = new Matrix();
  75863. matrix.copyFrom(this);
  75864. return matrix;
  75865. };
  75866. /**
  75867. * Returns the name of the current matrix class
  75868. * @returns the string "Matrix"
  75869. */
  75870. Matrix.prototype.getClassName = function () {
  75871. return "Matrix";
  75872. };
  75873. /**
  75874. * Gets the hash code of the current matrix
  75875. * @returns the hash code
  75876. */
  75877. Matrix.prototype.getHashCode = function () {
  75878. var hash = this._m[0] || 0;
  75879. for (var i = 1; i < 16; i++) {
  75880. hash = (hash * 397) ^ (this._m[i] || 0);
  75881. }
  75882. return hash;
  75883. };
  75884. /**
  75885. * Decomposes the current Matrix into a translation, rotation and scaling components
  75886. * @param scale defines the scale vector3 given as a reference to update
  75887. * @param rotation defines the rotation quaternion given as a reference to update
  75888. * @param translation defines the translation vector3 given as a reference to update
  75889. * @returns true if operation was successful
  75890. */
  75891. Matrix.prototype.decompose = function (scale, rotation, translation) {
  75892. if (this._isIdentity) {
  75893. if (translation) {
  75894. translation.setAll(0);
  75895. }
  75896. if (scale) {
  75897. scale.setAll(1);
  75898. }
  75899. if (rotation) {
  75900. rotation.copyFromFloats(0, 0, 0, 1);
  75901. }
  75902. return true;
  75903. }
  75904. var m = this._m;
  75905. if (translation) {
  75906. translation.copyFromFloats(m[12], m[13], m[14]);
  75907. }
  75908. scale = scale || MathTmp.Vector3[0];
  75909. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  75910. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  75911. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  75912. if (this.determinant() <= 0) {
  75913. scale.y *= -1;
  75914. }
  75915. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  75916. if (rotation) {
  75917. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  75918. }
  75919. return false;
  75920. }
  75921. if (rotation) {
  75922. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  75923. 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]);
  75924. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  75925. }
  75926. return true;
  75927. };
  75928. /**
  75929. * Gets specific row of the matrix
  75930. * @param index defines the number of the row to get
  75931. * @returns the index-th row of the current matrix as a new Vector4
  75932. */
  75933. Matrix.prototype.getRow = function (index) {
  75934. if (index < 0 || index > 3) {
  75935. return null;
  75936. }
  75937. var i = index * 4;
  75938. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  75939. };
  75940. /**
  75941. * Sets the index-th row of the current matrix to the vector4 values
  75942. * @param index defines the number of the row to set
  75943. * @param row defines the target vector4
  75944. * @returns the updated current matrix
  75945. */
  75946. Matrix.prototype.setRow = function (index, row) {
  75947. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  75948. };
  75949. /**
  75950. * Compute the transpose of the matrix
  75951. * @returns the new transposed matrix
  75952. */
  75953. Matrix.prototype.transpose = function () {
  75954. return Matrix.Transpose(this);
  75955. };
  75956. /**
  75957. * Compute the transpose of the matrix and store it in a given matrix
  75958. * @param result defines the target matrix
  75959. * @returns the current matrix
  75960. */
  75961. Matrix.prototype.transposeToRef = function (result) {
  75962. Matrix.TransposeToRef(this, result);
  75963. return this;
  75964. };
  75965. /**
  75966. * Sets the index-th row of the current matrix with the given 4 x float values
  75967. * @param index defines the row index
  75968. * @param x defines the x component to set
  75969. * @param y defines the y component to set
  75970. * @param z defines the z component to set
  75971. * @param w defines the w component to set
  75972. * @returns the updated current matrix
  75973. */
  75974. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  75975. if (index < 0 || index > 3) {
  75976. return this;
  75977. }
  75978. var i = index * 4;
  75979. this._m[i + 0] = x;
  75980. this._m[i + 1] = y;
  75981. this._m[i + 2] = z;
  75982. this._m[i + 3] = w;
  75983. this._markAsUpdated();
  75984. return this;
  75985. };
  75986. /**
  75987. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  75988. * @param scale defines the scale factor
  75989. * @returns a new matrix
  75990. */
  75991. Matrix.prototype.scale = function (scale) {
  75992. var result = new Matrix();
  75993. this.scaleToRef(scale, result);
  75994. return result;
  75995. };
  75996. /**
  75997. * Scale the current matrix values by a factor to a given result matrix
  75998. * @param scale defines the scale factor
  75999. * @param result defines the matrix to store the result
  76000. * @returns the current matrix
  76001. */
  76002. Matrix.prototype.scaleToRef = function (scale, result) {
  76003. for (var index = 0; index < 16; index++) {
  76004. result._m[index] = this._m[index] * scale;
  76005. }
  76006. result._markAsUpdated();
  76007. return this;
  76008. };
  76009. /**
  76010. * Scale the current matrix values by a factor and add the result to a given matrix
  76011. * @param scale defines the scale factor
  76012. * @param result defines the Matrix to store the result
  76013. * @returns the current matrix
  76014. */
  76015. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  76016. for (var index = 0; index < 16; index++) {
  76017. result._m[index] += this._m[index] * scale;
  76018. }
  76019. result._markAsUpdated();
  76020. return this;
  76021. };
  76022. /**
  76023. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  76024. * @param ref matrix to store the result
  76025. */
  76026. Matrix.prototype.toNormalMatrix = function (ref) {
  76027. var tmp = MathTmp.Matrix[0];
  76028. this.invertToRef(tmp);
  76029. tmp.transposeToRef(ref);
  76030. var m = ref._m;
  76031. 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);
  76032. };
  76033. /**
  76034. * Gets only rotation part of the current matrix
  76035. * @returns a new matrix sets to the extracted rotation matrix from the current one
  76036. */
  76037. Matrix.prototype.getRotationMatrix = function () {
  76038. var result = new Matrix();
  76039. this.getRotationMatrixToRef(result);
  76040. return result;
  76041. };
  76042. /**
  76043. * Extracts the rotation matrix from the current one and sets it as the given "result"
  76044. * @param result defines the target matrix to store data to
  76045. * @returns the current matrix
  76046. */
  76047. Matrix.prototype.getRotationMatrixToRef = function (result) {
  76048. var scale = MathTmp.Vector3[0];
  76049. if (!this.decompose(scale)) {
  76050. Matrix.IdentityToRef(result);
  76051. return this;
  76052. }
  76053. var m = this._m;
  76054. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  76055. 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);
  76056. return this;
  76057. };
  76058. /**
  76059. * Toggles model matrix from being right handed to left handed in place and vice versa
  76060. */
  76061. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  76062. var m = this._m;
  76063. m[2] *= -1;
  76064. m[6] *= -1;
  76065. m[8] *= -1;
  76066. m[9] *= -1;
  76067. m[14] *= -1;
  76068. this._markAsUpdated();
  76069. };
  76070. /**
  76071. * Toggles projection matrix from being right handed to left handed in place and vice versa
  76072. */
  76073. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  76074. var m = this._m;
  76075. m[8] *= -1;
  76076. m[9] *= -1;
  76077. m[10] *= -1;
  76078. m[11] *= -1;
  76079. this._markAsUpdated();
  76080. };
  76081. // Statics
  76082. /**
  76083. * Creates a matrix from an array
  76084. * @param array defines the source array
  76085. * @param offset defines an offset in the source array
  76086. * @returns a new Matrix set from the starting index of the given array
  76087. */
  76088. Matrix.FromArray = function (array, offset) {
  76089. if (offset === void 0) { offset = 0; }
  76090. var result = new Matrix();
  76091. Matrix.FromArrayToRef(array, offset, result);
  76092. return result;
  76093. };
  76094. /**
  76095. * Copy the content of an array into a given matrix
  76096. * @param array defines the source array
  76097. * @param offset defines an offset in the source array
  76098. * @param result defines the target matrix
  76099. */
  76100. Matrix.FromArrayToRef = function (array, offset, result) {
  76101. for (var index = 0; index < 16; index++) {
  76102. result._m[index] = array[index + offset];
  76103. }
  76104. result._markAsUpdated();
  76105. };
  76106. /**
  76107. * Stores an array into a matrix after having multiplied each component by a given factor
  76108. * @param array defines the source array
  76109. * @param offset defines the offset in the source array
  76110. * @param scale defines the scaling factor
  76111. * @param result defines the target matrix
  76112. */
  76113. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  76114. for (var index = 0; index < 16; index++) {
  76115. result._m[index] = array[index + offset] * scale;
  76116. }
  76117. result._markAsUpdated();
  76118. };
  76119. Object.defineProperty(Matrix, "IdentityReadOnly", {
  76120. /**
  76121. * Gets an identity matrix that must not be updated
  76122. */
  76123. get: function () {
  76124. return Matrix._identityReadOnly;
  76125. },
  76126. enumerable: true,
  76127. configurable: true
  76128. });
  76129. /**
  76130. * Stores a list of values (16) inside a given matrix
  76131. * @param initialM11 defines 1st value of 1st row
  76132. * @param initialM12 defines 2nd value of 1st row
  76133. * @param initialM13 defines 3rd value of 1st row
  76134. * @param initialM14 defines 4th value of 1st row
  76135. * @param initialM21 defines 1st value of 2nd row
  76136. * @param initialM22 defines 2nd value of 2nd row
  76137. * @param initialM23 defines 3rd value of 2nd row
  76138. * @param initialM24 defines 4th value of 2nd row
  76139. * @param initialM31 defines 1st value of 3rd row
  76140. * @param initialM32 defines 2nd value of 3rd row
  76141. * @param initialM33 defines 3rd value of 3rd row
  76142. * @param initialM34 defines 4th value of 3rd row
  76143. * @param initialM41 defines 1st value of 4th row
  76144. * @param initialM42 defines 2nd value of 4th row
  76145. * @param initialM43 defines 3rd value of 4th row
  76146. * @param initialM44 defines 4th value of 4th row
  76147. * @param result defines the target matrix
  76148. */
  76149. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  76150. var m = result._m;
  76151. m[0] = initialM11;
  76152. m[1] = initialM12;
  76153. m[2] = initialM13;
  76154. m[3] = initialM14;
  76155. m[4] = initialM21;
  76156. m[5] = initialM22;
  76157. m[6] = initialM23;
  76158. m[7] = initialM24;
  76159. m[8] = initialM31;
  76160. m[9] = initialM32;
  76161. m[10] = initialM33;
  76162. m[11] = initialM34;
  76163. m[12] = initialM41;
  76164. m[13] = initialM42;
  76165. m[14] = initialM43;
  76166. m[15] = initialM44;
  76167. result._markAsUpdated();
  76168. };
  76169. /**
  76170. * Creates new matrix from a list of values (16)
  76171. * @param initialM11 defines 1st value of 1st row
  76172. * @param initialM12 defines 2nd value of 1st row
  76173. * @param initialM13 defines 3rd value of 1st row
  76174. * @param initialM14 defines 4th value of 1st row
  76175. * @param initialM21 defines 1st value of 2nd row
  76176. * @param initialM22 defines 2nd value of 2nd row
  76177. * @param initialM23 defines 3rd value of 2nd row
  76178. * @param initialM24 defines 4th value of 2nd row
  76179. * @param initialM31 defines 1st value of 3rd row
  76180. * @param initialM32 defines 2nd value of 3rd row
  76181. * @param initialM33 defines 3rd value of 3rd row
  76182. * @param initialM34 defines 4th value of 3rd row
  76183. * @param initialM41 defines 1st value of 4th row
  76184. * @param initialM42 defines 2nd value of 4th row
  76185. * @param initialM43 defines 3rd value of 4th row
  76186. * @param initialM44 defines 4th value of 4th row
  76187. * @returns the new matrix
  76188. */
  76189. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  76190. var result = new Matrix();
  76191. var m = result._m;
  76192. m[0] = initialM11;
  76193. m[1] = initialM12;
  76194. m[2] = initialM13;
  76195. m[3] = initialM14;
  76196. m[4] = initialM21;
  76197. m[5] = initialM22;
  76198. m[6] = initialM23;
  76199. m[7] = initialM24;
  76200. m[8] = initialM31;
  76201. m[9] = initialM32;
  76202. m[10] = initialM33;
  76203. m[11] = initialM34;
  76204. m[12] = initialM41;
  76205. m[13] = initialM42;
  76206. m[14] = initialM43;
  76207. m[15] = initialM44;
  76208. result._markAsUpdated();
  76209. return result;
  76210. };
  76211. /**
  76212. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76213. * @param scale defines the scale vector3
  76214. * @param rotation defines the rotation quaternion
  76215. * @param translation defines the translation vector3
  76216. * @returns a new matrix
  76217. */
  76218. Matrix.Compose = function (scale, rotation, translation) {
  76219. var result = new Matrix();
  76220. Matrix.ComposeToRef(scale, rotation, translation, result);
  76221. return result;
  76222. };
  76223. /**
  76224. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  76225. * @param scale defines the scale vector3
  76226. * @param rotation defines the rotation quaternion
  76227. * @param translation defines the translation vector3
  76228. * @param result defines the target matrix
  76229. */
  76230. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  76231. var m = result._m;
  76232. var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
  76233. var x2 = x + x, y2 = y + y, z2 = z + z;
  76234. var xx = x * x2, xy = x * y2, xz = x * z2;
  76235. var yy = y * y2, yz = y * z2, zz = z * z2;
  76236. var wx = w * x2, wy = w * y2, wz = w * z2;
  76237. var sx = scale.x, sy = scale.y, sz = scale.z;
  76238. m[0] = (1 - (yy + zz)) * sx;
  76239. m[1] = (xy + wz) * sx;
  76240. m[2] = (xz - wy) * sx;
  76241. m[3] = 0;
  76242. m[4] = (xy - wz) * sy;
  76243. m[5] = (1 - (xx + zz)) * sy;
  76244. m[6] = (yz + wx) * sy;
  76245. m[7] = 0;
  76246. m[8] = (xz + wy) * sz;
  76247. m[9] = (yz - wx) * sz;
  76248. m[10] = (1 - (xx + yy)) * sz;
  76249. m[11] = 0;
  76250. m[12] = translation.x;
  76251. m[13] = translation.y;
  76252. m[14] = translation.z;
  76253. m[15] = 1;
  76254. };
  76255. /**
  76256. * Creates a new identity matrix
  76257. * @returns a new identity matrix
  76258. */
  76259. Matrix.Identity = function () {
  76260. 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);
  76261. identity._updateIdentityStatus(true);
  76262. return identity;
  76263. };
  76264. /**
  76265. * Creates a new identity matrix and stores the result in a given matrix
  76266. * @param result defines the target matrix
  76267. */
  76268. Matrix.IdentityToRef = function (result) {
  76269. 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);
  76270. result._updateIdentityStatus(true);
  76271. };
  76272. /**
  76273. * Creates a new zero matrix
  76274. * @returns a new zero matrix
  76275. */
  76276. Matrix.Zero = function () {
  76277. 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);
  76278. zero._updateIdentityStatus(false);
  76279. return zero;
  76280. };
  76281. /**
  76282. * Creates a new rotation matrix for "angle" radians around the X axis
  76283. * @param angle defines the angle (in radians) to use
  76284. * @return the new matrix
  76285. */
  76286. Matrix.RotationX = function (angle) {
  76287. var result = new Matrix();
  76288. Matrix.RotationXToRef(angle, result);
  76289. return result;
  76290. };
  76291. /**
  76292. * Creates a new matrix as the invert of a given matrix
  76293. * @param source defines the source matrix
  76294. * @returns the new matrix
  76295. */
  76296. Matrix.Invert = function (source) {
  76297. var result = new Matrix();
  76298. source.invertToRef(result);
  76299. return result;
  76300. };
  76301. /**
  76302. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  76303. * @param angle defines the angle (in radians) to use
  76304. * @param result defines the target matrix
  76305. */
  76306. Matrix.RotationXToRef = function (angle, result) {
  76307. var s = Math.sin(angle);
  76308. var c = Math.cos(angle);
  76309. 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);
  76310. result._updateIdentityStatus(c === 1 && s === 0);
  76311. };
  76312. /**
  76313. * Creates a new rotation matrix for "angle" radians around the Y axis
  76314. * @param angle defines the angle (in radians) to use
  76315. * @return the new matrix
  76316. */
  76317. Matrix.RotationY = function (angle) {
  76318. var result = new Matrix();
  76319. Matrix.RotationYToRef(angle, result);
  76320. return result;
  76321. };
  76322. /**
  76323. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  76324. * @param angle defines the angle (in radians) to use
  76325. * @param result defines the target matrix
  76326. */
  76327. Matrix.RotationYToRef = function (angle, result) {
  76328. var s = Math.sin(angle);
  76329. var c = Math.cos(angle);
  76330. 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);
  76331. result._updateIdentityStatus(c === 1 && s === 0);
  76332. };
  76333. /**
  76334. * Creates a new rotation matrix for "angle" radians around the Z axis
  76335. * @param angle defines the angle (in radians) to use
  76336. * @return the new matrix
  76337. */
  76338. Matrix.RotationZ = function (angle) {
  76339. var result = new Matrix();
  76340. Matrix.RotationZToRef(angle, result);
  76341. return result;
  76342. };
  76343. /**
  76344. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  76345. * @param angle defines the angle (in radians) to use
  76346. * @param result defines the target matrix
  76347. */
  76348. Matrix.RotationZToRef = function (angle, result) {
  76349. var s = Math.sin(angle);
  76350. var c = Math.cos(angle);
  76351. 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);
  76352. result._updateIdentityStatus(c === 1 && s === 0);
  76353. };
  76354. /**
  76355. * Creates a new rotation matrix for "angle" radians around the given axis
  76356. * @param axis defines the axis to use
  76357. * @param angle defines the angle (in radians) to use
  76358. * @return the new matrix
  76359. */
  76360. Matrix.RotationAxis = function (axis, angle) {
  76361. var result = new Matrix();
  76362. Matrix.RotationAxisToRef(axis, angle, result);
  76363. return result;
  76364. };
  76365. /**
  76366. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  76367. * @param axis defines the axis to use
  76368. * @param angle defines the angle (in radians) to use
  76369. * @param result defines the target matrix
  76370. */
  76371. Matrix.RotationAxisToRef = function (axis, angle, result) {
  76372. var s = Math.sin(-angle);
  76373. var c = Math.cos(-angle);
  76374. var c1 = 1 - c;
  76375. axis.normalize();
  76376. var m = result._m;
  76377. m[0] = (axis.x * axis.x) * c1 + c;
  76378. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  76379. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  76380. m[3] = 0.0;
  76381. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  76382. m[5] = (axis.y * axis.y) * c1 + c;
  76383. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  76384. m[7] = 0.0;
  76385. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  76386. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  76387. m[10] = (axis.z * axis.z) * c1 + c;
  76388. m[11] = 0.0;
  76389. m[12] = 0.0;
  76390. m[13] = 0.0;
  76391. m[14] = 0.0;
  76392. m[15] = 1.0;
  76393. result._markAsUpdated();
  76394. };
  76395. /**
  76396. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  76397. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  76398. * @param from defines the vector to align
  76399. * @param to defines the vector to align to
  76400. * @param result defines the target matrix
  76401. */
  76402. Matrix.RotationAlignToRef = function (from, to, result) {
  76403. var v = Vector3.Cross(to, from);
  76404. var c = Vector3.Dot(to, from);
  76405. var k = 1 / (1 + c);
  76406. var m = result._m;
  76407. m[0] = v.x * v.x * k + c;
  76408. m[1] = v.y * v.x * k - v.z;
  76409. m[2] = v.z * v.x * k + v.y;
  76410. m[3] = 0;
  76411. m[4] = v.x * v.y * k + v.z;
  76412. m[5] = v.y * v.y * k + c;
  76413. m[6] = v.z * v.y * k - v.x;
  76414. m[7] = 0;
  76415. m[8] = v.x * v.z * k - v.y;
  76416. m[9] = v.y * v.z * k + v.x;
  76417. m[10] = v.z * v.z * k + c;
  76418. m[11] = 0;
  76419. m[12] = 0;
  76420. m[13] = 0;
  76421. m[14] = 0;
  76422. m[15] = 1;
  76423. result._markAsUpdated();
  76424. };
  76425. /**
  76426. * Creates a rotation matrix
  76427. * @param yaw defines the yaw angle in radians (Y axis)
  76428. * @param pitch defines the pitch angle in radians (X axis)
  76429. * @param roll defines the roll angle in radians (X axis)
  76430. * @returns the new rotation matrix
  76431. */
  76432. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  76433. var result = new Matrix();
  76434. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  76435. return result;
  76436. };
  76437. /**
  76438. * Creates a rotation matrix and stores it in a given matrix
  76439. * @param yaw defines the yaw angle in radians (Y axis)
  76440. * @param pitch defines the pitch angle in radians (X axis)
  76441. * @param roll defines the roll angle in radians (X axis)
  76442. * @param result defines the target matrix
  76443. */
  76444. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  76445. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  76446. MathTmp.Quaternion[0].toRotationMatrix(result);
  76447. };
  76448. /**
  76449. * Creates a scaling matrix
  76450. * @param x defines the scale factor on X axis
  76451. * @param y defines the scale factor on Y axis
  76452. * @param z defines the scale factor on Z axis
  76453. * @returns the new matrix
  76454. */
  76455. Matrix.Scaling = function (x, y, z) {
  76456. var result = new Matrix();
  76457. Matrix.ScalingToRef(x, y, z, result);
  76458. return result;
  76459. };
  76460. /**
  76461. * Creates a scaling matrix and stores it in a given matrix
  76462. * @param x defines the scale factor on X axis
  76463. * @param y defines the scale factor on Y axis
  76464. * @param z defines the scale factor on Z axis
  76465. * @param result defines the target matrix
  76466. */
  76467. Matrix.ScalingToRef = function (x, y, z, result) {
  76468. 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);
  76469. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  76470. };
  76471. /**
  76472. * Creates a translation matrix
  76473. * @param x defines the translation on X axis
  76474. * @param y defines the translation on Y axis
  76475. * @param z defines the translationon Z axis
  76476. * @returns the new matrix
  76477. */
  76478. Matrix.Translation = function (x, y, z) {
  76479. var result = new Matrix();
  76480. Matrix.TranslationToRef(x, y, z, result);
  76481. return result;
  76482. };
  76483. /**
  76484. * Creates a translation matrix and stores it in a given matrix
  76485. * @param x defines the translation on X axis
  76486. * @param y defines the translation on Y axis
  76487. * @param z defines the translationon Z axis
  76488. * @param result defines the target matrix
  76489. */
  76490. Matrix.TranslationToRef = function (x, y, z, result) {
  76491. 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);
  76492. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  76493. };
  76494. /**
  76495. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76496. * @param startValue defines the start value
  76497. * @param endValue defines the end value
  76498. * @param gradient defines the gradient factor
  76499. * @returns the new matrix
  76500. */
  76501. Matrix.Lerp = function (startValue, endValue, gradient) {
  76502. var result = new Matrix();
  76503. Matrix.LerpToRef(startValue, endValue, gradient, result);
  76504. return result;
  76505. };
  76506. /**
  76507. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76508. * @param startValue defines the start value
  76509. * @param endValue defines the end value
  76510. * @param gradient defines the gradient factor
  76511. * @param result defines the Matrix object where to store data
  76512. */
  76513. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  76514. var resultM = result._m;
  76515. var startM = startValue.m;
  76516. var endM = endValue.m;
  76517. for (var index = 0; index < 16; index++) {
  76518. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  76519. }
  76520. result._markAsUpdated();
  76521. };
  76522. /**
  76523. * Builds a new matrix whose values are computed by:
  76524. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76525. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76526. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76527. * @param startValue defines the first matrix
  76528. * @param endValue defines the second matrix
  76529. * @param gradient defines the gradient between the two matrices
  76530. * @returns the new matrix
  76531. */
  76532. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  76533. var result = new Matrix();
  76534. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  76535. return result;
  76536. };
  76537. /**
  76538. * Update a matrix to values which are computed by:
  76539. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76540. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76541. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76542. * @param startValue defines the first matrix
  76543. * @param endValue defines the second matrix
  76544. * @param gradient defines the gradient between the two matrices
  76545. * @param result defines the target matrix
  76546. */
  76547. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  76548. var startScale = MathTmp.Vector3[0];
  76549. var startRotation = MathTmp.Quaternion[0];
  76550. var startTranslation = MathTmp.Vector3[1];
  76551. startValue.decompose(startScale, startRotation, startTranslation);
  76552. var endScale = MathTmp.Vector3[2];
  76553. var endRotation = MathTmp.Quaternion[1];
  76554. var endTranslation = MathTmp.Vector3[3];
  76555. endValue.decompose(endScale, endRotation, endTranslation);
  76556. var resultScale = MathTmp.Vector3[4];
  76557. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  76558. var resultRotation = MathTmp.Quaternion[2];
  76559. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  76560. var resultTranslation = MathTmp.Vector3[5];
  76561. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  76562. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  76563. };
  76564. /**
  76565. * 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"
  76566. * This function works in left handed mode
  76567. * @param eye defines the final position of the entity
  76568. * @param target defines where the entity should look at
  76569. * @param up defines the up vector for the entity
  76570. * @returns the new matrix
  76571. */
  76572. Matrix.LookAtLH = function (eye, target, up) {
  76573. var result = new Matrix();
  76574. Matrix.LookAtLHToRef(eye, target, up, result);
  76575. return result;
  76576. };
  76577. /**
  76578. * 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".
  76579. * This function works in left handed mode
  76580. * @param eye defines the final position of the entity
  76581. * @param target defines where the entity should look at
  76582. * @param up defines the up vector for the entity
  76583. * @param result defines the target matrix
  76584. */
  76585. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  76586. var xAxis = MathTmp.Vector3[0];
  76587. var yAxis = MathTmp.Vector3[1];
  76588. var zAxis = MathTmp.Vector3[2];
  76589. // Z axis
  76590. target.subtractToRef(eye, zAxis);
  76591. zAxis.normalize();
  76592. // X axis
  76593. Vector3.CrossToRef(up, zAxis, xAxis);
  76594. var xSquareLength = xAxis.lengthSquared();
  76595. if (xSquareLength === 0) {
  76596. xAxis.x = 1.0;
  76597. }
  76598. else {
  76599. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  76600. }
  76601. // Y axis
  76602. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  76603. yAxis.normalize();
  76604. // Eye angles
  76605. var ex = -Vector3.Dot(xAxis, eye);
  76606. var ey = -Vector3.Dot(yAxis, eye);
  76607. var ez = -Vector3.Dot(zAxis, eye);
  76608. 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);
  76609. };
  76610. /**
  76611. * 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"
  76612. * This function works in right handed mode
  76613. * @param eye defines the final position of the entity
  76614. * @param target defines where the entity should look at
  76615. * @param up defines the up vector for the entity
  76616. * @returns the new matrix
  76617. */
  76618. Matrix.LookAtRH = function (eye, target, up) {
  76619. var result = new Matrix();
  76620. Matrix.LookAtRHToRef(eye, target, up, result);
  76621. return result;
  76622. };
  76623. /**
  76624. * 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".
  76625. * This function works in right handed mode
  76626. * @param eye defines the final position of the entity
  76627. * @param target defines where the entity should look at
  76628. * @param up defines the up vector for the entity
  76629. * @param result defines the target matrix
  76630. */
  76631. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  76632. var xAxis = MathTmp.Vector3[0];
  76633. var yAxis = MathTmp.Vector3[1];
  76634. var zAxis = MathTmp.Vector3[2];
  76635. // Z axis
  76636. eye.subtractToRef(target, zAxis);
  76637. zAxis.normalize();
  76638. // X axis
  76639. Vector3.CrossToRef(up, zAxis, xAxis);
  76640. var xSquareLength = xAxis.lengthSquared();
  76641. if (xSquareLength === 0) {
  76642. xAxis.x = 1.0;
  76643. }
  76644. else {
  76645. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  76646. }
  76647. // Y axis
  76648. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  76649. yAxis.normalize();
  76650. // Eye angles
  76651. var ex = -Vector3.Dot(xAxis, eye);
  76652. var ey = -Vector3.Dot(yAxis, eye);
  76653. var ez = -Vector3.Dot(zAxis, eye);
  76654. 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);
  76655. };
  76656. /**
  76657. * Create a left-handed orthographic projection matrix
  76658. * @param width defines the viewport width
  76659. * @param height defines the viewport height
  76660. * @param znear defines the near clip plane
  76661. * @param zfar defines the far clip plane
  76662. * @returns a new matrix as a left-handed orthographic projection matrix
  76663. */
  76664. Matrix.OrthoLH = function (width, height, znear, zfar) {
  76665. var matrix = new Matrix();
  76666. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  76667. return matrix;
  76668. };
  76669. /**
  76670. * Store a left-handed orthographic projection to a given matrix
  76671. * @param width defines the viewport width
  76672. * @param height defines the viewport height
  76673. * @param znear defines the near clip plane
  76674. * @param zfar defines the far clip plane
  76675. * @param result defines the target matrix
  76676. */
  76677. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  76678. var n = znear;
  76679. var f = zfar;
  76680. var a = 2.0 / width;
  76681. var b = 2.0 / height;
  76682. var c = 2.0 / (f - n);
  76683. var d = -(f + n) / (f - n);
  76684. 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);
  76685. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  76686. };
  76687. /**
  76688. * Create a left-handed orthographic projection matrix
  76689. * @param left defines the viewport left coordinate
  76690. * @param right defines the viewport right coordinate
  76691. * @param bottom defines the viewport bottom coordinate
  76692. * @param top defines the viewport top coordinate
  76693. * @param znear defines the near clip plane
  76694. * @param zfar defines the far clip plane
  76695. * @returns a new matrix as a left-handed orthographic projection matrix
  76696. */
  76697. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  76698. var matrix = new Matrix();
  76699. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  76700. return matrix;
  76701. };
  76702. /**
  76703. * Stores a left-handed orthographic projection into a given matrix
  76704. * @param left defines the viewport left coordinate
  76705. * @param right defines the viewport right coordinate
  76706. * @param bottom defines the viewport bottom coordinate
  76707. * @param top defines the viewport top coordinate
  76708. * @param znear defines the near clip plane
  76709. * @param zfar defines the far clip plane
  76710. * @param result defines the target matrix
  76711. */
  76712. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  76713. var n = znear;
  76714. var f = zfar;
  76715. var a = 2.0 / (right - left);
  76716. var b = 2.0 / (top - bottom);
  76717. var c = 2.0 / (f - n);
  76718. var d = -(f + n) / (f - n);
  76719. var i0 = (left + right) / (left - right);
  76720. var i1 = (top + bottom) / (bottom - top);
  76721. 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);
  76722. result._markAsUpdated();
  76723. };
  76724. /**
  76725. * Creates a right-handed orthographic projection matrix
  76726. * @param left defines the viewport left coordinate
  76727. * @param right defines the viewport right coordinate
  76728. * @param bottom defines the viewport bottom coordinate
  76729. * @param top defines the viewport top coordinate
  76730. * @param znear defines the near clip plane
  76731. * @param zfar defines the far clip plane
  76732. * @returns a new matrix as a right-handed orthographic projection matrix
  76733. */
  76734. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  76735. var matrix = new Matrix();
  76736. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  76737. return matrix;
  76738. };
  76739. /**
  76740. * Stores a right-handed orthographic projection into a given matrix
  76741. * @param left defines the viewport left coordinate
  76742. * @param right defines the viewport right coordinate
  76743. * @param bottom defines the viewport bottom coordinate
  76744. * @param top defines the viewport top coordinate
  76745. * @param znear defines the near clip plane
  76746. * @param zfar defines the far clip plane
  76747. * @param result defines the target matrix
  76748. */
  76749. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  76750. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  76751. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  76752. };
  76753. /**
  76754. * Creates a left-handed perspective projection matrix
  76755. * @param width defines the viewport width
  76756. * @param height defines the viewport height
  76757. * @param znear defines the near clip plane
  76758. * @param zfar defines the far clip plane
  76759. * @returns a new matrix as a left-handed perspective projection matrix
  76760. */
  76761. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  76762. var matrix = new Matrix();
  76763. var n = znear;
  76764. var f = zfar;
  76765. var a = 2.0 * n / width;
  76766. var b = 2.0 * n / height;
  76767. var c = (f + n) / (f - n);
  76768. var d = -2.0 * f * n / (f - n);
  76769. 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);
  76770. matrix._updateIdentityStatus(false);
  76771. return matrix;
  76772. };
  76773. /**
  76774. * Creates a left-handed perspective projection matrix
  76775. * @param fov defines the horizontal field of view
  76776. * @param aspect defines the aspect ratio
  76777. * @param znear defines the near clip plane
  76778. * @param zfar defines the far clip plane
  76779. * @returns a new matrix as a left-handed perspective projection matrix
  76780. */
  76781. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  76782. var matrix = new Matrix();
  76783. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  76784. return matrix;
  76785. };
  76786. /**
  76787. * Stores a left-handed perspective projection into a given matrix
  76788. * @param fov defines the horizontal field of view
  76789. * @param aspect defines the aspect ratio
  76790. * @param znear defines the near clip plane
  76791. * @param zfar defines the far clip plane
  76792. * @param result defines the target matrix
  76793. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76794. */
  76795. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  76796. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  76797. var n = znear;
  76798. var f = zfar;
  76799. var t = 1.0 / (Math.tan(fov * 0.5));
  76800. var a = isVerticalFovFixed ? (t / aspect) : t;
  76801. var b = isVerticalFovFixed ? t : (t * aspect);
  76802. var c = (f + n) / (f - n);
  76803. var d = -2.0 * f * n / (f - n);
  76804. 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);
  76805. result._updateIdentityStatus(false);
  76806. };
  76807. /**
  76808. * Creates a right-handed perspective projection matrix
  76809. * @param fov defines the horizontal field of view
  76810. * @param aspect defines the aspect ratio
  76811. * @param znear defines the near clip plane
  76812. * @param zfar defines the far clip plane
  76813. * @returns a new matrix as a right-handed perspective projection matrix
  76814. */
  76815. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  76816. var matrix = new Matrix();
  76817. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  76818. return matrix;
  76819. };
  76820. /**
  76821. * Stores a right-handed perspective projection into a given matrix
  76822. * @param fov defines the horizontal field of view
  76823. * @param aspect defines the aspect ratio
  76824. * @param znear defines the near clip plane
  76825. * @param zfar defines the far clip plane
  76826. * @param result defines the target matrix
  76827. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76828. */
  76829. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  76830. //alternatively this could be expressed as:
  76831. // m = PerspectiveFovLHToRef
  76832. // m[10] *= -1.0;
  76833. // m[11] *= -1.0;
  76834. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  76835. var n = znear;
  76836. var f = zfar;
  76837. var t = 1.0 / (Math.tan(fov * 0.5));
  76838. var a = isVerticalFovFixed ? (t / aspect) : t;
  76839. var b = isVerticalFovFixed ? t : (t * aspect);
  76840. var c = -(f + n) / (f - n);
  76841. var d = -2 * f * n / (f - n);
  76842. 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);
  76843. result._updateIdentityStatus(false);
  76844. };
  76845. /**
  76846. * Stores a perspective projection for WebVR info a given matrix
  76847. * @param fov defines the field of view
  76848. * @param znear defines the near clip plane
  76849. * @param zfar defines the far clip plane
  76850. * @param result defines the target matrix
  76851. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  76852. */
  76853. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  76854. if (rightHanded === void 0) { rightHanded = false; }
  76855. var rightHandedFactor = rightHanded ? -1 : 1;
  76856. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  76857. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  76858. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  76859. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  76860. var xScale = 2.0 / (leftTan + rightTan);
  76861. var yScale = 2.0 / (upTan + downTan);
  76862. var m = result._m;
  76863. m[0] = xScale;
  76864. m[1] = m[2] = m[3] = m[4] = 0.0;
  76865. m[5] = yScale;
  76866. m[6] = m[7] = 0.0;
  76867. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  76868. m[9] = -((upTan - downTan) * yScale * 0.5);
  76869. m[10] = -zfar / (znear - zfar);
  76870. m[11] = 1.0 * rightHandedFactor;
  76871. m[12] = m[13] = m[15] = 0.0;
  76872. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  76873. result._markAsUpdated();
  76874. };
  76875. /**
  76876. * Computes a complete transformation matrix
  76877. * @param viewport defines the viewport to use
  76878. * @param world defines the world matrix
  76879. * @param view defines the view matrix
  76880. * @param projection defines the projection matrix
  76881. * @param zmin defines the near clip plane
  76882. * @param zmax defines the far clip plane
  76883. * @returns the transformation matrix
  76884. */
  76885. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  76886. var cw = viewport.width;
  76887. var ch = viewport.height;
  76888. var cx = viewport.x;
  76889. var cy = viewport.y;
  76890. 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);
  76891. var matrix = MathTmp.Matrix[0];
  76892. world.multiplyToRef(view, matrix);
  76893. matrix.multiplyToRef(projection, matrix);
  76894. return matrix.multiply(viewportMatrix);
  76895. };
  76896. /**
  76897. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  76898. * @param matrix defines the matrix to use
  76899. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  76900. */
  76901. Matrix.GetAsMatrix2x2 = function (matrix) {
  76902. var m = matrix.m;
  76903. return new Float32Array([m[0], m[1], m[4], m[5]]);
  76904. };
  76905. /**
  76906. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  76907. * @param matrix defines the matrix to use
  76908. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  76909. */
  76910. Matrix.GetAsMatrix3x3 = function (matrix) {
  76911. var m = matrix.m;
  76912. return new Float32Array([
  76913. m[0], m[1], m[2],
  76914. m[4], m[5], m[6],
  76915. m[8], m[9], m[10]
  76916. ]);
  76917. };
  76918. /**
  76919. * Compute the transpose of a given matrix
  76920. * @param matrix defines the matrix to transpose
  76921. * @returns the new matrix
  76922. */
  76923. Matrix.Transpose = function (matrix) {
  76924. var result = new Matrix();
  76925. Matrix.TransposeToRef(matrix, result);
  76926. return result;
  76927. };
  76928. /**
  76929. * Compute the transpose of a matrix and store it in a target matrix
  76930. * @param matrix defines the matrix to transpose
  76931. * @param result defines the target matrix
  76932. */
  76933. Matrix.TransposeToRef = function (matrix, result) {
  76934. var rm = result._m;
  76935. var mm = matrix.m;
  76936. rm[0] = mm[0];
  76937. rm[1] = mm[4];
  76938. rm[2] = mm[8];
  76939. rm[3] = mm[12];
  76940. rm[4] = mm[1];
  76941. rm[5] = mm[5];
  76942. rm[6] = mm[9];
  76943. rm[7] = mm[13];
  76944. rm[8] = mm[2];
  76945. rm[9] = mm[6];
  76946. rm[10] = mm[10];
  76947. rm[11] = mm[14];
  76948. rm[12] = mm[3];
  76949. rm[13] = mm[7];
  76950. rm[14] = mm[11];
  76951. rm[15] = mm[15];
  76952. // identity-ness does not change when transposing
  76953. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  76954. };
  76955. /**
  76956. * Computes a reflection matrix from a plane
  76957. * @param plane defines the reflection plane
  76958. * @returns a new matrix
  76959. */
  76960. Matrix.Reflection = function (plane) {
  76961. var matrix = new Matrix();
  76962. Matrix.ReflectionToRef(plane, matrix);
  76963. return matrix;
  76964. };
  76965. /**
  76966. * Computes a reflection matrix from a plane
  76967. * @param plane defines the reflection plane
  76968. * @param result defines the target matrix
  76969. */
  76970. Matrix.ReflectionToRef = function (plane, result) {
  76971. plane.normalize();
  76972. var x = plane.normal.x;
  76973. var y = plane.normal.y;
  76974. var z = plane.normal.z;
  76975. var temp = -2 * x;
  76976. var temp2 = -2 * y;
  76977. var temp3 = -2 * z;
  76978. 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);
  76979. };
  76980. /**
  76981. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  76982. * @param xaxis defines the value of the 1st axis
  76983. * @param yaxis defines the value of the 2nd axis
  76984. * @param zaxis defines the value of the 3rd axis
  76985. * @param result defines the target matrix
  76986. */
  76987. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  76988. 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);
  76989. };
  76990. /**
  76991. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  76992. * @param quat defines the quaternion to use
  76993. * @param result defines the target matrix
  76994. */
  76995. Matrix.FromQuaternionToRef = function (quat, result) {
  76996. var xx = quat.x * quat.x;
  76997. var yy = quat.y * quat.y;
  76998. var zz = quat.z * quat.z;
  76999. var xy = quat.x * quat.y;
  77000. var zw = quat.z * quat.w;
  77001. var zx = quat.z * quat.x;
  77002. var yw = quat.y * quat.w;
  77003. var yz = quat.y * quat.z;
  77004. var xw = quat.x * quat.w;
  77005. result._m[0] = 1.0 - (2.0 * (yy + zz));
  77006. result._m[1] = 2.0 * (xy + zw);
  77007. result._m[2] = 2.0 * (zx - yw);
  77008. result._m[3] = 0.0;
  77009. result._m[4] = 2.0 * (xy - zw);
  77010. result._m[5] = 1.0 - (2.0 * (zz + xx));
  77011. result._m[6] = 2.0 * (yz + xw);
  77012. result._m[7] = 0.0;
  77013. result._m[8] = 2.0 * (zx + yw);
  77014. result._m[9] = 2.0 * (yz - xw);
  77015. result._m[10] = 1.0 - (2.0 * (yy + xx));
  77016. result._m[11] = 0.0;
  77017. result._m[12] = 0.0;
  77018. result._m[13] = 0.0;
  77019. result._m[14] = 0.0;
  77020. result._m[15] = 1.0;
  77021. result._markAsUpdated();
  77022. };
  77023. Matrix._updateFlagSeed = 0;
  77024. Matrix._identityReadOnly = Matrix.Identity();
  77025. return Matrix;
  77026. }());
  77027. /**
  77028. * Represens a plane by the equation ax + by + cz + d = 0
  77029. */
  77030. var Plane = /** @class */ (function () {
  77031. /**
  77032. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77033. * @param a a component of the plane
  77034. * @param b b component of the plane
  77035. * @param c c component of the plane
  77036. * @param d d component of the plane
  77037. */
  77038. function Plane(a, b, c, d) {
  77039. this.normal = new Vector3(a, b, c);
  77040. this.d = d;
  77041. }
  77042. /**
  77043. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77044. */
  77045. Plane.prototype.asArray = function () {
  77046. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  77047. };
  77048. // Methods
  77049. /**
  77050. * @returns a new plane copied from the current Plane.
  77051. */
  77052. Plane.prototype.clone = function () {
  77053. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  77054. };
  77055. /**
  77056. * @returns the string "Plane".
  77057. */
  77058. Plane.prototype.getClassName = function () {
  77059. return "Plane";
  77060. };
  77061. /**
  77062. * @returns the Plane hash code.
  77063. */
  77064. Plane.prototype.getHashCode = function () {
  77065. var hash = this.normal.getHashCode();
  77066. hash = (hash * 397) ^ (this.d || 0);
  77067. return hash;
  77068. };
  77069. /**
  77070. * Normalize the current Plane in place.
  77071. * @returns the updated Plane.
  77072. */
  77073. Plane.prototype.normalize = function () {
  77074. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  77075. var magnitude = 0.0;
  77076. if (norm !== 0) {
  77077. magnitude = 1.0 / norm;
  77078. }
  77079. this.normal.x *= magnitude;
  77080. this.normal.y *= magnitude;
  77081. this.normal.z *= magnitude;
  77082. this.d *= magnitude;
  77083. return this;
  77084. };
  77085. /**
  77086. * Applies a transformation the plane and returns the result
  77087. * @param transformation the transformation matrix to be applied to the plane
  77088. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77089. */
  77090. Plane.prototype.transform = function (transformation) {
  77091. var transposedMatrix = MathTmp.Matrix[0];
  77092. Matrix.TransposeToRef(transformation, transposedMatrix);
  77093. var m = transposedMatrix.m;
  77094. var x = this.normal.x;
  77095. var y = this.normal.y;
  77096. var z = this.normal.z;
  77097. var d = this.d;
  77098. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  77099. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  77100. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  77101. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  77102. return new Plane(normalX, normalY, normalZ, finalD);
  77103. };
  77104. /**
  77105. * Calcualtte the dot product between the point and the plane normal
  77106. * @param point point to calculate the dot product with
  77107. * @returns the dot product (float) of the point coordinates and the plane normal.
  77108. */
  77109. Plane.prototype.dotCoordinate = function (point) {
  77110. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  77111. };
  77112. /**
  77113. * Updates the current Plane from the plane defined by the three given points.
  77114. * @param point1 one of the points used to contruct the plane
  77115. * @param point2 one of the points used to contruct the plane
  77116. * @param point3 one of the points used to contruct the plane
  77117. * @returns the updated Plane.
  77118. */
  77119. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  77120. var x1 = point2.x - point1.x;
  77121. var y1 = point2.y - point1.y;
  77122. var z1 = point2.z - point1.z;
  77123. var x2 = point3.x - point1.x;
  77124. var y2 = point3.y - point1.y;
  77125. var z2 = point3.z - point1.z;
  77126. var yz = (y1 * z2) - (z1 * y2);
  77127. var xz = (z1 * x2) - (x1 * z2);
  77128. var xy = (x1 * y2) - (y1 * x2);
  77129. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  77130. var invPyth;
  77131. if (pyth !== 0) {
  77132. invPyth = 1.0 / pyth;
  77133. }
  77134. else {
  77135. invPyth = 0.0;
  77136. }
  77137. this.normal.x = yz * invPyth;
  77138. this.normal.y = xz * invPyth;
  77139. this.normal.z = xy * invPyth;
  77140. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  77141. return this;
  77142. };
  77143. /**
  77144. * Checks if the plane is facing a given direction
  77145. * @param direction the direction to check if the plane is facing
  77146. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77147. * @returns True is the vector "direction" is the same side than the plane normal.
  77148. */
  77149. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  77150. var dot = Vector3.Dot(this.normal, direction);
  77151. return (dot <= epsilon);
  77152. };
  77153. /**
  77154. * Calculates the distance to a point
  77155. * @param point point to calculate distance to
  77156. * @returns the signed distance (float) from the given point to the Plane.
  77157. */
  77158. Plane.prototype.signedDistanceTo = function (point) {
  77159. return Vector3.Dot(point, this.normal) + this.d;
  77160. };
  77161. // Statics
  77162. /**
  77163. * Creates a plane from an array
  77164. * @param array the array to create a plane from
  77165. * @returns a new Plane from the given array.
  77166. */
  77167. Plane.FromArray = function (array) {
  77168. return new Plane(array[0], array[1], array[2], array[3]);
  77169. };
  77170. /**
  77171. * Creates a plane from three points
  77172. * @param point1 point used to create the plane
  77173. * @param point2 point used to create the plane
  77174. * @param point3 point used to create the plane
  77175. * @returns a new Plane defined by the three given points.
  77176. */
  77177. Plane.FromPoints = function (point1, point2, point3) {
  77178. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  77179. result.copyFromPoints(point1, point2, point3);
  77180. return result;
  77181. };
  77182. /**
  77183. * Creates a plane from an origin point and a normal
  77184. * @param origin origin of the plane to be constructed
  77185. * @param normal normal of the plane to be constructed
  77186. * @returns a new Plane the normal vector to this plane at the given origin point.
  77187. * Note : the vector "normal" is updated because normalized.
  77188. */
  77189. Plane.FromPositionAndNormal = function (origin, normal) {
  77190. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  77191. normal.normalize();
  77192. result.normal = normal;
  77193. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  77194. return result;
  77195. };
  77196. /**
  77197. * Calculates the distance from a plane and a point
  77198. * @param origin origin of the plane to be constructed
  77199. * @param normal normal of the plane to be constructed
  77200. * @param point point to calculate distance to
  77201. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77202. */
  77203. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  77204. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  77205. return Vector3.Dot(point, normal) + d;
  77206. };
  77207. return Plane;
  77208. }());
  77209. /**
  77210. * Class used to represent a viewport on screen
  77211. */
  77212. var Viewport = /** @class */ (function () {
  77213. /**
  77214. * Creates a Viewport object located at (x, y) and sized (width, height)
  77215. * @param x defines viewport left coordinate
  77216. * @param y defines viewport top coordinate
  77217. * @param width defines the viewport width
  77218. * @param height defines the viewport height
  77219. */
  77220. function Viewport(
  77221. /** viewport left coordinate */
  77222. x,
  77223. /** viewport top coordinate */
  77224. y,
  77225. /**viewport width */
  77226. width,
  77227. /** viewport height */
  77228. height) {
  77229. this.x = x;
  77230. this.y = y;
  77231. this.width = width;
  77232. this.height = height;
  77233. }
  77234. /**
  77235. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  77236. * @param renderWidth defines the rendering width
  77237. * @param renderHeight defines the rendering height
  77238. * @returns a new Viewport
  77239. */
  77240. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  77241. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  77242. };
  77243. /**
  77244. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  77245. * @param renderWidth defines the rendering width
  77246. * @param renderHeight defines the rendering height
  77247. * @param ref defines the target viewport
  77248. * @returns the current viewport
  77249. */
  77250. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  77251. ref.x = this.x * renderWidth;
  77252. ref.y = this.y * renderHeight;
  77253. ref.width = this.width * renderWidth;
  77254. ref.height = this.height * renderHeight;
  77255. return this;
  77256. };
  77257. /**
  77258. * Returns a new Viewport copied from the current one
  77259. * @returns a new Viewport
  77260. */
  77261. Viewport.prototype.clone = function () {
  77262. return new Viewport(this.x, this.y, this.width, this.height);
  77263. };
  77264. return Viewport;
  77265. }());
  77266. /**
  77267. * Reprasents a camera frustum
  77268. */
  77269. var Frustum = /** @class */ (function () {
  77270. function Frustum() {
  77271. }
  77272. /**
  77273. * Gets the planes representing the frustum
  77274. * @param transform matrix to be applied to the returned planes
  77275. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  77276. */
  77277. Frustum.GetPlanes = function (transform) {
  77278. var frustumPlanes = [];
  77279. for (var index = 0; index < 6; index++) {
  77280. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  77281. }
  77282. Frustum.GetPlanesToRef(transform, frustumPlanes);
  77283. return frustumPlanes;
  77284. };
  77285. /**
  77286. * Gets the near frustum plane transformed by the transform matrix
  77287. * @param transform transformation matrix to be applied to the resulting frustum plane
  77288. * @param frustumPlane the resuling frustum plane
  77289. */
  77290. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  77291. var m = transform.m;
  77292. frustumPlane.normal.x = m[3] + m[2];
  77293. frustumPlane.normal.y = m[7] + m[6];
  77294. frustumPlane.normal.z = m[11] + m[10];
  77295. frustumPlane.d = m[15] + m[14];
  77296. frustumPlane.normalize();
  77297. };
  77298. /**
  77299. * Gets the far frustum plane transformed by the transform matrix
  77300. * @param transform transformation matrix to be applied to the resulting frustum plane
  77301. * @param frustumPlane the resuling frustum plane
  77302. */
  77303. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  77304. var m = transform.m;
  77305. frustumPlane.normal.x = m[3] - m[2];
  77306. frustumPlane.normal.y = m[7] - m[6];
  77307. frustumPlane.normal.z = m[11] - m[10];
  77308. frustumPlane.d = m[15] - m[14];
  77309. frustumPlane.normalize();
  77310. };
  77311. /**
  77312. * Gets the left frustum plane transformed by the transform matrix
  77313. * @param transform transformation matrix to be applied to the resulting frustum plane
  77314. * @param frustumPlane the resuling frustum plane
  77315. */
  77316. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  77317. var m = transform.m;
  77318. frustumPlane.normal.x = m[3] + m[0];
  77319. frustumPlane.normal.y = m[7] + m[4];
  77320. frustumPlane.normal.z = m[11] + m[8];
  77321. frustumPlane.d = m[15] + m[12];
  77322. frustumPlane.normalize();
  77323. };
  77324. /**
  77325. * Gets the right frustum plane transformed by the transform matrix
  77326. * @param transform transformation matrix to be applied to the resulting frustum plane
  77327. * @param frustumPlane the resuling frustum plane
  77328. */
  77329. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  77330. var m = transform.m;
  77331. frustumPlane.normal.x = m[3] - m[0];
  77332. frustumPlane.normal.y = m[7] - m[4];
  77333. frustumPlane.normal.z = m[11] - m[8];
  77334. frustumPlane.d = m[15] - m[12];
  77335. frustumPlane.normalize();
  77336. };
  77337. /**
  77338. * Gets the top frustum plane transformed by the transform matrix
  77339. * @param transform transformation matrix to be applied to the resulting frustum plane
  77340. * @param frustumPlane the resuling frustum plane
  77341. */
  77342. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  77343. var m = transform.m;
  77344. frustumPlane.normal.x = m[3] - m[1];
  77345. frustumPlane.normal.y = m[7] - m[5];
  77346. frustumPlane.normal.z = m[11] - m[9];
  77347. frustumPlane.d = m[15] - m[13];
  77348. frustumPlane.normalize();
  77349. };
  77350. /**
  77351. * Gets the bottom frustum plane transformed by the transform matrix
  77352. * @param transform transformation matrix to be applied to the resulting frustum plane
  77353. * @param frustumPlane the resuling frustum plane
  77354. */
  77355. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  77356. var m = transform.m;
  77357. frustumPlane.normal.x = m[3] + m[1];
  77358. frustumPlane.normal.y = m[7] + m[5];
  77359. frustumPlane.normal.z = m[11] + m[9];
  77360. frustumPlane.d = m[15] + m[13];
  77361. frustumPlane.normalize();
  77362. };
  77363. /**
  77364. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  77365. * @param transform transformation matrix to be applied to the resulting frustum planes
  77366. * @param frustumPlanes the resuling frustum planes
  77367. */
  77368. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  77369. // Near
  77370. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  77371. // Far
  77372. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  77373. // Left
  77374. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  77375. // Right
  77376. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  77377. // Top
  77378. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  77379. // Bottom
  77380. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  77381. };
  77382. return Frustum;
  77383. }());
  77384. /** Defines supported spaces */
  77385. var Space;
  77386. (function (Space) {
  77387. /** Local (object) space */
  77388. Space[Space["LOCAL"] = 0] = "LOCAL";
  77389. /** World space */
  77390. Space[Space["WORLD"] = 1] = "WORLD";
  77391. /** Bone space */
  77392. Space[Space["BONE"] = 2] = "BONE";
  77393. })(Space || (Space = {}));
  77394. /** Defines the 3 main axes */
  77395. var Axis = /** @class */ (function () {
  77396. function Axis() {
  77397. }
  77398. /** X axis */
  77399. Axis.X = new Vector3(1.0, 0.0, 0.0);
  77400. /** Y axis */
  77401. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  77402. /** Z axis */
  77403. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  77404. return Axis;
  77405. }());
  77406. /** Class used to represent a Bezier curve */
  77407. var BezierCurve = /** @class */ (function () {
  77408. function BezierCurve() {
  77409. }
  77410. /**
  77411. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77412. * @param t defines the time
  77413. * @param x1 defines the left coordinate on X axis
  77414. * @param y1 defines the left coordinate on Y axis
  77415. * @param x2 defines the right coordinate on X axis
  77416. * @param y2 defines the right coordinate on Y axis
  77417. * @returns the interpolated value
  77418. */
  77419. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  77420. // Extract X (which is equal to time here)
  77421. var f0 = 1 - 3 * x2 + 3 * x1;
  77422. var f1 = 3 * x2 - 6 * x1;
  77423. var f2 = 3 * x1;
  77424. var refinedT = t;
  77425. for (var i = 0; i < 5; i++) {
  77426. var refinedT2 = refinedT * refinedT;
  77427. var refinedT3 = refinedT2 * refinedT;
  77428. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  77429. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  77430. refinedT -= (x - t) * slope;
  77431. refinedT = Math.min(1, Math.max(0, refinedT));
  77432. }
  77433. // Resolve cubic bezier for the given x
  77434. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  77435. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  77436. Math.pow(refinedT, 3);
  77437. };
  77438. return BezierCurve;
  77439. }());
  77440. /**
  77441. * Defines potential orientation for back face culling
  77442. */
  77443. var Orientation;
  77444. (function (Orientation) {
  77445. /**
  77446. * Clockwise
  77447. */
  77448. Orientation[Orientation["CW"] = 0] = "CW";
  77449. /** Counter clockwise */
  77450. Orientation[Orientation["CCW"] = 1] = "CCW";
  77451. })(Orientation || (Orientation = {}));
  77452. /**
  77453. * Defines angle representation
  77454. */
  77455. var Angle = /** @class */ (function () {
  77456. /**
  77457. * Creates an Angle object of "radians" radians (float).
  77458. * @param radians the angle in radians
  77459. */
  77460. function Angle(radians) {
  77461. this._radians = radians;
  77462. if (this._radians < 0.0) {
  77463. this._radians += (2.0 * Math.PI);
  77464. }
  77465. }
  77466. /**
  77467. * Get value in degrees
  77468. * @returns the Angle value in degrees (float)
  77469. */
  77470. Angle.prototype.degrees = function () {
  77471. return this._radians * 180.0 / Math.PI;
  77472. };
  77473. /**
  77474. * Get value in radians
  77475. * @returns the Angle value in radians (float)
  77476. */
  77477. Angle.prototype.radians = function () {
  77478. return this._radians;
  77479. };
  77480. /**
  77481. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77482. * @param a defines first vector
  77483. * @param b defines second vector
  77484. * @returns a new Angle
  77485. */
  77486. Angle.BetweenTwoPoints = function (a, b) {
  77487. var delta = b.subtract(a);
  77488. var theta = Math.atan2(delta.y, delta.x);
  77489. return new Angle(theta);
  77490. };
  77491. /**
  77492. * Gets a new Angle object from the given float in radians
  77493. * @param radians defines the angle value in radians
  77494. * @returns a new Angle
  77495. */
  77496. Angle.FromRadians = function (radians) {
  77497. return new Angle(radians);
  77498. };
  77499. /**
  77500. * Gets a new Angle object from the given float in degrees
  77501. * @param degrees defines the angle value in degrees
  77502. * @returns a new Angle
  77503. */
  77504. Angle.FromDegrees = function (degrees) {
  77505. return new Angle(degrees * Math.PI / 180.0);
  77506. };
  77507. return Angle;
  77508. }());
  77509. /**
  77510. * This represents an arc in a 2d space.
  77511. */
  77512. var Arc2 = /** @class */ (function () {
  77513. /**
  77514. * Creates an Arc object from the three given points : start, middle and end.
  77515. * @param startPoint Defines the start point of the arc
  77516. * @param midPoint Defines the midlle point of the arc
  77517. * @param endPoint Defines the end point of the arc
  77518. */
  77519. function Arc2(
  77520. /** Defines the start point of the arc */
  77521. startPoint,
  77522. /** Defines the mid point of the arc */
  77523. midPoint,
  77524. /** Defines the end point of the arc */
  77525. endPoint) {
  77526. this.startPoint = startPoint;
  77527. this.midPoint = midPoint;
  77528. this.endPoint = endPoint;
  77529. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  77530. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  77531. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  77532. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  77533. 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);
  77534. this.radius = this.centerPoint.subtract(this.startPoint).length();
  77535. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  77536. var a1 = this.startAngle.degrees();
  77537. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  77538. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  77539. // angles correction
  77540. if (a2 - a1 > +180.0) {
  77541. a2 -= 360.0;
  77542. }
  77543. if (a2 - a1 < -180.0) {
  77544. a2 += 360.0;
  77545. }
  77546. if (a3 - a2 > +180.0) {
  77547. a3 -= 360.0;
  77548. }
  77549. if (a3 - a2 < -180.0) {
  77550. a3 += 360.0;
  77551. }
  77552. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  77553. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  77554. }
  77555. return Arc2;
  77556. }());
  77557. /**
  77558. * Represents a 2D path made up of multiple 2D points
  77559. */
  77560. var Path2 = /** @class */ (function () {
  77561. /**
  77562. * Creates a Path2 object from the starting 2D coordinates x and y.
  77563. * @param x the starting points x value
  77564. * @param y the starting points y value
  77565. */
  77566. function Path2(x, y) {
  77567. this._points = new Array();
  77568. this._length = 0.0;
  77569. /**
  77570. * If the path start and end point are the same
  77571. */
  77572. this.closed = false;
  77573. this._points.push(new Vector2(x, y));
  77574. }
  77575. /**
  77576. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77577. * @param x the added points x value
  77578. * @param y the added points y value
  77579. * @returns the updated Path2.
  77580. */
  77581. Path2.prototype.addLineTo = function (x, y) {
  77582. if (this.closed) {
  77583. return this;
  77584. }
  77585. var newPoint = new Vector2(x, y);
  77586. var previousPoint = this._points[this._points.length - 1];
  77587. this._points.push(newPoint);
  77588. this._length += newPoint.subtract(previousPoint).length();
  77589. return this;
  77590. };
  77591. /**
  77592. * 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.
  77593. * @param midX middle point x value
  77594. * @param midY middle point y value
  77595. * @param endX end point x value
  77596. * @param endY end point y value
  77597. * @param numberOfSegments (default: 36)
  77598. * @returns the updated Path2.
  77599. */
  77600. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  77601. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  77602. if (this.closed) {
  77603. return this;
  77604. }
  77605. var startPoint = this._points[this._points.length - 1];
  77606. var midPoint = new Vector2(midX, midY);
  77607. var endPoint = new Vector2(endX, endY);
  77608. var arc = new Arc2(startPoint, midPoint, endPoint);
  77609. var increment = arc.angle.radians() / numberOfSegments;
  77610. if (arc.orientation === Orientation.CW) {
  77611. increment *= -1;
  77612. }
  77613. var currentAngle = arc.startAngle.radians() + increment;
  77614. for (var i = 0; i < numberOfSegments; i++) {
  77615. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  77616. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  77617. this.addLineTo(x, y);
  77618. currentAngle += increment;
  77619. }
  77620. return this;
  77621. };
  77622. /**
  77623. * Closes the Path2.
  77624. * @returns the Path2.
  77625. */
  77626. Path2.prototype.close = function () {
  77627. this.closed = true;
  77628. return this;
  77629. };
  77630. /**
  77631. * Gets the sum of the distance between each sequential point in the path
  77632. * @returns the Path2 total length (float).
  77633. */
  77634. Path2.prototype.length = function () {
  77635. var result = this._length;
  77636. if (!this.closed) {
  77637. var lastPoint = this._points[this._points.length - 1];
  77638. var firstPoint = this._points[0];
  77639. result += (firstPoint.subtract(lastPoint).length());
  77640. }
  77641. return result;
  77642. };
  77643. /**
  77644. * Gets the points which construct the path
  77645. * @returns the Path2 internal array of points.
  77646. */
  77647. Path2.prototype.getPoints = function () {
  77648. return this._points;
  77649. };
  77650. /**
  77651. * Retreives the point at the distance aways from the starting point
  77652. * @param normalizedLengthPosition the length along the path to retreive the point from
  77653. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  77654. */
  77655. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  77656. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  77657. return Vector2.Zero();
  77658. }
  77659. var lengthPosition = normalizedLengthPosition * this.length();
  77660. var previousOffset = 0;
  77661. for (var i = 0; i < this._points.length; i++) {
  77662. var j = (i + 1) % this._points.length;
  77663. var a = this._points[i];
  77664. var b = this._points[j];
  77665. var bToA = b.subtract(a);
  77666. var nextOffset = (bToA.length() + previousOffset);
  77667. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  77668. var dir = bToA.normalize();
  77669. var localOffset = lengthPosition - previousOffset;
  77670. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  77671. }
  77672. previousOffset = nextOffset;
  77673. }
  77674. return Vector2.Zero();
  77675. };
  77676. /**
  77677. * Creates a new path starting from an x and y position
  77678. * @param x starting x value
  77679. * @param y starting y value
  77680. * @returns a new Path2 starting at the coordinates (x, y).
  77681. */
  77682. Path2.StartingAt = function (x, y) {
  77683. return new Path2(x, y);
  77684. };
  77685. return Path2;
  77686. }());
  77687. /**
  77688. * Represents a 3D path made up of multiple 3D points
  77689. */
  77690. var Path3D = /** @class */ (function () {
  77691. /**
  77692. * new Path3D(path, normal, raw)
  77693. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  77694. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  77695. * @param path an array of Vector3, the curve axis of the Path3D
  77696. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  77697. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  77698. */
  77699. function Path3D(
  77700. /**
  77701. * an array of Vector3, the curve axis of the Path3D
  77702. */
  77703. path, firstNormal, raw) {
  77704. if (firstNormal === void 0) { firstNormal = null; }
  77705. this.path = path;
  77706. this._curve = new Array();
  77707. this._distances = new Array();
  77708. this._tangents = new Array();
  77709. this._normals = new Array();
  77710. this._binormals = new Array();
  77711. for (var p = 0; p < path.length; p++) {
  77712. this._curve[p] = path[p].clone(); // hard copy
  77713. }
  77714. this._raw = raw || false;
  77715. this._compute(firstNormal);
  77716. }
  77717. /**
  77718. * Returns the Path3D array of successive Vector3 designing its curve.
  77719. * @returns the Path3D array of successive Vector3 designing its curve.
  77720. */
  77721. Path3D.prototype.getCurve = function () {
  77722. return this._curve;
  77723. };
  77724. /**
  77725. * Returns an array populated with tangent vectors on each Path3D curve point.
  77726. * @returns an array populated with tangent vectors on each Path3D curve point.
  77727. */
  77728. Path3D.prototype.getTangents = function () {
  77729. return this._tangents;
  77730. };
  77731. /**
  77732. * Returns an array populated with normal vectors on each Path3D curve point.
  77733. * @returns an array populated with normal vectors on each Path3D curve point.
  77734. */
  77735. Path3D.prototype.getNormals = function () {
  77736. return this._normals;
  77737. };
  77738. /**
  77739. * Returns an array populated with binormal vectors on each Path3D curve point.
  77740. * @returns an array populated with binormal vectors on each Path3D curve point.
  77741. */
  77742. Path3D.prototype.getBinormals = function () {
  77743. return this._binormals;
  77744. };
  77745. /**
  77746. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  77747. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  77748. */
  77749. Path3D.prototype.getDistances = function () {
  77750. return this._distances;
  77751. };
  77752. /**
  77753. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  77754. * @param path path which all values are copied into the curves points
  77755. * @param firstNormal which should be projected onto the curve
  77756. * @returns the same object updated.
  77757. */
  77758. Path3D.prototype.update = function (path, firstNormal) {
  77759. if (firstNormal === void 0) { firstNormal = null; }
  77760. for (var p = 0; p < path.length; p++) {
  77761. this._curve[p].x = path[p].x;
  77762. this._curve[p].y = path[p].y;
  77763. this._curve[p].z = path[p].z;
  77764. }
  77765. this._compute(firstNormal);
  77766. return this;
  77767. };
  77768. // private function compute() : computes tangents, normals and binormals
  77769. Path3D.prototype._compute = function (firstNormal) {
  77770. var l = this._curve.length;
  77771. // first and last tangents
  77772. this._tangents[0] = this._getFirstNonNullVector(0);
  77773. if (!this._raw) {
  77774. this._tangents[0].normalize();
  77775. }
  77776. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  77777. if (!this._raw) {
  77778. this._tangents[l - 1].normalize();
  77779. }
  77780. // normals and binormals at first point : arbitrary vector with _normalVector()
  77781. var tg0 = this._tangents[0];
  77782. var pp0 = this._normalVector(tg0, firstNormal);
  77783. this._normals[0] = pp0;
  77784. if (!this._raw) {
  77785. this._normals[0].normalize();
  77786. }
  77787. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  77788. if (!this._raw) {
  77789. this._binormals[0].normalize();
  77790. }
  77791. this._distances[0] = 0.0;
  77792. // normals and binormals : next points
  77793. var prev; // previous vector (segment)
  77794. var cur; // current vector (segment)
  77795. var curTang; // current tangent
  77796. // previous normal
  77797. var prevBinor; // previous binormal
  77798. for (var i = 1; i < l; i++) {
  77799. // tangents
  77800. prev = this._getLastNonNullVector(i);
  77801. if (i < l - 1) {
  77802. cur = this._getFirstNonNullVector(i);
  77803. this._tangents[i] = prev.add(cur);
  77804. this._tangents[i].normalize();
  77805. }
  77806. this._distances[i] = this._distances[i - 1] + prev.length();
  77807. // normals and binormals
  77808. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  77809. curTang = this._tangents[i];
  77810. prevBinor = this._binormals[i - 1];
  77811. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  77812. if (!this._raw) {
  77813. this._normals[i].normalize();
  77814. }
  77815. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  77816. if (!this._raw) {
  77817. this._binormals[i].normalize();
  77818. }
  77819. }
  77820. };
  77821. // private function getFirstNonNullVector(index)
  77822. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  77823. Path3D.prototype._getFirstNonNullVector = function (index) {
  77824. var i = 1;
  77825. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  77826. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  77827. i++;
  77828. nNVector = this._curve[index + i].subtract(this._curve[index]);
  77829. }
  77830. return nNVector;
  77831. };
  77832. // private function getLastNonNullVector(index)
  77833. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  77834. Path3D.prototype._getLastNonNullVector = function (index) {
  77835. var i = 1;
  77836. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  77837. while (nLVector.length() === 0 && index > i + 1) {
  77838. i++;
  77839. nLVector = this._curve[index].subtract(this._curve[index - i]);
  77840. }
  77841. return nLVector;
  77842. };
  77843. // private function normalVector(v0, vt, va) :
  77844. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  77845. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  77846. Path3D.prototype._normalVector = function (vt, va) {
  77847. var normal0;
  77848. var tgl = vt.length();
  77849. if (tgl === 0.0) {
  77850. tgl = 1.0;
  77851. }
  77852. if (va === undefined || va === null) {
  77853. var point;
  77854. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  77855. point = new Vector3(0.0, -1.0, 0.0);
  77856. }
  77857. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  77858. point = new Vector3(1.0, 0.0, 0.0);
  77859. }
  77860. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  77861. point = new Vector3(0.0, 0.0, 1.0);
  77862. }
  77863. else {
  77864. point = Vector3.Zero();
  77865. }
  77866. normal0 = Vector3.Cross(vt, point);
  77867. }
  77868. else {
  77869. normal0 = Vector3.Cross(vt, va);
  77870. Vector3.CrossToRef(normal0, vt, normal0);
  77871. }
  77872. normal0.normalize();
  77873. return normal0;
  77874. };
  77875. return Path3D;
  77876. }());
  77877. /**
  77878. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77879. * A Curve3 is designed from a series of successive Vector3.
  77880. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77881. */
  77882. var Curve3 = /** @class */ (function () {
  77883. /**
  77884. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77885. * A Curve3 is designed from a series of successive Vector3.
  77886. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77887. * @param points points which make up the curve
  77888. */
  77889. function Curve3(points) {
  77890. this._length = 0.0;
  77891. this._points = points;
  77892. this._length = this._computeLength(points);
  77893. }
  77894. /**
  77895. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77896. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77897. * @param v1 (Vector3) the control point
  77898. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77899. * @param nbPoints (integer) the wanted number of points in the curve
  77900. * @returns the created Curve3
  77901. */
  77902. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  77903. nbPoints = nbPoints > 2 ? nbPoints : 3;
  77904. var bez = new Array();
  77905. var equation = function (t, val0, val1, val2) {
  77906. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  77907. return res;
  77908. };
  77909. for (var i = 0; i <= nbPoints; i++) {
  77910. 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)));
  77911. }
  77912. return new Curve3(bez);
  77913. };
  77914. /**
  77915. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77916. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77917. * @param v1 (Vector3) the first control point
  77918. * @param v2 (Vector3) the second control point
  77919. * @param v3 (Vector3) the end point of the Cubic Bezier
  77920. * @param nbPoints (integer) the wanted number of points in the curve
  77921. * @returns the created Curve3
  77922. */
  77923. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  77924. nbPoints = nbPoints > 3 ? nbPoints : 4;
  77925. var bez = new Array();
  77926. var equation = function (t, val0, val1, val2, val3) {
  77927. 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;
  77928. return res;
  77929. };
  77930. for (var i = 0; i <= nbPoints; i++) {
  77931. 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)));
  77932. }
  77933. return new Curve3(bez);
  77934. };
  77935. /**
  77936. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77937. * @param p1 (Vector3) the origin point of the Hermite Spline
  77938. * @param t1 (Vector3) the tangent vector at the origin point
  77939. * @param p2 (Vector3) the end point of the Hermite Spline
  77940. * @param t2 (Vector3) the tangent vector at the end point
  77941. * @param nbPoints (integer) the wanted number of points in the curve
  77942. * @returns the created Curve3
  77943. */
  77944. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  77945. var hermite = new Array();
  77946. var step = 1.0 / nbPoints;
  77947. for (var i = 0; i <= nbPoints; i++) {
  77948. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  77949. }
  77950. return new Curve3(hermite);
  77951. };
  77952. /**
  77953. * Returns a Curve3 object along a CatmullRom Spline curve :
  77954. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77955. * @param nbPoints (integer) the wanted number of points between each curve control points
  77956. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77957. * @returns the created Curve3
  77958. */
  77959. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  77960. var catmullRom = new Array();
  77961. var step = 1.0 / nbPoints;
  77962. var amount = 0.0;
  77963. if (closed) {
  77964. var pointsCount = points.length;
  77965. for (var i = 0; i < pointsCount; i++) {
  77966. amount = 0;
  77967. for (var c = 0; c < nbPoints; c++) {
  77968. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  77969. amount += step;
  77970. }
  77971. }
  77972. catmullRom.push(catmullRom[0]);
  77973. }
  77974. else {
  77975. var totalPoints = new Array();
  77976. totalPoints.push(points[0].clone());
  77977. Array.prototype.push.apply(totalPoints, points);
  77978. totalPoints.push(points[points.length - 1].clone());
  77979. for (var i = 0; i < totalPoints.length - 3; i++) {
  77980. amount = 0;
  77981. for (var c = 0; c < nbPoints; c++) {
  77982. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  77983. amount += step;
  77984. }
  77985. }
  77986. i--;
  77987. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  77988. }
  77989. return new Curve3(catmullRom);
  77990. };
  77991. /**
  77992. * @returns the Curve3 stored array of successive Vector3
  77993. */
  77994. Curve3.prototype.getPoints = function () {
  77995. return this._points;
  77996. };
  77997. /**
  77998. * @returns the computed length (float) of the curve.
  77999. */
  78000. Curve3.prototype.length = function () {
  78001. return this._length;
  78002. };
  78003. /**
  78004. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78005. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78006. * curveA and curveB keep unchanged.
  78007. * @param curve the curve to continue from this curve
  78008. * @returns the newly constructed curve
  78009. */
  78010. Curve3.prototype.continue = function (curve) {
  78011. var lastPoint = this._points[this._points.length - 1];
  78012. var continuedPoints = this._points.slice();
  78013. var curvePoints = curve.getPoints();
  78014. for (var i = 1; i < curvePoints.length; i++) {
  78015. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  78016. }
  78017. var continuedCurve = new Curve3(continuedPoints);
  78018. return continuedCurve;
  78019. };
  78020. Curve3.prototype._computeLength = function (path) {
  78021. var l = 0;
  78022. for (var i = 1; i < path.length; i++) {
  78023. l += (path[i].subtract(path[i - 1])).length();
  78024. }
  78025. return l;
  78026. };
  78027. return Curve3;
  78028. }());
  78029. // Vertex formats
  78030. /**
  78031. * Contains position and normal vectors for a vertex
  78032. */
  78033. var PositionNormalVertex = /** @class */ (function () {
  78034. /**
  78035. * Creates a PositionNormalVertex
  78036. * @param position the position of the vertex (defaut: 0,0,0)
  78037. * @param normal the normal of the vertex (defaut: 0,1,0)
  78038. */
  78039. function PositionNormalVertex(
  78040. /** the position of the vertex (defaut: 0,0,0) */
  78041. position,
  78042. /** the normal of the vertex (defaut: 0,1,0) */
  78043. normal) {
  78044. if (position === void 0) { position = Vector3.Zero(); }
  78045. if (normal === void 0) { normal = Vector3.Up(); }
  78046. this.position = position;
  78047. this.normal = normal;
  78048. }
  78049. /**
  78050. * Clones the PositionNormalVertex
  78051. * @returns the cloned PositionNormalVertex
  78052. */
  78053. PositionNormalVertex.prototype.clone = function () {
  78054. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  78055. };
  78056. return PositionNormalVertex;
  78057. }());
  78058. /**
  78059. * Contains position, normal and uv vectors for a vertex
  78060. */
  78061. var PositionNormalTextureVertex = /** @class */ (function () {
  78062. /**
  78063. * Creates a PositionNormalTextureVertex
  78064. * @param position the position of the vertex (defaut: 0,0,0)
  78065. * @param normal the normal of the vertex (defaut: 0,1,0)
  78066. * @param uv the uv of the vertex (default: 0,0)
  78067. */
  78068. function PositionNormalTextureVertex(
  78069. /** the position of the vertex (defaut: 0,0,0) */
  78070. position,
  78071. /** the normal of the vertex (defaut: 0,1,0) */
  78072. normal,
  78073. /** the uv of the vertex (default: 0,0) */
  78074. uv) {
  78075. if (position === void 0) { position = Vector3.Zero(); }
  78076. if (normal === void 0) { normal = Vector3.Up(); }
  78077. if (uv === void 0) { uv = Vector2.Zero(); }
  78078. this.position = position;
  78079. this.normal = normal;
  78080. this.uv = uv;
  78081. }
  78082. /**
  78083. * Clones the PositionNormalTextureVertex
  78084. * @returns the cloned PositionNormalTextureVertex
  78085. */
  78086. PositionNormalTextureVertex.prototype.clone = function () {
  78087. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  78088. };
  78089. return PositionNormalTextureVertex;
  78090. }());
  78091. // Temporary pre-allocated objects for engine internal use
  78092. // usage in any internal function :
  78093. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  78094. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  78095. /**
  78096. * @hidden
  78097. */
  78098. var Tmp = /** @class */ (function () {
  78099. function Tmp() {
  78100. }
  78101. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  78102. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  78103. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  78104. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  78105. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  78106. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  78107. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  78108. return Tmp;
  78109. }());
  78110. /**
  78111. * @hidden
  78112. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  78113. */
  78114. var MathTmp = /** @class */ (function () {
  78115. function MathTmp() {
  78116. }
  78117. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  78118. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  78119. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  78120. return MathTmp;
  78121. }());
  78122. /***/ }),
  78123. /***/ "./Maths/sphericalPolynomial.ts":
  78124. /*!**************************************!*\
  78125. !*** ./Maths/sphericalPolynomial.ts ***!
  78126. \**************************************/
  78127. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  78128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78129. "use strict";
  78130. __webpack_require__.r(__webpack_exports__);
  78131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  78132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  78133. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  78134. /**
  78135. * Class representing spherical polynomial coefficients to the 3rd degree
  78136. */
  78137. var SphericalPolynomial = /** @class */ (function () {
  78138. function SphericalPolynomial() {
  78139. /**
  78140. * The x coefficients of the spherical polynomial
  78141. */
  78142. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78143. /**
  78144. * The y coefficients of the spherical polynomial
  78145. */
  78146. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78147. /**
  78148. * The z coefficients of the spherical polynomial
  78149. */
  78150. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78151. /**
  78152. * The xx coefficients of the spherical polynomial
  78153. */
  78154. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78155. /**
  78156. * The yy coefficients of the spherical polynomial
  78157. */
  78158. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78159. /**
  78160. * The zz coefficients of the spherical polynomial
  78161. */
  78162. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78163. /**
  78164. * The xy coefficients of the spherical polynomial
  78165. */
  78166. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78167. /**
  78168. * The yz coefficients of the spherical polynomial
  78169. */
  78170. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78171. /**
  78172. * The zx coefficients of the spherical polynomial
  78173. */
  78174. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78175. }
  78176. /**
  78177. * Adds an ambient color to the spherical polynomial
  78178. * @param color the color to add
  78179. */
  78180. SphericalPolynomial.prototype.addAmbient = function (color) {
  78181. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  78182. this.xx = this.xx.add(colorVector);
  78183. this.yy = this.yy.add(colorVector);
  78184. this.zz = this.zz.add(colorVector);
  78185. };
  78186. /**
  78187. * Scales the spherical polynomial by the given amount
  78188. * @param scale the amount to scale
  78189. */
  78190. SphericalPolynomial.prototype.scale = function (scale) {
  78191. this.x = this.x.scale(scale);
  78192. this.y = this.y.scale(scale);
  78193. this.z = this.z.scale(scale);
  78194. this.xx = this.xx.scale(scale);
  78195. this.yy = this.yy.scale(scale);
  78196. this.zz = this.zz.scale(scale);
  78197. this.yz = this.yz.scale(scale);
  78198. this.zx = this.zx.scale(scale);
  78199. this.xy = this.xy.scale(scale);
  78200. };
  78201. /**
  78202. * Gets the spherical polynomial from harmonics
  78203. * @param harmonics the spherical harmonics
  78204. * @returns the spherical polynomial
  78205. */
  78206. SphericalPolynomial.FromHarmonics = function (harmonics) {
  78207. var result = new SphericalPolynomial();
  78208. result.x = harmonics.l11.scale(1.02333);
  78209. result.y = harmonics.l1_1.scale(1.02333);
  78210. result.z = harmonics.l10.scale(1.02333);
  78211. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  78212. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  78213. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  78214. result.yz = harmonics.l2_1.scale(0.858086);
  78215. result.zx = harmonics.l21.scale(0.858086);
  78216. result.xy = harmonics.l2_2.scale(0.858086);
  78217. result.scale(1.0 / Math.PI);
  78218. return result;
  78219. };
  78220. /**
  78221. * Constructs a spherical polynomial from an array.
  78222. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  78223. * @returns the spherical polynomial
  78224. */
  78225. SphericalPolynomial.FromArray = function (data) {
  78226. var sp = new SphericalPolynomial();
  78227. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  78228. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  78229. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  78230. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  78231. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  78232. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  78233. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  78234. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  78235. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  78236. return sp;
  78237. };
  78238. return SphericalPolynomial;
  78239. }());
  78240. /**
  78241. * Class representing spherical harmonics coefficients to the 3rd degree
  78242. */
  78243. var SphericalHarmonics = /** @class */ (function () {
  78244. function SphericalHarmonics() {
  78245. /**
  78246. * The l0,0 coefficients of the spherical harmonics
  78247. */
  78248. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78249. /**
  78250. * The l1,-1 coefficients of the spherical harmonics
  78251. */
  78252. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78253. /**
  78254. * The l1,0 coefficients of the spherical harmonics
  78255. */
  78256. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78257. /**
  78258. * The l1,1 coefficients of the spherical harmonics
  78259. */
  78260. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78261. /**
  78262. * The l2,-2 coefficients of the spherical harmonics
  78263. */
  78264. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78265. /**
  78266. * The l2,-1 coefficients of the spherical harmonics
  78267. */
  78268. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78269. /**
  78270. * The l2,0 coefficients of the spherical harmonics
  78271. */
  78272. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78273. /**
  78274. * The l2,1 coefficients of the spherical harmonics
  78275. */
  78276. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78277. /**
  78278. * The l2,2 coefficients of the spherical harmonics
  78279. */
  78280. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78281. }
  78282. /**
  78283. * Adds a light to the spherical harmonics
  78284. * @param direction the direction of the light
  78285. * @param color the color of the light
  78286. * @param deltaSolidAngle the delta solid angle of the light
  78287. */
  78288. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  78289. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  78290. var c = colorVector.scale(deltaSolidAngle);
  78291. this.l00 = this.l00.add(c.scale(0.282095));
  78292. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  78293. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  78294. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  78295. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  78296. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  78297. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  78298. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  78299. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  78300. };
  78301. /**
  78302. * Scales the spherical harmonics by the given amount
  78303. * @param scale the amount to scale
  78304. */
  78305. SphericalHarmonics.prototype.scale = function (scale) {
  78306. this.l00 = this.l00.scale(scale);
  78307. this.l1_1 = this.l1_1.scale(scale);
  78308. this.l10 = this.l10.scale(scale);
  78309. this.l11 = this.l11.scale(scale);
  78310. this.l2_2 = this.l2_2.scale(scale);
  78311. this.l2_1 = this.l2_1.scale(scale);
  78312. this.l20 = this.l20.scale(scale);
  78313. this.l21 = this.l21.scale(scale);
  78314. this.lL22 = this.lL22.scale(scale);
  78315. };
  78316. /**
  78317. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  78318. *
  78319. * ```
  78320. * E_lm = A_l * L_lm
  78321. * ```
  78322. *
  78323. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  78324. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  78325. * the scaling factors are given in equation 9.
  78326. */
  78327. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  78328. // Constant (Band 0)
  78329. this.l00 = this.l00.scale(3.141593);
  78330. // Linear (Band 1)
  78331. this.l1_1 = this.l1_1.scale(2.094395);
  78332. this.l10 = this.l10.scale(2.094395);
  78333. this.l11 = this.l11.scale(2.094395);
  78334. // Quadratic (Band 2)
  78335. this.l2_2 = this.l2_2.scale(0.785398);
  78336. this.l2_1 = this.l2_1.scale(0.785398);
  78337. this.l20 = this.l20.scale(0.785398);
  78338. this.l21 = this.l21.scale(0.785398);
  78339. this.lL22 = this.lL22.scale(0.785398);
  78340. };
  78341. /**
  78342. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  78343. *
  78344. * ```
  78345. * L = (1/pi) * E * rho
  78346. * ```
  78347. *
  78348. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  78349. */
  78350. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  78351. this.scale(1.0 / Math.PI);
  78352. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  78353. // (The pixel shader must apply albedo after texture fetches, etc).
  78354. };
  78355. /**
  78356. * Gets the spherical harmonics from polynomial
  78357. * @param polynomial the spherical polynomial
  78358. * @returns the spherical harmonics
  78359. */
  78360. SphericalHarmonics.FromPolynomial = function (polynomial) {
  78361. var result = new SphericalHarmonics();
  78362. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  78363. result.l1_1 = polynomial.y.scale(0.977204);
  78364. result.l10 = polynomial.z.scale(0.977204);
  78365. result.l11 = polynomial.x.scale(0.977204);
  78366. result.l2_2 = polynomial.xy.scale(1.16538);
  78367. result.l2_1 = polynomial.yz.scale(1.16538);
  78368. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  78369. result.l21 = polynomial.zx.scale(1.16538);
  78370. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  78371. result.scale(Math.PI);
  78372. return result;
  78373. };
  78374. /**
  78375. * Constructs a spherical harmonics from an array.
  78376. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  78377. * @returns the spherical harmonics
  78378. */
  78379. SphericalHarmonics.FromArray = function (data) {
  78380. var sh = new SphericalHarmonics();
  78381. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  78382. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  78383. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  78384. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  78385. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  78386. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  78387. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  78388. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  78389. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  78390. return sh;
  78391. };
  78392. return SphericalHarmonics;
  78393. }());
  78394. /***/ }),
  78395. /***/ "./Meshes/Builders/boxBuilder.ts":
  78396. /*!***************************************!*\
  78397. !*** ./Meshes/Builders/boxBuilder.ts ***!
  78398. \***************************************/
  78399. /*! exports provided: BoxBuilder */
  78400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78401. "use strict";
  78402. __webpack_require__.r(__webpack_exports__);
  78403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  78404. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78405. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78406. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78407. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  78408. var nbFaces = 6;
  78409. var indices = [0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23];
  78410. var normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0];
  78411. var uvs = [];
  78412. var positions = [];
  78413. var width = options.width || options.size || 1;
  78414. var height = options.height || options.size || 1;
  78415. var depth = options.depth || options.size || 1;
  78416. var wrap = options.wrap || false;
  78417. var topBaseAt = (options.topBaseAt === void 0) ? 1 : options.topBaseAt;
  78418. var bottomBaseAt = (options.bottomBaseAt === void 0) ? 0 : options.bottomBaseAt;
  78419. topBaseAt = (topBaseAt + 4) % 4; // places values as 0 to 3
  78420. bottomBaseAt = (bottomBaseAt + 4) % 4; // places values as 0 to 3
  78421. var topOrder = [2, 0, 3, 1];
  78422. var bottomOrder = [2, 0, 1, 3];
  78423. var topIndex = topOrder[topBaseAt];
  78424. var bottomIndex = bottomOrder[bottomBaseAt];
  78425. var basePositions = [1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1];
  78426. if (wrap) {
  78427. indices = [2, 3, 0, 2, 0, 1, 4, 5, 6, 4, 6, 7, 9, 10, 11, 9, 11, 8, 12, 14, 15, 12, 13, 14];
  78428. basePositions = [-1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1];
  78429. var topFaceBase = [[1, 1, 1], [-1, 1, 1], [-1, 1, -1], [1, 1, -1]];
  78430. var bottomFaceBase = [[-1, -1, 1], [1, -1, 1], [1, -1, -1], [-1, -1, -1]];
  78431. var topFaceOrder = [17, 18, 19, 16];
  78432. var bottomFaceOrder = [22, 23, 20, 21];
  78433. while (topIndex > 0) {
  78434. topFaceBase.unshift(topFaceBase.pop());
  78435. topFaceOrder.unshift(topFaceOrder.pop());
  78436. topIndex--;
  78437. }
  78438. while (bottomIndex > 0) {
  78439. bottomFaceBase.unshift(bottomFaceBase.pop());
  78440. bottomFaceOrder.unshift(bottomFaceOrder.pop());
  78441. bottomIndex--;
  78442. }
  78443. topFaceBase = topFaceBase.flat();
  78444. bottomFaceBase = bottomFaceBase.flat();
  78445. basePositions = basePositions.concat(topFaceBase).concat(bottomFaceBase);
  78446. indices.push(topFaceOrder[0], topFaceOrder[2], topFaceOrder[3], topFaceOrder[0], topFaceOrder[1], topFaceOrder[2]);
  78447. indices.push(bottomFaceOrder[0], bottomFaceOrder[2], bottomFaceOrder[3], bottomFaceOrder[0], bottomFaceOrder[1], bottomFaceOrder[2]);
  78448. }
  78449. var scaleArray = [width / 2, height / 2, depth / 2];
  78450. positions = basePositions.reduce(function (accumulator, currentValue, currentIndex) { return accumulator.concat(currentValue * scaleArray[currentIndex % 3]); }, []);
  78451. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78452. var faceUV = options.faceUV || new Array(6);
  78453. var faceColors = options.faceColors;
  78454. var colors = [];
  78455. // default face colors and UV if undefined
  78456. for (var f = 0; f < 6; f++) {
  78457. if (faceUV[f] === undefined) {
  78458. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78459. }
  78460. if (faceColors && faceColors[f] === undefined) {
  78461. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78462. }
  78463. }
  78464. // Create each face in turn.
  78465. for (var index = 0; index < nbFaces; index++) {
  78466. uvs.push(faceUV[index].z, faceUV[index].w);
  78467. uvs.push(faceUV[index].x, faceUV[index].w);
  78468. uvs.push(faceUV[index].x, faceUV[index].y);
  78469. uvs.push(faceUV[index].z, faceUV[index].y);
  78470. if (faceColors) {
  78471. for (var c = 0; c < 4; c++) {
  78472. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  78473. }
  78474. }
  78475. }
  78476. // sides
  78477. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78478. // Result
  78479. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78480. vertexData.indices = indices;
  78481. vertexData.positions = positions;
  78482. vertexData.normals = normals;
  78483. vertexData.uvs = uvs;
  78484. if (faceColors) {
  78485. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  78486. vertexData.colors = totalColors;
  78487. }
  78488. return vertexData;
  78489. };
  78490. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  78491. if (scene === void 0) { scene = null; }
  78492. var options = {
  78493. size: size,
  78494. sideOrientation: sideOrientation,
  78495. updatable: updatable
  78496. };
  78497. return BoxBuilder.CreateBox(name, options, scene);
  78498. };
  78499. /**
  78500. * Class containing static functions to help procedurally build meshes
  78501. */
  78502. var BoxBuilder = /** @class */ (function () {
  78503. function BoxBuilder() {
  78504. }
  78505. /**
  78506. * Creates a box mesh
  78507. * * The parameter `size` sets the size (float) of each box side (default 1)
  78508. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  78509. * * 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)
  78510. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  78511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78512. * * 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
  78513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78514. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  78515. * @param name defines the name of the mesh
  78516. * @param options defines the options used to create the mesh
  78517. * @param scene defines the hosting scene
  78518. * @returns the box mesh
  78519. */
  78520. BoxBuilder.CreateBox = function (name, options, scene) {
  78521. if (scene === void 0) { scene = null; }
  78522. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78523. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78524. box._originalBuilderSideOrientation = options.sideOrientation;
  78525. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  78526. vertexData.applyToMesh(box, options.updatable);
  78527. return box;
  78528. };
  78529. return BoxBuilder;
  78530. }());
  78531. /***/ }),
  78532. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  78533. /*!********************************************!*\
  78534. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  78535. \********************************************/
  78536. /*! exports provided: CylinderBuilder */
  78537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78538. "use strict";
  78539. __webpack_require__.r(__webpack_exports__);
  78540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  78541. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78542. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78543. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78544. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  78545. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  78546. var height = options.height || 2;
  78547. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  78548. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  78549. var tessellation = options.tessellation || 24;
  78550. var subdivisions = options.subdivisions || 1;
  78551. var hasRings = options.hasRings ? true : false;
  78552. var enclose = options.enclose ? true : false;
  78553. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  78554. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78555. var faceUV = options.faceUV || new Array(3);
  78556. var faceColors = options.faceColors;
  78557. // default face colors and UV if undefined
  78558. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  78559. var ringNb = (hasRings) ? subdivisions : 1;
  78560. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  78561. var f;
  78562. for (f = 0; f < surfaceNb; f++) {
  78563. if (faceColors && faceColors[f] === undefined) {
  78564. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78565. }
  78566. }
  78567. for (f = 0; f < surfaceNb; f++) {
  78568. if (faceUV && faceUV[f] === undefined) {
  78569. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78570. }
  78571. }
  78572. var indices = new Array();
  78573. var positions = new Array();
  78574. var normals = new Array();
  78575. var uvs = new Array();
  78576. var colors = new Array();
  78577. var angle_step = Math.PI * 2 * arc / tessellation;
  78578. var angle;
  78579. var h;
  78580. var radius;
  78581. var tan = (diameterBottom - diameterTop) / 2 / height;
  78582. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78583. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78584. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78585. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78586. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78587. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  78588. // positions, normals, uvs
  78589. var i;
  78590. var j;
  78591. var r;
  78592. var ringIdx = 1;
  78593. var s = 1; // surface index
  78594. var cs = 0;
  78595. var v = 0;
  78596. for (i = 0; i <= subdivisions; i++) {
  78597. h = i / subdivisions;
  78598. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  78599. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  78600. for (r = 0; r < ringIdx; r++) {
  78601. if (hasRings) {
  78602. s += r;
  78603. }
  78604. if (enclose) {
  78605. s += 2 * r;
  78606. }
  78607. for (j = 0; j <= tessellation; j++) {
  78608. angle = j * angle_step;
  78609. // position
  78610. ringVertex.x = Math.cos(-angle) * radius;
  78611. ringVertex.y = -height / 2 + h * height;
  78612. ringVertex.z = Math.sin(-angle) * radius;
  78613. // normal
  78614. if (diameterTop === 0 && i === subdivisions) {
  78615. // if no top cap, reuse former normals
  78616. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  78617. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  78618. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  78619. }
  78620. else {
  78621. ringNormal.x = ringVertex.x;
  78622. ringNormal.z = ringVertex.z;
  78623. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  78624. ringNormal.normalize();
  78625. }
  78626. // keep first ring vertex values for enclose
  78627. if (j === 0) {
  78628. ringFirstVertex.copyFrom(ringVertex);
  78629. ringFirstNormal.copyFrom(ringNormal);
  78630. }
  78631. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  78632. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  78633. if (hasRings) {
  78634. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  78635. }
  78636. else {
  78637. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  78638. }
  78639. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  78640. if (faceColors) {
  78641. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  78642. }
  78643. }
  78644. // if enclose, add four vertices and their dedicated normals
  78645. if (arc !== 1 && enclose) {
  78646. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  78647. positions.push(0, ringVertex.y, 0);
  78648. positions.push(0, ringVertex.y, 0);
  78649. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  78650. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  78651. quadNormal.normalize();
  78652. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  78653. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  78654. quadNormal.normalize();
  78655. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  78656. if (hasRings) {
  78657. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  78658. }
  78659. else {
  78660. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  78661. }
  78662. uvs.push(faceUV[s + 1].x, v);
  78663. uvs.push(faceUV[s + 1].z, v);
  78664. if (hasRings) {
  78665. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  78666. }
  78667. else {
  78668. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  78669. }
  78670. uvs.push(faceUV[s + 2].x, v);
  78671. uvs.push(faceUV[s + 2].z, v);
  78672. if (faceColors) {
  78673. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  78674. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  78675. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  78676. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  78677. }
  78678. }
  78679. if (cs !== s) {
  78680. cs = s;
  78681. }
  78682. }
  78683. }
  78684. // indices
  78685. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  78686. var s;
  78687. i = 0;
  78688. for (s = 0; s < subdivisions; s++) {
  78689. var i0 = 0;
  78690. var i1 = 0;
  78691. var i2 = 0;
  78692. var i3 = 0;
  78693. for (j = 0; j < tessellation; j++) {
  78694. i0 = i * (e + 1) + j;
  78695. i1 = (i + 1) * (e + 1) + j;
  78696. i2 = i * (e + 1) + (j + 1);
  78697. i3 = (i + 1) * (e + 1) + (j + 1);
  78698. indices.push(i0, i1, i2);
  78699. indices.push(i3, i2, i1);
  78700. }
  78701. if (arc !== 1 && enclose) { // if enclose, add two quads
  78702. indices.push(i0 + 2, i1 + 2, i2 + 2);
  78703. indices.push(i3 + 2, i2 + 2, i1 + 2);
  78704. indices.push(i0 + 4, i1 + 4, i2 + 4);
  78705. indices.push(i3 + 4, i2 + 4, i1 + 4);
  78706. }
  78707. i = (hasRings) ? (i + 2) : (i + 1);
  78708. }
  78709. // Caps
  78710. var createCylinderCap = function (isTop) {
  78711. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  78712. if (radius === 0) {
  78713. return;
  78714. }
  78715. // Cap positions, normals & uvs
  78716. var angle;
  78717. var circleVector;
  78718. var i;
  78719. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  78720. var c = null;
  78721. if (faceColors) {
  78722. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  78723. }
  78724. // cap center
  78725. var vbase = positions.length / 3;
  78726. var offset = isTop ? height / 2 : -height / 2;
  78727. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  78728. positions.push(center.x, center.y, center.z);
  78729. normals.push(0, isTop ? 1 : -1, 0);
  78730. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  78731. if (c) {
  78732. colors.push(c.r, c.g, c.b, c.a);
  78733. }
  78734. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  78735. for (i = 0; i <= tessellation; i++) {
  78736. angle = Math.PI * 2 * i * arc / tessellation;
  78737. var cos = Math.cos(-angle);
  78738. var sin = Math.sin(-angle);
  78739. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  78740. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  78741. positions.push(circleVector.x, circleVector.y, circleVector.z);
  78742. normals.push(0, isTop ? 1 : -1, 0);
  78743. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  78744. if (c) {
  78745. colors.push(c.r, c.g, c.b, c.a);
  78746. }
  78747. }
  78748. // Cap indices
  78749. for (i = 0; i < tessellation; i++) {
  78750. if (!isTop) {
  78751. indices.push(vbase);
  78752. indices.push(vbase + (i + 1));
  78753. indices.push(vbase + (i + 2));
  78754. }
  78755. else {
  78756. indices.push(vbase);
  78757. indices.push(vbase + (i + 2));
  78758. indices.push(vbase + (i + 1));
  78759. }
  78760. }
  78761. };
  78762. // add caps to geometry
  78763. createCylinderCap(false);
  78764. createCylinderCap(true);
  78765. // Sides
  78766. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78767. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78768. vertexData.indices = indices;
  78769. vertexData.positions = positions;
  78770. vertexData.normals = normals;
  78771. vertexData.uvs = uvs;
  78772. if (faceColors) {
  78773. vertexData.colors = colors;
  78774. }
  78775. return vertexData;
  78776. };
  78777. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  78778. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  78779. if (scene !== undefined) {
  78780. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  78781. updatable = scene;
  78782. }
  78783. scene = subdivisions;
  78784. subdivisions = 1;
  78785. }
  78786. var options = {
  78787. height: height,
  78788. diameterTop: diameterTop,
  78789. diameterBottom: diameterBottom,
  78790. tessellation: tessellation,
  78791. subdivisions: subdivisions,
  78792. sideOrientation: sideOrientation,
  78793. updatable: updatable
  78794. };
  78795. return CylinderBuilder.CreateCylinder(name, options, scene);
  78796. };
  78797. /**
  78798. * Class containing static functions to help procedurally build meshes
  78799. */
  78800. var CylinderBuilder = /** @class */ (function () {
  78801. function CylinderBuilder() {
  78802. }
  78803. /**
  78804. * Creates a cylinder or a cone mesh
  78805. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  78806. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  78807. * * 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.
  78808. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  78809. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  78810. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  78811. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  78812. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  78813. * * 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).
  78814. * * 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
  78815. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  78816. * * 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
  78817. * * 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.
  78818. * * If `enclose` is false, a ring surface is one element.
  78819. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  78820. * * 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
  78821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78822. * * 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
  78823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78824. * @param name defines the name of the mesh
  78825. * @param options defines the options used to create the mesh
  78826. * @param scene defines the hosting scene
  78827. * @returns the cylinder mesh
  78828. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  78829. */
  78830. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  78831. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78832. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78833. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  78834. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  78835. vertexData.applyToMesh(cylinder, options.updatable);
  78836. return cylinder;
  78837. };
  78838. return CylinderBuilder;
  78839. }());
  78840. /***/ }),
  78841. /***/ "./Meshes/Builders/decalBuilder.ts":
  78842. /*!*****************************************!*\
  78843. !*** ./Meshes/Builders/decalBuilder.ts ***!
  78844. \*****************************************/
  78845. /*! exports provided: DecalBuilder */
  78846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78847. "use strict";
  78848. __webpack_require__.r(__webpack_exports__);
  78849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  78850. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78851. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78852. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  78853. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78854. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  78855. var options = {
  78856. position: position,
  78857. normal: normal,
  78858. size: size,
  78859. angle: angle
  78860. };
  78861. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  78862. };
  78863. /**
  78864. * Class containing static functions to help procedurally build meshes
  78865. */
  78866. var DecalBuilder = /** @class */ (function () {
  78867. function DecalBuilder() {
  78868. }
  78869. /**
  78870. * Creates a decal mesh.
  78871. * 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
  78872. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  78873. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  78874. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  78875. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  78876. * @param name defines the name of the mesh
  78877. * @param sourceMesh defines the mesh where the decal must be applied
  78878. * @param options defines the options used to create the mesh
  78879. * @param scene defines the hosting scene
  78880. * @returns the decal mesh
  78881. * @see https://doc.babylonjs.com/how_to/decals
  78882. */
  78883. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  78884. var indices = sourceMesh.getIndices();
  78885. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  78886. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  78887. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78888. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  78889. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  78890. var angle = options.angle || 0;
  78891. // Getting correct rotation
  78892. if (!normal) {
  78893. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  78894. var camera = sourceMesh.getScene().activeCamera;
  78895. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  78896. normal = camera.globalPosition.subtract(cameraWorldTarget);
  78897. }
  78898. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  78899. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  78900. var pitch = Math.atan2(normal.y, len);
  78901. // Matrix
  78902. 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));
  78903. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  78904. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  78905. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  78906. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  78907. vertexData.indices = [];
  78908. vertexData.positions = [];
  78909. vertexData.normals = [];
  78910. vertexData.uvs = [];
  78911. var currentVertexDataIndex = 0;
  78912. var extractDecalVector3 = function (indexId) {
  78913. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  78914. if (!indices || !positions || !normals) {
  78915. return result;
  78916. }
  78917. var vertexId = indices[indexId];
  78918. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  78919. // Send vector to decal local world
  78920. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  78921. // Get normal
  78922. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  78923. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  78924. return result;
  78925. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  78926. var clip = function (vertices, axis) {
  78927. if (vertices.length === 0) {
  78928. return vertices;
  78929. }
  78930. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  78931. var clipVertices = function (v0, v1) {
  78932. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  78933. 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));
  78934. };
  78935. var result = new Array();
  78936. for (var index = 0; index < vertices.length; index += 3) {
  78937. var v1Out;
  78938. var v2Out;
  78939. var v3Out;
  78940. var total = 0;
  78941. var nV1 = null;
  78942. var nV2 = null;
  78943. var nV3 = null;
  78944. var nV4 = null;
  78945. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  78946. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  78947. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  78948. v1Out = d1 > 0;
  78949. v2Out = d2 > 0;
  78950. v3Out = d3 > 0;
  78951. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  78952. switch (total) {
  78953. case 0:
  78954. result.push(vertices[index]);
  78955. result.push(vertices[index + 1]);
  78956. result.push(vertices[index + 2]);
  78957. break;
  78958. case 1:
  78959. if (v1Out) {
  78960. nV1 = vertices[index + 1];
  78961. nV2 = vertices[index + 2];
  78962. nV3 = clipVertices(vertices[index], nV1);
  78963. nV4 = clipVertices(vertices[index], nV2);
  78964. }
  78965. if (v2Out) {
  78966. nV1 = vertices[index];
  78967. nV2 = vertices[index + 2];
  78968. nV3 = clipVertices(vertices[index + 1], nV1);
  78969. nV4 = clipVertices(vertices[index + 1], nV2);
  78970. result.push(nV3);
  78971. result.push(nV2.clone());
  78972. result.push(nV1.clone());
  78973. result.push(nV2.clone());
  78974. result.push(nV3.clone());
  78975. result.push(nV4);
  78976. break;
  78977. }
  78978. if (v3Out) {
  78979. nV1 = vertices[index];
  78980. nV2 = vertices[index + 1];
  78981. nV3 = clipVertices(vertices[index + 2], nV1);
  78982. nV4 = clipVertices(vertices[index + 2], nV2);
  78983. }
  78984. if (nV1 && nV2 && nV3 && nV4) {
  78985. result.push(nV1.clone());
  78986. result.push(nV2.clone());
  78987. result.push(nV3);
  78988. result.push(nV4);
  78989. result.push(nV3.clone());
  78990. result.push(nV2.clone());
  78991. }
  78992. break;
  78993. case 2:
  78994. if (!v1Out) {
  78995. nV1 = vertices[index].clone();
  78996. nV2 = clipVertices(nV1, vertices[index + 1]);
  78997. nV3 = clipVertices(nV1, vertices[index + 2]);
  78998. result.push(nV1);
  78999. result.push(nV2);
  79000. result.push(nV3);
  79001. }
  79002. if (!v2Out) {
  79003. nV1 = vertices[index + 1].clone();
  79004. nV2 = clipVertices(nV1, vertices[index + 2]);
  79005. nV3 = clipVertices(nV1, vertices[index]);
  79006. result.push(nV1);
  79007. result.push(nV2);
  79008. result.push(nV3);
  79009. }
  79010. if (!v3Out) {
  79011. nV1 = vertices[index + 2].clone();
  79012. nV2 = clipVertices(nV1, vertices[index]);
  79013. nV3 = clipVertices(nV1, vertices[index + 1]);
  79014. result.push(nV1);
  79015. result.push(nV2);
  79016. result.push(nV3);
  79017. }
  79018. break;
  79019. case 3:
  79020. break;
  79021. }
  79022. }
  79023. return result;
  79024. };
  79025. for (var index = 0; index < indices.length; index += 3) {
  79026. var faceVertices = new Array();
  79027. faceVertices.push(extractDecalVector3(index));
  79028. faceVertices.push(extractDecalVector3(index + 1));
  79029. faceVertices.push(extractDecalVector3(index + 2));
  79030. // Clip
  79031. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  79032. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  79033. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  79034. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  79035. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  79036. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  79037. if (faceVertices.length === 0) {
  79038. continue;
  79039. }
  79040. // Add UVs and get back to world
  79041. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  79042. var vertex = faceVertices[vIndex];
  79043. //TODO check for Int32Array | Uint32Array | Uint16Array
  79044. vertexData.indices.push(currentVertexDataIndex);
  79045. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  79046. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  79047. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  79048. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  79049. currentVertexDataIndex++;
  79050. }
  79051. }
  79052. // Return mesh
  79053. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  79054. vertexData.applyToMesh(decal);
  79055. decal.position = position.clone();
  79056. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  79057. return decal;
  79058. };
  79059. return DecalBuilder;
  79060. }());
  79061. /***/ }),
  79062. /***/ "./Meshes/Builders/discBuilder.ts":
  79063. /*!****************************************!*\
  79064. !*** ./Meshes/Builders/discBuilder.ts ***!
  79065. \****************************************/
  79066. /*! exports provided: DiscBuilder */
  79067. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79068. "use strict";
  79069. __webpack_require__.r(__webpack_exports__);
  79070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  79071. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79072. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79073. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  79074. var positions = new Array();
  79075. var indices = new Array();
  79076. var normals = new Array();
  79077. var uvs = new Array();
  79078. var radius = options.radius || 0.5;
  79079. var tessellation = options.tessellation || 64;
  79080. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  79081. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  79082. // positions and uvs
  79083. positions.push(0, 0, 0); // disc center first
  79084. uvs.push(0.5, 0.5);
  79085. var theta = Math.PI * 2 * arc;
  79086. var step = theta / tessellation;
  79087. for (var a = 0; a < theta; a += step) {
  79088. var x = Math.cos(a);
  79089. var y = Math.sin(a);
  79090. var u = (x + 1) / 2;
  79091. var v = (1 - y) / 2;
  79092. positions.push(radius * x, radius * y, 0);
  79093. uvs.push(u, v);
  79094. }
  79095. if (arc === 1) {
  79096. positions.push(positions[3], positions[4], positions[5]); // close the circle
  79097. uvs.push(uvs[2], uvs[3]);
  79098. }
  79099. //indices
  79100. var vertexNb = positions.length / 3;
  79101. for (var i = 1; i < vertexNb - 1; i++) {
  79102. indices.push(i + 1, 0, i);
  79103. }
  79104. // result
  79105. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  79106. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79107. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  79108. vertexData.indices = indices;
  79109. vertexData.positions = positions;
  79110. vertexData.normals = normals;
  79111. vertexData.uvs = uvs;
  79112. return vertexData;
  79113. };
  79114. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  79115. if (scene === void 0) { scene = null; }
  79116. var options = {
  79117. radius: radius,
  79118. tessellation: tessellation,
  79119. sideOrientation: sideOrientation,
  79120. updatable: updatable
  79121. };
  79122. return DiscBuilder.CreateDisc(name, options, scene);
  79123. };
  79124. /**
  79125. * Class containing static functions to help procedurally build meshes
  79126. */
  79127. var DiscBuilder = /** @class */ (function () {
  79128. function DiscBuilder() {
  79129. }
  79130. /**
  79131. * Creates a plane polygonal mesh. By default, this is a disc
  79132. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  79133. * * 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
  79134. * * 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
  79135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79136. * * 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
  79137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79138. * @param name defines the name of the mesh
  79139. * @param options defines the options used to create the mesh
  79140. * @param scene defines the hosting scene
  79141. * @returns the plane polygonal mesh
  79142. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  79143. */
  79144. DiscBuilder.CreateDisc = function (name, options, scene) {
  79145. if (scene === void 0) { scene = null; }
  79146. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  79147. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79148. disc._originalBuilderSideOrientation = options.sideOrientation;
  79149. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  79150. vertexData.applyToMesh(disc, options.updatable);
  79151. return disc;
  79152. };
  79153. return DiscBuilder;
  79154. }());
  79155. /***/ }),
  79156. /***/ "./Meshes/Builders/groundBuilder.ts":
  79157. /*!******************************************!*\
  79158. !*** ./Meshes/Builders/groundBuilder.ts ***!
  79159. \******************************************/
  79160. /*! exports provided: GroundBuilder */
  79161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79162. "use strict";
  79163. __webpack_require__.r(__webpack_exports__);
  79164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  79165. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79166. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79167. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79168. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  79169. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  79170. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  79171. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  79172. var indices = [];
  79173. var positions = [];
  79174. var normals = [];
  79175. var uvs = [];
  79176. var row, col;
  79177. var width = options.width || 1;
  79178. var height = options.height || 1;
  79179. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  79180. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  79181. for (row = 0; row <= subdivisionsY; row++) {
  79182. for (col = 0; col <= subdivisionsX; col++) {
  79183. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  79184. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  79185. positions.push(position.x, position.y, position.z);
  79186. normals.push(normal.x, normal.y, normal.z);
  79187. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  79188. }
  79189. }
  79190. for (row = 0; row < subdivisionsY; row++) {
  79191. for (col = 0; col < subdivisionsX; col++) {
  79192. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  79193. indices.push(col + 1 + row * (subdivisionsX + 1));
  79194. indices.push(col + row * (subdivisionsX + 1));
  79195. indices.push(col + (row + 1) * (subdivisionsX + 1));
  79196. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  79197. indices.push(col + row * (subdivisionsX + 1));
  79198. }
  79199. }
  79200. // Result
  79201. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79202. vertexData.indices = indices;
  79203. vertexData.positions = positions;
  79204. vertexData.normals = normals;
  79205. vertexData.uvs = uvs;
  79206. return vertexData;
  79207. };
  79208. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  79209. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  79210. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  79211. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  79212. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  79213. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  79214. var precision = options.precision || { w: 1, h: 1 };
  79215. var indices = new Array();
  79216. var positions = new Array();
  79217. var normals = new Array();
  79218. var uvs = new Array();
  79219. var row, col, tileRow, tileCol;
  79220. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  79221. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  79222. precision.w = (precision.w < 1) ? 1 : precision.w;
  79223. precision.h = (precision.h < 1) ? 1 : precision.h;
  79224. var tileSize = {
  79225. 'w': (xmax - xmin) / subdivisions.w,
  79226. 'h': (zmax - zmin) / subdivisions.h
  79227. };
  79228. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  79229. // Indices
  79230. var base = positions.length / 3;
  79231. var rowLength = precision.w + 1;
  79232. for (row = 0; row < precision.h; row++) {
  79233. for (col = 0; col < precision.w; col++) {
  79234. var square = [
  79235. base + col + row * rowLength,
  79236. base + (col + 1) + row * rowLength,
  79237. base + (col + 1) + (row + 1) * rowLength,
  79238. base + col + (row + 1) * rowLength
  79239. ];
  79240. indices.push(square[1]);
  79241. indices.push(square[2]);
  79242. indices.push(square[3]);
  79243. indices.push(square[0]);
  79244. indices.push(square[1]);
  79245. indices.push(square[3]);
  79246. }
  79247. }
  79248. // Position, normals and uvs
  79249. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79250. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  79251. for (row = 0; row <= precision.h; row++) {
  79252. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  79253. for (col = 0; col <= precision.w; col++) {
  79254. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  79255. position.y = 0;
  79256. positions.push(position.x, position.y, position.z);
  79257. normals.push(normal.x, normal.y, normal.z);
  79258. uvs.push(col / precision.w, row / precision.h);
  79259. }
  79260. }
  79261. }
  79262. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  79263. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  79264. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  79265. }
  79266. }
  79267. // Result
  79268. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79269. vertexData.indices = indices;
  79270. vertexData.positions = positions;
  79271. vertexData.normals = normals;
  79272. vertexData.uvs = uvs;
  79273. return vertexData;
  79274. };
  79275. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  79276. var indices = [];
  79277. var positions = [];
  79278. var normals = [];
  79279. var uvs = [];
  79280. var row, col;
  79281. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  79282. var alphaFilter = options.alphaFilter || 0.0;
  79283. var invert = false;
  79284. if (options.minHeight > options.maxHeight) {
  79285. invert = true;
  79286. var temp = options.maxHeight;
  79287. options.maxHeight = options.minHeight;
  79288. options.minHeight = temp;
  79289. }
  79290. // Vertices
  79291. for (row = 0; row <= options.subdivisions; row++) {
  79292. for (col = 0; col <= options.subdivisions; col++) {
  79293. 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));
  79294. // Compute height
  79295. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  79296. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  79297. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  79298. var r = options.buffer[pos] / 255.0;
  79299. var g = options.buffer[pos + 1] / 255.0;
  79300. var b = options.buffer[pos + 2] / 255.0;
  79301. var a = options.buffer[pos + 3] / 255.0;
  79302. if (invert) {
  79303. r = 1.0 - r;
  79304. g = 1.0 - g;
  79305. b = 1.0 - b;
  79306. }
  79307. var gradient = r * filter.r + g * filter.g + b * filter.b;
  79308. // If our alpha channel is not within our filter then we will assign a 'special' height
  79309. // Then when building the indices, we will ignore any vertex that is using the special height
  79310. if (a >= alphaFilter) {
  79311. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  79312. }
  79313. else {
  79314. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  79315. }
  79316. // Add vertex
  79317. positions.push(position.x, position.y, position.z);
  79318. normals.push(0, 0, 0);
  79319. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  79320. }
  79321. }
  79322. // Indices
  79323. for (row = 0; row < options.subdivisions; row++) {
  79324. for (col = 0; col < options.subdivisions; col++) {
  79325. // Calculate Indices
  79326. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  79327. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  79328. var idx3 = (col + row * (options.subdivisions + 1));
  79329. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  79330. // Check that all indices are visible (based on our special height)
  79331. // Only display the vertex if all Indices are visible
  79332. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  79333. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  79334. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  79335. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  79336. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  79337. indices.push(idx1);
  79338. indices.push(idx2);
  79339. indices.push(idx3);
  79340. }
  79341. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  79342. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  79343. indices.push(idx4);
  79344. indices.push(idx1);
  79345. indices.push(idx3);
  79346. }
  79347. }
  79348. }
  79349. // Normals
  79350. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  79351. // Result
  79352. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79353. vertexData.indices = indices;
  79354. vertexData.positions = positions;
  79355. vertexData.normals = normals;
  79356. vertexData.uvs = uvs;
  79357. return vertexData;
  79358. };
  79359. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  79360. var options = {
  79361. width: width,
  79362. height: height,
  79363. subdivisions: subdivisions,
  79364. updatable: updatable
  79365. };
  79366. return GroundBuilder.CreateGround(name, options, scene);
  79367. };
  79368. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  79369. var options = {
  79370. xmin: xmin,
  79371. zmin: zmin,
  79372. xmax: xmax,
  79373. zmax: zmax,
  79374. subdivisions: subdivisions,
  79375. precision: precision,
  79376. updatable: updatable
  79377. };
  79378. return GroundBuilder.CreateTiledGround(name, options, scene);
  79379. };
  79380. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  79381. var options = {
  79382. width: width,
  79383. height: height,
  79384. subdivisions: subdivisions,
  79385. minHeight: minHeight,
  79386. maxHeight: maxHeight,
  79387. updatable: updatable,
  79388. onReady: onReady,
  79389. alphaFilter: alphaFilter
  79390. };
  79391. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  79392. };
  79393. /**
  79394. * Class containing static functions to help procedurally build meshes
  79395. */
  79396. var GroundBuilder = /** @class */ (function () {
  79397. function GroundBuilder() {
  79398. }
  79399. /**
  79400. * Creates a ground mesh
  79401. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  79402. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  79403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79404. * @param name defines the name of the mesh
  79405. * @param options defines the options used to create the mesh
  79406. * @param scene defines the hosting scene
  79407. * @returns the ground mesh
  79408. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  79409. */
  79410. GroundBuilder.CreateGround = function (name, options, scene) {
  79411. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  79412. ground._setReady(false);
  79413. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  79414. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  79415. ground._width = options.width || 1;
  79416. ground._height = options.height || 1;
  79417. ground._maxX = ground._width / 2;
  79418. ground._maxZ = ground._height / 2;
  79419. ground._minX = -ground._maxX;
  79420. ground._minZ = -ground._maxZ;
  79421. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  79422. vertexData.applyToMesh(ground, options.updatable);
  79423. ground._setReady(true);
  79424. return ground;
  79425. };
  79426. /**
  79427. * Creates a tiled ground mesh
  79428. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  79429. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  79430. * * 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
  79431. * * 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
  79432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79433. * @param name defines the name of the mesh
  79434. * @param options defines the options used to create the mesh
  79435. * @param scene defines the hosting scene
  79436. * @returns the tiled ground mesh
  79437. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  79438. */
  79439. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  79440. if (scene === void 0) { scene = null; }
  79441. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79442. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  79443. vertexData.applyToMesh(tiledGround, options.updatable);
  79444. return tiledGround;
  79445. };
  79446. /**
  79447. * Creates a ground mesh from a height map
  79448. * * The parameter `url` sets the URL of the height map image resource.
  79449. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  79450. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  79451. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  79452. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  79453. * * 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.
  79454. * * 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).
  79455. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79457. * @param name defines the name of the mesh
  79458. * @param url defines the url to the height map
  79459. * @param options defines the options used to create the mesh
  79460. * @param scene defines the hosting scene
  79461. * @returns the ground mesh
  79462. * @see https://doc.babylonjs.com/babylon101/height_map
  79463. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  79464. */
  79465. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  79466. if (scene === void 0) { scene = null; }
  79467. var width = options.width || 10.0;
  79468. var height = options.height || 10.0;
  79469. var subdivisions = options.subdivisions || 1 | 0;
  79470. var minHeight = options.minHeight || 0.0;
  79471. var maxHeight = options.maxHeight || 1.0;
  79472. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  79473. var alphaFilter = options.alphaFilter || 0.0;
  79474. var updatable = options.updatable;
  79475. var onReady = options.onReady;
  79476. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  79477. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  79478. ground._subdivisionsX = subdivisions;
  79479. ground._subdivisionsY = subdivisions;
  79480. ground._width = width;
  79481. ground._height = height;
  79482. ground._maxX = ground._width / 2.0;
  79483. ground._maxZ = ground._height / 2.0;
  79484. ground._minX = -ground._maxX;
  79485. ground._minZ = -ground._maxZ;
  79486. ground._setReady(false);
  79487. var onload = function (img) {
  79488. // Getting height map data
  79489. var canvas = document.createElement("canvas");
  79490. var context = canvas.getContext("2d");
  79491. if (!context) {
  79492. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  79493. }
  79494. if (scene.isDisposed) {
  79495. return;
  79496. }
  79497. var bufferWidth = img.width;
  79498. var bufferHeight = img.height;
  79499. canvas.width = bufferWidth;
  79500. canvas.height = bufferHeight;
  79501. context.drawImage(img, 0, 0);
  79502. // Create VertexData from map data
  79503. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  79504. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  79505. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  79506. width: width, height: height,
  79507. subdivisions: subdivisions,
  79508. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  79509. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  79510. alphaFilter: alphaFilter
  79511. });
  79512. vertexData.applyToMesh(ground, updatable);
  79513. //execute ready callback, if set
  79514. if (onReady) {
  79515. onReady(ground);
  79516. }
  79517. ground._setReady(true);
  79518. };
  79519. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  79520. return ground;
  79521. };
  79522. return GroundBuilder;
  79523. }());
  79524. /***/ }),
  79525. /***/ "./Meshes/Builders/hemisphereBuilder.ts":
  79526. /*!**********************************************!*\
  79527. !*** ./Meshes/Builders/hemisphereBuilder.ts ***!
  79528. \**********************************************/
  79529. /*! exports provided: HemisphereBuilder */
  79530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79531. "use strict";
  79532. __webpack_require__.r(__webpack_exports__);
  79533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return HemisphereBuilder; });
  79534. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79535. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  79536. /**
  79537. * Creates a hemispheric light
  79538. */
  79539. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateHemisphere = function (name, segments, diameter, scene) {
  79540. var options = {
  79541. segments: segments,
  79542. diameter: diameter
  79543. };
  79544. return HemisphereBuilder.CreateHemisphere(name, options, scene);
  79545. };
  79546. /**
  79547. * Class containing static functions to help procedurally build meshes
  79548. */
  79549. var HemisphereBuilder = /** @class */ (function () {
  79550. function HemisphereBuilder() {
  79551. }
  79552. /**
  79553. * Creates a hemisphere mesh
  79554. * @param name defines the name of the mesh
  79555. * @param options defines the options used to create the mesh
  79556. * @param scene defines the hosting scene
  79557. * @returns the hemisphere mesh
  79558. */
  79559. HemisphereBuilder.CreateHemisphere = function (name, options, scene) {
  79560. if (!options.diameter) {
  79561. options.diameter = 1;
  79562. }
  79563. if (!options.segments) {
  79564. options.segments = 16;
  79565. }
  79566. var halfSphere = _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("", { slice: 0.5, diameter: options.diameter, segments: options.segments }, scene);
  79567. var disc = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc("", options.diameter / 2, (options.segments * 3) + (4 - options.segments), scene);
  79568. disc.rotation.x = -Math.PI / 2;
  79569. disc.parent = halfSphere;
  79570. var merged = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].MergeMeshes([disc, halfSphere], true);
  79571. merged.name = name;
  79572. return merged;
  79573. };
  79574. return HemisphereBuilder;
  79575. }());
  79576. /***/ }),
  79577. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  79578. /*!*********************************************!*\
  79579. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  79580. \*********************************************/
  79581. /*! exports provided: IcoSphereBuilder */
  79582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79583. "use strict";
  79584. __webpack_require__.r(__webpack_exports__);
  79585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  79586. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79587. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79588. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79589. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  79590. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79591. var radius = options.radius || 1;
  79592. var flat = (options.flat === undefined) ? true : options.flat;
  79593. var subdivisions = options.subdivisions || 4;
  79594. var radiusX = options.radiusX || radius;
  79595. var radiusY = options.radiusY || radius;
  79596. var radiusZ = options.radiusZ || radius;
  79597. var t = (1 + Math.sqrt(5)) / 2;
  79598. // 12 vertex x,y,z
  79599. var ico_vertices = [
  79600. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  79601. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  79602. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  79603. ];
  79604. // index of 3 vertex makes a face of icopshere
  79605. var ico_indices = [
  79606. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  79607. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  79608. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  79609. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  79610. ];
  79611. // vertex for uv have aliased position, not for UV
  79612. var vertices_unalias_id = [
  79613. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  79614. // vertex alias
  79615. 0,
  79616. 2,
  79617. 3,
  79618. 3,
  79619. 3,
  79620. 4,
  79621. 7,
  79622. 8,
  79623. 9,
  79624. 9,
  79625. 10,
  79626. 11 // 23: B + 12
  79627. ];
  79628. // uv as integer step (not pixels !)
  79629. var ico_vertexuv = [
  79630. 5, 1, 3, 1, 6, 4, 0, 0,
  79631. 5, 3, 4, 2, 2, 2, 4, 0,
  79632. 2, 0, 1, 1, 6, 0, 6, 2,
  79633. // vertex alias (for same vertex on different faces)
  79634. 0, 4,
  79635. 3, 3,
  79636. 4, 4,
  79637. 3, 1,
  79638. 4, 2,
  79639. 4, 4,
  79640. 0, 2,
  79641. 1, 1,
  79642. 2, 2,
  79643. 3, 3,
  79644. 1, 3,
  79645. 2, 4 // 23: B + 12
  79646. ];
  79647. // Vertices[0, 1, ...9, A, B] : position on UV plane
  79648. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  79649. // First island of uv mapping
  79650. // v = 4h 3+ 2
  79651. // v = 3h 9+ 4
  79652. // v = 2h 9+ 5 B
  79653. // v = 1h 9 1 0
  79654. // v = 0h 3 8 7 A
  79655. // u = 0 1 2 3 4 5 6 *a
  79656. // Second island of uv mapping
  79657. // v = 4h 0+ B+ 4+
  79658. // v = 3h A+ 2+
  79659. // v = 2h 7+ 6 3+
  79660. // v = 1h 8+ 3+
  79661. // v = 0h
  79662. // u = 0 1 2 3 4 5 6 *a
  79663. // Face layout on texture UV mapping
  79664. // ============
  79665. // \ 4 /\ 16 / ======
  79666. // \ / \ / /\ 11 /
  79667. // \/ 7 \/ / \ /
  79668. // ======= / 10 \/
  79669. // /\ 17 /\ =======
  79670. // / \ / \ \ 15 /\
  79671. // / 8 \/ 12 \ \ / \
  79672. // ============ \/ 6 \
  79673. // \ 18 /\ ============
  79674. // \ / \ \ 5 /\ 0 /
  79675. // \/ 13 \ \ / \ /
  79676. // ======= \/ 1 \/
  79677. // =============
  79678. // /\ 19 /\ 2 /\
  79679. // / \ / \ / \
  79680. // / 14 \/ 9 \/ 3 \
  79681. // ===================
  79682. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  79683. var ustep = 138 / 1024;
  79684. var vstep = 239 / 1024;
  79685. var uoffset = 60 / 1024;
  79686. var voffset = 26 / 1024;
  79687. // Second island should have margin, not to touch the first island
  79688. // avoid any borderline artefact in pixel rounding
  79689. var island_u_offset = -40 / 1024;
  79690. var island_v_offset = +20 / 1024;
  79691. // face is either island 0 or 1 :
  79692. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  79693. var island = [
  79694. 0, 0, 0, 0, 1,
  79695. 0, 0, 1, 1, 0,
  79696. 0, 0, 1, 1, 0,
  79697. 0, 1, 1, 1, 0 // 15 - 19
  79698. ];
  79699. var indices = new Array();
  79700. var positions = new Array();
  79701. var normals = new Array();
  79702. var uvs = new Array();
  79703. var current_indice = 0;
  79704. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  79705. var face_vertex_pos = new Array(3);
  79706. var face_vertex_uv = new Array(3);
  79707. var v012;
  79708. for (v012 = 0; v012 < 3; v012++) {
  79709. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79710. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  79711. }
  79712. // create all with normals
  79713. for (var face = 0; face < 20; face++) {
  79714. // 3 vertex per face
  79715. for (v012 = 0; v012 < 3; v012++) {
  79716. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  79717. var v_id = ico_indices[3 * face + v012];
  79718. // vertex have 3D position (x,y,z)
  79719. 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]);
  79720. // Normalize to get normal, then scale to radius
  79721. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  79722. // uv Coordinates from vertex ID
  79723. 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);
  79724. }
  79725. // Subdivide the face (interpolate pos, norm, uv)
  79726. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  79727. // - norm is linear interpolation of vertex corner normal
  79728. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  79729. // - uv is linear interpolation
  79730. //
  79731. // Topology is as below for sub-divide by 2
  79732. // vertex shown as v0,v1,v2
  79733. // interp index is i1 to progress in range [v0,v1[
  79734. // interp index is i2 to progress in range [v0,v2[
  79735. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  79736. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  79737. //
  79738. //
  79739. // i2 v2
  79740. // ^ ^
  79741. // / / \
  79742. // / / \
  79743. // / / \
  79744. // / / (0,1) \
  79745. // / #---------\
  79746. // / / \ (0,0)'/ \
  79747. // / / \ / \
  79748. // / / \ / \
  79749. // / / (0,0) \ / (1,0) \
  79750. // / #---------#---------\
  79751. // v0 v1
  79752. //
  79753. // --------------------> i1
  79754. //
  79755. // interp of (i1,i2):
  79756. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  79757. // along i1 : lerp(x0,x1, i1/(S-i2))
  79758. //
  79759. // centroid of triangle is needed to get help normal computation
  79760. // (c1,c2) are used for centroid location
  79761. var interp_vertex = function (i1, i2, c1, c2) {
  79762. // vertex is interpolated from
  79763. // - face_vertex_pos[0..2]
  79764. // - face_vertex_uv[0..2]
  79765. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  79766. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  79767. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  79768. pos_interp.normalize();
  79769. var vertex_normal;
  79770. if (flat) {
  79771. // in flat mode, recalculate normal as face centroid normal
  79772. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  79773. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  79774. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  79775. }
  79776. else {
  79777. // in smooth mode, recalculate normal from each single vertex position
  79778. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  79779. }
  79780. // Vertex normal need correction due to X,Y,Z radius scaling
  79781. vertex_normal.x /= radiusX;
  79782. vertex_normal.y /= radiusY;
  79783. vertex_normal.z /= radiusZ;
  79784. vertex_normal.normalize();
  79785. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  79786. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  79787. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  79788. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  79789. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  79790. uvs.push(uv_interp.x, uv_interp.y);
  79791. // push each vertex has member of a face
  79792. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  79793. indices.push(current_indice);
  79794. current_indice++;
  79795. };
  79796. for (var i2 = 0; i2 < subdivisions; i2++) {
  79797. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  79798. // face : (i1,i2) for /\ :
  79799. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  79800. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  79801. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  79802. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  79803. if (i1 + i2 + 1 < subdivisions) {
  79804. // face : (i1,i2)' for \/ :
  79805. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  79806. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  79807. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  79808. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  79809. }
  79810. }
  79811. }
  79812. }
  79813. // Sides
  79814. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79815. // Result
  79816. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79817. vertexData.indices = indices;
  79818. vertexData.positions = positions;
  79819. vertexData.normals = normals;
  79820. vertexData.uvs = uvs;
  79821. return vertexData;
  79822. };
  79823. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  79824. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  79825. };
  79826. /**
  79827. * Class containing static functions to help procedurally build meshes
  79828. */
  79829. var IcoSphereBuilder = /** @class */ (function () {
  79830. function IcoSphereBuilder() {
  79831. }
  79832. /**
  79833. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79834. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79835. * * 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`)
  79836. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79837. * * 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
  79838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79839. * * 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
  79840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79841. * @param name defines the name of the mesh
  79842. * @param options defines the options used to create the mesh
  79843. * @param scene defines the hosting scene
  79844. * @returns the icosahedron mesh
  79845. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79846. */
  79847. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  79848. if (scene === void 0) { scene = null; }
  79849. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79850. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79851. sphere._originalBuilderSideOrientation = options.sideOrientation;
  79852. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  79853. vertexData.applyToMesh(sphere, options.updatable);
  79854. return sphere;
  79855. };
  79856. return IcoSphereBuilder;
  79857. }());
  79858. /***/ }),
  79859. /***/ "./Meshes/Builders/index.ts":
  79860. /*!**********************************!*\
  79861. !*** ./Meshes/Builders/index.ts ***!
  79862. \**********************************/
  79863. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  79864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79865. "use strict";
  79866. __webpack_require__.r(__webpack_exports__);
  79867. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  79868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  79869. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  79870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  79871. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  79873. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  79874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  79875. /* harmony import */ var _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  79876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__["HemisphereBuilder"]; });
  79877. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  79878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"]; });
  79879. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  79880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusBuilder"]; });
  79881. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  79882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__["TorusKnotBuilder"]; });
  79883. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  79884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"]; });
  79885. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  79886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__["PolygonBuilder"]; });
  79887. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  79888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__["ShapeBuilder"]; });
  79889. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  79890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_11__["LatheBuilder"]; });
  79891. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  79892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_12__["PlaneBuilder"]; });
  79893. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  79894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_13__["GroundBuilder"]; });
  79895. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  79896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__["TubeBuilder"]; });
  79897. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  79898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__["PolyhedronBuilder"]; });
  79899. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  79900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  79901. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  79902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  79903. /***/ }),
  79904. /***/ "./Meshes/Builders/latheBuilder.ts":
  79905. /*!*****************************************!*\
  79906. !*** ./Meshes/Builders/latheBuilder.ts ***!
  79907. \*****************************************/
  79908. /*! exports provided: LatheBuilder */
  79909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79910. "use strict";
  79911. __webpack_require__.r(__webpack_exports__);
  79912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  79913. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79914. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79915. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79916. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  79917. var options = {
  79918. shape: shape,
  79919. radius: radius,
  79920. tessellation: tessellation,
  79921. sideOrientation: sideOrientation,
  79922. updatable: updatable
  79923. };
  79924. return LatheBuilder.CreateLathe(name, options, scene);
  79925. };
  79926. /**
  79927. * Class containing static functions to help procedurally build meshes
  79928. */
  79929. var LatheBuilder = /** @class */ (function () {
  79930. function LatheBuilder() {
  79931. }
  79932. /**
  79933. * Creates lathe mesh.
  79934. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  79935. * * 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
  79936. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  79937. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  79938. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  79939. * * 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
  79940. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  79941. * * 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
  79942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79943. * * 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
  79944. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79946. * @param name defines the name of the mesh
  79947. * @param options defines the options used to create the mesh
  79948. * @param scene defines the hosting scene
  79949. * @returns the lathe mesh
  79950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  79951. */
  79952. LatheBuilder.CreateLathe = function (name, options, scene) {
  79953. if (scene === void 0) { scene = null; }
  79954. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  79955. var closed = (options.closed === undefined) ? true : options.closed;
  79956. var shape = options.shape;
  79957. var radius = options.radius || 1;
  79958. var tessellation = options.tessellation || 64;
  79959. var clip = options.clip || 0;
  79960. var updatable = options.updatable;
  79961. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79962. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79963. var pi2 = Math.PI * 2;
  79964. var paths = new Array();
  79965. var invertUV = options.invertUV || false;
  79966. var i = 0;
  79967. var p = 0;
  79968. var step = pi2 / tessellation * arc;
  79969. var rotated;
  79970. var path = new Array();
  79971. for (i = 0; i <= tessellation - clip; i++) {
  79972. var path = [];
  79973. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  79974. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  79975. 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));
  79976. }
  79977. for (p = 0; p < shape.length; p++) {
  79978. 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);
  79979. path.push(rotated);
  79980. }
  79981. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  79982. 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));
  79983. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  79984. }
  79985. paths.push(path);
  79986. }
  79987. // lathe ribbon
  79988. 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);
  79989. return lathe;
  79990. };
  79991. return LatheBuilder;
  79992. }());
  79993. /***/ }),
  79994. /***/ "./Meshes/Builders/linesBuilder.ts":
  79995. /*!*****************************************!*\
  79996. !*** ./Meshes/Builders/linesBuilder.ts ***!
  79997. \*****************************************/
  79998. /*! exports provided: LinesBuilder */
  79999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80000. "use strict";
  80001. __webpack_require__.r(__webpack_exports__);
  80002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  80003. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80004. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80005. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80006. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  80007. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  80008. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  80009. var indices = [];
  80010. var positions = [];
  80011. var lines = options.lines;
  80012. var colors = options.colors;
  80013. var vertexColors = [];
  80014. var idx = 0;
  80015. for (var l = 0; l < lines.length; l++) {
  80016. var points = lines[l];
  80017. for (var index = 0; index < points.length; index++) {
  80018. positions.push(points[index].x, points[index].y, points[index].z);
  80019. if (colors) {
  80020. var color = colors[l];
  80021. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  80022. }
  80023. if (index > 0) {
  80024. indices.push(idx - 1);
  80025. indices.push(idx);
  80026. }
  80027. idx++;
  80028. }
  80029. }
  80030. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80031. vertexData.indices = indices;
  80032. vertexData.positions = positions;
  80033. if (colors) {
  80034. vertexData.colors = vertexColors;
  80035. }
  80036. return vertexData;
  80037. };
  80038. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  80039. var dashSize = options.dashSize || 3;
  80040. var gapSize = options.gapSize || 1;
  80041. var dashNb = options.dashNb || 200;
  80042. var points = options.points;
  80043. var positions = new Array();
  80044. var indices = new Array();
  80045. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80046. var lg = 0;
  80047. var nb = 0;
  80048. var shft = 0;
  80049. var dashshft = 0;
  80050. var curshft = 0;
  80051. var idx = 0;
  80052. var i = 0;
  80053. for (i = 0; i < points.length - 1; i++) {
  80054. points[i + 1].subtractToRef(points[i], curvect);
  80055. lg += curvect.length();
  80056. }
  80057. shft = lg / dashNb;
  80058. dashshft = dashSize * shft / (dashSize + gapSize);
  80059. for (i = 0; i < points.length - 1; i++) {
  80060. points[i + 1].subtractToRef(points[i], curvect);
  80061. nb = Math.floor(curvect.length() / shft);
  80062. curvect.normalize();
  80063. for (var j = 0; j < nb; j++) {
  80064. curshft = shft * j;
  80065. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  80066. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  80067. indices.push(idx, idx + 1);
  80068. idx += 2;
  80069. }
  80070. }
  80071. // Result
  80072. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80073. vertexData.positions = positions;
  80074. vertexData.indices = indices;
  80075. return vertexData;
  80076. };
  80077. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  80078. if (scene === void 0) { scene = null; }
  80079. if (updatable === void 0) { updatable = false; }
  80080. if (instance === void 0) { instance = null; }
  80081. var options = {
  80082. points: points,
  80083. updatable: updatable,
  80084. instance: instance
  80085. };
  80086. return LinesBuilder.CreateLines(name, options, scene);
  80087. };
  80088. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  80089. if (scene === void 0) { scene = null; }
  80090. var options = {
  80091. points: points,
  80092. dashSize: dashSize,
  80093. gapSize: gapSize,
  80094. dashNb: dashNb,
  80095. updatable: updatable,
  80096. instance: instance
  80097. };
  80098. return LinesBuilder.CreateDashedLines(name, options, scene);
  80099. };
  80100. /**
  80101. * Class containing static functions to help procedurally build meshes
  80102. */
  80103. var LinesBuilder = /** @class */ (function () {
  80104. function LinesBuilder() {
  80105. }
  80106. /**
  80107. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  80108. * * 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
  80109. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  80110. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  80111. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  80112. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  80113. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  80114. * * 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
  80115. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  80116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  80118. * @param name defines the name of the new line system
  80119. * @param options defines the options used to create the line system
  80120. * @param scene defines the hosting scene
  80121. * @returns a new line system mesh
  80122. */
  80123. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  80124. var instance = options.instance;
  80125. var lines = options.lines;
  80126. var colors = options.colors;
  80127. if (instance) { // lines update
  80128. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  80129. var vertexColor;
  80130. var lineColors;
  80131. if (colors) {
  80132. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  80133. }
  80134. var i = 0;
  80135. var c = 0;
  80136. for (var l = 0; l < lines.length; l++) {
  80137. var points = lines[l];
  80138. for (var p = 0; p < points.length; p++) {
  80139. positions[i] = points[p].x;
  80140. positions[i + 1] = points[p].y;
  80141. positions[i + 2] = points[p].z;
  80142. if (colors && vertexColor) {
  80143. lineColors = colors[l];
  80144. vertexColor[c] = lineColors[p].r;
  80145. vertexColor[c + 1] = lineColors[p].g;
  80146. vertexColor[c + 2] = lineColors[p].b;
  80147. vertexColor[c + 3] = lineColors[p].a;
  80148. c += 4;
  80149. }
  80150. i += 3;
  80151. }
  80152. }
  80153. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  80154. if (colors && vertexColor) {
  80155. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  80156. }
  80157. return instance;
  80158. }
  80159. // line system creation
  80160. var useVertexColor = (colors) ? true : false;
  80161. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  80162. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  80163. vertexData.applyToMesh(lineSystem, options.updatable);
  80164. return lineSystem;
  80165. };
  80166. /**
  80167. * Creates a line mesh
  80168. * 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
  80169. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  80170. * * The parameter `points` is an array successive Vector3
  80171. * * 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
  80172. * * The optional parameter `colors` is an array of successive Color4, one per line point
  80173. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  80174. * * When updating an instance, remember that only point positions can change, not the number of points
  80175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80176. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  80177. * @param name defines the name of the new line system
  80178. * @param options defines the options used to create the line system
  80179. * @param scene defines the hosting scene
  80180. * @returns a new line mesh
  80181. */
  80182. LinesBuilder.CreateLines = function (name, options, scene) {
  80183. if (scene === void 0) { scene = null; }
  80184. var colors = (options.colors) ? [options.colors] : null;
  80185. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  80186. return lines;
  80187. };
  80188. /**
  80189. * Creates a dashed line mesh
  80190. * * 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
  80191. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  80192. * * The parameter `points` is an array successive Vector3
  80193. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  80194. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  80195. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80196. * * 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
  80197. * * When updating an instance, remember that only point positions can change, not the number of points
  80198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80199. * @param name defines the name of the mesh
  80200. * @param options defines the options used to create the mesh
  80201. * @param scene defines the hosting scene
  80202. * @returns the dashed line mesh
  80203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  80204. */
  80205. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  80206. if (scene === void 0) { scene = null; }
  80207. var points = options.points;
  80208. var instance = options.instance;
  80209. var gapSize = options.gapSize || 1;
  80210. var dashSize = options.dashSize || 3;
  80211. if (instance) { // dashed lines update
  80212. var positionFunction = function (positions) {
  80213. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80214. var nbSeg = positions.length / 6;
  80215. var lg = 0;
  80216. var nb = 0;
  80217. var shft = 0;
  80218. var dashshft = 0;
  80219. var curshft = 0;
  80220. var p = 0;
  80221. var i = 0;
  80222. var j = 0;
  80223. for (i = 0; i < points.length - 1; i++) {
  80224. points[i + 1].subtractToRef(points[i], curvect);
  80225. lg += curvect.length();
  80226. }
  80227. shft = lg / nbSeg;
  80228. var dashSize = instance._creationDataStorage.dashSize;
  80229. var gapSize = instance._creationDataStorage.gapSize;
  80230. dashshft = dashSize * shft / (dashSize + gapSize);
  80231. for (i = 0; i < points.length - 1; i++) {
  80232. points[i + 1].subtractToRef(points[i], curvect);
  80233. nb = Math.floor(curvect.length() / shft);
  80234. curvect.normalize();
  80235. j = 0;
  80236. while (j < nb && p < positions.length) {
  80237. curshft = shft * j;
  80238. positions[p] = points[i].x + curshft * curvect.x;
  80239. positions[p + 1] = points[i].y + curshft * curvect.y;
  80240. positions[p + 2] = points[i].z + curshft * curvect.z;
  80241. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  80242. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  80243. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  80244. p += 6;
  80245. j++;
  80246. }
  80247. }
  80248. while (p < positions.length) {
  80249. positions[p] = points[i].x;
  80250. positions[p + 1] = points[i].y;
  80251. positions[p + 2] = points[i].z;
  80252. p += 3;
  80253. }
  80254. };
  80255. instance.updateMeshPositions(positionFunction, false);
  80256. return instance;
  80257. }
  80258. // dashed lines creation
  80259. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  80260. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  80261. vertexData.applyToMesh(dashedLines, options.updatable);
  80262. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  80263. dashedLines._creationDataStorage.dashSize = dashSize;
  80264. dashedLines._creationDataStorage.gapSize = gapSize;
  80265. return dashedLines;
  80266. };
  80267. return LinesBuilder;
  80268. }());
  80269. /***/ }),
  80270. /***/ "./Meshes/Builders/planeBuilder.ts":
  80271. /*!*****************************************!*\
  80272. !*** ./Meshes/Builders/planeBuilder.ts ***!
  80273. \*****************************************/
  80274. /*! exports provided: PlaneBuilder */
  80275. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80276. "use strict";
  80277. __webpack_require__.r(__webpack_exports__);
  80278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  80279. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80280. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80281. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  80282. var indices = [];
  80283. var positions = [];
  80284. var normals = [];
  80285. var uvs = [];
  80286. var width = options.width || options.size || 1;
  80287. var height = options.height || options.size || 1;
  80288. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  80289. // Vertices
  80290. var halfWidth = width / 2.0;
  80291. var halfHeight = height / 2.0;
  80292. positions.push(-halfWidth, -halfHeight, 0);
  80293. normals.push(0, 0, -1.0);
  80294. uvs.push(0.0, 0.0);
  80295. positions.push(halfWidth, -halfHeight, 0);
  80296. normals.push(0, 0, -1.0);
  80297. uvs.push(1.0, 0.0);
  80298. positions.push(halfWidth, halfHeight, 0);
  80299. normals.push(0, 0, -1.0);
  80300. uvs.push(1.0, 1.0);
  80301. positions.push(-halfWidth, halfHeight, 0);
  80302. normals.push(0, 0, -1.0);
  80303. uvs.push(0.0, 1.0);
  80304. // Indices
  80305. indices.push(0);
  80306. indices.push(1);
  80307. indices.push(2);
  80308. indices.push(0);
  80309. indices.push(2);
  80310. indices.push(3);
  80311. // Sides
  80312. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80313. // Result
  80314. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  80315. vertexData.indices = indices;
  80316. vertexData.positions = positions;
  80317. vertexData.normals = normals;
  80318. vertexData.uvs = uvs;
  80319. return vertexData;
  80320. };
  80321. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  80322. var options = {
  80323. size: size,
  80324. width: size,
  80325. height: size,
  80326. sideOrientation: sideOrientation,
  80327. updatable: updatable
  80328. };
  80329. return PlaneBuilder.CreatePlane(name, options, scene);
  80330. };
  80331. /**
  80332. * Class containing static functions to help procedurally build meshes
  80333. */
  80334. var PlaneBuilder = /** @class */ (function () {
  80335. function PlaneBuilder() {
  80336. }
  80337. /**
  80338. * Creates a plane mesh
  80339. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  80340. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  80341. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  80342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80343. * * 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
  80344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80345. * @param name defines the name of the mesh
  80346. * @param options defines the options used to create the mesh
  80347. * @param scene defines the hosting scene
  80348. * @returns the plane mesh
  80349. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  80350. */
  80351. PlaneBuilder.CreatePlane = function (name, options, scene) {
  80352. if (scene === void 0) { scene = null; }
  80353. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  80354. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80355. plane._originalBuilderSideOrientation = options.sideOrientation;
  80356. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  80357. vertexData.applyToMesh(plane, options.updatable);
  80358. if (options.sourcePlane) {
  80359. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  80360. plane.setDirection(options.sourcePlane.normal.scale(-1));
  80361. }
  80362. return plane;
  80363. };
  80364. return PlaneBuilder;
  80365. }());
  80366. /***/ }),
  80367. /***/ "./Meshes/Builders/polygonBuilder.ts":
  80368. /*!*******************************************!*\
  80369. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  80370. \*******************************************/
  80371. /*! exports provided: PolygonBuilder */
  80372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80373. "use strict";
  80374. __webpack_require__.r(__webpack_exports__);
  80375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  80376. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80377. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80378. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80379. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  80380. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  80381. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  80382. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  80383. var faceUV = fUV || new Array(3);
  80384. var faceColors = fColors;
  80385. var colors = [];
  80386. // default face colors and UV if undefined
  80387. for (var f = 0; f < 3; f++) {
  80388. if (faceUV[f] === undefined) {
  80389. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  80390. }
  80391. if (faceColors && faceColors[f] === undefined) {
  80392. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  80393. }
  80394. }
  80395. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  80396. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  80397. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  80398. var indices = polygon.getIndices();
  80399. // set face colours and textures
  80400. var idx = 0;
  80401. var face = 0;
  80402. for (var index = 0; index < normals.length; index += 3) {
  80403. //Edge Face no. 1
  80404. if (Math.abs(normals[index + 1]) < 0.001) {
  80405. face = 1;
  80406. }
  80407. //Top Face no. 0
  80408. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  80409. face = 0;
  80410. }
  80411. //Bottom Face no. 2
  80412. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  80413. face = 2;
  80414. }
  80415. idx = index / 3;
  80416. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  80417. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  80418. if (faceColors) {
  80419. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  80420. }
  80421. }
  80422. // sides
  80423. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  80424. // Result
  80425. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80426. vertexData.indices = indices;
  80427. vertexData.positions = positions;
  80428. vertexData.normals = normals;
  80429. vertexData.uvs = uvs;
  80430. if (faceColors) {
  80431. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  80432. vertexData.colors = totalColors;
  80433. }
  80434. return vertexData;
  80435. };
  80436. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  80437. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80438. var options = {
  80439. shape: shape,
  80440. holes: holes,
  80441. updatable: updatable,
  80442. sideOrientation: sideOrientation
  80443. };
  80444. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  80445. };
  80446. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  80447. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80448. var options = {
  80449. shape: shape,
  80450. holes: holes,
  80451. depth: depth,
  80452. updatable: updatable,
  80453. sideOrientation: sideOrientation
  80454. };
  80455. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  80456. };
  80457. /**
  80458. * Class containing static functions to help procedurally build meshes
  80459. */
  80460. var PolygonBuilder = /** @class */ (function () {
  80461. function PolygonBuilder() {
  80462. }
  80463. /**
  80464. * Creates a polygon mesh
  80465. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  80466. * * 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
  80467. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80469. * * 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)
  80470. * * Remember you can only change the shape positions, not their number when updating a polygon
  80471. * @param name defines the name of the mesh
  80472. * @param options defines the options used to create the mesh
  80473. * @param scene defines the hosting scene
  80474. * @param earcutInjection can be used to inject your own earcut reference
  80475. * @returns the polygon mesh
  80476. */
  80477. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  80478. if (scene === void 0) { scene = null; }
  80479. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80480. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80481. var shape = options.shape;
  80482. var holes = options.holes || [];
  80483. var depth = options.depth || 0;
  80484. var contours = [];
  80485. var hole = [];
  80486. for (var i = 0; i < shape.length; i++) {
  80487. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  80488. }
  80489. var epsilon = 0.00000001;
  80490. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  80491. contours.pop();
  80492. }
  80493. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene, earcutInjection);
  80494. for (var hNb = 0; hNb < holes.length; hNb++) {
  80495. hole = [];
  80496. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  80497. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  80498. }
  80499. polygonTriangulation.addHole(hole);
  80500. }
  80501. var polygon = polygonTriangulation.build(options.updatable, depth);
  80502. polygon._originalBuilderSideOrientation = options.sideOrientation;
  80503. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  80504. vertexData.applyToMesh(polygon, options.updatable);
  80505. return polygon;
  80506. };
  80507. /**
  80508. * Creates an extruded polygon mesh, with depth in the Y direction.
  80509. * * 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)
  80510. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  80511. * @param name defines the name of the mesh
  80512. * @param options defines the options used to create the mesh
  80513. * @param scene defines the hosting scene
  80514. * @param earcutInjection can be used to inject your own earcut reference
  80515. * @returns the polygon mesh
  80516. */
  80517. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  80518. if (scene === void 0) { scene = null; }
  80519. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80520. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  80521. };
  80522. return PolygonBuilder;
  80523. }());
  80524. /***/ }),
  80525. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  80526. /*!**********************************************!*\
  80527. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  80528. \**********************************************/
  80529. /*! exports provided: PolyhedronBuilder */
  80530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80531. "use strict";
  80532. __webpack_require__.r(__webpack_exports__);
  80533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  80534. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80535. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80536. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80537. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  80538. // provided polyhedron types :
  80539. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80540. // 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)
  80541. var polyhedra = [];
  80542. 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]] };
  80543. 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]] };
  80544. polyhedra[2] = {
  80545. 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]],
  80546. 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]]
  80547. };
  80548. polyhedra[3] = {
  80549. 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]],
  80550. 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]]
  80551. };
  80552. polyhedra[4] = {
  80553. 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]],
  80554. 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]]
  80555. };
  80556. 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]] };
  80557. 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]] };
  80558. 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]] };
  80559. 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]] };
  80560. 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]] };
  80561. 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]] };
  80562. 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]] };
  80563. 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]] };
  80564. 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]] };
  80565. polyhedra[14] = {
  80566. 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]],
  80567. 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]]
  80568. };
  80569. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  80570. var size = options.size;
  80571. var sizeX = options.sizeX || size || 1;
  80572. var sizeY = options.sizeY || size || 1;
  80573. var sizeZ = options.sizeZ || size || 1;
  80574. var data = options.custom || polyhedra[type];
  80575. var nbfaces = data.face.length;
  80576. var faceUV = options.faceUV || new Array(nbfaces);
  80577. var faceColors = options.faceColors;
  80578. var flat = (options.flat === undefined) ? true : options.flat;
  80579. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80580. var positions = new Array();
  80581. var indices = new Array();
  80582. var normals = new Array();
  80583. var uvs = new Array();
  80584. var colors = new Array();
  80585. var index = 0;
  80586. var faceIdx = 0; // face cursor in the array "indexes"
  80587. var indexes = new Array();
  80588. var i = 0;
  80589. var f = 0;
  80590. var u, v, ang, x, y, tmp;
  80591. // default face colors and UV if undefined
  80592. if (flat) {
  80593. for (f = 0; f < nbfaces; f++) {
  80594. if (faceColors && faceColors[f] === undefined) {
  80595. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  80596. }
  80597. if (faceUV && faceUV[f] === undefined) {
  80598. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  80599. }
  80600. }
  80601. }
  80602. if (!flat) {
  80603. for (i = 0; i < data.vertex.length; i++) {
  80604. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  80605. uvs.push(0, 0);
  80606. }
  80607. for (f = 0; f < nbfaces; f++) {
  80608. for (i = 0; i < data.face[f].length - 2; i++) {
  80609. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  80610. }
  80611. }
  80612. }
  80613. else {
  80614. for (f = 0; f < nbfaces; f++) {
  80615. var fl = data.face[f].length; // number of vertices of the current face
  80616. ang = 2 * Math.PI / fl;
  80617. x = 0.5 * Math.tan(ang / 2);
  80618. y = 0.5;
  80619. // positions, uvs, colors
  80620. for (i = 0; i < fl; i++) {
  80621. // positions
  80622. 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);
  80623. indexes.push(index);
  80624. index++;
  80625. // uvs
  80626. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  80627. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  80628. uvs.push(u, v);
  80629. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  80630. y = x * Math.sin(ang) + y * Math.cos(ang);
  80631. x = tmp;
  80632. // colors
  80633. if (faceColors) {
  80634. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  80635. }
  80636. }
  80637. // indices from indexes
  80638. for (i = 0; i < fl - 2; i++) {
  80639. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  80640. }
  80641. faceIdx += fl;
  80642. }
  80643. }
  80644. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  80645. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80646. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80647. vertexData.positions = positions;
  80648. vertexData.indices = indices;
  80649. vertexData.normals = normals;
  80650. vertexData.uvs = uvs;
  80651. if (faceColors && flat) {
  80652. vertexData.colors = colors;
  80653. }
  80654. return vertexData;
  80655. };
  80656. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  80657. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  80658. };
  80659. /**
  80660. * Class containing static functions to help procedurally build meshes
  80661. */
  80662. var PolyhedronBuilder = /** @class */ (function () {
  80663. function PolyhedronBuilder() {
  80664. }
  80665. /**
  80666. * Creates a polyhedron mesh
  80667. * * 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
  80668. * * The parameter `size` (positive float, default 1) sets the polygon size
  80669. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80670. * * 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`
  80671. * * 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
  80672. * * 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)`)
  80673. * * 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
  80674. * * 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
  80675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80676. * * 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
  80677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80678. * @param name defines the name of the mesh
  80679. * @param options defines the options used to create the mesh
  80680. * @param scene defines the hosting scene
  80681. * @returns the polyhedron mesh
  80682. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  80683. */
  80684. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  80685. if (scene === void 0) { scene = null; }
  80686. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80687. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80688. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  80689. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  80690. vertexData.applyToMesh(polyhedron, options.updatable);
  80691. return polyhedron;
  80692. };
  80693. return PolyhedronBuilder;
  80694. }());
  80695. /***/ }),
  80696. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  80697. /*!******************************************!*\
  80698. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  80699. \******************************************/
  80700. /*! exports provided: RibbonBuilder */
  80701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80702. "use strict";
  80703. __webpack_require__.r(__webpack_exports__);
  80704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  80705. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80706. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80707. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  80708. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80709. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  80710. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  80711. var pathArray = options.pathArray;
  80712. var closeArray = options.closeArray || false;
  80713. var closePath = options.closePath || false;
  80714. var invertUV = options.invertUV || false;
  80715. var defaultOffset = Math.floor(pathArray[0].length / 2);
  80716. var offset = options.offset || defaultOffset;
  80717. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  80718. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  80719. var customUV = options.uvs;
  80720. var customColors = options.colors;
  80721. var positions = [];
  80722. var indices = [];
  80723. var normals = [];
  80724. var uvs = [];
  80725. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  80726. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  80727. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  80728. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  80729. var minlg; // minimal length among all paths from pathArray
  80730. var lg = []; // array of path lengths : nb of vertex per path
  80731. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  80732. var p; // path iterator
  80733. var i; // point iterator
  80734. var j; // point iterator
  80735. // if single path in pathArray
  80736. if (pathArray.length < 2) {
  80737. var ar1 = [];
  80738. var ar2 = [];
  80739. for (i = 0; i < pathArray[0].length - offset; i++) {
  80740. ar1.push(pathArray[0][i]);
  80741. ar2.push(pathArray[0][i + offset]);
  80742. }
  80743. pathArray = [ar1, ar2];
  80744. }
  80745. // positions and horizontal distances (u)
  80746. var idc = 0;
  80747. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  80748. var path;
  80749. var l;
  80750. minlg = pathArray[0].length;
  80751. var vectlg;
  80752. var dist;
  80753. for (p = 0; p < pathArray.length; p++) {
  80754. uTotalDistance[p] = 0;
  80755. us[p] = [0];
  80756. path = pathArray[p];
  80757. l = path.length;
  80758. minlg = (minlg < l) ? minlg : l;
  80759. j = 0;
  80760. while (j < l) {
  80761. positions.push(path[j].x, path[j].y, path[j].z);
  80762. if (j > 0) {
  80763. vectlg = path[j].subtract(path[j - 1]).length();
  80764. dist = vectlg + uTotalDistance[p];
  80765. us[p].push(dist);
  80766. uTotalDistance[p] = dist;
  80767. }
  80768. j++;
  80769. }
  80770. if (closePath) { // an extra hidden vertex is added in the "positions" array
  80771. j--;
  80772. positions.push(path[0].x, path[0].y, path[0].z);
  80773. vectlg = path[j].subtract(path[0]).length();
  80774. dist = vectlg + uTotalDistance[p];
  80775. us[p].push(dist);
  80776. uTotalDistance[p] = dist;
  80777. }
  80778. lg[p] = l + closePathCorr;
  80779. idx[p] = idc;
  80780. idc += (l + closePathCorr);
  80781. }
  80782. // vertical distances (v)
  80783. var path1;
  80784. var path2;
  80785. var vertex1 = null;
  80786. var vertex2 = null;
  80787. for (i = 0; i < minlg + closePathCorr; i++) {
  80788. vTotalDistance[i] = 0;
  80789. vs[i] = [0];
  80790. for (p = 0; p < pathArray.length - 1; p++) {
  80791. path1 = pathArray[p];
  80792. path2 = pathArray[p + 1];
  80793. if (i === minlg) { // closePath
  80794. vertex1 = path1[0];
  80795. vertex2 = path2[0];
  80796. }
  80797. else {
  80798. vertex1 = path1[i];
  80799. vertex2 = path2[i];
  80800. }
  80801. vectlg = vertex2.subtract(vertex1).length();
  80802. dist = vectlg + vTotalDistance[i];
  80803. vs[i].push(dist);
  80804. vTotalDistance[i] = dist;
  80805. }
  80806. if (closeArray && vertex2 && vertex1) {
  80807. path1 = pathArray[p];
  80808. path2 = pathArray[0];
  80809. if (i === minlg) { // closePath
  80810. vertex2 = path2[0];
  80811. }
  80812. vectlg = vertex2.subtract(vertex1).length();
  80813. dist = vectlg + vTotalDistance[i];
  80814. vTotalDistance[i] = dist;
  80815. }
  80816. }
  80817. // uvs
  80818. var u;
  80819. var v;
  80820. if (customUV) {
  80821. for (p = 0; p < customUV.length; p++) {
  80822. uvs.push(customUV[p].x, customUV[p].y);
  80823. }
  80824. }
  80825. else {
  80826. for (p = 0; p < pathArray.length; p++) {
  80827. for (i = 0; i < minlg + closePathCorr; i++) {
  80828. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  80829. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  80830. if (invertUV) {
  80831. uvs.push(v, u);
  80832. }
  80833. else {
  80834. uvs.push(u, v);
  80835. }
  80836. }
  80837. }
  80838. }
  80839. // indices
  80840. p = 0; // path index
  80841. var pi = 0; // positions array index
  80842. var l1 = lg[p] - 1; // path1 length
  80843. var l2 = lg[p + 1] - 1; // path2 length
  80844. var min = (l1 < l2) ? l1 : l2; // current path stop index
  80845. var shft = idx[1] - idx[0]; // shift
  80846. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  80847. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  80848. // 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
  80849. indices.push(pi, pi + shft, pi + 1);
  80850. indices.push(pi + shft + 1, pi + 1, pi + shft);
  80851. pi += 1;
  80852. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  80853. p++;
  80854. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  80855. shft = idx[0] - idx[p];
  80856. l1 = lg[p] - 1;
  80857. l2 = lg[0] - 1;
  80858. }
  80859. else {
  80860. shft = idx[p + 1] - idx[p];
  80861. l1 = lg[p] - 1;
  80862. l2 = lg[p + 1] - 1;
  80863. }
  80864. pi = idx[p];
  80865. min = (l1 < l2) ? l1 + pi : l2 + pi;
  80866. }
  80867. }
  80868. // normals
  80869. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  80870. if (closePath) { // update both the first and last vertex normals to their average value
  80871. var indexFirst = 0;
  80872. var indexLast = 0;
  80873. for (p = 0; p < pathArray.length; p++) {
  80874. indexFirst = idx[p] * 3;
  80875. if (p + 1 < pathArray.length) {
  80876. indexLast = (idx[p + 1] - 1) * 3;
  80877. }
  80878. else {
  80879. indexLast = normals.length - 3;
  80880. }
  80881. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  80882. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  80883. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  80884. normals[indexLast] = normals[indexFirst];
  80885. normals[indexLast + 1] = normals[indexFirst + 1];
  80886. normals[indexLast + 2] = normals[indexFirst + 2];
  80887. }
  80888. }
  80889. // sides
  80890. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80891. // Colors
  80892. var colors = null;
  80893. if (customColors) {
  80894. colors = new Float32Array(customColors.length * 4);
  80895. for (var c = 0; c < customColors.length; c++) {
  80896. colors[c * 4] = customColors[c].r;
  80897. colors[c * 4 + 1] = customColors[c].g;
  80898. colors[c * 4 + 2] = customColors[c].b;
  80899. colors[c * 4 + 3] = customColors[c].a;
  80900. }
  80901. }
  80902. // Result
  80903. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  80904. var positions32 = new Float32Array(positions);
  80905. var normals32 = new Float32Array(normals);
  80906. var uvs32 = new Float32Array(uvs);
  80907. vertexData.indices = indices;
  80908. vertexData.positions = positions32;
  80909. vertexData.normals = normals32;
  80910. vertexData.uvs = uvs32;
  80911. if (colors) {
  80912. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  80913. }
  80914. if (closePath) {
  80915. vertexData._idx = idx;
  80916. }
  80917. return vertexData;
  80918. };
  80919. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  80920. if (closeArray === void 0) { closeArray = false; }
  80921. if (updatable === void 0) { updatable = false; }
  80922. return RibbonBuilder.CreateRibbon(name, {
  80923. pathArray: pathArray,
  80924. closeArray: closeArray,
  80925. closePath: closePath,
  80926. offset: offset,
  80927. updatable: updatable,
  80928. sideOrientation: sideOrientation,
  80929. instance: instance
  80930. }, scene);
  80931. };
  80932. /**
  80933. * Class containing static functions to help procedurally build meshes
  80934. */
  80935. var RibbonBuilder = /** @class */ (function () {
  80936. function RibbonBuilder() {
  80937. }
  80938. /**
  80939. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  80940. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  80941. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  80942. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  80943. * * 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
  80944. * * 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
  80945. * * 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
  80946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80947. * * 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
  80948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80949. * * 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
  80950. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  80951. * * 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
  80952. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  80953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80954. * @param name defines the name of the mesh
  80955. * @param options defines the options used to create the mesh
  80956. * @param scene defines the hosting scene
  80957. * @returns the ribbon mesh
  80958. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  80959. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80960. */
  80961. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  80962. if (scene === void 0) { scene = null; }
  80963. var pathArray = options.pathArray;
  80964. var closeArray = options.closeArray;
  80965. var closePath = options.closePath;
  80966. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80967. var instance = options.instance;
  80968. var updatable = options.updatable;
  80969. if (instance) { // existing ribbon instance update
  80970. // positionFunction : ribbon case
  80971. // only pathArray and sideOrientation parameters are taken into account for positions update
  80972. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  80973. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  80974. var positionFunction = function (positions) {
  80975. var minlg = pathArray[0].length;
  80976. var mesh = instance;
  80977. var i = 0;
  80978. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  80979. for (var si = 1; si <= ns; ++si) {
  80980. for (var p = 0; p < pathArray.length; ++p) {
  80981. var path = pathArray[p];
  80982. var l = path.length;
  80983. minlg = (minlg < l) ? minlg : l;
  80984. for (var j = 0; j < minlg; ++j) {
  80985. var pathPoint = path[j];
  80986. positions[i] = pathPoint.x;
  80987. positions[i + 1] = pathPoint.y;
  80988. positions[i + 2] = pathPoint.z;
  80989. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  80990. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  80991. i += 3;
  80992. }
  80993. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  80994. var pathPoint = path[0];
  80995. positions[i] = pathPoint.x;
  80996. positions[i + 1] = pathPoint.y;
  80997. positions[i + 2] = pathPoint.z;
  80998. i += 3;
  80999. }
  81000. }
  81001. }
  81002. };
  81003. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  81004. positionFunction(positions);
  81005. if (instance._boundingInfo) {
  81006. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  81007. }
  81008. else {
  81009. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  81010. }
  81011. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  81012. if (options.colors) {
  81013. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  81014. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  81015. var color = options.colors[c];
  81016. colors[colorIndex] = color.r;
  81017. colors[colorIndex + 1] = color.g;
  81018. colors[colorIndex + 2] = color.b;
  81019. colors[colorIndex + 3] = color.a;
  81020. }
  81021. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  81022. }
  81023. if (options.uvs) {
  81024. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  81025. for (var i = 0; i < options.uvs.length; i++) {
  81026. uvs[i * 2] = options.uvs[i].x;
  81027. uvs[i * 2 + 1] = options.uvs[i].y;
  81028. }
  81029. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  81030. }
  81031. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  81032. var indices = instance.getIndices();
  81033. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  81034. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  81035. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  81036. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  81037. var indexFirst = 0;
  81038. var indexLast = 0;
  81039. for (var p = 0; p < pathArray.length; p++) {
  81040. indexFirst = instance._creationDataStorage.idx[p] * 3;
  81041. if (p + 1 < pathArray.length) {
  81042. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  81043. }
  81044. else {
  81045. indexLast = normals.length - 3;
  81046. }
  81047. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  81048. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  81049. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  81050. normals[indexLast] = normals[indexFirst];
  81051. normals[indexLast + 1] = normals[indexFirst + 1];
  81052. normals[indexLast + 2] = normals[indexFirst + 2];
  81053. }
  81054. }
  81055. if (!(instance.areNormalsFrozen)) {
  81056. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  81057. }
  81058. }
  81059. return instance;
  81060. }
  81061. else { // new ribbon creation
  81062. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81063. ribbon._originalBuilderSideOrientation = sideOrientation;
  81064. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  81065. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  81066. if (closePath) {
  81067. ribbon._creationDataStorage.idx = vertexData._idx;
  81068. }
  81069. ribbon._creationDataStorage.closePath = closePath;
  81070. ribbon._creationDataStorage.closeArray = closeArray;
  81071. vertexData.applyToMesh(ribbon, updatable);
  81072. return ribbon;
  81073. }
  81074. };
  81075. return RibbonBuilder;
  81076. }());
  81077. /***/ }),
  81078. /***/ "./Meshes/Builders/shapeBuilder.ts":
  81079. /*!*****************************************!*\
  81080. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  81081. \*****************************************/
  81082. /*! exports provided: ShapeBuilder */
  81083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81084. "use strict";
  81085. __webpack_require__.r(__webpack_exports__);
  81086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  81087. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81088. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81089. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  81090. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  81091. if (scene === void 0) { scene = null; }
  81092. var options = {
  81093. shape: shape,
  81094. path: path,
  81095. scale: scale,
  81096. rotation: rotation,
  81097. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  81098. sideOrientation: sideOrientation,
  81099. instance: instance,
  81100. updatable: updatable
  81101. };
  81102. return ShapeBuilder.ExtrudeShape(name, options, scene);
  81103. };
  81104. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  81105. var options = {
  81106. shape: shape,
  81107. path: path,
  81108. scaleFunction: scaleFunction,
  81109. rotationFunction: rotationFunction,
  81110. ribbonCloseArray: ribbonCloseArray,
  81111. ribbonClosePath: ribbonClosePath,
  81112. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  81113. sideOrientation: sideOrientation,
  81114. instance: instance,
  81115. updatable: updatable
  81116. };
  81117. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  81118. };
  81119. /**
  81120. * Class containing static functions to help procedurally build meshes
  81121. */
  81122. var ShapeBuilder = /** @class */ (function () {
  81123. function ShapeBuilder() {
  81124. }
  81125. /**
  81126. * 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.
  81127. * * 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.
  81128. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  81129. * * 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.
  81130. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  81131. * * 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
  81132. * * 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
  81133. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  81134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81135. * * 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
  81136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  81137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81138. * @param name defines the name of the mesh
  81139. * @param options defines the options used to create the mesh
  81140. * @param scene defines the hosting scene
  81141. * @returns the extruded shape mesh
  81142. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  81143. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81144. */
  81145. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  81146. if (scene === void 0) { scene = null; }
  81147. var path = options.path;
  81148. var shape = options.shape;
  81149. var scale = options.scale || 1;
  81150. var rotation = options.rotation || 0;
  81151. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  81152. var updatable = options.updatable;
  81153. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81154. var instance = options.instance || null;
  81155. var invertUV = options.invertUV || false;
  81156. 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);
  81157. };
  81158. /**
  81159. * Creates an custom extruded shape mesh.
  81160. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  81161. * * 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.
  81162. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  81163. * * 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
  81164. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  81165. * * 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
  81166. * * It must returns a float value that will be the scale value applied to the shape on each path point
  81167. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81168. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  81169. * * 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
  81170. * * 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
  81171. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  81172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81173. * * 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
  81174. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  81175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81176. * @param name defines the name of the mesh
  81177. * @param options defines the options used to create the mesh
  81178. * @param scene defines the hosting scene
  81179. * @returns the custom extruded shape mesh
  81180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  81181. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  81182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81183. */
  81184. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  81185. if (scene === void 0) { scene = null; }
  81186. var path = options.path;
  81187. var shape = options.shape;
  81188. var scaleFunction = options.scaleFunction || (function () { return 1; });
  81189. var rotationFunction = options.rotationFunction || (function () { return 0; });
  81190. var ribbonCloseArray = options.ribbonCloseArray || false;
  81191. var ribbonClosePath = options.ribbonClosePath || false;
  81192. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  81193. var updatable = options.updatable;
  81194. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81195. var instance = options.instance;
  81196. var invertUV = options.invertUV || false;
  81197. 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);
  81198. };
  81199. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  81200. // extrusion geometry
  81201. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  81202. var tangents = path3D.getTangents();
  81203. var normals = path3D.getNormals();
  81204. var binormals = path3D.getBinormals();
  81205. var distances = path3D.getDistances();
  81206. var angle = 0;
  81207. var returnScale = function () { return scale !== null ? scale : 1; };
  81208. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  81209. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  81210. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  81211. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  81212. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  81213. for (var i = 0; i < curve.length; i++) {
  81214. var shapePath = new Array();
  81215. var angleStep = rotate(i, distances[i]);
  81216. var scaleRatio = scl(i, distances[i]);
  81217. for (var p = 0; p < shape.length; p++) {
  81218. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  81219. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  81220. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  81221. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  81222. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  81223. shapePath[p] = rotated;
  81224. }
  81225. shapePaths[index] = shapePath;
  81226. angle += angleStep;
  81227. index++;
  81228. }
  81229. // cap
  81230. var capPath = function (shapePath) {
  81231. var pointCap = Array();
  81232. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  81233. var i;
  81234. for (i = 0; i < shapePath.length; i++) {
  81235. barycenter.addInPlace(shapePath[i]);
  81236. }
  81237. barycenter.scaleInPlace(1.0 / shapePath.length);
  81238. for (i = 0; i < shapePath.length; i++) {
  81239. pointCap.push(barycenter);
  81240. }
  81241. return pointCap;
  81242. };
  81243. switch (cap) {
  81244. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  81245. break;
  81246. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  81247. shapePaths[0] = capPath(shapePaths[2]);
  81248. shapePaths[1] = shapePaths[2];
  81249. break;
  81250. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  81251. shapePaths[index] = shapePaths[index - 1];
  81252. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  81253. break;
  81254. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  81255. shapePaths[0] = capPath(shapePaths[2]);
  81256. shapePaths[1] = shapePaths[2];
  81257. shapePaths[index] = shapePaths[index - 1];
  81258. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  81259. break;
  81260. default:
  81261. break;
  81262. }
  81263. return shapePaths;
  81264. };
  81265. var path3D;
  81266. var pathArray;
  81267. if (instance) { // instance update
  81268. var storage = instance._creationDataStorage;
  81269. path3D = storage.path3D.update(curve);
  81270. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  81271. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  81272. return instance;
  81273. }
  81274. // extruded shape creation
  81275. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  81276. var newShapePaths = new Array();
  81277. cap = (cap < 0 || cap > 3) ? 0 : cap;
  81278. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  81279. 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);
  81280. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  81281. extrudedGeneric._creationDataStorage.path3D = path3D;
  81282. extrudedGeneric._creationDataStorage.cap = cap;
  81283. return extrudedGeneric;
  81284. };
  81285. return ShapeBuilder;
  81286. }());
  81287. /***/ }),
  81288. /***/ "./Meshes/Builders/sphereBuilder.ts":
  81289. /*!******************************************!*\
  81290. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  81291. \******************************************/
  81292. /*! exports provided: SphereBuilder */
  81293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81294. "use strict";
  81295. __webpack_require__.r(__webpack_exports__);
  81296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  81297. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81298. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81299. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81300. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  81301. var segments = options.segments || 32;
  81302. var diameterX = options.diameterX || options.diameter || 1;
  81303. var diameterY = options.diameterY || options.diameter || 1;
  81304. var diameterZ = options.diameterZ || options.diameter || 1;
  81305. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  81306. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  81307. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  81308. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  81309. var totalZRotationSteps = 2 + segments;
  81310. var totalYRotationSteps = 2 * totalZRotationSteps;
  81311. var indices = [];
  81312. var positions = [];
  81313. var normals = [];
  81314. var uvs = [];
  81315. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  81316. var normalizedZ = zRotationStep / totalZRotationSteps;
  81317. var angleZ = normalizedZ * Math.PI * slice;
  81318. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  81319. var normalizedY = yRotationStep / totalYRotationSteps;
  81320. var angleY = normalizedY * Math.PI * 2 * arc;
  81321. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  81322. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  81323. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  81324. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  81325. var vertex = complete.multiply(radius);
  81326. var normal = complete.divide(radius).normalize();
  81327. positions.push(vertex.x, vertex.y, vertex.z);
  81328. normals.push(normal.x, normal.y, normal.z);
  81329. uvs.push(normalizedY, normalizedZ);
  81330. }
  81331. if (zRotationStep > 0) {
  81332. var verticesCount = positions.length / 3;
  81333. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  81334. indices.push((firstIndex));
  81335. indices.push((firstIndex + 1));
  81336. indices.push(firstIndex + totalYRotationSteps + 1);
  81337. indices.push((firstIndex + totalYRotationSteps + 1));
  81338. indices.push((firstIndex + 1));
  81339. indices.push((firstIndex + totalYRotationSteps + 2));
  81340. }
  81341. }
  81342. }
  81343. // Sides
  81344. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81345. // Result
  81346. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81347. vertexData.indices = indices;
  81348. vertexData.positions = positions;
  81349. vertexData.normals = normals;
  81350. vertexData.uvs = uvs;
  81351. return vertexData;
  81352. };
  81353. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  81354. var options = {
  81355. segments: segments,
  81356. diameterX: diameter,
  81357. diameterY: diameter,
  81358. diameterZ: diameter,
  81359. sideOrientation: sideOrientation,
  81360. updatable: updatable
  81361. };
  81362. return SphereBuilder.CreateSphere(name, options, scene);
  81363. };
  81364. /**
  81365. * Class containing static functions to help procedurally build meshes
  81366. */
  81367. var SphereBuilder = /** @class */ (function () {
  81368. function SphereBuilder() {
  81369. }
  81370. /**
  81371. * Creates a sphere mesh
  81372. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  81373. * * 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`)
  81374. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  81375. * * 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
  81376. * * 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)
  81377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81378. * * 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
  81379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81380. * @param name defines the name of the mesh
  81381. * @param options defines the options used to create the mesh
  81382. * @param scene defines the hosting scene
  81383. * @returns the sphere mesh
  81384. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  81385. */
  81386. SphereBuilder.CreateSphere = function (name, options, scene) {
  81387. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81388. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81389. sphere._originalBuilderSideOrientation = options.sideOrientation;
  81390. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  81391. vertexData.applyToMesh(sphere, options.updatable);
  81392. return sphere;
  81393. };
  81394. return SphereBuilder;
  81395. }());
  81396. /***/ }),
  81397. /***/ "./Meshes/Builders/torusBuilder.ts":
  81398. /*!*****************************************!*\
  81399. !*** ./Meshes/Builders/torusBuilder.ts ***!
  81400. \*****************************************/
  81401. /*! exports provided: TorusBuilder */
  81402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81403. "use strict";
  81404. __webpack_require__.r(__webpack_exports__);
  81405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  81406. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81407. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81408. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81409. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  81410. var indices = [];
  81411. var positions = [];
  81412. var normals = [];
  81413. var uvs = [];
  81414. var diameter = options.diameter || 1;
  81415. var thickness = options.thickness || 0.5;
  81416. var tessellation = options.tessellation || 16;
  81417. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  81418. var stride = tessellation + 1;
  81419. for (var i = 0; i <= tessellation; i++) {
  81420. var u = i / tessellation;
  81421. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  81422. 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));
  81423. for (var j = 0; j <= tessellation; j++) {
  81424. var v = 1 - j / tessellation;
  81425. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  81426. var dx = Math.cos(innerAngle);
  81427. var dy = Math.sin(innerAngle);
  81428. // Create a vertex.
  81429. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  81430. var position = normal.scale(thickness / 2);
  81431. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  81432. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  81433. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  81434. positions.push(position.x, position.y, position.z);
  81435. normals.push(normal.x, normal.y, normal.z);
  81436. uvs.push(textureCoordinate.x, textureCoordinate.y);
  81437. // And create indices for two triangles.
  81438. var nextI = (i + 1) % stride;
  81439. var nextJ = (j + 1) % stride;
  81440. indices.push(i * stride + j);
  81441. indices.push(i * stride + nextJ);
  81442. indices.push(nextI * stride + j);
  81443. indices.push(i * stride + nextJ);
  81444. indices.push(nextI * stride + nextJ);
  81445. indices.push(nextI * stride + j);
  81446. }
  81447. }
  81448. // Sides
  81449. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81450. // Result
  81451. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81452. vertexData.indices = indices;
  81453. vertexData.positions = positions;
  81454. vertexData.normals = normals;
  81455. vertexData.uvs = uvs;
  81456. return vertexData;
  81457. };
  81458. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  81459. var options = {
  81460. diameter: diameter,
  81461. thickness: thickness,
  81462. tessellation: tessellation,
  81463. sideOrientation: sideOrientation,
  81464. updatable: updatable
  81465. };
  81466. return TorusBuilder.CreateTorus(name, options, scene);
  81467. };
  81468. /**
  81469. * Class containing static functions to help procedurally build meshes
  81470. */
  81471. var TorusBuilder = /** @class */ (function () {
  81472. function TorusBuilder() {
  81473. }
  81474. /**
  81475. * Creates a torus mesh
  81476. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  81477. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  81478. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  81479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81480. * * 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
  81481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81482. * @param name defines the name of the mesh
  81483. * @param options defines the options used to create the mesh
  81484. * @param scene defines the hosting scene
  81485. * @returns the torus mesh
  81486. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  81487. */
  81488. TorusBuilder.CreateTorus = function (name, options, scene) {
  81489. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81490. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81491. torus._originalBuilderSideOrientation = options.sideOrientation;
  81492. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  81493. vertexData.applyToMesh(torus, options.updatable);
  81494. return torus;
  81495. };
  81496. return TorusBuilder;
  81497. }());
  81498. /***/ }),
  81499. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  81500. /*!*********************************************!*\
  81501. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  81502. \*********************************************/
  81503. /*! exports provided: TorusKnotBuilder */
  81504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81505. "use strict";
  81506. __webpack_require__.r(__webpack_exports__);
  81507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  81508. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81509. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81510. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81511. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  81512. var indices = new Array();
  81513. var positions = new Array();
  81514. var normals = new Array();
  81515. var uvs = new Array();
  81516. var radius = options.radius || 2;
  81517. var tube = options.tube || 0.5;
  81518. var radialSegments = options.radialSegments || 32;
  81519. var tubularSegments = options.tubularSegments || 32;
  81520. var p = options.p || 2;
  81521. var q = options.q || 3;
  81522. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  81523. // Helper
  81524. var getPos = function (angle) {
  81525. var cu = Math.cos(angle);
  81526. var su = Math.sin(angle);
  81527. var quOverP = q / p * angle;
  81528. var cs = Math.cos(quOverP);
  81529. var tx = radius * (2 + cs) * 0.5 * cu;
  81530. var ty = radius * (2 + cs) * su * 0.5;
  81531. var tz = radius * Math.sin(quOverP) * 0.5;
  81532. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  81533. };
  81534. // Vertices
  81535. var i;
  81536. var j;
  81537. for (i = 0; i <= radialSegments; i++) {
  81538. var modI = i % radialSegments;
  81539. var u = modI / radialSegments * 2 * p * Math.PI;
  81540. var p1 = getPos(u);
  81541. var p2 = getPos(u + 0.01);
  81542. var tang = p2.subtract(p1);
  81543. var n = p2.add(p1);
  81544. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  81545. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  81546. bitan.normalize();
  81547. n.normalize();
  81548. for (j = 0; j < tubularSegments; j++) {
  81549. var modJ = j % tubularSegments;
  81550. var v = modJ / tubularSegments * 2 * Math.PI;
  81551. var cx = -tube * Math.cos(v);
  81552. var cy = tube * Math.sin(v);
  81553. positions.push(p1.x + cx * n.x + cy * bitan.x);
  81554. positions.push(p1.y + cx * n.y + cy * bitan.y);
  81555. positions.push(p1.z + cx * n.z + cy * bitan.z);
  81556. uvs.push(i / radialSegments);
  81557. uvs.push(j / tubularSegments);
  81558. }
  81559. }
  81560. for (i = 0; i < radialSegments; i++) {
  81561. for (j = 0; j < tubularSegments; j++) {
  81562. var jNext = (j + 1) % tubularSegments;
  81563. var a = i * tubularSegments + j;
  81564. var b = (i + 1) * tubularSegments + j;
  81565. var c = (i + 1) * tubularSegments + jNext;
  81566. var d = i * tubularSegments + jNext;
  81567. indices.push(d);
  81568. indices.push(b);
  81569. indices.push(a);
  81570. indices.push(d);
  81571. indices.push(c);
  81572. indices.push(b);
  81573. }
  81574. }
  81575. // Normals
  81576. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  81577. // Sides
  81578. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81579. // Result
  81580. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81581. vertexData.indices = indices;
  81582. vertexData.positions = positions;
  81583. vertexData.normals = normals;
  81584. vertexData.uvs = uvs;
  81585. return vertexData;
  81586. };
  81587. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  81588. var options = {
  81589. radius: radius,
  81590. tube: tube,
  81591. radialSegments: radialSegments,
  81592. tubularSegments: tubularSegments,
  81593. p: p,
  81594. q: q,
  81595. sideOrientation: sideOrientation,
  81596. updatable: updatable
  81597. };
  81598. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  81599. };
  81600. /**
  81601. * Class containing static functions to help procedurally build meshes
  81602. */
  81603. var TorusKnotBuilder = /** @class */ (function () {
  81604. function TorusKnotBuilder() {
  81605. }
  81606. /**
  81607. * Creates a torus knot mesh
  81608. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  81609. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  81610. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  81611. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  81612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81613. * * 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
  81614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81615. * @param name defines the name of the mesh
  81616. * @param options defines the options used to create the mesh
  81617. * @param scene defines the hosting scene
  81618. * @returns the torus knot mesh
  81619. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  81620. */
  81621. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  81622. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81623. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81624. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  81625. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  81626. vertexData.applyToMesh(torusKnot, options.updatable);
  81627. return torusKnot;
  81628. };
  81629. return TorusKnotBuilder;
  81630. }());
  81631. /***/ }),
  81632. /***/ "./Meshes/Builders/tubeBuilder.ts":
  81633. /*!****************************************!*\
  81634. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  81635. \****************************************/
  81636. /*! exports provided: TubeBuilder */
  81637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81638. "use strict";
  81639. __webpack_require__.r(__webpack_exports__);
  81640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  81641. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81642. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81643. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  81644. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  81645. var options = {
  81646. path: path,
  81647. radius: radius,
  81648. tessellation: tessellation,
  81649. radiusFunction: radiusFunction,
  81650. arc: 1,
  81651. cap: cap,
  81652. updatable: updatable,
  81653. sideOrientation: sideOrientation,
  81654. instance: instance
  81655. };
  81656. return TubeBuilder.CreateTube(name, options, scene);
  81657. };
  81658. /**
  81659. * Class containing static functions to help procedurally build meshes
  81660. */
  81661. var TubeBuilder = /** @class */ (function () {
  81662. function TubeBuilder() {
  81663. }
  81664. /**
  81665. * Creates a tube mesh.
  81666. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  81667. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  81668. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  81669. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  81670. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  81671. * * 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)
  81672. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  81673. * * 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
  81674. * * 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
  81675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81676. * * 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
  81677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  81678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81679. * @param name defines the name of the mesh
  81680. * @param options defines the options used to create the mesh
  81681. * @param scene defines the hosting scene
  81682. * @returns the tube mesh
  81683. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  81684. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  81685. */
  81686. TubeBuilder.CreateTube = function (name, options, scene) {
  81687. if (scene === void 0) { scene = null; }
  81688. var path = options.path;
  81689. var instance = options.instance;
  81690. var radius = 1.0;
  81691. if (options.radius !== undefined) {
  81692. radius = options.radius;
  81693. }
  81694. else if (instance) {
  81695. radius = instance._creationDataStorage.radius;
  81696. }
  81697. var tessellation = options.tessellation || 64 | 0;
  81698. var radiusFunction = options.radiusFunction || null;
  81699. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  81700. var invertUV = options.invertUV || false;
  81701. var updatable = options.updatable;
  81702. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81703. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  81704. // tube geometry
  81705. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  81706. var tangents = path3D.getTangents();
  81707. var normals = path3D.getNormals();
  81708. var distances = path3D.getDistances();
  81709. var pi2 = Math.PI * 2;
  81710. var step = pi2 / tessellation * arc;
  81711. var returnRadius = function () { return radius; };
  81712. var radiusFunctionFinal = radiusFunction || returnRadius;
  81713. var circlePath;
  81714. var rad;
  81715. var normal;
  81716. var rotated;
  81717. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  81718. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  81719. for (var i = 0; i < path.length; i++) {
  81720. rad = radiusFunctionFinal(i, distances[i]); // current radius
  81721. circlePath = Array(); // current circle array
  81722. normal = normals[i]; // current normal
  81723. for (var t = 0; t < tessellation; t++) {
  81724. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  81725. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  81726. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  81727. rotated.scaleInPlace(rad).addInPlace(path[i]);
  81728. circlePath[t] = rotated;
  81729. }
  81730. circlePaths[index] = circlePath;
  81731. index++;
  81732. }
  81733. // cap
  81734. var capPath = function (nbPoints, pathIndex) {
  81735. var pointCap = Array();
  81736. for (var i = 0; i < nbPoints; i++) {
  81737. pointCap.push(path[pathIndex]);
  81738. }
  81739. return pointCap;
  81740. };
  81741. switch (cap) {
  81742. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  81743. break;
  81744. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  81745. circlePaths[0] = capPath(tessellation, 0);
  81746. circlePaths[1] = circlePaths[2].slice(0);
  81747. break;
  81748. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  81749. circlePaths[index] = circlePaths[index - 1].slice(0);
  81750. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  81751. break;
  81752. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  81753. circlePaths[0] = capPath(tessellation, 0);
  81754. circlePaths[1] = circlePaths[2].slice(0);
  81755. circlePaths[index] = circlePaths[index - 1].slice(0);
  81756. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  81757. break;
  81758. default:
  81759. break;
  81760. }
  81761. return circlePaths;
  81762. };
  81763. var path3D;
  81764. var pathArray;
  81765. if (instance) { // tube update
  81766. var storage = instance._creationDataStorage;
  81767. var arc = options.arc || storage.arc;
  81768. path3D = storage.path3D.update(path);
  81769. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  81770. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  81771. // Update mode, no need to recreate the storage.
  81772. storage.path3D = path3D;
  81773. storage.pathArray = pathArray;
  81774. storage.arc = arc;
  81775. storage.radius = radius;
  81776. return instance;
  81777. }
  81778. // tube creation
  81779. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  81780. var newPathArray = new Array();
  81781. cap = (cap < 0 || cap > 3) ? 0 : cap;
  81782. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  81783. 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);
  81784. tube._creationDataStorage.pathArray = pathArray;
  81785. tube._creationDataStorage.path3D = path3D;
  81786. tube._creationDataStorage.tessellation = tessellation;
  81787. tube._creationDataStorage.cap = cap;
  81788. tube._creationDataStorage.arc = options.arc;
  81789. tube._creationDataStorage.radius = radius;
  81790. return tube;
  81791. };
  81792. return TubeBuilder;
  81793. }());
  81794. /***/ }),
  81795. /***/ "./Meshes/Compression/dracoCompression.ts":
  81796. /*!************************************************!*\
  81797. !*** ./Meshes/Compression/dracoCompression.ts ***!
  81798. \************************************************/
  81799. /*! exports provided: DracoCompression */
  81800. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81801. "use strict";
  81802. __webpack_require__.r(__webpack_exports__);
  81803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  81804. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  81805. /* harmony import */ var _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/workerPool */ "./Misc/workerPool.ts");
  81806. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81807. /**
  81808. * Draco compression (https://google.github.io/draco/)
  81809. *
  81810. * This class wraps the Draco module.
  81811. *
  81812. * **Encoder**
  81813. *
  81814. * The encoder is not currently implemented.
  81815. *
  81816. * **Decoder**
  81817. *
  81818. * 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.
  81819. *
  81820. * To update the configuration, use the following code:
  81821. * ```javascript
  81822. * DracoCompression.Configuration = {
  81823. * decoder: {
  81824. * wasmUrl: "<url to the WebAssembly library>",
  81825. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  81826. * fallbackUrl: "<url to the fallback JavaScript library>",
  81827. * }
  81828. * };
  81829. * ```
  81830. *
  81831. * 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.
  81832. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  81833. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  81834. *
  81835. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  81836. * ```javascript
  81837. * var dracoCompression = new DracoCompression();
  81838. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  81839. * [VertexBuffer.PositionKind]: 0
  81840. * });
  81841. * ```
  81842. *
  81843. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  81844. */
  81845. var DracoCompression = /** @class */ (function () {
  81846. /**
  81847. * Constructor
  81848. * @param numWorkers The number of workers for async operations
  81849. */
  81850. function DracoCompression(numWorkers) {
  81851. if (numWorkers === void 0) { numWorkers = DracoCompression.DefaultNumWorkers; }
  81852. if (!URL || !URL.createObjectURL) {
  81853. throw new Error("Object URLs are not available");
  81854. }
  81855. if (!Worker) {
  81856. throw new Error("Workers are not available");
  81857. }
  81858. this._workerPoolPromise = this._loadDecoderWasmBinaryAsync().then(function (decoderWasmBinary) {
  81859. var workerBlobUrl = URL.createObjectURL(new Blob(["(" + DracoCompression._Worker.toString() + ")()"], { type: "application/javascript" }));
  81860. var workerPromises = new Array(numWorkers);
  81861. for (var i = 0; i < workerPromises.length; i++) {
  81862. workerPromises[i] = new Promise(function (resolve, reject) {
  81863. var decoder = DracoCompression.Configuration.decoder;
  81864. if (decoder) {
  81865. var worker_1 = new Worker(workerBlobUrl);
  81866. var onError_1 = function (error) {
  81867. worker_1.removeEventListener("error", onError_1);
  81868. worker_1.removeEventListener("message", onMessage_1);
  81869. reject(error);
  81870. };
  81871. var onMessage_1 = function (message) {
  81872. if (message.data === "done") {
  81873. worker_1.removeEventListener("error", onError_1);
  81874. worker_1.removeEventListener("message", onMessage_1);
  81875. resolve(worker_1);
  81876. }
  81877. };
  81878. worker_1.addEventListener("error", onError_1);
  81879. worker_1.addEventListener("message", onMessage_1);
  81880. worker_1.postMessage({
  81881. id: "initDecoder",
  81882. decoderWasmUrl: decoder.wasmUrl ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(decoder.wasmUrl) : null,
  81883. decoderWasmBinary: decoderWasmBinary,
  81884. fallbackUrl: decoder.fallbackUrl ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(decoder.fallbackUrl) : null
  81885. });
  81886. }
  81887. });
  81888. }
  81889. return Promise.all(workerPromises).then(function (workers) {
  81890. return new _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__["WorkerPool"](workers);
  81891. });
  81892. });
  81893. }
  81894. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  81895. /**
  81896. * Returns true if the decoder is available.
  81897. */
  81898. get: function () {
  81899. if (typeof DracoDecoderModule !== "undefined") {
  81900. return true;
  81901. }
  81902. var decoder = DracoCompression.Configuration.decoder;
  81903. if (decoder) {
  81904. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  81905. return true;
  81906. }
  81907. if (decoder.fallbackUrl) {
  81908. return true;
  81909. }
  81910. }
  81911. return false;
  81912. },
  81913. enumerable: true,
  81914. configurable: true
  81915. });
  81916. DracoCompression.GetDefaultNumWorkers = function () {
  81917. var hardwareConcurrency = navigator && navigator.hardwareConcurrency;
  81918. if (!hardwareConcurrency) {
  81919. return 1;
  81920. }
  81921. // Use 50% of the available logical processors but capped at 4.
  81922. return Math.min(Math.floor(hardwareConcurrency * 0.5), 4);
  81923. };
  81924. /**
  81925. * Stop all async operations and release resources.
  81926. */
  81927. DracoCompression.prototype.dispose = function () {
  81928. this._workerPoolPromise.then(function (workerPool) {
  81929. workerPool.dispose();
  81930. });
  81931. delete this._workerPoolPromise;
  81932. };
  81933. /**
  81934. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  81935. * @returns a promise that resolves when ready
  81936. */
  81937. DracoCompression.prototype.whenReadyAsync = function () {
  81938. return this._workerPoolPromise.then(function () { });
  81939. };
  81940. /**
  81941. * Decode Draco compressed mesh data to vertex data.
  81942. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  81943. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  81944. * @returns A promise that resolves with the decoded vertex data
  81945. */
  81946. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  81947. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  81948. return this._workerPoolPromise.then(function (workerPool) {
  81949. return new Promise(function (resolve, reject) {
  81950. workerPool.push(function (worker, onComplete) {
  81951. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81952. var onError = function (error) {
  81953. worker.removeEventListener("error", onError);
  81954. worker.removeEventListener("message", onMessage);
  81955. reject(error);
  81956. onComplete();
  81957. };
  81958. var onMessage = function (message) {
  81959. if (message.data === "done") {
  81960. worker.removeEventListener("error", onError);
  81961. worker.removeEventListener("message", onMessage);
  81962. resolve(vertexData);
  81963. onComplete();
  81964. }
  81965. else if (message.data.id === "indices") {
  81966. vertexData.indices = message.data.value;
  81967. }
  81968. else {
  81969. vertexData.set(message.data.value, message.data.id);
  81970. }
  81971. };
  81972. worker.addEventListener("error", onError);
  81973. worker.addEventListener("message", onMessage);
  81974. var dataViewCopy = new Uint8Array(dataView.byteLength);
  81975. dataViewCopy.set(new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength));
  81976. worker.postMessage({ id: "decodeMesh", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);
  81977. });
  81978. });
  81979. });
  81980. };
  81981. /**
  81982. * The worker function that gets converted to a blob url to pass into a worker.
  81983. */
  81984. DracoCompression._Worker = function () {
  81985. var nativeAttributeTypes = {
  81986. "position": "POSITION",
  81987. "normal": "NORMAL",
  81988. "color": "COLOR",
  81989. "uv": "TEX_COORD"
  81990. };
  81991. // self is actually a DedicatedWorkerGlobalScope
  81992. var _self = self;
  81993. var decoderModulePromise;
  81994. function initDecoder(decoderWasmUrl, decoderWasmBinary, fallbackUrl) {
  81995. if (decoderWasmUrl && decoderWasmBinary && typeof WebAssembly === "object") {
  81996. importScripts(decoderWasmUrl);
  81997. decoderModulePromise = DracoDecoderModule({
  81998. wasmBinary: decoderWasmBinary
  81999. });
  82000. }
  82001. else if (fallbackUrl) {
  82002. importScripts(fallbackUrl);
  82003. decoderModulePromise = DracoDecoderModule();
  82004. }
  82005. else {
  82006. throw Error("Failed to initialize Draco decoder");
  82007. }
  82008. _self.postMessage("done");
  82009. }
  82010. function decodeMesh(dataView, attributes) {
  82011. decoderModulePromise.then(function (decoderModule) {
  82012. var buffer = new decoderModule.DecoderBuffer();
  82013. buffer.Init(dataView, dataView.byteLength);
  82014. var decoder = new decoderModule.Decoder();
  82015. var geometry;
  82016. var status;
  82017. try {
  82018. var type = decoder.GetEncodedGeometryType(buffer);
  82019. switch (type) {
  82020. case decoderModule.TRIANGULAR_MESH:
  82021. geometry = new decoderModule.Mesh();
  82022. status = decoder.DecodeBufferToMesh(buffer, geometry);
  82023. break;
  82024. case decoderModule.POINT_CLOUD:
  82025. geometry = new decoderModule.PointCloud();
  82026. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  82027. break;
  82028. default:
  82029. throw new Error("Invalid geometry type " + type);
  82030. }
  82031. if (!status.ok() || !geometry.ptr) {
  82032. throw new Error(status.error_msg());
  82033. }
  82034. var numPoints_1 = geometry.num_points();
  82035. if (type === decoderModule.TRIANGULAR_MESH) {
  82036. var numFaces = geometry.num_faces();
  82037. var faceIndices = new decoderModule.DracoInt32Array();
  82038. try {
  82039. var indices = new Uint32Array(numFaces * 3);
  82040. for (var i = 0; i < numFaces; i++) {
  82041. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  82042. var offset = i * 3;
  82043. indices[offset + 0] = faceIndices.GetValue(0);
  82044. indices[offset + 1] = faceIndices.GetValue(1);
  82045. indices[offset + 2] = faceIndices.GetValue(2);
  82046. }
  82047. _self.postMessage({ id: "indices", value: indices }, [indices.buffer]);
  82048. }
  82049. finally {
  82050. decoderModule.destroy(faceIndices);
  82051. }
  82052. }
  82053. var processAttribute = function (kind, attribute) {
  82054. var dracoData = new decoderModule.DracoFloat32Array();
  82055. try {
  82056. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  82057. var babylonData = new Float32Array(numPoints_1 * attribute.num_components());
  82058. for (var i = 0; i < babylonData.length; i++) {
  82059. babylonData[i] = dracoData.GetValue(i);
  82060. }
  82061. _self.postMessage({ id: kind, value: babylonData }, [babylonData.buffer]);
  82062. }
  82063. finally {
  82064. decoderModule.destroy(dracoData);
  82065. }
  82066. };
  82067. if (attributes) {
  82068. for (var kind in attributes) {
  82069. var id = attributes[kind];
  82070. var attribute = decoder.GetAttributeByUniqueId(geometry, id);
  82071. processAttribute(kind, attribute);
  82072. }
  82073. }
  82074. else {
  82075. for (var kind in nativeAttributeTypes) {
  82076. var id = decoder.GetAttributeId(geometry, decoderModule[nativeAttributeTypes[kind]]);
  82077. if (id !== -1) {
  82078. var attribute = decoder.GetAttribute(geometry, id);
  82079. processAttribute(kind, attribute);
  82080. }
  82081. }
  82082. }
  82083. }
  82084. finally {
  82085. if (geometry) {
  82086. decoderModule.destroy(geometry);
  82087. }
  82088. decoderModule.destroy(decoder);
  82089. decoderModule.destroy(buffer);
  82090. }
  82091. _self.postMessage("done");
  82092. });
  82093. }
  82094. _self.onmessage = function (event) {
  82095. var data = event.data;
  82096. switch (data.id) {
  82097. case "initDecoder": {
  82098. initDecoder(data.decoderWasmUrl, data.decoderWasmBinary, data.fallbackUrl);
  82099. break;
  82100. }
  82101. case "decodeMesh": {
  82102. decodeMesh(data.dataView, data.attributes);
  82103. break;
  82104. }
  82105. }
  82106. };
  82107. };
  82108. DracoCompression.prototype._loadDecoderWasmBinaryAsync = function () {
  82109. var decoder = DracoCompression.Configuration.decoder;
  82110. if (decoder && decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  82111. var wasmBinaryUrl_1 = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(decoder.wasmBinaryUrl);
  82112. return new Promise(function (resolve, reject) {
  82113. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(wasmBinaryUrl_1, function (data) {
  82114. resolve(data);
  82115. }, undefined, undefined, true, function (request, exception) {
  82116. reject(exception);
  82117. });
  82118. });
  82119. }
  82120. else {
  82121. return Promise.resolve(null);
  82122. }
  82123. };
  82124. /**
  82125. * The configuration. Defaults to the following urls:
  82126. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  82127. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  82128. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  82129. */
  82130. DracoCompression.Configuration = {
  82131. decoder: {
  82132. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  82133. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  82134. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  82135. }
  82136. };
  82137. /**
  82138. * Default number of workers to create when creating the draco compression object.
  82139. */
  82140. DracoCompression.DefaultNumWorkers = DracoCompression.GetDefaultNumWorkers();
  82141. return DracoCompression;
  82142. }());
  82143. /***/ }),
  82144. /***/ "./Meshes/Compression/index.ts":
  82145. /*!*************************************!*\
  82146. !*** ./Meshes/Compression/index.ts ***!
  82147. \*************************************/
  82148. /*! exports provided: DracoCompression */
  82149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82150. "use strict";
  82151. __webpack_require__.r(__webpack_exports__);
  82152. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  82153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  82154. /***/ }),
  82155. /***/ "./Meshes/abstractMesh.ts":
  82156. /*!********************************!*\
  82157. !*** ./Meshes/abstractMesh.ts ***!
  82158. \********************************/
  82159. /*! exports provided: AbstractMesh */
  82160. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  82161. "use strict";
  82162. __webpack_require__.r(__webpack_exports__);
  82163. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  82164. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  82165. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  82166. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  82167. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  82168. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  82169. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  82170. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  82171. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  82172. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  82173. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  82174. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  82175. /** @hidden */
  82176. var _FacetDataStorage = /** @class */ (function () {
  82177. function _FacetDataStorage() {
  82178. this.facetNb = 0; // facet number
  82179. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  82180. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  82181. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  82182. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  82183. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  82184. this.subDiv = {
  82185. max: 1,
  82186. X: 1,
  82187. Y: 1,
  82188. Z: 1
  82189. };
  82190. this.facetDepthSort = false; // is the facet depth sort to be computed
  82191. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  82192. }
  82193. return _FacetDataStorage;
  82194. }());
  82195. /**
  82196. * Class used to store all common mesh properties
  82197. */
  82198. var AbstractMesh = /** @class */ (function (_super) {
  82199. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  82200. // Constructor
  82201. /**
  82202. * Creates a new AbstractMesh
  82203. * @param name defines the name of the mesh
  82204. * @param scene defines the hosting scene
  82205. */
  82206. function AbstractMesh(name, scene) {
  82207. if (scene === void 0) { scene = null; }
  82208. var _this = _super.call(this, name, scene, false) || this;
  82209. _this._facetData = new _FacetDataStorage();
  82210. /**
  82211. * The culling strategy to use to check whether the mesh must be rendered or not.
  82212. * This value can be changed at any time and will be used on the next render mesh selection.
  82213. * The possible values are :
  82214. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82215. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82216. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82217. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82218. * Please read each static variable documentation to get details about the culling process.
  82219. * */
  82220. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  82221. // Events
  82222. /**
  82223. * An event triggered when this mesh collides with another one
  82224. */
  82225. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  82226. /**
  82227. * An event triggered when the collision's position changes
  82228. */
  82229. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  82230. /**
  82231. * An event triggered when material is changed
  82232. */
  82233. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  82234. // Properties
  82235. /**
  82236. * Gets or sets the orientation for POV movement & rotation
  82237. */
  82238. _this.definedFacingForward = true;
  82239. /** @hidden */
  82240. _this._occlusionQuery = null;
  82241. _this._visibility = 1.0;
  82242. /** @hidden */
  82243. _this._isActive = false;
  82244. /** @hidden */
  82245. _this._renderingGroup = null;
  82246. /** Gets or sets the alpha index used to sort transparent meshes
  82247. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  82248. */
  82249. _this.alphaIndex = Number.MAX_VALUE;
  82250. /**
  82251. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  82252. */
  82253. _this.isVisible = true;
  82254. /**
  82255. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82256. */
  82257. _this.isPickable = true;
  82258. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  82259. _this.showSubMeshesBoundingBox = false;
  82260. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  82261. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  82262. */
  82263. _this.isBlocker = false;
  82264. /**
  82265. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  82266. */
  82267. _this.enablePointerMoveEvents = false;
  82268. /**
  82269. * Specifies the rendering group id for this mesh (0 by default)
  82270. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82271. */
  82272. _this.renderingGroupId = 0;
  82273. _this._material = null;
  82274. _this._receiveShadows = false;
  82275. /** Defines color to use when rendering outline */
  82276. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  82277. /** Define width to use when rendering outline */
  82278. _this.outlineWidth = 0.02;
  82279. /** Defines color to use when rendering overlay */
  82280. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  82281. /** Defines alpha to use when rendering overlay */
  82282. _this.overlayAlpha = 0.5;
  82283. _this._hasVertexAlpha = false;
  82284. _this._useVertexColors = true;
  82285. _this._computeBonesUsingShaders = true;
  82286. _this._numBoneInfluencers = 4;
  82287. _this._applyFog = true;
  82288. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  82289. _this.useOctreeForRenderingSelection = true;
  82290. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  82291. _this.useOctreeForPicking = true;
  82292. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  82293. _this.useOctreeForCollisions = true;
  82294. _this._layerMask = 0x0FFFFFFF;
  82295. /**
  82296. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  82297. */
  82298. _this.alwaysSelectAsActiveMesh = false;
  82299. /**
  82300. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  82301. */
  82302. _this.doNotSyncBoundingInfo = false;
  82303. /**
  82304. * Gets or sets the current action manager
  82305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82306. */
  82307. _this.actionManager = null;
  82308. // Collisions
  82309. _this._checkCollisions = false;
  82310. _this._collisionMask = -1;
  82311. _this._collisionGroup = -1;
  82312. /**
  82313. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82315. */
  82316. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  82317. /**
  82318. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82320. */
  82321. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  82322. _this._collider = null;
  82323. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  82324. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  82325. // Edges
  82326. /**
  82327. * Defines edge width used when edgesRenderer is enabled
  82328. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82329. */
  82330. _this.edgesWidth = 1;
  82331. /**
  82332. * Defines edge color used when edgesRenderer is enabled
  82333. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82334. */
  82335. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  82336. /** @hidden */
  82337. _this._edgesRenderer = null;
  82338. /** @hidden */
  82339. _this._masterMesh = null;
  82340. /** @hidden */
  82341. _this._boundingInfo = null;
  82342. /** @hidden */
  82343. _this._renderId = 0;
  82344. /** @hidden */
  82345. _this._intersectionsInProgress = new Array();
  82346. /** @hidden */
  82347. _this._unIndexed = false;
  82348. /** @hidden */
  82349. _this._lightSources = new Array();
  82350. // Loading properties
  82351. /** @hidden */
  82352. _this._waitingActions = null;
  82353. /** @hidden */
  82354. _this._waitingFreezeWorldMatrix = null;
  82355. // Skeleton
  82356. _this._skeleton = null;
  82357. /** @hidden */
  82358. _this._bonesTransformMatrices = null;
  82359. /**
  82360. * An event triggered when the mesh is rebuilt.
  82361. */
  82362. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  82363. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  82364. if (collidedMesh === void 0) { collidedMesh = null; }
  82365. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  82366. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  82367. _this.position.addInPlace(_this._diffPositionForCollisions);
  82368. }
  82369. if (collidedMesh) {
  82370. _this.onCollideObservable.notifyObservers(collidedMesh);
  82371. }
  82372. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  82373. };
  82374. _this.getScene().addMesh(_this);
  82375. _this._resyncLightSources();
  82376. return _this;
  82377. }
  82378. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  82379. /**
  82380. * No billboard
  82381. */
  82382. get: function () {
  82383. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  82384. },
  82385. enumerable: true,
  82386. configurable: true
  82387. });
  82388. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  82389. /** Billboard on X axis */
  82390. get: function () {
  82391. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  82392. },
  82393. enumerable: true,
  82394. configurable: true
  82395. });
  82396. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  82397. /** Billboard on Y axis */
  82398. get: function () {
  82399. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  82400. },
  82401. enumerable: true,
  82402. configurable: true
  82403. });
  82404. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  82405. /** Billboard on Z axis */
  82406. get: function () {
  82407. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  82408. },
  82409. enumerable: true,
  82410. configurable: true
  82411. });
  82412. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  82413. /** Billboard on all axes */
  82414. get: function () {
  82415. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  82416. },
  82417. enumerable: true,
  82418. configurable: true
  82419. });
  82420. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  82421. /**
  82422. * Gets the number of facets in the mesh
  82423. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82424. */
  82425. get: function () {
  82426. return this._facetData.facetNb;
  82427. },
  82428. enumerable: true,
  82429. configurable: true
  82430. });
  82431. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  82432. /**
  82433. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82435. */
  82436. get: function () {
  82437. return this._facetData.partitioningSubdivisions;
  82438. },
  82439. set: function (nb) {
  82440. this._facetData.partitioningSubdivisions = nb;
  82441. },
  82442. enumerable: true,
  82443. configurable: true
  82444. });
  82445. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  82446. /**
  82447. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82448. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82449. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82450. */
  82451. get: function () {
  82452. return this._facetData.partitioningBBoxRatio;
  82453. },
  82454. set: function (ratio) {
  82455. this._facetData.partitioningBBoxRatio = ratio;
  82456. },
  82457. enumerable: true,
  82458. configurable: true
  82459. });
  82460. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  82461. /**
  82462. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82463. * Works only for updatable meshes.
  82464. * Doesn't work with multi-materials
  82465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82466. */
  82467. get: function () {
  82468. return this._facetData.facetDepthSort;
  82469. },
  82470. set: function (sort) {
  82471. this._facetData.facetDepthSort = sort;
  82472. },
  82473. enumerable: true,
  82474. configurable: true
  82475. });
  82476. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  82477. /**
  82478. * The location (Vector3) where the facet depth sort must be computed from.
  82479. * By default, the active camera position.
  82480. * Used only when facet depth sort is enabled
  82481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82482. */
  82483. get: function () {
  82484. return this._facetData.facetDepthSortFrom;
  82485. },
  82486. set: function (location) {
  82487. this._facetData.facetDepthSortFrom = location;
  82488. },
  82489. enumerable: true,
  82490. configurable: true
  82491. });
  82492. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  82493. /**
  82494. * gets a boolean indicating if facetData is enabled
  82495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82496. */
  82497. get: function () {
  82498. return this._facetData.facetDataEnabled;
  82499. },
  82500. enumerable: true,
  82501. configurable: true
  82502. });
  82503. /** @hidden */
  82504. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  82505. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  82506. return false;
  82507. }
  82508. this._markSubMeshesAsMiscDirty();
  82509. return true;
  82510. };
  82511. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  82512. /** Set a function to call when this mesh collides with another one */
  82513. set: function (callback) {
  82514. if (this._onCollideObserver) {
  82515. this.onCollideObservable.remove(this._onCollideObserver);
  82516. }
  82517. this._onCollideObserver = this.onCollideObservable.add(callback);
  82518. },
  82519. enumerable: true,
  82520. configurable: true
  82521. });
  82522. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  82523. /** Set a function to call when the collision's position changes */
  82524. set: function (callback) {
  82525. if (this._onCollisionPositionChangeObserver) {
  82526. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  82527. }
  82528. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  82529. },
  82530. enumerable: true,
  82531. configurable: true
  82532. });
  82533. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  82534. /**
  82535. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82536. */
  82537. get: function () {
  82538. return this._visibility;
  82539. },
  82540. /**
  82541. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82542. */
  82543. set: function (value) {
  82544. if (this._visibility === value) {
  82545. return;
  82546. }
  82547. this._visibility = value;
  82548. this._markSubMeshesAsMiscDirty();
  82549. },
  82550. enumerable: true,
  82551. configurable: true
  82552. });
  82553. Object.defineProperty(AbstractMesh.prototype, "material", {
  82554. /** Gets or sets current material */
  82555. get: function () {
  82556. return this._material;
  82557. },
  82558. set: function (value) {
  82559. if (this._material === value) {
  82560. return;
  82561. }
  82562. // remove from material mesh map id needed
  82563. if (this._material && this._material.meshMap) {
  82564. this._material.meshMap[this.uniqueId] = undefined;
  82565. }
  82566. this._material = value;
  82567. if (value && value.meshMap) {
  82568. value.meshMap[this.uniqueId] = this;
  82569. }
  82570. if (this.onMaterialChangedObservable.hasObservers) {
  82571. this.onMaterialChangedObservable.notifyObservers(this);
  82572. }
  82573. if (!this.subMeshes) {
  82574. return;
  82575. }
  82576. this._unBindEffect();
  82577. },
  82578. enumerable: true,
  82579. configurable: true
  82580. });
  82581. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  82582. /**
  82583. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82584. * @see http://doc.babylonjs.com/babylon101/shadows
  82585. */
  82586. get: function () {
  82587. return this._receiveShadows;
  82588. },
  82589. set: function (value) {
  82590. if (this._receiveShadows === value) {
  82591. return;
  82592. }
  82593. this._receiveShadows = value;
  82594. this._markSubMeshesAsLightDirty();
  82595. },
  82596. enumerable: true,
  82597. configurable: true
  82598. });
  82599. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  82600. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82601. get: function () {
  82602. return this._hasVertexAlpha;
  82603. },
  82604. set: function (value) {
  82605. if (this._hasVertexAlpha === value) {
  82606. return;
  82607. }
  82608. this._hasVertexAlpha = value;
  82609. this._markSubMeshesAsAttributesDirty();
  82610. this._markSubMeshesAsMiscDirty();
  82611. },
  82612. enumerable: true,
  82613. configurable: true
  82614. });
  82615. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  82616. /** 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) */
  82617. get: function () {
  82618. return this._useVertexColors;
  82619. },
  82620. set: function (value) {
  82621. if (this._useVertexColors === value) {
  82622. return;
  82623. }
  82624. this._useVertexColors = value;
  82625. this._markSubMeshesAsAttributesDirty();
  82626. },
  82627. enumerable: true,
  82628. configurable: true
  82629. });
  82630. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  82631. /**
  82632. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82633. */
  82634. get: function () {
  82635. return this._computeBonesUsingShaders;
  82636. },
  82637. set: function (value) {
  82638. if (this._computeBonesUsingShaders === value) {
  82639. return;
  82640. }
  82641. this._computeBonesUsingShaders = value;
  82642. this._markSubMeshesAsAttributesDirty();
  82643. },
  82644. enumerable: true,
  82645. configurable: true
  82646. });
  82647. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  82648. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82649. get: function () {
  82650. return this._numBoneInfluencers;
  82651. },
  82652. set: function (value) {
  82653. if (this._numBoneInfluencers === value) {
  82654. return;
  82655. }
  82656. this._numBoneInfluencers = value;
  82657. this._markSubMeshesAsAttributesDirty();
  82658. },
  82659. enumerable: true,
  82660. configurable: true
  82661. });
  82662. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  82663. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82664. get: function () {
  82665. return this._applyFog;
  82666. },
  82667. set: function (value) {
  82668. if (this._applyFog === value) {
  82669. return;
  82670. }
  82671. this._applyFog = value;
  82672. this._markSubMeshesAsMiscDirty();
  82673. },
  82674. enumerable: true,
  82675. configurable: true
  82676. });
  82677. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  82678. /**
  82679. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82680. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82681. */
  82682. get: function () {
  82683. return this._layerMask;
  82684. },
  82685. set: function (value) {
  82686. if (value === this._layerMask) {
  82687. return;
  82688. }
  82689. this._layerMask = value;
  82690. this._resyncLightSources();
  82691. },
  82692. enumerable: true,
  82693. configurable: true
  82694. });
  82695. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  82696. /**
  82697. * Gets or sets a collision mask used to mask collisions (default is -1).
  82698. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82699. */
  82700. get: function () {
  82701. return this._collisionMask;
  82702. },
  82703. set: function (mask) {
  82704. this._collisionMask = !isNaN(mask) ? mask : -1;
  82705. },
  82706. enumerable: true,
  82707. configurable: true
  82708. });
  82709. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  82710. /**
  82711. * Gets or sets the current collision group mask (-1 by default).
  82712. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82713. */
  82714. get: function () {
  82715. return this._collisionGroup;
  82716. },
  82717. set: function (mask) {
  82718. this._collisionGroup = !isNaN(mask) ? mask : -1;
  82719. },
  82720. enumerable: true,
  82721. configurable: true
  82722. });
  82723. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  82724. /** @hidden */
  82725. get: function () {
  82726. return null;
  82727. },
  82728. enumerable: true,
  82729. configurable: true
  82730. });
  82731. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  82732. get: function () {
  82733. return this._skeleton;
  82734. },
  82735. /**
  82736. * Gets or sets a skeleton to apply skining transformations
  82737. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82738. */
  82739. set: function (value) {
  82740. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  82741. this._skeleton._unregisterMeshWithPoseMatrix(this);
  82742. }
  82743. if (value && value.needInitialSkinMatrix) {
  82744. value._registerMeshWithPoseMatrix(this);
  82745. }
  82746. this._skeleton = value;
  82747. if (!this._skeleton) {
  82748. this._bonesTransformMatrices = null;
  82749. }
  82750. this._markSubMeshesAsAttributesDirty();
  82751. },
  82752. enumerable: true,
  82753. configurable: true
  82754. });
  82755. /**
  82756. * Returns the string "AbstractMesh"
  82757. * @returns "AbstractMesh"
  82758. */
  82759. AbstractMesh.prototype.getClassName = function () {
  82760. return "AbstractMesh";
  82761. };
  82762. /**
  82763. * Gets a string representation of the current mesh
  82764. * @param fullDetails defines a boolean indicating if full details must be included
  82765. * @returns a string representation of the current mesh
  82766. */
  82767. AbstractMesh.prototype.toString = function (fullDetails) {
  82768. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  82769. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  82770. if (this._skeleton) {
  82771. ret += ", skeleton: " + this._skeleton.name;
  82772. }
  82773. if (fullDetails) {
  82774. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  82775. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  82776. }
  82777. return ret;
  82778. };
  82779. /**
  82780. * @hidden
  82781. */
  82782. AbstractMesh.prototype._getEffectiveParent = function () {
  82783. if (this._masterMesh && this.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  82784. return this._masterMesh;
  82785. }
  82786. return _super.prototype._getEffectiveParent.call(this);
  82787. };
  82788. /** @hidden */
  82789. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  82790. if (initialCall === void 0) { initialCall = true; }
  82791. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  82792. if (trigger) {
  82793. if (this.actionManager.hasSpecificTrigger(trigger)) {
  82794. return this.actionManager;
  82795. }
  82796. }
  82797. else {
  82798. return this.actionManager;
  82799. }
  82800. }
  82801. if (!this.parent) {
  82802. return null;
  82803. }
  82804. return this.parent._getActionManagerForTrigger(trigger, false);
  82805. };
  82806. /** @hidden */
  82807. AbstractMesh.prototype._rebuild = function () {
  82808. this.onRebuildObservable.notifyObservers(this);
  82809. if (this._occlusionQuery) {
  82810. this._occlusionQuery = null;
  82811. }
  82812. if (!this.subMeshes) {
  82813. return;
  82814. }
  82815. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82816. var subMesh = _a[_i];
  82817. subMesh._rebuild();
  82818. }
  82819. };
  82820. /** @hidden */
  82821. AbstractMesh.prototype._resyncLightSources = function () {
  82822. this._lightSources.length = 0;
  82823. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  82824. var light = _a[_i];
  82825. if (!light.isEnabled()) {
  82826. continue;
  82827. }
  82828. if (light.canAffectMesh(this)) {
  82829. this._lightSources.push(light);
  82830. }
  82831. }
  82832. this._markSubMeshesAsLightDirty();
  82833. };
  82834. /** @hidden */
  82835. AbstractMesh.prototype._resyncLighSource = function (light) {
  82836. var isIn = light.isEnabled() && light.canAffectMesh(this);
  82837. var index = this._lightSources.indexOf(light);
  82838. if (index === -1) {
  82839. if (!isIn) {
  82840. return;
  82841. }
  82842. this._lightSources.push(light);
  82843. }
  82844. else {
  82845. if (isIn) {
  82846. return;
  82847. }
  82848. this._lightSources.splice(index, 1);
  82849. }
  82850. this._markSubMeshesAsLightDirty();
  82851. };
  82852. /** @hidden */
  82853. AbstractMesh.prototype._unBindEffect = function () {
  82854. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82855. var subMesh = _a[_i];
  82856. subMesh.setEffect(null);
  82857. }
  82858. };
  82859. /** @hidden */
  82860. AbstractMesh.prototype._removeLightSource = function (light) {
  82861. var index = this._lightSources.indexOf(light);
  82862. if (index === -1) {
  82863. return;
  82864. }
  82865. this._lightSources.splice(index, 1);
  82866. this._markSubMeshesAsLightDirty();
  82867. };
  82868. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  82869. if (!this.subMeshes) {
  82870. return;
  82871. }
  82872. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82873. var subMesh = _a[_i];
  82874. if (subMesh._materialDefines) {
  82875. func(subMesh._materialDefines);
  82876. }
  82877. }
  82878. };
  82879. /** @hidden */
  82880. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  82881. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  82882. };
  82883. /** @hidden */
  82884. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  82885. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  82886. };
  82887. /** @hidden */
  82888. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  82889. if (!this.subMeshes) {
  82890. return;
  82891. }
  82892. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82893. var subMesh = _a[_i];
  82894. var material = subMesh.getMaterial();
  82895. if (material) {
  82896. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  82897. }
  82898. }
  82899. };
  82900. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  82901. /**
  82902. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82903. */
  82904. get: function () {
  82905. return this._scaling;
  82906. },
  82907. set: function (newScaling) {
  82908. this._scaling = newScaling;
  82909. if (this.physicsImpostor) {
  82910. this.physicsImpostor.forceUpdate();
  82911. }
  82912. },
  82913. enumerable: true,
  82914. configurable: true
  82915. });
  82916. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  82917. // Methods
  82918. /**
  82919. * Returns true if the mesh is blocked. Implemented by child classes
  82920. */
  82921. get: function () {
  82922. return false;
  82923. },
  82924. enumerable: true,
  82925. configurable: true
  82926. });
  82927. /**
  82928. * Returns the mesh itself by default. Implemented by child classes
  82929. * @param camera defines the camera to use to pick the right LOD level
  82930. * @returns the currentAbstractMesh
  82931. */
  82932. AbstractMesh.prototype.getLOD = function (camera) {
  82933. return this;
  82934. };
  82935. /**
  82936. * Returns 0 by default. Implemented by child classes
  82937. * @returns an integer
  82938. */
  82939. AbstractMesh.prototype.getTotalVertices = function () {
  82940. return 0;
  82941. };
  82942. /**
  82943. * Returns a positive integer : the total number of indices in this mesh geometry.
  82944. * @returns the numner of indices or zero if the mesh has no geometry.
  82945. */
  82946. AbstractMesh.prototype.getTotalIndices = function () {
  82947. return 0;
  82948. };
  82949. /**
  82950. * Returns null by default. Implemented by child classes
  82951. * @returns null
  82952. */
  82953. AbstractMesh.prototype.getIndices = function () {
  82954. return null;
  82955. };
  82956. /**
  82957. * Returns the array of the requested vertex data kind. Implemented by child classes
  82958. * @param kind defines the vertex data kind to use
  82959. * @returns null
  82960. */
  82961. AbstractMesh.prototype.getVerticesData = function (kind) {
  82962. return null;
  82963. };
  82964. /**
  82965. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82966. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82967. * Note that a new underlying VertexBuffer object is created each call.
  82968. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82969. * @param kind defines vertex data kind:
  82970. * * VertexBuffer.PositionKind
  82971. * * VertexBuffer.UVKind
  82972. * * VertexBuffer.UV2Kind
  82973. * * VertexBuffer.UV3Kind
  82974. * * VertexBuffer.UV4Kind
  82975. * * VertexBuffer.UV5Kind
  82976. * * VertexBuffer.UV6Kind
  82977. * * VertexBuffer.ColorKind
  82978. * * VertexBuffer.MatricesIndicesKind
  82979. * * VertexBuffer.MatricesIndicesExtraKind
  82980. * * VertexBuffer.MatricesWeightsKind
  82981. * * VertexBuffer.MatricesWeightsExtraKind
  82982. * @param data defines the data source
  82983. * @param updatable defines if the data must be flagged as updatable (or static)
  82984. * @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
  82985. * @returns the current mesh
  82986. */
  82987. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  82988. return this;
  82989. };
  82990. /**
  82991. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82992. * If the mesh has no geometry, it is simply returned as it is.
  82993. * @param kind defines vertex data kind:
  82994. * * VertexBuffer.PositionKind
  82995. * * VertexBuffer.UVKind
  82996. * * VertexBuffer.UV2Kind
  82997. * * VertexBuffer.UV3Kind
  82998. * * VertexBuffer.UV4Kind
  82999. * * VertexBuffer.UV5Kind
  83000. * * VertexBuffer.UV6Kind
  83001. * * VertexBuffer.ColorKind
  83002. * * VertexBuffer.MatricesIndicesKind
  83003. * * VertexBuffer.MatricesIndicesExtraKind
  83004. * * VertexBuffer.MatricesWeightsKind
  83005. * * VertexBuffer.MatricesWeightsExtraKind
  83006. * @param data defines the data source
  83007. * @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
  83008. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83009. * @returns the current mesh
  83010. */
  83011. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  83012. return this;
  83013. };
  83014. /**
  83015. * Sets the mesh indices,
  83016. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83017. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83018. * @param totalVertices Defines the total number of vertices
  83019. * @returns the current mesh
  83020. */
  83021. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  83022. return this;
  83023. };
  83024. /**
  83025. * Gets a boolean indicating if specific vertex data is present
  83026. * @param kind defines the vertex data kind to use
  83027. * @returns true is data kind is present
  83028. */
  83029. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  83030. return false;
  83031. };
  83032. /**
  83033. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83034. * @returns a BoundingInfo
  83035. */
  83036. AbstractMesh.prototype.getBoundingInfo = function () {
  83037. if (this._masterMesh) {
  83038. return this._masterMesh.getBoundingInfo();
  83039. }
  83040. if (!this._boundingInfo) {
  83041. // this._boundingInfo is being created here
  83042. this._updateBoundingInfo();
  83043. }
  83044. // cannot be null.
  83045. return this._boundingInfo;
  83046. };
  83047. /**
  83048. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83049. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83050. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83051. * @returns the current mesh
  83052. */
  83053. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants, ignoreRotation) {
  83054. if (includeDescendants === void 0) { includeDescendants = true; }
  83055. if (ignoreRotation === void 0) { ignoreRotation = false; }
  83056. var storedRotation = null;
  83057. var storedRotationQuaternion = null;
  83058. if (ignoreRotation) {
  83059. if (this.rotationQuaternion) {
  83060. storedRotationQuaternion = this.rotationQuaternion.clone();
  83061. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
  83062. }
  83063. else if (this.rotation) {
  83064. storedRotation = this.rotation.clone();
  83065. this.rotation.copyFromFloats(0, 0, 0);
  83066. }
  83067. }
  83068. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  83069. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  83070. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  83071. if (maxDimension === 0) {
  83072. return this;
  83073. }
  83074. var scale = 1 / maxDimension;
  83075. this.scaling.scaleInPlace(scale);
  83076. if (ignoreRotation) {
  83077. if (this.rotationQuaternion && storedRotationQuaternion) {
  83078. this.rotationQuaternion.copyFrom(storedRotationQuaternion);
  83079. }
  83080. else if (this.rotation && storedRotation) {
  83081. this.rotation.copyFrom(storedRotation);
  83082. }
  83083. }
  83084. return this;
  83085. };
  83086. /**
  83087. * Overwrite the current bounding info
  83088. * @param boundingInfo defines the new bounding info
  83089. * @returns the current mesh
  83090. */
  83091. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  83092. this._boundingInfo = boundingInfo;
  83093. return this;
  83094. };
  83095. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  83096. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83097. get: function () {
  83098. 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));
  83099. },
  83100. enumerable: true,
  83101. configurable: true
  83102. });
  83103. /** @hidden */
  83104. AbstractMesh.prototype._preActivate = function () {
  83105. };
  83106. /** @hidden */
  83107. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  83108. };
  83109. /** @hidden */
  83110. AbstractMesh.prototype._activate = function (renderId) {
  83111. this._renderId = renderId;
  83112. return true;
  83113. };
  83114. /** @hidden */
  83115. AbstractMesh.prototype._freeze = function () {
  83116. // Do nothing
  83117. };
  83118. /** @hidden */
  83119. AbstractMesh.prototype._unFreeze = function () {
  83120. // Do nothing
  83121. };
  83122. /**
  83123. * Gets the current world matrix
  83124. * @returns a Matrix
  83125. */
  83126. AbstractMesh.prototype.getWorldMatrix = function () {
  83127. if (this._masterMesh && this.billboardMode === _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  83128. return this._masterMesh.getWorldMatrix();
  83129. }
  83130. return _super.prototype.getWorldMatrix.call(this);
  83131. };
  83132. /** @hidden */
  83133. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  83134. if (this._masterMesh) {
  83135. return this._masterMesh._getWorldMatrixDeterminant();
  83136. }
  83137. return _super.prototype._getWorldMatrixDeterminant.call(this);
  83138. };
  83139. // ================================== Point of View Movement =================================
  83140. /**
  83141. * Perform relative position change from the point of view of behind the front of the mesh.
  83142. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83143. * Supports definition of mesh facing forward or backward
  83144. * @param amountRight defines the distance on the right axis
  83145. * @param amountUp defines the distance on the up axis
  83146. * @param amountForward defines the distance on the forward axis
  83147. * @returns the current mesh
  83148. */
  83149. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  83150. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  83151. return this;
  83152. };
  83153. /**
  83154. * Calculate relative position change from the point of view of behind the front of the mesh.
  83155. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83156. * Supports definition of mesh facing forward or backward
  83157. * @param amountRight defines the distance on the right axis
  83158. * @param amountUp defines the distance on the up axis
  83159. * @param amountForward defines the distance on the forward axis
  83160. * @returns the new displacement vector
  83161. */
  83162. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  83163. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  83164. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  83165. rotQuaternion.toRotationMatrix(rotMatrix);
  83166. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83167. var defForwardMult = this.definedFacingForward ? -1 : 1;
  83168. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  83169. return translationDelta;
  83170. };
  83171. // ================================== Point of View Rotation =================================
  83172. /**
  83173. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83174. * Supports definition of mesh facing forward or backward
  83175. * @param flipBack defines the flip
  83176. * @param twirlClockwise defines the twirl
  83177. * @param tiltRight defines the tilt
  83178. * @returns the current mesh
  83179. */
  83180. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  83181. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  83182. return this;
  83183. };
  83184. /**
  83185. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83186. * Supports definition of mesh facing forward or backward.
  83187. * @param flipBack defines the flip
  83188. * @param twirlClockwise defines the twirl
  83189. * @param tiltRight defines the tilt
  83190. * @returns the new rotation vector
  83191. */
  83192. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  83193. var defForwardMult = this.definedFacingForward ? 1 : -1;
  83194. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  83195. };
  83196. /**
  83197. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83198. * This means the mesh underlying bounding box and sphere are recomputed.
  83199. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83200. * @returns the current mesh
  83201. */
  83202. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  83203. if (applySkeleton === void 0) { applySkeleton = false; }
  83204. if (this._boundingInfo && this._boundingInfo.isLocked) {
  83205. return this;
  83206. }
  83207. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  83208. return this;
  83209. };
  83210. /** @hidden */
  83211. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  83212. if (data) {
  83213. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  83214. if (this._boundingInfo) {
  83215. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  83216. }
  83217. else {
  83218. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  83219. }
  83220. }
  83221. if (this.subMeshes) {
  83222. for (var index = 0; index < this.subMeshes.length; index++) {
  83223. this.subMeshes[index].refreshBoundingInfo();
  83224. }
  83225. }
  83226. this._updateBoundingInfo();
  83227. };
  83228. /** @hidden */
  83229. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  83230. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  83231. if (data && applySkeleton && this.skeleton) {
  83232. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  83233. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  83234. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  83235. if (matricesWeightsData && matricesIndicesData) {
  83236. var needExtras = this.numBoneInfluencers > 4;
  83237. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  83238. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  83239. this.skeleton.prepare();
  83240. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  83241. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  83242. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  83243. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  83244. var matWeightIdx = 0;
  83245. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  83246. finalMatrix.reset();
  83247. var inf;
  83248. var weight;
  83249. for (inf = 0; inf < 4; inf++) {
  83250. weight = matricesWeightsData[matWeightIdx + inf];
  83251. if (weight > 0) {
  83252. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  83253. finalMatrix.addToSelf(tempMatrix);
  83254. }
  83255. }
  83256. if (needExtras) {
  83257. for (inf = 0; inf < 4; inf++) {
  83258. weight = matricesWeightsExtraData[matWeightIdx + inf];
  83259. if (weight > 0) {
  83260. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  83261. finalMatrix.addToSelf(tempMatrix);
  83262. }
  83263. }
  83264. }
  83265. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  83266. tempVector.toArray(data, index);
  83267. }
  83268. }
  83269. }
  83270. return data;
  83271. };
  83272. /** @hidden */
  83273. AbstractMesh.prototype._updateBoundingInfo = function () {
  83274. var effectiveMesh = this._effectiveMesh;
  83275. if (this._boundingInfo) {
  83276. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  83277. }
  83278. else {
  83279. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  83280. }
  83281. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  83282. return this;
  83283. };
  83284. /** @hidden */
  83285. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  83286. if (!this.subMeshes) {
  83287. return this;
  83288. }
  83289. var count = this.subMeshes.length;
  83290. for (var subIndex = 0; subIndex < count; subIndex++) {
  83291. var subMesh = this.subMeshes[subIndex];
  83292. if (count > 1 || !subMesh.IsGlobal) {
  83293. subMesh.updateBoundingInfo(matrix);
  83294. }
  83295. }
  83296. return this;
  83297. };
  83298. /** @hidden */
  83299. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  83300. if (this.doNotSyncBoundingInfo) {
  83301. return;
  83302. }
  83303. // Bounding info
  83304. this._updateBoundingInfo();
  83305. };
  83306. Object.defineProperty(AbstractMesh.prototype, "_effectiveMesh", {
  83307. /** @hidden */
  83308. get: function () {
  83309. return (this.skeleton && this.skeleton.overrideMesh) || this;
  83310. },
  83311. enumerable: true,
  83312. configurable: true
  83313. });
  83314. /**
  83315. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83316. * A mesh is in the frustum if its bounding box intersects the frustum
  83317. * @param frustumPlanes defines the frustum to test
  83318. * @returns true if the mesh is in the frustum planes
  83319. */
  83320. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  83321. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  83322. };
  83323. /**
  83324. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83325. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83326. * @param frustumPlanes defines the frustum to test
  83327. * @returns true if the mesh is completely in the frustum planes
  83328. */
  83329. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  83330. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  83331. };
  83332. /**
  83333. * True if the mesh intersects another mesh or a SolidParticle object
  83334. * @param mesh defines a target mesh or SolidParticle to test
  83335. * @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)
  83336. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83337. * @returns true if there is an intersection
  83338. */
  83339. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  83340. if (precise === void 0) { precise = false; }
  83341. if (!this._boundingInfo || !mesh._boundingInfo) {
  83342. return false;
  83343. }
  83344. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  83345. return true;
  83346. }
  83347. if (includeDescendants) {
  83348. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  83349. var child = _a[_i];
  83350. if (child.intersectsMesh(mesh, precise, true)) {
  83351. return true;
  83352. }
  83353. }
  83354. }
  83355. return false;
  83356. };
  83357. /**
  83358. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83359. * @param point defines the point to test
  83360. * @returns true if there is an intersection
  83361. */
  83362. AbstractMesh.prototype.intersectsPoint = function (point) {
  83363. if (!this._boundingInfo) {
  83364. return false;
  83365. }
  83366. return this._boundingInfo.intersectsPoint(point);
  83367. };
  83368. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  83369. // Collisions
  83370. /**
  83371. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83372. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83373. */
  83374. get: function () {
  83375. return this._checkCollisions;
  83376. },
  83377. set: function (collisionEnabled) {
  83378. this._checkCollisions = collisionEnabled;
  83379. },
  83380. enumerable: true,
  83381. configurable: true
  83382. });
  83383. Object.defineProperty(AbstractMesh.prototype, "collider", {
  83384. /**
  83385. * Gets Collider object used to compute collisions (not physics)
  83386. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83387. */
  83388. get: function () {
  83389. return this._collider;
  83390. },
  83391. enumerable: true,
  83392. configurable: true
  83393. });
  83394. /**
  83395. * Move the mesh using collision engine
  83396. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83397. * @param displacement defines the requested displacement vector
  83398. * @returns the current mesh
  83399. */
  83400. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  83401. var globalPosition = this.getAbsolutePosition();
  83402. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  83403. var coordinator = this.getScene().collisionCoordinator;
  83404. if (!this._collider) {
  83405. this._collider = coordinator.createCollider();
  83406. }
  83407. this._collider._radius = this.ellipsoid;
  83408. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  83409. return this;
  83410. };
  83411. // Collisions
  83412. /** @hidden */
  83413. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  83414. this._generatePointsArray();
  83415. if (!this._positions) {
  83416. return this;
  83417. }
  83418. // Transformation
  83419. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  83420. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  83421. subMesh._lastColliderWorldVertices = [];
  83422. subMesh._trianglePlanes = [];
  83423. var start = subMesh.verticesStart;
  83424. var end = (subMesh.verticesStart + subMesh.verticesCount);
  83425. for (var i = start; i < end; i++) {
  83426. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  83427. }
  83428. }
  83429. // Collide
  83430. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  83431. if (collider.collisionFound) {
  83432. collider.collidedMesh = this;
  83433. }
  83434. return this;
  83435. };
  83436. /** @hidden */
  83437. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  83438. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  83439. var len = subMeshes.length;
  83440. for (var index = 0; index < len; index++) {
  83441. var subMesh = subMeshes.data[index];
  83442. // Bounding test
  83443. if (len > 1 && !subMesh._checkCollision(collider)) {
  83444. continue;
  83445. }
  83446. this._collideForSubMesh(subMesh, transformMatrix, collider);
  83447. }
  83448. return this;
  83449. };
  83450. /** @hidden */
  83451. AbstractMesh.prototype._checkCollision = function (collider) {
  83452. // Bounding box test
  83453. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  83454. return this;
  83455. }
  83456. // Transformation matrix
  83457. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  83458. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  83459. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  83460. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  83461. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  83462. return this;
  83463. };
  83464. // Picking
  83465. /** @hidden */
  83466. AbstractMesh.prototype._generatePointsArray = function () {
  83467. return false;
  83468. };
  83469. /**
  83470. * Checks if the passed Ray intersects with the mesh
  83471. * @param ray defines the ray to use
  83472. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83473. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83474. * @returns the picking info
  83475. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83476. */
  83477. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  83478. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  83479. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  83480. var boundingInfo = this._boundingInfo;
  83481. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  83482. return pickingInfo;
  83483. }
  83484. if (!this._generatePointsArray()) {
  83485. return pickingInfo;
  83486. }
  83487. var intersectInfo = null;
  83488. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  83489. var len = subMeshes.length;
  83490. for (var index = 0; index < len; index++) {
  83491. var subMesh = subMeshes.data[index];
  83492. // Bounding test
  83493. if (len > 1 && !subMesh.canIntersects(ray)) {
  83494. continue;
  83495. }
  83496. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  83497. if (currentIntersectInfo) {
  83498. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  83499. intersectInfo = currentIntersectInfo;
  83500. intersectInfo.subMeshId = index;
  83501. if (fastCheck) {
  83502. break;
  83503. }
  83504. }
  83505. }
  83506. }
  83507. if (intersectInfo) {
  83508. // Get picked point
  83509. var world = this.getWorldMatrix();
  83510. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  83511. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  83512. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  83513. ray.direction.scaleToRef(intersectInfo.distance, direction);
  83514. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  83515. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  83516. // Return result
  83517. pickingInfo.hit = true;
  83518. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  83519. pickingInfo.pickedPoint = pickedPoint;
  83520. pickingInfo.pickedMesh = this;
  83521. pickingInfo.bu = intersectInfo.bu || 0;
  83522. pickingInfo.bv = intersectInfo.bv || 0;
  83523. pickingInfo.faceId = intersectInfo.faceId;
  83524. pickingInfo.subMeshId = intersectInfo.subMeshId;
  83525. return pickingInfo;
  83526. }
  83527. return pickingInfo;
  83528. };
  83529. /**
  83530. * Clones the current mesh
  83531. * @param name defines the mesh name
  83532. * @param newParent defines the new mesh parent
  83533. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83534. * @returns the new mesh
  83535. */
  83536. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83537. return null;
  83538. };
  83539. /**
  83540. * Disposes all the submeshes of the current meshnp
  83541. * @returns the current mesh
  83542. */
  83543. AbstractMesh.prototype.releaseSubMeshes = function () {
  83544. if (this.subMeshes) {
  83545. while (this.subMeshes.length) {
  83546. this.subMeshes[0].dispose();
  83547. }
  83548. }
  83549. else {
  83550. this.subMeshes = new Array();
  83551. }
  83552. return this;
  83553. };
  83554. /**
  83555. * Releases resources associated with this abstract mesh.
  83556. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83557. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83558. */
  83559. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  83560. var _this = this;
  83561. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  83562. var index;
  83563. // Smart Array Retainers.
  83564. this.getScene().freeActiveMeshes();
  83565. this.getScene().freeRenderingGroups();
  83566. // Action manager
  83567. if (this.actionManager !== undefined && this.actionManager !== null) {
  83568. this.actionManager.dispose();
  83569. this.actionManager = null;
  83570. }
  83571. // Skeleton
  83572. this._skeleton = null;
  83573. // Intersections in progress
  83574. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  83575. var other = this._intersectionsInProgress[index];
  83576. var pos = other._intersectionsInProgress.indexOf(this);
  83577. other._intersectionsInProgress.splice(pos, 1);
  83578. }
  83579. this._intersectionsInProgress = [];
  83580. // Lights
  83581. var lights = this.getScene().lights;
  83582. lights.forEach(function (light) {
  83583. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  83584. if (meshIndex !== -1) {
  83585. light.includedOnlyMeshes.splice(meshIndex, 1);
  83586. }
  83587. meshIndex = light.excludedMeshes.indexOf(_this);
  83588. if (meshIndex !== -1) {
  83589. light.excludedMeshes.splice(meshIndex, 1);
  83590. }
  83591. // Shadow generators
  83592. var generator = light.getShadowGenerator();
  83593. if (generator) {
  83594. var shadowMap = generator.getShadowMap();
  83595. if (shadowMap && shadowMap.renderList) {
  83596. meshIndex = shadowMap.renderList.indexOf(_this);
  83597. if (meshIndex !== -1) {
  83598. shadowMap.renderList.splice(meshIndex, 1);
  83599. }
  83600. }
  83601. }
  83602. });
  83603. // SubMeshes
  83604. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  83605. this.releaseSubMeshes();
  83606. }
  83607. // Query
  83608. var engine = this.getScene().getEngine();
  83609. if (this._occlusionQuery) {
  83610. this.isOcclusionQueryInProgress = false;
  83611. engine.deleteQuery(this._occlusionQuery);
  83612. this._occlusionQuery = null;
  83613. }
  83614. // Engine
  83615. engine.wipeCaches();
  83616. // Remove from scene
  83617. this.getScene().removeMesh(this);
  83618. if (disposeMaterialAndTextures) {
  83619. if (this.material) {
  83620. if (this.material.getClassName() === "MultiMaterial") {
  83621. this.material.dispose(false, true, true);
  83622. }
  83623. else {
  83624. this.material.dispose(false, true);
  83625. }
  83626. }
  83627. }
  83628. if (!doNotRecurse) {
  83629. // Particles
  83630. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  83631. if (this.getScene().particleSystems[index].emitter === this) {
  83632. this.getScene().particleSystems[index].dispose();
  83633. index--;
  83634. }
  83635. }
  83636. }
  83637. // facet data
  83638. if (this._facetData.facetDataEnabled) {
  83639. this.disableFacetData();
  83640. }
  83641. this.onAfterWorldMatrixUpdateObservable.clear();
  83642. this.onCollideObservable.clear();
  83643. this.onCollisionPositionChangeObservable.clear();
  83644. this.onRebuildObservable.clear();
  83645. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  83646. };
  83647. /**
  83648. * Adds the passed mesh as a child to the current mesh
  83649. * @param mesh defines the child mesh
  83650. * @returns the current mesh
  83651. */
  83652. AbstractMesh.prototype.addChild = function (mesh) {
  83653. mesh.setParent(this);
  83654. return this;
  83655. };
  83656. /**
  83657. * Removes the passed mesh from the current mesh children list
  83658. * @param mesh defines the child mesh
  83659. * @returns the current mesh
  83660. */
  83661. AbstractMesh.prototype.removeChild = function (mesh) {
  83662. mesh.setParent(null);
  83663. return this;
  83664. };
  83665. // Facet data
  83666. /** @hidden */
  83667. AbstractMesh.prototype._initFacetData = function () {
  83668. var data = this._facetData;
  83669. if (!data.facetNormals) {
  83670. data.facetNormals = new Array();
  83671. }
  83672. if (!data.facetPositions) {
  83673. data.facetPositions = new Array();
  83674. }
  83675. if (!data.facetPartitioning) {
  83676. data.facetPartitioning = new Array();
  83677. }
  83678. data.facetNb = (this.getIndices().length / 3) | 0;
  83679. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  83680. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  83681. for (var f = 0; f < data.facetNb; f++) {
  83682. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83683. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83684. }
  83685. data.facetDataEnabled = true;
  83686. return this;
  83687. };
  83688. /**
  83689. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83690. * This method can be called within the render loop.
  83691. * 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
  83692. * @returns the current mesh
  83693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83694. */
  83695. AbstractMesh.prototype.updateFacetData = function () {
  83696. var data = this._facetData;
  83697. if (!data.facetDataEnabled) {
  83698. this._initFacetData();
  83699. }
  83700. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  83701. var indices = this.getIndices();
  83702. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  83703. var bInfo = this.getBoundingInfo();
  83704. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  83705. // init arrays, matrix and sort function on first call
  83706. data.facetDepthSortEnabled = true;
  83707. if (indices instanceof Uint16Array) {
  83708. data.depthSortedIndices = new Uint16Array(indices);
  83709. }
  83710. else if (indices instanceof Uint32Array) {
  83711. data.depthSortedIndices = new Uint32Array(indices);
  83712. }
  83713. else {
  83714. var needs32bits = false;
  83715. for (var i = 0; i < indices.length; i++) {
  83716. if (indices[i] > 65535) {
  83717. needs32bits = true;
  83718. break;
  83719. }
  83720. }
  83721. if (needs32bits) {
  83722. data.depthSortedIndices = new Uint32Array(indices);
  83723. }
  83724. else {
  83725. data.depthSortedIndices = new Uint16Array(indices);
  83726. }
  83727. }
  83728. data.facetDepthSortFunction = function (f1, f2) {
  83729. return (f2.sqDistance - f1.sqDistance);
  83730. };
  83731. if (!data.facetDepthSortFrom) {
  83732. var camera = this.getScene().activeCamera;
  83733. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83734. }
  83735. data.depthSortedFacets = [];
  83736. for (var f = 0; f < data.facetNb; f++) {
  83737. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  83738. data.depthSortedFacets.push(depthSortedFacet);
  83739. }
  83740. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  83741. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83742. }
  83743. 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"];
  83744. 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"];
  83745. 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"];
  83746. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  83747. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  83748. data.subDiv.max = data.partitioningSubdivisions;
  83749. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  83750. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  83751. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  83752. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  83753. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  83754. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  83755. // set the parameters for ComputeNormals()
  83756. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  83757. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  83758. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  83759. data.facetParameters.bInfo = bInfo;
  83760. data.facetParameters.bbSize = data.bbSize;
  83761. data.facetParameters.subDiv = data.subDiv;
  83762. data.facetParameters.ratio = this.partitioningBBoxRatio;
  83763. data.facetParameters.depthSort = data.facetDepthSort;
  83764. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  83765. this.computeWorldMatrix(true);
  83766. this._worldMatrix.invertToRef(data.invertedMatrix);
  83767. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  83768. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  83769. }
  83770. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  83771. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  83772. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  83773. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  83774. var l = (data.depthSortedIndices.length / 3) | 0;
  83775. for (var f = 0; f < l; f++) {
  83776. var sind = data.depthSortedFacets[f].ind;
  83777. data.depthSortedIndices[f * 3] = indices[sind];
  83778. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  83779. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  83780. }
  83781. this.updateIndices(data.depthSortedIndices, undefined, true);
  83782. }
  83783. return this;
  83784. };
  83785. /**
  83786. * Returns the facetLocalNormals array.
  83787. * The normals are expressed in the mesh local spac
  83788. * @returns an array of Vector3
  83789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83790. */
  83791. AbstractMesh.prototype.getFacetLocalNormals = function () {
  83792. if (!this._facetData.facetNormals) {
  83793. this.updateFacetData();
  83794. }
  83795. return this._facetData.facetNormals;
  83796. };
  83797. /**
  83798. * Returns the facetLocalPositions array.
  83799. * The facet positions are expressed in the mesh local space
  83800. * @returns an array of Vector3
  83801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83802. */
  83803. AbstractMesh.prototype.getFacetLocalPositions = function () {
  83804. if (!this._facetData.facetPositions) {
  83805. this.updateFacetData();
  83806. }
  83807. return this._facetData.facetPositions;
  83808. };
  83809. /**
  83810. * Returns the facetLocalPartioning array
  83811. * @returns an array of array of numbers
  83812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83813. */
  83814. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  83815. if (!this._facetData.facetPartitioning) {
  83816. this.updateFacetData();
  83817. }
  83818. return this._facetData.facetPartitioning;
  83819. };
  83820. /**
  83821. * Returns the i-th facet position in the world system.
  83822. * This method allocates a new Vector3 per call
  83823. * @param i defines the facet index
  83824. * @returns a new Vector3
  83825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83826. */
  83827. AbstractMesh.prototype.getFacetPosition = function (i) {
  83828. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83829. this.getFacetPositionToRef(i, pos);
  83830. return pos;
  83831. };
  83832. /**
  83833. * Sets the reference Vector3 with the i-th facet position in the world system
  83834. * @param i defines the facet index
  83835. * @param ref defines the target vector
  83836. * @returns the current mesh
  83837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83838. */
  83839. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  83840. var localPos = (this.getFacetLocalPositions())[i];
  83841. var world = this.getWorldMatrix();
  83842. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  83843. return this;
  83844. };
  83845. /**
  83846. * Returns the i-th facet normal in the world system.
  83847. * This method allocates a new Vector3 per call
  83848. * @param i defines the facet index
  83849. * @returns a new Vector3
  83850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83851. */
  83852. AbstractMesh.prototype.getFacetNormal = function (i) {
  83853. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83854. this.getFacetNormalToRef(i, norm);
  83855. return norm;
  83856. };
  83857. /**
  83858. * Sets the reference Vector3 with the i-th facet normal in the world system
  83859. * @param i defines the facet index
  83860. * @param ref defines the target vector
  83861. * @returns the current mesh
  83862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83863. */
  83864. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  83865. var localNorm = (this.getFacetLocalNormals())[i];
  83866. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  83867. return this;
  83868. };
  83869. /**
  83870. * 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)
  83871. * @param x defines x coordinate
  83872. * @param y defines y coordinate
  83873. * @param z defines z coordinate
  83874. * @returns the array of facet indexes
  83875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83876. */
  83877. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  83878. var bInfo = this.getBoundingInfo();
  83879. var data = this._facetData;
  83880. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  83881. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  83882. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  83883. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  83884. return null;
  83885. }
  83886. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  83887. };
  83888. /**
  83889. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83890. * @param projected sets as the (x,y,z) world projection on the facet
  83891. * @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
  83892. * @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
  83893. * @param x defines x coordinate
  83894. * @param y defines y coordinate
  83895. * @param z defines z coordinate
  83896. * @returns the face index if found (or null instead)
  83897. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83898. */
  83899. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  83900. if (checkFace === void 0) { checkFace = false; }
  83901. if (facing === void 0) { facing = true; }
  83902. var world = this.getWorldMatrix();
  83903. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  83904. world.invertToRef(invMat);
  83905. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  83906. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  83907. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  83908. if (projected) {
  83909. // tranform the local computed projected vector to world coordinates
  83910. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  83911. }
  83912. return closest;
  83913. };
  83914. /**
  83915. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83916. * @param projected sets as the (x,y,z) local projection on the facet
  83917. * @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
  83918. * @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
  83919. * @param x defines x coordinate
  83920. * @param y defines y coordinate
  83921. * @param z defines z coordinate
  83922. * @returns the face index if found (or null instead)
  83923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83924. */
  83925. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  83926. if (checkFace === void 0) { checkFace = false; }
  83927. if (facing === void 0) { facing = true; }
  83928. var closest = null;
  83929. var tmpx = 0.0;
  83930. var tmpy = 0.0;
  83931. var tmpz = 0.0;
  83932. var d = 0.0; // tmp dot facet normal * facet position
  83933. var t0 = 0.0;
  83934. var projx = 0.0;
  83935. var projy = 0.0;
  83936. var projz = 0.0;
  83937. // Get all the facets in the same partitioning block than (x, y, z)
  83938. var facetPositions = this.getFacetLocalPositions();
  83939. var facetNormals = this.getFacetLocalNormals();
  83940. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  83941. if (!facetsInBlock) {
  83942. return null;
  83943. }
  83944. // Get the closest facet to (x, y, z)
  83945. var shortest = Number.MAX_VALUE; // init distance vars
  83946. var tmpDistance = shortest;
  83947. var fib; // current facet in the block
  83948. var norm; // current facet normal
  83949. var p0; // current facet barycenter position
  83950. // loop on all the facets in the current partitioning block
  83951. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  83952. fib = facetsInBlock[idx];
  83953. norm = facetNormals[fib];
  83954. p0 = facetPositions[fib];
  83955. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  83956. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  83957. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  83958. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  83959. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  83960. projx = x + norm.x * t0;
  83961. projy = y + norm.y * t0;
  83962. projz = z + norm.z * t0;
  83963. tmpx = projx - x;
  83964. tmpy = projy - y;
  83965. tmpz = projz - z;
  83966. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  83967. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  83968. shortest = tmpDistance;
  83969. closest = fib;
  83970. if (projected) {
  83971. projected.x = projx;
  83972. projected.y = projy;
  83973. projected.z = projz;
  83974. }
  83975. }
  83976. }
  83977. }
  83978. return closest;
  83979. };
  83980. /**
  83981. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83982. * @returns the parameters
  83983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83984. */
  83985. AbstractMesh.prototype.getFacetDataParameters = function () {
  83986. return this._facetData.facetParameters;
  83987. };
  83988. /**
  83989. * Disables the feature FacetData and frees the related memory
  83990. * @returns the current mesh
  83991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83992. */
  83993. AbstractMesh.prototype.disableFacetData = function () {
  83994. if (this._facetData.facetDataEnabled) {
  83995. this._facetData.facetDataEnabled = false;
  83996. this._facetData.facetPositions = new Array();
  83997. this._facetData.facetNormals = new Array();
  83998. this._facetData.facetPartitioning = new Array();
  83999. this._facetData.facetParameters = null;
  84000. this._facetData.depthSortedIndices = new Uint32Array(0);
  84001. }
  84002. return this;
  84003. };
  84004. /**
  84005. * Updates the AbstractMesh indices array
  84006. * @param indices defines the data source
  84007. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84008. * @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)
  84009. * @returns the current mesh
  84010. */
  84011. AbstractMesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  84012. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  84013. return this;
  84014. };
  84015. /**
  84016. * Creates new normals data for the mesh
  84017. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84018. * @returns the current mesh
  84019. */
  84020. AbstractMesh.prototype.createNormals = function (updatable) {
  84021. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  84022. var indices = this.getIndices();
  84023. var normals;
  84024. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  84025. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  84026. }
  84027. else {
  84028. normals = [];
  84029. }
  84030. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  84031. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  84032. return this;
  84033. };
  84034. /**
  84035. * Align the mesh with a normal
  84036. * @param normal defines the normal to use
  84037. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84038. * @returns the current mesh
  84039. */
  84040. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  84041. if (!upDirection) {
  84042. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  84043. }
  84044. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  84045. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  84046. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  84047. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  84048. if (this.rotationQuaternion) {
  84049. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  84050. }
  84051. else {
  84052. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  84053. }
  84054. return this;
  84055. };
  84056. /** @hidden */
  84057. AbstractMesh.prototype._checkOcclusionQuery = function () {
  84058. return false;
  84059. };
  84060. /** No occlusion */
  84061. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  84062. /** Occlusion set to optimisitic */
  84063. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  84064. /** Occlusion set to strict */
  84065. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  84066. /** Use an accurante occlusion algorithm */
  84067. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  84068. /** Use a conservative occlusion algorithm */
  84069. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  84070. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  84071. * Test order :
  84072. * Is the bounding sphere outside the frustum ?
  84073. * If not, are the bounding box vertices outside the frustum ?
  84074. * It not, then the cullable object is in the frustum.
  84075. */
  84076. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  84077. /** Culling strategy : Bounding Sphere Only.
  84078. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  84079. * It's also less accurate than the standard because some not visible objects can still be selected.
  84080. * Test : is the bounding sphere outside the frustum ?
  84081. * If not, then the cullable object is in the frustum.
  84082. */
  84083. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  84084. /** Culling strategy : Optimistic Inclusion.
  84085. * This in an inclusion test first, then the standard exclusion test.
  84086. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  84087. * 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.
  84088. * Anyway, it's as accurate as the standard strategy.
  84089. * Test :
  84090. * Is the cullable object bounding sphere center in the frustum ?
  84091. * If not, apply the default culling strategy.
  84092. */
  84093. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  84094. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  84095. * This in an inclusion test first, then the bounding sphere only exclusion test.
  84096. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  84097. * 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.
  84098. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  84099. * Test :
  84100. * Is the cullable object bounding sphere center in the frustum ?
  84101. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  84102. */
  84103. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  84104. return AbstractMesh;
  84105. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  84106. /***/ }),
  84107. /***/ "./Meshes/buffer.ts":
  84108. /*!**************************!*\
  84109. !*** ./Meshes/buffer.ts ***!
  84110. \**************************/
  84111. /*! exports provided: Buffer, VertexBuffer */
  84112. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84113. "use strict";
  84114. __webpack_require__.r(__webpack_exports__);
  84115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  84116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  84117. /**
  84118. * Class used to store data that will be store in GPU memory
  84119. */
  84120. var Buffer = /** @class */ (function () {
  84121. /**
  84122. * Constructor
  84123. * @param engine the engine
  84124. * @param data the data to use for this buffer
  84125. * @param updatable whether the data is updatable
  84126. * @param stride the stride (optional)
  84127. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84128. * @param instanced whether the buffer is instanced (optional)
  84129. * @param useBytes set to true if the stride in in bytes (optional)
  84130. */
  84131. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  84132. if (stride === void 0) { stride = 0; }
  84133. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  84134. if (instanced === void 0) { instanced = false; }
  84135. if (useBytes === void 0) { useBytes = false; }
  84136. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  84137. this._engine = engine.getScene().getEngine();
  84138. }
  84139. else {
  84140. this._engine = engine;
  84141. }
  84142. this._updatable = updatable;
  84143. this._instanced = instanced;
  84144. this._data = data;
  84145. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  84146. if (!postponeInternalCreation) { // by default
  84147. this.create();
  84148. }
  84149. }
  84150. /**
  84151. * Create a new VertexBuffer based on the current buffer
  84152. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84153. * @param offset defines offset in the buffer (0 by default)
  84154. * @param size defines the size in floats of attributes (position is 3 for instance)
  84155. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84156. * @param instanced defines if the vertex buffer contains indexed data
  84157. * @param useBytes defines if the offset and stride are in bytes
  84158. * @returns the new vertex buffer
  84159. */
  84160. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  84161. if (useBytes === void 0) { useBytes = false; }
  84162. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  84163. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  84164. // a lot of these parameters are ignored as they are overriden by the buffer
  84165. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  84166. };
  84167. // Properties
  84168. /**
  84169. * Gets a boolean indicating if the Buffer is updatable?
  84170. * @returns true if the buffer is updatable
  84171. */
  84172. Buffer.prototype.isUpdatable = function () {
  84173. return this._updatable;
  84174. };
  84175. /**
  84176. * Gets current buffer's data
  84177. * @returns a DataArray or null
  84178. */
  84179. Buffer.prototype.getData = function () {
  84180. return this._data;
  84181. };
  84182. /**
  84183. * Gets underlying native buffer
  84184. * @returns underlying native buffer
  84185. */
  84186. Buffer.prototype.getBuffer = function () {
  84187. return this._buffer;
  84188. };
  84189. /**
  84190. * Gets the stride in float32 units (i.e. byte stride / 4).
  84191. * May not be an integer if the byte stride is not divisible by 4.
  84192. * DEPRECATED. Use byteStride instead.
  84193. * @returns the stride in float32 units
  84194. */
  84195. Buffer.prototype.getStrideSize = function () {
  84196. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  84197. };
  84198. // Methods
  84199. /**
  84200. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84201. * @param data defines the data to store
  84202. */
  84203. Buffer.prototype.create = function (data) {
  84204. if (data === void 0) { data = null; }
  84205. if (!data && this._buffer) {
  84206. return; // nothing to do
  84207. }
  84208. data = data || this._data;
  84209. if (!data) {
  84210. return;
  84211. }
  84212. if (!this._buffer) { // create buffer
  84213. if (this._updatable) {
  84214. this._buffer = this._engine.createDynamicVertexBuffer(data);
  84215. this._data = data;
  84216. }
  84217. else {
  84218. this._buffer = this._engine.createVertexBuffer(data);
  84219. }
  84220. }
  84221. else if (this._updatable) { // update buffer
  84222. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  84223. this._data = data;
  84224. }
  84225. };
  84226. /** @hidden */
  84227. Buffer.prototype._rebuild = function () {
  84228. this._buffer = null;
  84229. this.create(this._data);
  84230. };
  84231. /**
  84232. * Update current buffer data
  84233. * @param data defines the data to store
  84234. */
  84235. Buffer.prototype.update = function (data) {
  84236. this.create(data);
  84237. };
  84238. /**
  84239. * Updates the data directly.
  84240. * @param data the new data
  84241. * @param offset the new offset
  84242. * @param vertexCount the vertex count (optional)
  84243. * @param useBytes set to true if the offset is in bytes
  84244. */
  84245. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  84246. if (useBytes === void 0) { useBytes = false; }
  84247. if (!this._buffer) {
  84248. return;
  84249. }
  84250. if (this._updatable) { // update buffer
  84251. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  84252. this._data = null;
  84253. }
  84254. };
  84255. /**
  84256. * Release all resources
  84257. */
  84258. Buffer.prototype.dispose = function () {
  84259. if (!this._buffer) {
  84260. return;
  84261. }
  84262. if (this._engine._releaseBuffer(this._buffer)) {
  84263. this._buffer = null;
  84264. }
  84265. };
  84266. return Buffer;
  84267. }());
  84268. /**
  84269. * Specialized buffer used to store vertex data
  84270. */
  84271. var VertexBuffer = /** @class */ (function () {
  84272. /**
  84273. * Constructor
  84274. * @param engine the engine
  84275. * @param data the data to use for this vertex buffer
  84276. * @param kind the vertex buffer kind
  84277. * @param updatable whether the data is updatable
  84278. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84279. * @param stride the stride (optional)
  84280. * @param instanced whether the buffer is instanced (optional)
  84281. * @param offset the offset of the data (optional)
  84282. * @param size the number of components (optional)
  84283. * @param type the type of the component (optional)
  84284. * @param normalized whether the data contains normalized data (optional)
  84285. * @param useBytes set to true if stride and offset are in bytes (optional)
  84286. */
  84287. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  84288. if (normalized === void 0) { normalized = false; }
  84289. if (useBytes === void 0) { useBytes = false; }
  84290. if (data instanceof Buffer) {
  84291. this._buffer = data;
  84292. this._ownsBuffer = false;
  84293. }
  84294. else {
  84295. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  84296. this._ownsBuffer = true;
  84297. }
  84298. this._kind = kind;
  84299. if (type == undefined) {
  84300. var data_1 = this.getData();
  84301. this.type = VertexBuffer.FLOAT;
  84302. if (data_1 instanceof Int8Array) {
  84303. this.type = VertexBuffer.BYTE;
  84304. }
  84305. else if (data_1 instanceof Uint8Array) {
  84306. this.type = VertexBuffer.UNSIGNED_BYTE;
  84307. }
  84308. else if (data_1 instanceof Int16Array) {
  84309. this.type = VertexBuffer.SHORT;
  84310. }
  84311. else if (data_1 instanceof Uint16Array) {
  84312. this.type = VertexBuffer.UNSIGNED_SHORT;
  84313. }
  84314. else if (data_1 instanceof Int32Array) {
  84315. this.type = VertexBuffer.INT;
  84316. }
  84317. else if (data_1 instanceof Uint32Array) {
  84318. this.type = VertexBuffer.UNSIGNED_INT;
  84319. }
  84320. }
  84321. else {
  84322. this.type = type;
  84323. }
  84324. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  84325. if (useBytes) {
  84326. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  84327. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  84328. this.byteOffset = offset || 0;
  84329. }
  84330. else {
  84331. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  84332. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  84333. this.byteOffset = (offset || 0) * typeByteLength;
  84334. }
  84335. this.normalized = normalized;
  84336. this._instanced = instanced !== undefined ? instanced : false;
  84337. this._instanceDivisor = instanced ? 1 : 0;
  84338. }
  84339. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  84340. /**
  84341. * Gets or sets the instance divisor when in instanced mode
  84342. */
  84343. get: function () {
  84344. return this._instanceDivisor;
  84345. },
  84346. set: function (value) {
  84347. this._instanceDivisor = value;
  84348. if (value == 0) {
  84349. this._instanced = false;
  84350. }
  84351. else {
  84352. this._instanced = true;
  84353. }
  84354. },
  84355. enumerable: true,
  84356. configurable: true
  84357. });
  84358. /** @hidden */
  84359. VertexBuffer.prototype._rebuild = function () {
  84360. if (!this._buffer) {
  84361. return;
  84362. }
  84363. this._buffer._rebuild();
  84364. };
  84365. /**
  84366. * Returns the kind of the VertexBuffer (string)
  84367. * @returns a string
  84368. */
  84369. VertexBuffer.prototype.getKind = function () {
  84370. return this._kind;
  84371. };
  84372. // Properties
  84373. /**
  84374. * Gets a boolean indicating if the VertexBuffer is updatable?
  84375. * @returns true if the buffer is updatable
  84376. */
  84377. VertexBuffer.prototype.isUpdatable = function () {
  84378. return this._buffer.isUpdatable();
  84379. };
  84380. /**
  84381. * Gets current buffer's data
  84382. * @returns a DataArray or null
  84383. */
  84384. VertexBuffer.prototype.getData = function () {
  84385. return this._buffer.getData();
  84386. };
  84387. /**
  84388. * Gets underlying native buffer
  84389. * @returns underlying native buffer
  84390. */
  84391. VertexBuffer.prototype.getBuffer = function () {
  84392. return this._buffer.getBuffer();
  84393. };
  84394. /**
  84395. * Gets the stride in float32 units (i.e. byte stride / 4).
  84396. * May not be an integer if the byte stride is not divisible by 4.
  84397. * DEPRECATED. Use byteStride instead.
  84398. * @returns the stride in float32 units
  84399. */
  84400. VertexBuffer.prototype.getStrideSize = function () {
  84401. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  84402. };
  84403. /**
  84404. * Returns the offset as a multiple of the type byte length.
  84405. * DEPRECATED. Use byteOffset instead.
  84406. * @returns the offset in bytes
  84407. */
  84408. VertexBuffer.prototype.getOffset = function () {
  84409. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  84410. };
  84411. /**
  84412. * Returns the number of components per vertex attribute (integer)
  84413. * @returns the size in float
  84414. */
  84415. VertexBuffer.prototype.getSize = function () {
  84416. return this._size;
  84417. };
  84418. /**
  84419. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84420. * @returns true if this buffer is instanced
  84421. */
  84422. VertexBuffer.prototype.getIsInstanced = function () {
  84423. return this._instanced;
  84424. };
  84425. /**
  84426. * Returns the instancing divisor, zero for non-instanced (integer).
  84427. * @returns a number
  84428. */
  84429. VertexBuffer.prototype.getInstanceDivisor = function () {
  84430. return this._instanceDivisor;
  84431. };
  84432. // Methods
  84433. /**
  84434. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84435. * @param data defines the data to store
  84436. */
  84437. VertexBuffer.prototype.create = function (data) {
  84438. this._buffer.create(data);
  84439. };
  84440. /**
  84441. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84442. * This function will create a new buffer if the current one is not updatable
  84443. * @param data defines the data to store
  84444. */
  84445. VertexBuffer.prototype.update = function (data) {
  84446. this._buffer.update(data);
  84447. };
  84448. /**
  84449. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84450. * Returns the directly updated WebGLBuffer.
  84451. * @param data the new data
  84452. * @param offset the new offset
  84453. * @param useBytes set to true if the offset is in bytes
  84454. */
  84455. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  84456. if (useBytes === void 0) { useBytes = false; }
  84457. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  84458. };
  84459. /**
  84460. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84461. */
  84462. VertexBuffer.prototype.dispose = function () {
  84463. if (this._ownsBuffer) {
  84464. this._buffer.dispose();
  84465. }
  84466. };
  84467. /**
  84468. * Enumerates each value of this vertex buffer as numbers.
  84469. * @param count the number of values to enumerate
  84470. * @param callback the callback function called for each value
  84471. */
  84472. VertexBuffer.prototype.forEach = function (count, callback) {
  84473. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  84474. };
  84475. /**
  84476. * Deduces the stride given a kind.
  84477. * @param kind The kind string to deduce
  84478. * @returns The deduced stride
  84479. */
  84480. VertexBuffer.DeduceStride = function (kind) {
  84481. switch (kind) {
  84482. case VertexBuffer.UVKind:
  84483. case VertexBuffer.UV2Kind:
  84484. case VertexBuffer.UV3Kind:
  84485. case VertexBuffer.UV4Kind:
  84486. case VertexBuffer.UV5Kind:
  84487. case VertexBuffer.UV6Kind:
  84488. return 2;
  84489. case VertexBuffer.NormalKind:
  84490. case VertexBuffer.PositionKind:
  84491. return 3;
  84492. case VertexBuffer.ColorKind:
  84493. case VertexBuffer.MatricesIndicesKind:
  84494. case VertexBuffer.MatricesIndicesExtraKind:
  84495. case VertexBuffer.MatricesWeightsKind:
  84496. case VertexBuffer.MatricesWeightsExtraKind:
  84497. case VertexBuffer.TangentKind:
  84498. return 4;
  84499. default:
  84500. throw new Error("Invalid kind '" + kind + "'");
  84501. }
  84502. };
  84503. /**
  84504. * Gets the byte length of the given type.
  84505. * @param type the type
  84506. * @returns the number of bytes
  84507. */
  84508. VertexBuffer.GetTypeByteLength = function (type) {
  84509. switch (type) {
  84510. case VertexBuffer.BYTE:
  84511. case VertexBuffer.UNSIGNED_BYTE:
  84512. return 1;
  84513. case VertexBuffer.SHORT:
  84514. case VertexBuffer.UNSIGNED_SHORT:
  84515. return 2;
  84516. case VertexBuffer.INT:
  84517. case VertexBuffer.FLOAT:
  84518. return 4;
  84519. default:
  84520. throw new Error("Invalid type '" + type + "'");
  84521. }
  84522. };
  84523. /**
  84524. * Enumerates each value of the given parameters as numbers.
  84525. * @param data the data to enumerate
  84526. * @param byteOffset the byte offset of the data
  84527. * @param byteStride the byte stride of the data
  84528. * @param componentCount the number of components per element
  84529. * @param componentType the type of the component
  84530. * @param count the total number of components
  84531. * @param normalized whether the data is normalized
  84532. * @param callback the callback function called for each value
  84533. */
  84534. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  84535. if (data instanceof Array) {
  84536. var offset = byteOffset / 4;
  84537. var stride = byteStride / 4;
  84538. for (var index = 0; index < count; index += componentCount) {
  84539. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  84540. callback(data[offset + componentIndex], index + componentIndex);
  84541. }
  84542. offset += stride;
  84543. }
  84544. }
  84545. else {
  84546. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  84547. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  84548. for (var index = 0; index < count; index += componentCount) {
  84549. var componentByteOffset = byteOffset;
  84550. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  84551. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  84552. callback(value, index + componentIndex);
  84553. componentByteOffset += componentByteLength;
  84554. }
  84555. byteOffset += byteStride;
  84556. }
  84557. }
  84558. };
  84559. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  84560. switch (type) {
  84561. case VertexBuffer.BYTE: {
  84562. var value = dataView.getInt8(byteOffset);
  84563. if (normalized) {
  84564. value = Math.max(value / 127, -1);
  84565. }
  84566. return value;
  84567. }
  84568. case VertexBuffer.UNSIGNED_BYTE: {
  84569. var value = dataView.getUint8(byteOffset);
  84570. if (normalized) {
  84571. value = value / 255;
  84572. }
  84573. return value;
  84574. }
  84575. case VertexBuffer.SHORT: {
  84576. var value = dataView.getInt16(byteOffset, true);
  84577. if (normalized) {
  84578. value = Math.max(value / 16383, -1);
  84579. }
  84580. return value;
  84581. }
  84582. case VertexBuffer.UNSIGNED_SHORT: {
  84583. var value = dataView.getUint16(byteOffset, true);
  84584. if (normalized) {
  84585. value = value / 65535;
  84586. }
  84587. return value;
  84588. }
  84589. case VertexBuffer.FLOAT: {
  84590. return dataView.getFloat32(byteOffset, true);
  84591. }
  84592. default: {
  84593. throw new Error("Invalid component type " + type);
  84594. }
  84595. }
  84596. };
  84597. /**
  84598. * The byte type.
  84599. */
  84600. VertexBuffer.BYTE = 5120;
  84601. /**
  84602. * The unsigned byte type.
  84603. */
  84604. VertexBuffer.UNSIGNED_BYTE = 5121;
  84605. /**
  84606. * The short type.
  84607. */
  84608. VertexBuffer.SHORT = 5122;
  84609. /**
  84610. * The unsigned short type.
  84611. */
  84612. VertexBuffer.UNSIGNED_SHORT = 5123;
  84613. /**
  84614. * The integer type.
  84615. */
  84616. VertexBuffer.INT = 5124;
  84617. /**
  84618. * The unsigned integer type.
  84619. */
  84620. VertexBuffer.UNSIGNED_INT = 5125;
  84621. /**
  84622. * The float type.
  84623. */
  84624. VertexBuffer.FLOAT = 5126;
  84625. // Enums
  84626. /**
  84627. * Positions
  84628. */
  84629. VertexBuffer.PositionKind = "position";
  84630. /**
  84631. * Normals
  84632. */
  84633. VertexBuffer.NormalKind = "normal";
  84634. /**
  84635. * Tangents
  84636. */
  84637. VertexBuffer.TangentKind = "tangent";
  84638. /**
  84639. * Texture coordinates
  84640. */
  84641. VertexBuffer.UVKind = "uv";
  84642. /**
  84643. * Texture coordinates 2
  84644. */
  84645. VertexBuffer.UV2Kind = "uv2";
  84646. /**
  84647. * Texture coordinates 3
  84648. */
  84649. VertexBuffer.UV3Kind = "uv3";
  84650. /**
  84651. * Texture coordinates 4
  84652. */
  84653. VertexBuffer.UV4Kind = "uv4";
  84654. /**
  84655. * Texture coordinates 5
  84656. */
  84657. VertexBuffer.UV5Kind = "uv5";
  84658. /**
  84659. * Texture coordinates 6
  84660. */
  84661. VertexBuffer.UV6Kind = "uv6";
  84662. /**
  84663. * Colors
  84664. */
  84665. VertexBuffer.ColorKind = "color";
  84666. /**
  84667. * Matrix indices (for bones)
  84668. */
  84669. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  84670. /**
  84671. * Matrix weights (for bones)
  84672. */
  84673. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  84674. /**
  84675. * Additional matrix indices (for bones)
  84676. */
  84677. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  84678. /**
  84679. * Additional matrix weights (for bones)
  84680. */
  84681. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  84682. return VertexBuffer;
  84683. }());
  84684. /***/ }),
  84685. /***/ "./Meshes/csg.ts":
  84686. /*!***********************!*\
  84687. !*** ./Meshes/csg.ts ***!
  84688. \***********************/
  84689. /*! exports provided: CSG */
  84690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84691. "use strict";
  84692. __webpack_require__.r(__webpack_exports__);
  84693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  84694. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  84695. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  84696. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  84697. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  84698. /**
  84699. * Unique ID when we import meshes from Babylon to CSG
  84700. */
  84701. var currentCSGMeshId = 0;
  84702. /**
  84703. * Represents a vertex of a polygon. Use your own vertex class instead of this
  84704. * one to provide additional features like texture coordinates and vertex
  84705. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  84706. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  84707. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  84708. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  84709. * is not used anywhere else.
  84710. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  84711. */
  84712. var Vertex = /** @class */ (function () {
  84713. /**
  84714. * Initializes the vertex
  84715. * @param pos The position of the vertex
  84716. * @param normal The normal of the vertex
  84717. * @param uv The texture coordinate of the vertex
  84718. */
  84719. function Vertex(
  84720. /**
  84721. * The position of the vertex
  84722. */
  84723. pos,
  84724. /**
  84725. * The normal of the vertex
  84726. */
  84727. normal,
  84728. /**
  84729. * The texture coordinate of the vertex
  84730. */
  84731. uv) {
  84732. this.pos = pos;
  84733. this.normal = normal;
  84734. this.uv = uv;
  84735. }
  84736. /**
  84737. * Make a clone, or deep copy, of the vertex
  84738. * @returns A new Vertex
  84739. */
  84740. Vertex.prototype.clone = function () {
  84741. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  84742. };
  84743. /**
  84744. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  84745. * orientation of a polygon is flipped.
  84746. */
  84747. Vertex.prototype.flip = function () {
  84748. this.normal = this.normal.scale(-1);
  84749. };
  84750. /**
  84751. * Create a new vertex between this vertex and `other` by linearly
  84752. * interpolating all properties using a parameter of `t`. Subclasses should
  84753. * override this to interpolate additional properties.
  84754. * @param other the vertex to interpolate against
  84755. * @param t The factor used to linearly interpolate between the vertices
  84756. */
  84757. Vertex.prototype.interpolate = function (other, t) {
  84758. 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));
  84759. };
  84760. return Vertex;
  84761. }());
  84762. /**
  84763. * Represents a plane in 3D space.
  84764. */
  84765. var Plane = /** @class */ (function () {
  84766. /**
  84767. * Initializes the plane
  84768. * @param normal The normal for the plane
  84769. * @param w
  84770. */
  84771. function Plane(normal, w) {
  84772. this.normal = normal;
  84773. this.w = w;
  84774. }
  84775. /**
  84776. * Construct a plane from three points
  84777. * @param a Point a
  84778. * @param b Point b
  84779. * @param c Point c
  84780. */
  84781. Plane.FromPoints = function (a, b, c) {
  84782. var v0 = c.subtract(a);
  84783. var v1 = b.subtract(a);
  84784. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  84785. return null;
  84786. }
  84787. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  84788. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  84789. };
  84790. /**
  84791. * Clone, or make a deep copy of the plane
  84792. * @returns a new Plane
  84793. */
  84794. Plane.prototype.clone = function () {
  84795. return new Plane(this.normal.clone(), this.w);
  84796. };
  84797. /**
  84798. * Flip the face of the plane
  84799. */
  84800. Plane.prototype.flip = function () {
  84801. this.normal.scaleInPlace(-1);
  84802. this.w = -this.w;
  84803. };
  84804. /**
  84805. * Split `polygon` by this plane if needed, then put the polygon or polygon
  84806. * fragments in the appropriate lists. Coplanar polygons go into either
  84807. `* coplanarFront` or `coplanarBack` depending on their orientation with
  84808. * respect to this plane. Polygons in front or in back of this plane go into
  84809. * either `front` or `back`
  84810. * @param polygon The polygon to be split
  84811. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  84812. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  84813. * @param front Will contain the polygons in front of the plane
  84814. * @param back Will contain the polygons begind the plane
  84815. */
  84816. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  84817. var COPLANAR = 0;
  84818. var FRONT = 1;
  84819. var BACK = 2;
  84820. var SPANNING = 3;
  84821. // Classify each point as well as the entire polygon into one of the above
  84822. // four classes.
  84823. var polygonType = 0;
  84824. var types = [];
  84825. var i;
  84826. var t;
  84827. for (i = 0; i < polygon.vertices.length; i++) {
  84828. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  84829. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  84830. polygonType |= type;
  84831. types.push(type);
  84832. }
  84833. // Put the polygon in the correct list, splitting it when necessary
  84834. switch (polygonType) {
  84835. case COPLANAR:
  84836. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  84837. break;
  84838. case FRONT:
  84839. front.push(polygon);
  84840. break;
  84841. case BACK:
  84842. back.push(polygon);
  84843. break;
  84844. case SPANNING:
  84845. var f = [], b = [];
  84846. for (i = 0; i < polygon.vertices.length; i++) {
  84847. var j = (i + 1) % polygon.vertices.length;
  84848. var ti = types[i], tj = types[j];
  84849. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  84850. if (ti !== BACK) {
  84851. f.push(vi);
  84852. }
  84853. if (ti !== FRONT) {
  84854. b.push(ti !== BACK ? vi.clone() : vi);
  84855. }
  84856. if ((ti | tj) === SPANNING) {
  84857. 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));
  84858. var v = vi.interpolate(vj, t);
  84859. f.push(v);
  84860. b.push(v.clone());
  84861. }
  84862. }
  84863. var poly;
  84864. if (f.length >= 3) {
  84865. poly = new Polygon(f, polygon.shared);
  84866. if (poly.plane) {
  84867. front.push(poly);
  84868. }
  84869. }
  84870. if (b.length >= 3) {
  84871. poly = new Polygon(b, polygon.shared);
  84872. if (poly.plane) {
  84873. back.push(poly);
  84874. }
  84875. }
  84876. break;
  84877. }
  84878. };
  84879. /**
  84880. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  84881. * point is on the plane
  84882. */
  84883. Plane.EPSILON = 1e-5;
  84884. return Plane;
  84885. }());
  84886. /**
  84887. * Represents a convex polygon. The vertices used to initialize a polygon must
  84888. * be coplanar and form a convex loop.
  84889. *
  84890. * Each convex polygon has a `shared` property, which is shared between all
  84891. * polygons that are clones of each other or were split from the same polygon.
  84892. * This can be used to define per-polygon properties (such as surface color)
  84893. */
  84894. var Polygon = /** @class */ (function () {
  84895. /**
  84896. * Initializes the polygon
  84897. * @param vertices The vertices of the polygon
  84898. * @param shared The properties shared across all polygons
  84899. */
  84900. function Polygon(vertices, shared) {
  84901. this.vertices = vertices;
  84902. this.shared = shared;
  84903. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  84904. }
  84905. /**
  84906. * Clones, or makes a deep copy, or the polygon
  84907. */
  84908. Polygon.prototype.clone = function () {
  84909. var vertices = this.vertices.map(function (v) { return v.clone(); });
  84910. return new Polygon(vertices, this.shared);
  84911. };
  84912. /**
  84913. * Flips the faces of the polygon
  84914. */
  84915. Polygon.prototype.flip = function () {
  84916. this.vertices.reverse().map(function (v) { v.flip(); });
  84917. this.plane.flip();
  84918. };
  84919. return Polygon;
  84920. }());
  84921. /**
  84922. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  84923. * by picking a polygon to split along. That polygon (and all other coplanar
  84924. * polygons) are added directly to that node and the other polygons are added to
  84925. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  84926. * no distinction between internal and leaf nodes
  84927. */
  84928. var Node = /** @class */ (function () {
  84929. /**
  84930. * Initializes the node
  84931. * @param polygons A collection of polygons held in the node
  84932. */
  84933. function Node(polygons) {
  84934. this.plane = null;
  84935. this.front = null;
  84936. this.back = null;
  84937. this.polygons = new Array();
  84938. if (polygons) {
  84939. this.build(polygons);
  84940. }
  84941. }
  84942. /**
  84943. * Clones, or makes a deep copy, of the node
  84944. * @returns The cloned node
  84945. */
  84946. Node.prototype.clone = function () {
  84947. var node = new Node();
  84948. node.plane = this.plane && this.plane.clone();
  84949. node.front = this.front && this.front.clone();
  84950. node.back = this.back && this.back.clone();
  84951. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  84952. return node;
  84953. };
  84954. /**
  84955. * Convert solid space to empty space and empty space to solid space
  84956. */
  84957. Node.prototype.invert = function () {
  84958. for (var i = 0; i < this.polygons.length; i++) {
  84959. this.polygons[i].flip();
  84960. }
  84961. if (this.plane) {
  84962. this.plane.flip();
  84963. }
  84964. if (this.front) {
  84965. this.front.invert();
  84966. }
  84967. if (this.back) {
  84968. this.back.invert();
  84969. }
  84970. var temp = this.front;
  84971. this.front = this.back;
  84972. this.back = temp;
  84973. };
  84974. /**
  84975. * Recursively remove all polygons in `polygons` that are inside this BSP
  84976. * tree.
  84977. * @param polygons Polygons to remove from the BSP
  84978. * @returns Polygons clipped from the BSP
  84979. */
  84980. Node.prototype.clipPolygons = function (polygons) {
  84981. if (!this.plane) {
  84982. return polygons.slice();
  84983. }
  84984. var front = new Array(), back = new Array();
  84985. for (var i = 0; i < polygons.length; i++) {
  84986. this.plane.splitPolygon(polygons[i], front, back, front, back);
  84987. }
  84988. if (this.front) {
  84989. front = this.front.clipPolygons(front);
  84990. }
  84991. if (this.back) {
  84992. back = this.back.clipPolygons(back);
  84993. }
  84994. else {
  84995. back = [];
  84996. }
  84997. return front.concat(back);
  84998. };
  84999. /**
  85000. * Remove all polygons in this BSP tree that are inside the other BSP tree
  85001. * `bsp`.
  85002. * @param bsp BSP containing polygons to remove from this BSP
  85003. */
  85004. Node.prototype.clipTo = function (bsp) {
  85005. this.polygons = bsp.clipPolygons(this.polygons);
  85006. if (this.front) {
  85007. this.front.clipTo(bsp);
  85008. }
  85009. if (this.back) {
  85010. this.back.clipTo(bsp);
  85011. }
  85012. };
  85013. /**
  85014. * Return a list of all polygons in this BSP tree
  85015. * @returns List of all polygons in this BSP tree
  85016. */
  85017. Node.prototype.allPolygons = function () {
  85018. var polygons = this.polygons.slice();
  85019. if (this.front) {
  85020. polygons = polygons.concat(this.front.allPolygons());
  85021. }
  85022. if (this.back) {
  85023. polygons = polygons.concat(this.back.allPolygons());
  85024. }
  85025. return polygons;
  85026. };
  85027. /**
  85028. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  85029. * new polygons are filtered down to the bottom of the tree and become new
  85030. * nodes there. Each set of polygons is partitioned using the first polygon
  85031. * (no heuristic is used to pick a good split)
  85032. * @param polygons Polygons used to construct the BSP tree
  85033. */
  85034. Node.prototype.build = function (polygons) {
  85035. if (!polygons.length) {
  85036. return;
  85037. }
  85038. if (!this.plane) {
  85039. this.plane = polygons[0].plane.clone();
  85040. }
  85041. var front = new Array(), back = new Array();
  85042. for (var i = 0; i < polygons.length; i++) {
  85043. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  85044. }
  85045. if (front.length) {
  85046. if (!this.front) {
  85047. this.front = new Node();
  85048. }
  85049. this.front.build(front);
  85050. }
  85051. if (back.length) {
  85052. if (!this.back) {
  85053. this.back = new Node();
  85054. }
  85055. this.back.build(back);
  85056. }
  85057. };
  85058. return Node;
  85059. }());
  85060. /**
  85061. * Class for building Constructive Solid Geometry
  85062. */
  85063. var CSG = /** @class */ (function () {
  85064. function CSG() {
  85065. this.polygons = new Array();
  85066. }
  85067. /**
  85068. * Convert the Mesh to CSG
  85069. * @param mesh The Mesh to convert to CSG
  85070. * @returns A new CSG from the Mesh
  85071. */
  85072. CSG.FromMesh = function (mesh) {
  85073. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  85074. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  85075. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  85076. mesh.computeWorldMatrix(true);
  85077. matrix = mesh.getWorldMatrix();
  85078. meshPosition = mesh.position.clone();
  85079. meshRotation = mesh.rotation.clone();
  85080. if (mesh.rotationQuaternion) {
  85081. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  85082. }
  85083. meshScaling = mesh.scaling.clone();
  85084. }
  85085. else {
  85086. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  85087. }
  85088. 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);
  85089. var subMeshes = mesh.subMeshes;
  85090. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  85091. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  85092. vertices = [];
  85093. for (var j = 0; j < 3; j++) {
  85094. 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]);
  85095. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  85096. 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]);
  85097. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  85098. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  85099. vertex = new Vertex(position, normal, uv);
  85100. vertices.push(vertex);
  85101. }
  85102. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  85103. // To handle the case of degenerated triangle
  85104. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  85105. if (polygon.plane) {
  85106. polygons.push(polygon);
  85107. }
  85108. }
  85109. }
  85110. var csg = CSG.FromPolygons(polygons);
  85111. csg.matrix = matrix;
  85112. csg.position = meshPosition;
  85113. csg.rotation = meshRotation;
  85114. csg.scaling = meshScaling;
  85115. csg.rotationQuaternion = meshRotationQuaternion;
  85116. currentCSGMeshId++;
  85117. return csg;
  85118. };
  85119. /**
  85120. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  85121. * @param polygons Polygons used to construct a CSG solid
  85122. */
  85123. CSG.FromPolygons = function (polygons) {
  85124. var csg = new CSG();
  85125. csg.polygons = polygons;
  85126. return csg;
  85127. };
  85128. /**
  85129. * Clones, or makes a deep copy, of the CSG
  85130. * @returns A new CSG
  85131. */
  85132. CSG.prototype.clone = function () {
  85133. var csg = new CSG();
  85134. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  85135. csg.copyTransformAttributes(this);
  85136. return csg;
  85137. };
  85138. /**
  85139. * Unions this CSG with another CSG
  85140. * @param csg The CSG to union against this CSG
  85141. * @returns The unioned CSG
  85142. */
  85143. CSG.prototype.union = function (csg) {
  85144. var a = new Node(this.clone().polygons);
  85145. var b = new Node(csg.clone().polygons);
  85146. a.clipTo(b);
  85147. b.clipTo(a);
  85148. b.invert();
  85149. b.clipTo(a);
  85150. b.invert();
  85151. a.build(b.allPolygons());
  85152. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  85153. };
  85154. /**
  85155. * Unions this CSG with another CSG in place
  85156. * @param csg The CSG to union against this CSG
  85157. */
  85158. CSG.prototype.unionInPlace = function (csg) {
  85159. var a = new Node(this.polygons);
  85160. var b = new Node(csg.polygons);
  85161. a.clipTo(b);
  85162. b.clipTo(a);
  85163. b.invert();
  85164. b.clipTo(a);
  85165. b.invert();
  85166. a.build(b.allPolygons());
  85167. this.polygons = a.allPolygons();
  85168. };
  85169. /**
  85170. * Subtracts this CSG with another CSG
  85171. * @param csg The CSG to subtract against this CSG
  85172. * @returns A new CSG
  85173. */
  85174. CSG.prototype.subtract = function (csg) {
  85175. var a = new Node(this.clone().polygons);
  85176. var b = new Node(csg.clone().polygons);
  85177. a.invert();
  85178. a.clipTo(b);
  85179. b.clipTo(a);
  85180. b.invert();
  85181. b.clipTo(a);
  85182. b.invert();
  85183. a.build(b.allPolygons());
  85184. a.invert();
  85185. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  85186. };
  85187. /**
  85188. * Subtracts this CSG with another CSG in place
  85189. * @param csg The CSG to subtact against this CSG
  85190. */
  85191. CSG.prototype.subtractInPlace = function (csg) {
  85192. var a = new Node(this.polygons);
  85193. var b = new Node(csg.polygons);
  85194. a.invert();
  85195. a.clipTo(b);
  85196. b.clipTo(a);
  85197. b.invert();
  85198. b.clipTo(a);
  85199. b.invert();
  85200. a.build(b.allPolygons());
  85201. a.invert();
  85202. this.polygons = a.allPolygons();
  85203. };
  85204. /**
  85205. * Intersect this CSG with another CSG
  85206. * @param csg The CSG to intersect against this CSG
  85207. * @returns A new CSG
  85208. */
  85209. CSG.prototype.intersect = function (csg) {
  85210. var a = new Node(this.clone().polygons);
  85211. var b = new Node(csg.clone().polygons);
  85212. a.invert();
  85213. b.clipTo(a);
  85214. b.invert();
  85215. a.clipTo(b);
  85216. b.clipTo(a);
  85217. a.build(b.allPolygons());
  85218. a.invert();
  85219. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  85220. };
  85221. /**
  85222. * Intersects this CSG with another CSG in place
  85223. * @param csg The CSG to intersect against this CSG
  85224. */
  85225. CSG.prototype.intersectInPlace = function (csg) {
  85226. var a = new Node(this.polygons);
  85227. var b = new Node(csg.polygons);
  85228. a.invert();
  85229. b.clipTo(a);
  85230. b.invert();
  85231. a.clipTo(b);
  85232. b.clipTo(a);
  85233. a.build(b.allPolygons());
  85234. a.invert();
  85235. this.polygons = a.allPolygons();
  85236. };
  85237. /**
  85238. * Return a new CSG solid with solid and empty space switched. This solid is
  85239. * not modified.
  85240. * @returns A new CSG solid with solid and empty space switched
  85241. */
  85242. CSG.prototype.inverse = function () {
  85243. var csg = this.clone();
  85244. csg.inverseInPlace();
  85245. return csg;
  85246. };
  85247. /**
  85248. * Inverses the CSG in place
  85249. */
  85250. CSG.prototype.inverseInPlace = function () {
  85251. this.polygons.map(function (p) { p.flip(); });
  85252. };
  85253. /**
  85254. * This is used to keep meshes transformations so they can be restored
  85255. * when we build back a Babylon Mesh
  85256. * NB : All CSG operations are performed in world coordinates
  85257. * @param csg The CSG to copy the transform attributes from
  85258. * @returns This CSG
  85259. */
  85260. CSG.prototype.copyTransformAttributes = function (csg) {
  85261. this.matrix = csg.matrix;
  85262. this.position = csg.position;
  85263. this.rotation = csg.rotation;
  85264. this.scaling = csg.scaling;
  85265. this.rotationQuaternion = csg.rotationQuaternion;
  85266. return this;
  85267. };
  85268. /**
  85269. * Build Raw mesh from CSG
  85270. * Coordinates here are in world space
  85271. * @param name The name of the mesh geometry
  85272. * @param scene The Scene
  85273. * @param keepSubMeshes Specifies if the submeshes should be kept
  85274. * @returns A new Mesh
  85275. */
  85276. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  85277. var matrix = this.matrix.clone();
  85278. matrix.invert();
  85279. 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;
  85280. if (keepSubMeshes) {
  85281. // Sort Polygons, since subMeshes are indices range
  85282. polygons.sort(function (a, b) {
  85283. if (a.shared.meshId === b.shared.meshId) {
  85284. return a.shared.subMeshId - b.shared.subMeshId;
  85285. }
  85286. else {
  85287. return a.shared.meshId - b.shared.meshId;
  85288. }
  85289. });
  85290. }
  85291. for (var i = 0, il = polygons.length; i < il; i++) {
  85292. polygon = polygons[i];
  85293. // Building SubMeshes
  85294. if (!subMesh_dict[polygon.shared.meshId]) {
  85295. subMesh_dict[polygon.shared.meshId] = {};
  85296. }
  85297. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  85298. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  85299. indexStart: +Infinity,
  85300. indexEnd: -Infinity,
  85301. materialIndex: polygon.shared.materialIndex
  85302. };
  85303. }
  85304. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  85305. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  85306. polygonIndices[0] = 0;
  85307. polygonIndices[1] = j - 1;
  85308. polygonIndices[2] = j;
  85309. for (var k = 0; k < 3; k++) {
  85310. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  85311. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  85312. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  85313. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  85314. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  85315. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  85316. // Check if 2 points can be merged
  85317. if (!(typeof vertex_idx !== 'undefined' &&
  85318. normals[vertex_idx * 3] === localNormal.x &&
  85319. normals[vertex_idx * 3 + 1] === localNormal.y &&
  85320. normals[vertex_idx * 3 + 2] === localNormal.z &&
  85321. uvs[vertex_idx * 2] === uv.x &&
  85322. uvs[vertex_idx * 2 + 1] === uv.y)) {
  85323. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  85324. uvs.push(uv.x, uv.y);
  85325. normals.push(normal.x, normal.y, normal.z);
  85326. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  85327. }
  85328. indices.push(vertex_idx);
  85329. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  85330. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  85331. currentIndex++;
  85332. }
  85333. }
  85334. }
  85335. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  85336. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  85337. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  85338. mesh.setIndices(indices, null);
  85339. if (keepSubMeshes) {
  85340. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  85341. var materialIndexOffset = 0, materialMaxIndex;
  85342. mesh.subMeshes = new Array();
  85343. for (var m in subMesh_dict) {
  85344. materialMaxIndex = -1;
  85345. for (var sm in subMesh_dict[m]) {
  85346. subMesh_obj = subMesh_dict[m][sm];
  85347. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  85348. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  85349. }
  85350. materialIndexOffset += ++materialMaxIndex;
  85351. }
  85352. }
  85353. return mesh;
  85354. };
  85355. /**
  85356. * Build Mesh from CSG taking material and transforms into account
  85357. * @param name The name of the Mesh
  85358. * @param material The material of the Mesh
  85359. * @param scene The Scene
  85360. * @param keepSubMeshes Specifies if submeshes should be kept
  85361. * @returns The new Mesh
  85362. */
  85363. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  85364. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  85365. mesh.material = material;
  85366. mesh.position.copyFrom(this.position);
  85367. mesh.rotation.copyFrom(this.rotation);
  85368. if (this.rotationQuaternion) {
  85369. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  85370. }
  85371. mesh.scaling.copyFrom(this.scaling);
  85372. mesh.computeWorldMatrix(true);
  85373. return mesh;
  85374. };
  85375. return CSG;
  85376. }());
  85377. /***/ }),
  85378. /***/ "./Meshes/geometry.ts":
  85379. /*!****************************!*\
  85380. !*** ./Meshes/geometry.ts ***!
  85381. \****************************/
  85382. /*! exports provided: Geometry */
  85383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85384. "use strict";
  85385. __webpack_require__.r(__webpack_exports__);
  85386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  85387. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85388. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85389. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  85390. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  85391. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  85392. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  85393. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  85394. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  85395. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  85396. /**
  85397. * Class used to store geometry data (vertex buffers + index buffer)
  85398. */
  85399. var Geometry = /** @class */ (function () {
  85400. /**
  85401. * Creates a new geometry
  85402. * @param id defines the unique ID
  85403. * @param scene defines the hosting scene
  85404. * @param vertexData defines the VertexData used to get geometry data
  85405. * @param updatable defines if geometry must be updatable (false by default)
  85406. * @param mesh defines the mesh that will be associated with the geometry
  85407. */
  85408. function Geometry(id, scene, vertexData, updatable, mesh) {
  85409. if (updatable === void 0) { updatable = false; }
  85410. if (mesh === void 0) { mesh = null; }
  85411. /**
  85412. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85413. */
  85414. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  85415. this._totalVertices = 0;
  85416. this._isDisposed = false;
  85417. this._indexBufferIsUpdatable = false;
  85418. this.id = id;
  85419. this.uniqueId = scene.getUniqueId();
  85420. this._engine = scene.getEngine();
  85421. this._meshes = [];
  85422. this._scene = scene;
  85423. //Init vertex buffer cache
  85424. this._vertexBuffers = {};
  85425. this._indices = [];
  85426. this._updatable = updatable;
  85427. // vertexData
  85428. if (vertexData) {
  85429. this.setAllVerticesData(vertexData, updatable);
  85430. }
  85431. else {
  85432. this._totalVertices = 0;
  85433. this._indices = [];
  85434. }
  85435. if (this._engine.getCaps().vertexArrayObject) {
  85436. this._vertexArrayObjects = {};
  85437. }
  85438. // applyToMesh
  85439. if (mesh) {
  85440. this.applyToMesh(mesh);
  85441. mesh.computeWorldMatrix(true);
  85442. }
  85443. }
  85444. Object.defineProperty(Geometry.prototype, "boundingBias", {
  85445. /**
  85446. * 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
  85447. */
  85448. get: function () {
  85449. return this._boundingBias;
  85450. },
  85451. /**
  85452. * 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
  85453. */
  85454. set: function (value) {
  85455. if (this._boundingBias) {
  85456. this._boundingBias.copyFrom(value);
  85457. }
  85458. else {
  85459. this._boundingBias = value.clone();
  85460. }
  85461. this._updateBoundingInfo(true, null);
  85462. },
  85463. enumerable: true,
  85464. configurable: true
  85465. });
  85466. /**
  85467. * Static function used to attach a new empty geometry to a mesh
  85468. * @param mesh defines the mesh to attach the geometry to
  85469. * @returns the new Geometry
  85470. */
  85471. Geometry.CreateGeometryForMesh = function (mesh) {
  85472. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  85473. geometry.applyToMesh(mesh);
  85474. return geometry;
  85475. };
  85476. Object.defineProperty(Geometry.prototype, "extend", {
  85477. /**
  85478. * Gets the current extend of the geometry
  85479. */
  85480. get: function () {
  85481. return this._extend;
  85482. },
  85483. enumerable: true,
  85484. configurable: true
  85485. });
  85486. /**
  85487. * Gets the hosting scene
  85488. * @returns the hosting Scene
  85489. */
  85490. Geometry.prototype.getScene = function () {
  85491. return this._scene;
  85492. };
  85493. /**
  85494. * Gets the hosting engine
  85495. * @returns the hosting Engine
  85496. */
  85497. Geometry.prototype.getEngine = function () {
  85498. return this._engine;
  85499. };
  85500. /**
  85501. * Defines if the geometry is ready to use
  85502. * @returns true if the geometry is ready to be used
  85503. */
  85504. Geometry.prototype.isReady = function () {
  85505. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  85506. };
  85507. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  85508. /**
  85509. * Gets a value indicating that the geometry should not be serialized
  85510. */
  85511. get: function () {
  85512. for (var index = 0; index < this._meshes.length; index++) {
  85513. if (!this._meshes[index].doNotSerialize) {
  85514. return false;
  85515. }
  85516. }
  85517. return true;
  85518. },
  85519. enumerable: true,
  85520. configurable: true
  85521. });
  85522. /** @hidden */
  85523. Geometry.prototype._rebuild = function () {
  85524. if (this._vertexArrayObjects) {
  85525. this._vertexArrayObjects = {};
  85526. }
  85527. // Index buffer
  85528. if (this._meshes.length !== 0 && this._indices) {
  85529. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  85530. }
  85531. // Vertex buffers
  85532. for (var key in this._vertexBuffers) {
  85533. var vertexBuffer = this._vertexBuffers[key];
  85534. vertexBuffer._rebuild();
  85535. }
  85536. };
  85537. /**
  85538. * Affects all geometry data in one call
  85539. * @param vertexData defines the geometry data
  85540. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85541. */
  85542. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  85543. vertexData.applyToGeometry(this, updatable);
  85544. this.notifyUpdate();
  85545. };
  85546. /**
  85547. * Set specific vertex data
  85548. * @param kind defines the data kind (Position, normal, etc...)
  85549. * @param data defines the vertex data to use
  85550. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85551. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85552. */
  85553. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  85554. if (updatable === void 0) { updatable = false; }
  85555. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  85556. this.setVerticesBuffer(buffer);
  85557. };
  85558. /**
  85559. * Removes a specific vertex data
  85560. * @param kind defines the data kind (Position, normal, etc...)
  85561. */
  85562. Geometry.prototype.removeVerticesData = function (kind) {
  85563. if (this._vertexBuffers[kind]) {
  85564. this._vertexBuffers[kind].dispose();
  85565. delete this._vertexBuffers[kind];
  85566. }
  85567. };
  85568. /**
  85569. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85570. * @param buffer defines the vertex buffer to use
  85571. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85572. */
  85573. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  85574. if (totalVertices === void 0) { totalVertices = null; }
  85575. var kind = buffer.getKind();
  85576. if (this._vertexBuffers[kind]) {
  85577. this._vertexBuffers[kind].dispose();
  85578. }
  85579. this._vertexBuffers[kind] = buffer;
  85580. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  85581. var data = buffer.getData();
  85582. if (totalVertices != null) {
  85583. this._totalVertices = totalVertices;
  85584. }
  85585. else {
  85586. if (data != null) {
  85587. this._totalVertices = data.length / (buffer.byteStride / 4);
  85588. }
  85589. }
  85590. this._updateExtend(data);
  85591. this._resetPointsArrayCache();
  85592. var meshes = this._meshes;
  85593. var numOfMeshes = meshes.length;
  85594. for (var index = 0; index < numOfMeshes; index++) {
  85595. var mesh = meshes[index];
  85596. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85597. mesh._createGlobalSubMesh(false);
  85598. mesh.computeWorldMatrix(true);
  85599. }
  85600. }
  85601. this.notifyUpdate(kind);
  85602. if (this._vertexArrayObjects) {
  85603. this._disposeVertexArrayObjects();
  85604. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  85605. }
  85606. };
  85607. /**
  85608. * Update a specific vertex buffer
  85609. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  85610. * It will do nothing if the buffer is not updatable
  85611. * @param kind defines the data kind (Position, normal, etc...)
  85612. * @param data defines the data to use
  85613. * @param offset defines the offset in the target buffer where to store the data
  85614. * @param useBytes set to true if the offset is in bytes
  85615. */
  85616. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  85617. if (useBytes === void 0) { useBytes = false; }
  85618. var vertexBuffer = this.getVertexBuffer(kind);
  85619. if (!vertexBuffer) {
  85620. return;
  85621. }
  85622. vertexBuffer.updateDirectly(data, offset, useBytes);
  85623. this.notifyUpdate(kind);
  85624. };
  85625. /**
  85626. * Update a specific vertex buffer
  85627. * This function will create a new buffer if the current one is not updatable
  85628. * @param kind defines the data kind (Position, normal, etc...)
  85629. * @param data defines the data to use
  85630. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85631. */
  85632. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  85633. if (updateExtends === void 0) { updateExtends = false; }
  85634. var vertexBuffer = this.getVertexBuffer(kind);
  85635. if (!vertexBuffer) {
  85636. return;
  85637. }
  85638. vertexBuffer.update(data);
  85639. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  85640. this._updateBoundingInfo(updateExtends, data);
  85641. }
  85642. this.notifyUpdate(kind);
  85643. };
  85644. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  85645. if (updateExtends) {
  85646. this._updateExtend(data);
  85647. }
  85648. this._resetPointsArrayCache();
  85649. if (updateExtends) {
  85650. var meshes = this._meshes;
  85651. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  85652. var mesh = meshes_1[_i];
  85653. if (mesh._boundingInfo) {
  85654. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  85655. }
  85656. else {
  85657. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85658. }
  85659. var subMeshes = mesh.subMeshes;
  85660. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  85661. var subMesh = subMeshes_1[_a];
  85662. subMesh.refreshBoundingInfo();
  85663. }
  85664. }
  85665. }
  85666. };
  85667. /** @hidden */
  85668. Geometry.prototype._bind = function (effect, indexToBind) {
  85669. if (!effect) {
  85670. return;
  85671. }
  85672. if (indexToBind === undefined) {
  85673. indexToBind = this._indexBuffer;
  85674. }
  85675. var vbs = this.getVertexBuffers();
  85676. if (!vbs) {
  85677. return;
  85678. }
  85679. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  85680. this._engine.bindBuffers(vbs, indexToBind, effect);
  85681. return;
  85682. }
  85683. // Using VAO
  85684. if (!this._vertexArrayObjects[effect.key]) {
  85685. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  85686. }
  85687. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  85688. };
  85689. /**
  85690. * Gets total number of vertices
  85691. * @returns the total number of vertices
  85692. */
  85693. Geometry.prototype.getTotalVertices = function () {
  85694. if (!this.isReady()) {
  85695. return 0;
  85696. }
  85697. return this._totalVertices;
  85698. };
  85699. /**
  85700. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85701. * @param kind defines the data kind (Position, normal, etc...)
  85702. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85703. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85704. * @returns a float array containing vertex data
  85705. */
  85706. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  85707. var vertexBuffer = this.getVertexBuffer(kind);
  85708. if (!vertexBuffer) {
  85709. return null;
  85710. }
  85711. var data = vertexBuffer.getData();
  85712. if (!data) {
  85713. return null;
  85714. }
  85715. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  85716. var count = this._totalVertices * vertexBuffer.getSize();
  85717. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  85718. var copy_1 = [];
  85719. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  85720. return copy_1;
  85721. }
  85722. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  85723. if (data instanceof Array) {
  85724. var offset = vertexBuffer.byteOffset / 4;
  85725. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  85726. }
  85727. else if (data instanceof ArrayBuffer) {
  85728. return new Float32Array(data, vertexBuffer.byteOffset, count);
  85729. }
  85730. else {
  85731. var offset = data.byteOffset + vertexBuffer.byteOffset;
  85732. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  85733. var result = new Float32Array(count);
  85734. var source = new Float32Array(data.buffer, offset, count);
  85735. result.set(source);
  85736. return result;
  85737. }
  85738. return new Float32Array(data.buffer, offset, count);
  85739. }
  85740. }
  85741. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  85742. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  85743. }
  85744. return data;
  85745. };
  85746. /**
  85747. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85748. * @param kind defines the data kind (Position, normal, etc...)
  85749. * @returns true if the vertex buffer with the specified kind is updatable
  85750. */
  85751. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  85752. var vb = this._vertexBuffers[kind];
  85753. if (!vb) {
  85754. return false;
  85755. }
  85756. return vb.isUpdatable();
  85757. };
  85758. /**
  85759. * Gets a specific vertex buffer
  85760. * @param kind defines the data kind (Position, normal, etc...)
  85761. * @returns a VertexBuffer
  85762. */
  85763. Geometry.prototype.getVertexBuffer = function (kind) {
  85764. if (!this.isReady()) {
  85765. return null;
  85766. }
  85767. return this._vertexBuffers[kind];
  85768. };
  85769. /**
  85770. * Returns all vertex buffers
  85771. * @return an object holding all vertex buffers indexed by kind
  85772. */
  85773. Geometry.prototype.getVertexBuffers = function () {
  85774. if (!this.isReady()) {
  85775. return null;
  85776. }
  85777. return this._vertexBuffers;
  85778. };
  85779. /**
  85780. * Gets a boolean indicating if specific vertex buffer is present
  85781. * @param kind defines the data kind (Position, normal, etc...)
  85782. * @returns true if data is present
  85783. */
  85784. Geometry.prototype.isVerticesDataPresent = function (kind) {
  85785. if (!this._vertexBuffers) {
  85786. if (this._delayInfo) {
  85787. return this._delayInfo.indexOf(kind) !== -1;
  85788. }
  85789. return false;
  85790. }
  85791. return this._vertexBuffers[kind] !== undefined;
  85792. };
  85793. /**
  85794. * Gets a list of all attached data kinds (Position, normal, etc...)
  85795. * @returns a list of string containing all kinds
  85796. */
  85797. Geometry.prototype.getVerticesDataKinds = function () {
  85798. var result = [];
  85799. var kind;
  85800. if (!this._vertexBuffers && this._delayInfo) {
  85801. for (kind in this._delayInfo) {
  85802. result.push(kind);
  85803. }
  85804. }
  85805. else {
  85806. for (kind in this._vertexBuffers) {
  85807. result.push(kind);
  85808. }
  85809. }
  85810. return result;
  85811. };
  85812. /**
  85813. * Update index buffer
  85814. * @param indices defines the indices to store in the index buffer
  85815. * @param offset defines the offset in the target buffer where to store the data
  85816. * @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)
  85817. */
  85818. Geometry.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  85819. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  85820. if (!this._indexBuffer) {
  85821. return;
  85822. }
  85823. if (!this._indexBufferIsUpdatable) {
  85824. this.setIndices(indices, null, true);
  85825. }
  85826. else {
  85827. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  85828. if (!gpuMemoryOnly) {
  85829. this._indices = indices.slice();
  85830. }
  85831. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  85832. if (needToUpdateSubMeshes) {
  85833. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  85834. var mesh = _a[_i];
  85835. mesh._createGlobalSubMesh(true);
  85836. }
  85837. }
  85838. }
  85839. };
  85840. /**
  85841. * Creates a new index buffer
  85842. * @param indices defines the indices to store in the index buffer
  85843. * @param totalVertices defines the total number of vertices (could be null)
  85844. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85845. */
  85846. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  85847. if (totalVertices === void 0) { totalVertices = null; }
  85848. if (updatable === void 0) { updatable = false; }
  85849. if (this._indexBuffer) {
  85850. this._engine._releaseBuffer(this._indexBuffer);
  85851. }
  85852. this._disposeVertexArrayObjects();
  85853. this._indices = indices;
  85854. this._indexBufferIsUpdatable = updatable;
  85855. if (this._meshes.length !== 0 && this._indices) {
  85856. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  85857. }
  85858. if (totalVertices != undefined) { // including null and undefined
  85859. this._totalVertices = totalVertices;
  85860. }
  85861. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  85862. var mesh = _a[_i];
  85863. mesh._createGlobalSubMesh(true);
  85864. }
  85865. this.notifyUpdate();
  85866. };
  85867. /**
  85868. * Return the total number of indices
  85869. * @returns the total number of indices
  85870. */
  85871. Geometry.prototype.getTotalIndices = function () {
  85872. if (!this.isReady()) {
  85873. return 0;
  85874. }
  85875. return this._indices.length;
  85876. };
  85877. /**
  85878. * Gets the index buffer array
  85879. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85881. * @returns the index buffer array
  85882. */
  85883. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  85884. if (!this.isReady()) {
  85885. return null;
  85886. }
  85887. var orig = this._indices;
  85888. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  85889. return orig;
  85890. }
  85891. else {
  85892. var len = orig.length;
  85893. var copy = [];
  85894. for (var i = 0; i < len; i++) {
  85895. copy.push(orig[i]);
  85896. }
  85897. return copy;
  85898. }
  85899. };
  85900. /**
  85901. * Gets the index buffer
  85902. * @return the index buffer
  85903. */
  85904. Geometry.prototype.getIndexBuffer = function () {
  85905. if (!this.isReady()) {
  85906. return null;
  85907. }
  85908. return this._indexBuffer;
  85909. };
  85910. /** @hidden */
  85911. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  85912. if (effect === void 0) { effect = null; }
  85913. if (!effect || !this._vertexArrayObjects) {
  85914. return;
  85915. }
  85916. if (this._vertexArrayObjects[effect.key]) {
  85917. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  85918. delete this._vertexArrayObjects[effect.key];
  85919. }
  85920. };
  85921. /**
  85922. * Release the associated resources for a specific mesh
  85923. * @param mesh defines the source mesh
  85924. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85925. */
  85926. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  85927. var meshes = this._meshes;
  85928. var index = meshes.indexOf(mesh);
  85929. if (index === -1) {
  85930. return;
  85931. }
  85932. meshes.splice(index, 1);
  85933. mesh._geometry = null;
  85934. if (meshes.length === 0 && shouldDispose) {
  85935. this.dispose();
  85936. }
  85937. };
  85938. /**
  85939. * Apply current geometry to a given mesh
  85940. * @param mesh defines the mesh to apply geometry to
  85941. */
  85942. Geometry.prototype.applyToMesh = function (mesh) {
  85943. if (mesh._geometry === this) {
  85944. return;
  85945. }
  85946. var previousGeometry = mesh._geometry;
  85947. if (previousGeometry) {
  85948. previousGeometry.releaseForMesh(mesh);
  85949. }
  85950. var meshes = this._meshes;
  85951. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  85952. mesh._geometry = this;
  85953. this._scene.pushGeometry(this);
  85954. meshes.push(mesh);
  85955. if (this.isReady()) {
  85956. this._applyToMesh(mesh);
  85957. }
  85958. else {
  85959. mesh._boundingInfo = this._boundingInfo;
  85960. }
  85961. };
  85962. Geometry.prototype._updateExtend = function (data) {
  85963. if (data === void 0) { data = null; }
  85964. if (!data) {
  85965. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  85966. }
  85967. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  85968. };
  85969. Geometry.prototype._applyToMesh = function (mesh) {
  85970. var numOfMeshes = this._meshes.length;
  85971. // vertexBuffers
  85972. for (var kind in this._vertexBuffers) {
  85973. if (numOfMeshes === 1) {
  85974. this._vertexBuffers[kind].create();
  85975. }
  85976. var buffer = this._vertexBuffers[kind].getBuffer();
  85977. if (buffer) {
  85978. buffer.references = numOfMeshes;
  85979. }
  85980. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  85981. if (!this._extend) {
  85982. this._updateExtend();
  85983. }
  85984. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85985. mesh._createGlobalSubMesh(false);
  85986. //bounding info was just created again, world matrix should be applied again.
  85987. mesh._updateBoundingInfo();
  85988. }
  85989. }
  85990. // indexBuffer
  85991. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  85992. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  85993. }
  85994. if (this._indexBuffer) {
  85995. this._indexBuffer.references = numOfMeshes;
  85996. }
  85997. // morphTargets
  85998. mesh._syncGeometryWithMorphTargetManager();
  85999. // instances
  86000. mesh.synchronizeInstances();
  86001. };
  86002. Geometry.prototype.notifyUpdate = function (kind) {
  86003. if (this.onGeometryUpdated) {
  86004. this.onGeometryUpdated(this, kind);
  86005. }
  86006. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  86007. var mesh = _a[_i];
  86008. mesh._markSubMeshesAsAttributesDirty();
  86009. }
  86010. };
  86011. /**
  86012. * Load the geometry if it was flagged as delay loaded
  86013. * @param scene defines the hosting scene
  86014. * @param onLoaded defines a callback called when the geometry is loaded
  86015. */
  86016. Geometry.prototype.load = function (scene, onLoaded) {
  86017. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  86018. return;
  86019. }
  86020. if (this.isReady()) {
  86021. if (onLoaded) {
  86022. onLoaded();
  86023. }
  86024. return;
  86025. }
  86026. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  86027. this._queueLoad(scene, onLoaded);
  86028. };
  86029. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  86030. var _this = this;
  86031. if (!this.delayLoadingFile) {
  86032. return;
  86033. }
  86034. scene._addPendingData(this);
  86035. scene._loadFile(this.delayLoadingFile, function (data) {
  86036. if (!_this._delayLoadingFunction) {
  86037. return;
  86038. }
  86039. _this._delayLoadingFunction(JSON.parse(data), _this);
  86040. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  86041. _this._delayInfo = [];
  86042. scene._removePendingData(_this);
  86043. var meshes = _this._meshes;
  86044. var numOfMeshes = meshes.length;
  86045. for (var index = 0; index < numOfMeshes; index++) {
  86046. _this._applyToMesh(meshes[index]);
  86047. }
  86048. if (onLoaded) {
  86049. onLoaded();
  86050. }
  86051. }, undefined, true);
  86052. };
  86053. /**
  86054. * Invert the geometry to move from a right handed system to a left handed one.
  86055. */
  86056. Geometry.prototype.toLeftHanded = function () {
  86057. // Flip faces
  86058. var tIndices = this.getIndices(false);
  86059. if (tIndices != null && tIndices.length > 0) {
  86060. for (var i = 0; i < tIndices.length; i += 3) {
  86061. var tTemp = tIndices[i + 0];
  86062. tIndices[i + 0] = tIndices[i + 2];
  86063. tIndices[i + 2] = tTemp;
  86064. }
  86065. this.setIndices(tIndices);
  86066. }
  86067. // Negate position.z
  86068. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  86069. if (tPositions != null && tPositions.length > 0) {
  86070. for (var i = 0; i < tPositions.length; i += 3) {
  86071. tPositions[i + 2] = -tPositions[i + 2];
  86072. }
  86073. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  86074. }
  86075. // Negate normal.z
  86076. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  86077. if (tNormals != null && tNormals.length > 0) {
  86078. for (var i = 0; i < tNormals.length; i += 3) {
  86079. tNormals[i + 2] = -tNormals[i + 2];
  86080. }
  86081. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  86082. }
  86083. };
  86084. // Cache
  86085. /** @hidden */
  86086. Geometry.prototype._resetPointsArrayCache = function () {
  86087. this._positions = null;
  86088. };
  86089. /** @hidden */
  86090. Geometry.prototype._generatePointsArray = function () {
  86091. if (this._positions) {
  86092. return true;
  86093. }
  86094. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  86095. if (!data || data.length === 0) {
  86096. return false;
  86097. }
  86098. this._positions = [];
  86099. for (var index = 0; index < data.length; index += 3) {
  86100. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  86101. }
  86102. return true;
  86103. };
  86104. /**
  86105. * Gets a value indicating if the geometry is disposed
  86106. * @returns true if the geometry was disposed
  86107. */
  86108. Geometry.prototype.isDisposed = function () {
  86109. return this._isDisposed;
  86110. };
  86111. Geometry.prototype._disposeVertexArrayObjects = function () {
  86112. if (this._vertexArrayObjects) {
  86113. for (var kind in this._vertexArrayObjects) {
  86114. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  86115. }
  86116. this._vertexArrayObjects = {};
  86117. }
  86118. };
  86119. /**
  86120. * Free all associated resources
  86121. */
  86122. Geometry.prototype.dispose = function () {
  86123. var meshes = this._meshes;
  86124. var numOfMeshes = meshes.length;
  86125. var index;
  86126. for (index = 0; index < numOfMeshes; index++) {
  86127. this.releaseForMesh(meshes[index]);
  86128. }
  86129. this._meshes = [];
  86130. this._disposeVertexArrayObjects();
  86131. for (var kind in this._vertexBuffers) {
  86132. this._vertexBuffers[kind].dispose();
  86133. }
  86134. this._vertexBuffers = {};
  86135. this._totalVertices = 0;
  86136. if (this._indexBuffer) {
  86137. this._engine._releaseBuffer(this._indexBuffer);
  86138. }
  86139. this._indexBuffer = null;
  86140. this._indices = [];
  86141. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  86142. this.delayLoadingFile = null;
  86143. this._delayLoadingFunction = null;
  86144. this._delayInfo = [];
  86145. this._boundingInfo = null;
  86146. this._scene.removeGeometry(this);
  86147. this._isDisposed = true;
  86148. };
  86149. /**
  86150. * Clone the current geometry into a new geometry
  86151. * @param id defines the unique ID of the new geometry
  86152. * @returns a new geometry object
  86153. */
  86154. Geometry.prototype.copy = function (id) {
  86155. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  86156. vertexData.indices = [];
  86157. var indices = this.getIndices();
  86158. if (indices) {
  86159. for (var index = 0; index < indices.length; index++) {
  86160. vertexData.indices.push(indices[index]);
  86161. }
  86162. }
  86163. var updatable = false;
  86164. var stopChecking = false;
  86165. var kind;
  86166. for (kind in this._vertexBuffers) {
  86167. // using slice() to make a copy of the array and not just reference it
  86168. var data = this.getVerticesData(kind);
  86169. if (data) {
  86170. if (data instanceof Float32Array) {
  86171. vertexData.set(new Float32Array(data), kind);
  86172. }
  86173. else {
  86174. vertexData.set(data.slice(0), kind);
  86175. }
  86176. if (!stopChecking) {
  86177. var vb = this.getVertexBuffer(kind);
  86178. if (vb) {
  86179. updatable = vb.isUpdatable();
  86180. stopChecking = !updatable;
  86181. }
  86182. }
  86183. }
  86184. }
  86185. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  86186. geometry.delayLoadState = this.delayLoadState;
  86187. geometry.delayLoadingFile = this.delayLoadingFile;
  86188. geometry._delayLoadingFunction = this._delayLoadingFunction;
  86189. for (kind in this._delayInfo) {
  86190. geometry._delayInfo = geometry._delayInfo || [];
  86191. geometry._delayInfo.push(kind);
  86192. }
  86193. // Bounding info
  86194. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  86195. return geometry;
  86196. };
  86197. /**
  86198. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86199. * @return a JSON representation of the current geometry data (without the vertices data)
  86200. */
  86201. Geometry.prototype.serialize = function () {
  86202. var serializationObject = {};
  86203. serializationObject.id = this.id;
  86204. serializationObject.updatable = this._updatable;
  86205. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  86206. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  86207. }
  86208. return serializationObject;
  86209. };
  86210. Geometry.prototype.toNumberArray = function (origin) {
  86211. if (Array.isArray(origin)) {
  86212. return origin;
  86213. }
  86214. else {
  86215. return Array.prototype.slice.call(origin);
  86216. }
  86217. };
  86218. /**
  86219. * Serialize all vertices data into a JSON oject
  86220. * @returns a JSON representation of the current geometry data
  86221. */
  86222. Geometry.prototype.serializeVerticeData = function () {
  86223. var serializationObject = this.serialize();
  86224. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  86225. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  86226. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  86227. serializationObject.positions._updatable = true;
  86228. }
  86229. }
  86230. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  86231. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  86232. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  86233. serializationObject.normals._updatable = true;
  86234. }
  86235. }
  86236. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  86237. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  86238. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  86239. serializationObject.tangets._updatable = true;
  86240. }
  86241. }
  86242. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  86243. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  86244. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  86245. serializationObject.uvs._updatable = true;
  86246. }
  86247. }
  86248. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  86249. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  86250. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  86251. serializationObject.uv2s._updatable = true;
  86252. }
  86253. }
  86254. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  86255. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  86256. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  86257. serializationObject.uv3s._updatable = true;
  86258. }
  86259. }
  86260. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  86261. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  86262. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  86263. serializationObject.uv4s._updatable = true;
  86264. }
  86265. }
  86266. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  86267. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  86268. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  86269. serializationObject.uv5s._updatable = true;
  86270. }
  86271. }
  86272. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  86273. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  86274. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  86275. serializationObject.uv6s._updatable = true;
  86276. }
  86277. }
  86278. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  86279. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  86280. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  86281. serializationObject.colors._updatable = true;
  86282. }
  86283. }
  86284. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  86285. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  86286. serializationObject.matricesIndices._isExpanded = true;
  86287. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  86288. serializationObject.matricesIndices._updatable = true;
  86289. }
  86290. }
  86291. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  86292. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  86293. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  86294. serializationObject.matricesWeights._updatable = true;
  86295. }
  86296. }
  86297. serializationObject.indices = this.toNumberArray(this.getIndices());
  86298. return serializationObject;
  86299. };
  86300. // Statics
  86301. /**
  86302. * Extracts a clone of a mesh geometry
  86303. * @param mesh defines the source mesh
  86304. * @param id defines the unique ID of the new geometry object
  86305. * @returns the new geometry object
  86306. */
  86307. Geometry.ExtractFromMesh = function (mesh, id) {
  86308. var geometry = mesh._geometry;
  86309. if (!geometry) {
  86310. return null;
  86311. }
  86312. return geometry.copy(id);
  86313. };
  86314. /**
  86315. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86316. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86317. * Be aware Math.random() could cause collisions, but:
  86318. * "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"
  86319. * @returns a string containing a new GUID
  86320. */
  86321. Geometry.RandomId = function () {
  86322. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  86323. };
  86324. /** @hidden */
  86325. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  86326. var scene = mesh.getScene();
  86327. // Geometry
  86328. var geometryId = parsedGeometry.geometryId;
  86329. if (geometryId) {
  86330. var geometry = scene.getGeometryByID(geometryId);
  86331. if (geometry) {
  86332. geometry.applyToMesh(mesh);
  86333. }
  86334. }
  86335. else if (parsedGeometry instanceof ArrayBuffer) {
  86336. var binaryInfo = mesh._binaryInfo;
  86337. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  86338. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  86339. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  86340. }
  86341. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  86342. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  86343. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  86344. }
  86345. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  86346. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  86347. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  86348. }
  86349. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  86350. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  86351. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  86352. }
  86353. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  86354. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  86355. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  86356. }
  86357. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  86358. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  86359. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  86360. }
  86361. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  86362. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  86363. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  86364. }
  86365. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  86366. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  86367. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  86368. }
  86369. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  86370. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  86371. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  86372. }
  86373. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  86374. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  86375. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  86376. }
  86377. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  86378. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  86379. var floatIndices = [];
  86380. for (var i = 0; i < matricesIndicesData.length; i++) {
  86381. var index = matricesIndicesData[i];
  86382. floatIndices.push(index & 0x000000FF);
  86383. floatIndices.push((index & 0x0000FF00) >> 8);
  86384. floatIndices.push((index & 0x00FF0000) >> 16);
  86385. floatIndices.push(index >> 24);
  86386. }
  86387. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  86388. }
  86389. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  86390. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  86391. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  86392. }
  86393. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  86394. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  86395. mesh.setIndices(indicesData, null);
  86396. }
  86397. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  86398. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  86399. mesh.subMeshes = [];
  86400. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  86401. var materialIndex = subMeshesData[(i * 5) + 0];
  86402. var verticesStart = subMeshesData[(i * 5) + 1];
  86403. var verticesCount = subMeshesData[(i * 5) + 2];
  86404. var indexStart = subMeshesData[(i * 5) + 3];
  86405. var indexCount = subMeshesData[(i * 5) + 4];
  86406. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  86407. }
  86408. }
  86409. }
  86410. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  86411. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  86412. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  86413. if (parsedGeometry.tangents) {
  86414. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  86415. }
  86416. if (parsedGeometry.uvs) {
  86417. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  86418. }
  86419. if (parsedGeometry.uvs2) {
  86420. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  86421. }
  86422. if (parsedGeometry.uvs3) {
  86423. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  86424. }
  86425. if (parsedGeometry.uvs4) {
  86426. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  86427. }
  86428. if (parsedGeometry.uvs5) {
  86429. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  86430. }
  86431. if (parsedGeometry.uvs6) {
  86432. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  86433. }
  86434. if (parsedGeometry.colors) {
  86435. 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);
  86436. }
  86437. if (parsedGeometry.matricesIndices) {
  86438. if (!parsedGeometry.matricesIndices._isExpanded) {
  86439. var floatIndices = [];
  86440. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  86441. var matricesIndex = parsedGeometry.matricesIndices[i];
  86442. floatIndices.push(matricesIndex & 0x000000FF);
  86443. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  86444. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  86445. floatIndices.push(matricesIndex >> 24);
  86446. }
  86447. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  86448. }
  86449. else {
  86450. delete parsedGeometry.matricesIndices._isExpanded;
  86451. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  86452. }
  86453. }
  86454. if (parsedGeometry.matricesIndicesExtra) {
  86455. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  86456. var floatIndices = [];
  86457. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  86458. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  86459. floatIndices.push(matricesIndex & 0x000000FF);
  86460. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  86461. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  86462. floatIndices.push(matricesIndex >> 24);
  86463. }
  86464. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  86465. }
  86466. else {
  86467. delete parsedGeometry.matricesIndices._isExpanded;
  86468. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  86469. }
  86470. }
  86471. if (parsedGeometry.matricesWeights) {
  86472. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  86473. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  86474. }
  86475. if (parsedGeometry.matricesWeightsExtra) {
  86476. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  86477. }
  86478. mesh.setIndices(parsedGeometry.indices, null);
  86479. }
  86480. // SubMeshes
  86481. if (parsedGeometry.subMeshes) {
  86482. mesh.subMeshes = [];
  86483. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  86484. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  86485. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  86486. }
  86487. }
  86488. // Flat shading
  86489. if (mesh._shouldGenerateFlatShading) {
  86490. mesh.convertToFlatShadedMesh();
  86491. delete mesh._shouldGenerateFlatShading;
  86492. }
  86493. // Update
  86494. mesh.computeWorldMatrix(true);
  86495. scene.onMeshImportedObservable.notifyObservers(mesh);
  86496. };
  86497. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  86498. var epsilon = 1e-3;
  86499. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  86500. return;
  86501. }
  86502. var noInfluenceBoneIndex = 0.0;
  86503. if (parsedGeometry.skeletonId > -1) {
  86504. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  86505. if (!skeleton) {
  86506. return;
  86507. }
  86508. noInfluenceBoneIndex = skeleton.bones.length;
  86509. }
  86510. else {
  86511. return;
  86512. }
  86513. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  86514. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  86515. var matricesWeights = parsedGeometry.matricesWeights;
  86516. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  86517. var influencers = parsedGeometry.numBoneInfluencer;
  86518. var size = matricesWeights.length;
  86519. for (var i = 0; i < size; i += 4) {
  86520. var weight = 0.0;
  86521. var firstZeroWeight = -1;
  86522. for (var j = 0; j < 4; j++) {
  86523. var w = matricesWeights[i + j];
  86524. weight += w;
  86525. if (w < epsilon && firstZeroWeight < 0) {
  86526. firstZeroWeight = j;
  86527. }
  86528. }
  86529. if (matricesWeightsExtra) {
  86530. for (var j = 0; j < 4; j++) {
  86531. var w = matricesWeightsExtra[i + j];
  86532. weight += w;
  86533. if (w < epsilon && firstZeroWeight < 0) {
  86534. firstZeroWeight = j + 4;
  86535. }
  86536. }
  86537. }
  86538. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  86539. firstZeroWeight = influencers - 1;
  86540. }
  86541. if (weight > epsilon) {
  86542. var mweight = 1.0 / weight;
  86543. for (var j = 0; j < 4; j++) {
  86544. matricesWeights[i + j] *= mweight;
  86545. }
  86546. if (matricesWeightsExtra) {
  86547. for (var j = 0; j < 4; j++) {
  86548. matricesWeightsExtra[i + j] *= mweight;
  86549. }
  86550. }
  86551. }
  86552. else {
  86553. if (firstZeroWeight >= 4) {
  86554. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  86555. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  86556. }
  86557. else {
  86558. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  86559. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  86560. }
  86561. }
  86562. }
  86563. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  86564. if (parsedGeometry.matricesWeightsExtra) {
  86565. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  86566. }
  86567. };
  86568. /**
  86569. * Create a new geometry from persisted data (Using .babylon file format)
  86570. * @param parsedVertexData defines the persisted data
  86571. * @param scene defines the hosting scene
  86572. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86573. * @returns the new geometry object
  86574. */
  86575. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  86576. if (scene.getGeometryByID(parsedVertexData.id)) {
  86577. return null; // null since geometry could be something else than a box...
  86578. }
  86579. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  86580. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  86581. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  86582. }
  86583. if (parsedVertexData.delayLoadingFile) {
  86584. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  86585. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  86586. 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));
  86587. geometry._delayInfo = [];
  86588. if (parsedVertexData.hasUVs) {
  86589. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  86590. }
  86591. if (parsedVertexData.hasUVs2) {
  86592. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  86593. }
  86594. if (parsedVertexData.hasUVs3) {
  86595. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  86596. }
  86597. if (parsedVertexData.hasUVs4) {
  86598. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  86599. }
  86600. if (parsedVertexData.hasUVs5) {
  86601. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  86602. }
  86603. if (parsedVertexData.hasUVs6) {
  86604. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  86605. }
  86606. if (parsedVertexData.hasColors) {
  86607. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  86608. }
  86609. if (parsedVertexData.hasMatricesIndices) {
  86610. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  86611. }
  86612. if (parsedVertexData.hasMatricesWeights) {
  86613. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  86614. }
  86615. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  86616. }
  86617. else {
  86618. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  86619. }
  86620. scene.pushGeometry(geometry, true);
  86621. return geometry;
  86622. };
  86623. return Geometry;
  86624. }());
  86625. /***/ }),
  86626. /***/ "./Meshes/groundMesh.ts":
  86627. /*!******************************!*\
  86628. !*** ./Meshes/groundMesh.ts ***!
  86629. \******************************/
  86630. /*! exports provided: GroundMesh */
  86631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86632. "use strict";
  86633. __webpack_require__.r(__webpack_exports__);
  86634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  86635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  86636. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86637. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86638. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  86639. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  86640. return GroundMesh.Parse(parsedMesh, scene);
  86641. };
  86642. /**
  86643. * Mesh representing the gorund
  86644. */
  86645. var GroundMesh = /** @class */ (function (_super) {
  86646. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  86647. function GroundMesh(name, scene) {
  86648. var _this = _super.call(this, name, scene) || this;
  86649. /** If octree should be generated */
  86650. _this.generateOctree = false;
  86651. return _this;
  86652. }
  86653. /**
  86654. * "GroundMesh"
  86655. * @returns "GroundMesh"
  86656. */
  86657. GroundMesh.prototype.getClassName = function () {
  86658. return "GroundMesh";
  86659. };
  86660. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  86661. /**
  86662. * The minimum of x and y subdivisions
  86663. */
  86664. get: function () {
  86665. return Math.min(this._subdivisionsX, this._subdivisionsY);
  86666. },
  86667. enumerable: true,
  86668. configurable: true
  86669. });
  86670. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  86671. /**
  86672. * X subdivisions
  86673. */
  86674. get: function () {
  86675. return this._subdivisionsX;
  86676. },
  86677. enumerable: true,
  86678. configurable: true
  86679. });
  86680. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  86681. /**
  86682. * Y subdivisions
  86683. */
  86684. get: function () {
  86685. return this._subdivisionsY;
  86686. },
  86687. enumerable: true,
  86688. configurable: true
  86689. });
  86690. /**
  86691. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86692. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86693. * @param chunksCount the number of subdivisions for x and y
  86694. * @param octreeBlocksSize (Default: 32)
  86695. */
  86696. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  86697. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  86698. this._subdivisionsX = chunksCount;
  86699. this._subdivisionsY = chunksCount;
  86700. this.subdivide(chunksCount);
  86701. // Call the octree system optimization if it is defined.
  86702. var thisAsAny = this;
  86703. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  86704. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  86705. }
  86706. };
  86707. /**
  86708. * Returns a height (y) value in the Worl system :
  86709. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86710. * @param x x coordinate
  86711. * @param z z coordinate
  86712. * @returns the ground y position if (x, z) are outside the ground surface.
  86713. */
  86714. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  86715. var world = this.getWorldMatrix();
  86716. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  86717. world.invertToRef(invMat);
  86718. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  86719. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  86720. x = tmpVect.x;
  86721. z = tmpVect.z;
  86722. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  86723. return this.position.y;
  86724. }
  86725. if (!this._heightQuads || this._heightQuads.length == 0) {
  86726. this._initHeightQuads();
  86727. this._computeHeightQuads();
  86728. }
  86729. var facet = this._getFacetAt(x, z);
  86730. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  86731. // return y in the World system
  86732. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  86733. return tmpVect.y;
  86734. };
  86735. /**
  86736. * Returns a normalized vector (Vector3) orthogonal to the ground
  86737. * at the ground coordinates (x, z) expressed in the World system.
  86738. * @param x x coordinate
  86739. * @param z z coordinate
  86740. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86741. */
  86742. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  86743. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  86744. this.getNormalAtCoordinatesToRef(x, z, normal);
  86745. return normal;
  86746. };
  86747. /**
  86748. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86749. * at the ground coordinates (x, z) expressed in the World system.
  86750. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86751. * @param x x coordinate
  86752. * @param z z coordinate
  86753. * @param ref vector to store the result
  86754. * @returns the GroundMesh.
  86755. */
  86756. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  86757. var world = this.getWorldMatrix();
  86758. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  86759. world.invertToRef(tmpMat);
  86760. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  86761. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  86762. x = tmpVect.x;
  86763. z = tmpVect.z;
  86764. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  86765. return this;
  86766. }
  86767. if (!this._heightQuads || this._heightQuads.length == 0) {
  86768. this._initHeightQuads();
  86769. this._computeHeightQuads();
  86770. }
  86771. var facet = this._getFacetAt(x, z);
  86772. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  86773. return this;
  86774. };
  86775. /**
  86776. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86777. * if the ground has been updated.
  86778. * This can be used in the render loop.
  86779. * @returns the GroundMesh.
  86780. */
  86781. GroundMesh.prototype.updateCoordinateHeights = function () {
  86782. if (!this._heightQuads || this._heightQuads.length == 0) {
  86783. this._initHeightQuads();
  86784. }
  86785. this._computeHeightQuads();
  86786. return this;
  86787. };
  86788. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  86789. GroundMesh.prototype._getFacetAt = function (x, z) {
  86790. // retrieve col and row from x, z coordinates in the ground local system
  86791. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  86792. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  86793. var quad = this._heightQuads[row * this._subdivisionsX + col];
  86794. var facet;
  86795. if (z < quad.slope.x * x + quad.slope.y) {
  86796. facet = quad.facet1;
  86797. }
  86798. else {
  86799. facet = quad.facet2;
  86800. }
  86801. return facet;
  86802. };
  86803. // Creates and populates the heightMap array with "facet" elements :
  86804. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  86805. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  86806. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  86807. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  86808. // Returns the GroundMesh.
  86809. GroundMesh.prototype._initHeightQuads = function () {
  86810. var subdivisionsX = this._subdivisionsX;
  86811. var subdivisionsY = this._subdivisionsY;
  86812. this._heightQuads = new Array();
  86813. for (var row = 0; row < subdivisionsY; row++) {
  86814. for (var col = 0; col < subdivisionsX; col++) {
  86815. 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) };
  86816. this._heightQuads[row * subdivisionsX + col] = quad;
  86817. }
  86818. }
  86819. return this;
  86820. };
  86821. // Compute each quad element values and update the the heightMap array :
  86822. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  86823. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  86824. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  86825. // Returns the GroundMesh.
  86826. GroundMesh.prototype._computeHeightQuads = function () {
  86827. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  86828. if (!positions) {
  86829. return this;
  86830. }
  86831. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  86832. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  86833. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  86834. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  86835. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  86836. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  86837. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  86838. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  86839. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  86840. var i = 0;
  86841. var j = 0;
  86842. var k = 0;
  86843. var cd = 0; // 2D slope coefficient : z = cd * x + h
  86844. var h = 0;
  86845. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  86846. var d2 = 0;
  86847. var subdivisionsX = this._subdivisionsX;
  86848. var subdivisionsY = this._subdivisionsY;
  86849. for (var row = 0; row < subdivisionsY; row++) {
  86850. for (var col = 0; col < subdivisionsX; col++) {
  86851. i = col * 3;
  86852. j = row * (subdivisionsX + 1) * 3;
  86853. k = (row + 1) * (subdivisionsX + 1) * 3;
  86854. v1.x = positions[j + i];
  86855. v1.y = positions[j + i + 1];
  86856. v1.z = positions[j + i + 2];
  86857. v2.x = positions[j + i + 3];
  86858. v2.y = positions[j + i + 4];
  86859. v2.z = positions[j + i + 5];
  86860. v3.x = positions[k + i];
  86861. v3.y = positions[k + i + 1];
  86862. v3.z = positions[k + i + 2];
  86863. v4.x = positions[k + i + 3];
  86864. v4.y = positions[k + i + 4];
  86865. v4.z = positions[k + i + 5];
  86866. // 2D slope V1V4
  86867. cd = (v4.z - v1.z) / (v4.x - v1.x);
  86868. h = v1.z - cd * v1.x; // v1 belongs to the slope
  86869. // facet equations :
  86870. // we compute each facet normal vector
  86871. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  86872. // we compute the value d by applying the equation to v1 which belongs to the plane
  86873. // then we store the facet equation in a Vector4
  86874. v2.subtractToRef(v1, v1v2);
  86875. v3.subtractToRef(v1, v1v3);
  86876. v4.subtractToRef(v1, v1v4);
  86877. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  86878. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  86879. norm1.normalize();
  86880. norm2.normalize();
  86881. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  86882. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  86883. var quad = this._heightQuads[row * subdivisionsX + col];
  86884. quad.slope.copyFromFloats(cd, h);
  86885. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  86886. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  86887. }
  86888. }
  86889. return this;
  86890. };
  86891. /**
  86892. * Serializes this ground mesh
  86893. * @param serializationObject object to write serialization to
  86894. */
  86895. GroundMesh.prototype.serialize = function (serializationObject) {
  86896. _super.prototype.serialize.call(this, serializationObject);
  86897. serializationObject.subdivisionsX = this._subdivisionsX;
  86898. serializationObject.subdivisionsY = this._subdivisionsY;
  86899. serializationObject.minX = this._minX;
  86900. serializationObject.maxX = this._maxX;
  86901. serializationObject.minZ = this._minZ;
  86902. serializationObject.maxZ = this._maxZ;
  86903. serializationObject.width = this._width;
  86904. serializationObject.height = this._height;
  86905. };
  86906. /**
  86907. * Parses a serialized ground mesh
  86908. * @param parsedMesh the serialized mesh
  86909. * @param scene the scene to create the ground mesh in
  86910. * @returns the created ground mesh
  86911. */
  86912. GroundMesh.Parse = function (parsedMesh, scene) {
  86913. var result = new GroundMesh(parsedMesh.name, scene);
  86914. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  86915. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  86916. result._minX = parsedMesh.minX;
  86917. result._maxX = parsedMesh.maxX;
  86918. result._minZ = parsedMesh.minZ;
  86919. result._maxZ = parsedMesh.maxZ;
  86920. result._width = parsedMesh.width;
  86921. result._height = parsedMesh.height;
  86922. return result;
  86923. };
  86924. return GroundMesh;
  86925. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  86926. /***/ }),
  86927. /***/ "./Meshes/index.ts":
  86928. /*!*************************!*\
  86929. !*** ./Meshes/index.ts ***!
  86930. \*************************/
  86931. /*! 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 */
  86932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86933. "use strict";
  86934. __webpack_require__.r(__webpack_exports__);
  86935. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  86936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  86937. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  86938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  86939. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  86940. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  86941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  86942. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  86943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  86944. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  86945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  86946. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  86947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  86948. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  86949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  86950. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  86951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  86952. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  86953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  86954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  86955. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  86956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["MeshLODLevel"]; });
  86957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  86958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  86959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  86960. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  86961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  86962. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  86963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  86964. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  86965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  86966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  86967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  86968. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  86969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  86970. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  86971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  86972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  86973. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  86974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  86975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  86976. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  86977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_16__["TransformNode"]; });
  86978. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  86979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["BoxBuilder"]; });
  86980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["SphereBuilder"]; });
  86981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["CylinderBuilder"]; });
  86982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LinesBuilder"]; });
  86983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PlaneBuilder"]; });
  86984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DiscBuilder"]; });
  86985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["RibbonBuilder"]; });
  86986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["HemisphereBuilder"]; });
  86987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusBuilder"]; });
  86988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusKnotBuilder"]; });
  86989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolygonBuilder"]; });
  86990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["ShapeBuilder"]; });
  86991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LatheBuilder"]; });
  86992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["GroundBuilder"]; });
  86993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TubeBuilder"]; });
  86994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  86995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"]; });
  86996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  86997. /***/ }),
  86998. /***/ "./Meshes/instancedMesh.ts":
  86999. /*!*********************************!*\
  87000. !*** ./Meshes/instancedMesh.ts ***!
  87001. \*********************************/
  87002. /*! exports provided: InstancedMesh */
  87003. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87004. "use strict";
  87005. __webpack_require__.r(__webpack_exports__);
  87006. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  87007. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  87008. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  87009. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  87010. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  87011. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  87012. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  87013. return new InstancedMesh(name, mesh);
  87014. };
  87015. /**
  87016. * Creates an instance based on a source mesh.
  87017. */
  87018. var InstancedMesh = /** @class */ (function (_super) {
  87019. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  87020. function InstancedMesh(name, source) {
  87021. var _this = _super.call(this, name, source.getScene()) || this;
  87022. /** @hidden */
  87023. _this._indexInSourceMeshInstanceArray = -1;
  87024. source.addInstance(_this);
  87025. _this._sourceMesh = source;
  87026. _this.position.copyFrom(source.position);
  87027. _this.rotation.copyFrom(source.rotation);
  87028. _this.scaling.copyFrom(source.scaling);
  87029. if (source.rotationQuaternion) {
  87030. _this.rotationQuaternion = source.rotationQuaternion.clone();
  87031. }
  87032. _this.infiniteDistance = source.infiniteDistance;
  87033. _this.setPivotMatrix(source.getPivotMatrix());
  87034. _this.refreshBoundingInfo();
  87035. _this._syncSubMeshes();
  87036. return _this;
  87037. }
  87038. /**
  87039. * Returns the string "InstancedMesh".
  87040. */
  87041. InstancedMesh.prototype.getClassName = function () {
  87042. return "InstancedMesh";
  87043. };
  87044. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  87045. // Methods
  87046. /**
  87047. * If the source mesh receives shadows
  87048. */
  87049. get: function () {
  87050. return this._sourceMesh.receiveShadows;
  87051. },
  87052. enumerable: true,
  87053. configurable: true
  87054. });
  87055. Object.defineProperty(InstancedMesh.prototype, "material", {
  87056. /**
  87057. * The material of the source mesh
  87058. */
  87059. get: function () {
  87060. return this._sourceMesh.material;
  87061. },
  87062. enumerable: true,
  87063. configurable: true
  87064. });
  87065. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  87066. /**
  87067. * Visibility of the source mesh
  87068. */
  87069. get: function () {
  87070. return this._sourceMesh.visibility;
  87071. },
  87072. enumerable: true,
  87073. configurable: true
  87074. });
  87075. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  87076. /**
  87077. * Skeleton of the source mesh
  87078. */
  87079. get: function () {
  87080. return this._sourceMesh.skeleton;
  87081. },
  87082. enumerable: true,
  87083. configurable: true
  87084. });
  87085. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  87086. /**
  87087. * Rendering ground id of the source mesh
  87088. */
  87089. get: function () {
  87090. return this._sourceMesh.renderingGroupId;
  87091. },
  87092. set: function (value) {
  87093. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  87094. return;
  87095. }
  87096. //no-op with warning
  87097. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  87098. },
  87099. enumerable: true,
  87100. configurable: true
  87101. });
  87102. /**
  87103. * Returns the total number of vertices (integer).
  87104. */
  87105. InstancedMesh.prototype.getTotalVertices = function () {
  87106. return this._sourceMesh.getTotalVertices();
  87107. };
  87108. /**
  87109. * Returns a positive integer : the total number of indices in this mesh geometry.
  87110. * @returns the numner of indices or zero if the mesh has no geometry.
  87111. */
  87112. InstancedMesh.prototype.getTotalIndices = function () {
  87113. return this._sourceMesh.getTotalIndices();
  87114. };
  87115. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  87116. /**
  87117. * The source mesh of the instance
  87118. */
  87119. get: function () {
  87120. return this._sourceMesh;
  87121. },
  87122. enumerable: true,
  87123. configurable: true
  87124. });
  87125. /**
  87126. * Is this node ready to be used/rendered
  87127. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87128. * @return {boolean} is it ready
  87129. */
  87130. InstancedMesh.prototype.isReady = function (completeCheck) {
  87131. if (completeCheck === void 0) { completeCheck = false; }
  87132. return this._sourceMesh.isReady(completeCheck, true);
  87133. };
  87134. /**
  87135. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87136. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87137. * @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.
  87138. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87139. */
  87140. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  87141. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  87142. };
  87143. /**
  87144. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87145. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87146. * The `data` are either a numeric array either a Float32Array.
  87147. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87148. * 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).
  87149. * Note that a new underlying VertexBuffer object is created each call.
  87150. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87151. *
  87152. * Possible `kind` values :
  87153. * - VertexBuffer.PositionKind
  87154. * - VertexBuffer.UVKind
  87155. * - VertexBuffer.UV2Kind
  87156. * - VertexBuffer.UV3Kind
  87157. * - VertexBuffer.UV4Kind
  87158. * - VertexBuffer.UV5Kind
  87159. * - VertexBuffer.UV6Kind
  87160. * - VertexBuffer.ColorKind
  87161. * - VertexBuffer.MatricesIndicesKind
  87162. * - VertexBuffer.MatricesIndicesExtraKind
  87163. * - VertexBuffer.MatricesWeightsKind
  87164. * - VertexBuffer.MatricesWeightsExtraKind
  87165. *
  87166. * Returns the Mesh.
  87167. */
  87168. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  87169. if (this.sourceMesh) {
  87170. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  87171. }
  87172. return this.sourceMesh;
  87173. };
  87174. /**
  87175. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87176. * If the mesh has no geometry, it is simply returned as it is.
  87177. * The `data` are either a numeric array either a Float32Array.
  87178. * No new underlying VertexBuffer object is created.
  87179. * 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.
  87180. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87181. *
  87182. * Possible `kind` values :
  87183. * - VertexBuffer.PositionKind
  87184. * - VertexBuffer.UVKind
  87185. * - VertexBuffer.UV2Kind
  87186. * - VertexBuffer.UV3Kind
  87187. * - VertexBuffer.UV4Kind
  87188. * - VertexBuffer.UV5Kind
  87189. * - VertexBuffer.UV6Kind
  87190. * - VertexBuffer.ColorKind
  87191. * - VertexBuffer.MatricesIndicesKind
  87192. * - VertexBuffer.MatricesIndicesExtraKind
  87193. * - VertexBuffer.MatricesWeightsKind
  87194. * - VertexBuffer.MatricesWeightsExtraKind
  87195. *
  87196. * Returns the Mesh.
  87197. */
  87198. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  87199. if (this.sourceMesh) {
  87200. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  87201. }
  87202. return this.sourceMesh;
  87203. };
  87204. /**
  87205. * Sets the mesh indices.
  87206. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87207. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87208. * This method creates a new index buffer each call.
  87209. * Returns the Mesh.
  87210. */
  87211. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  87212. if (totalVertices === void 0) { totalVertices = null; }
  87213. if (this.sourceMesh) {
  87214. this.sourceMesh.setIndices(indices, totalVertices);
  87215. }
  87216. return this.sourceMesh;
  87217. };
  87218. /**
  87219. * Boolean : True if the mesh owns the requested kind of data.
  87220. */
  87221. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  87222. return this._sourceMesh.isVerticesDataPresent(kind);
  87223. };
  87224. /**
  87225. * Returns an array of indices (IndicesArray).
  87226. */
  87227. InstancedMesh.prototype.getIndices = function () {
  87228. return this._sourceMesh.getIndices();
  87229. };
  87230. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  87231. get: function () {
  87232. return this._sourceMesh._positions;
  87233. },
  87234. enumerable: true,
  87235. configurable: true
  87236. });
  87237. /**
  87238. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87239. * This means the mesh underlying bounding box and sphere are recomputed.
  87240. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87241. * @returns the current mesh
  87242. */
  87243. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  87244. if (applySkeleton === void 0) { applySkeleton = false; }
  87245. if (this._boundingInfo && this._boundingInfo.isLocked) {
  87246. return this;
  87247. }
  87248. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  87249. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  87250. return this;
  87251. };
  87252. /** @hidden */
  87253. InstancedMesh.prototype._preActivate = function () {
  87254. if (this._currentLOD) {
  87255. this._currentLOD._preActivate();
  87256. }
  87257. return this;
  87258. };
  87259. /** @hidden */
  87260. InstancedMesh.prototype._activate = function (renderId) {
  87261. if (this._currentLOD) {
  87262. this._currentLOD._registerInstanceForRenderId(this, renderId);
  87263. }
  87264. if (this._edgesRenderer && this._edgesRenderer.isEnabled && this._sourceMesh._renderingGroup) {
  87265. this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer);
  87266. }
  87267. if (!this._currentLOD._isActive) {
  87268. this._currentLOD._isActive = true;
  87269. return true;
  87270. }
  87271. return false;
  87272. };
  87273. /**
  87274. * Returns the current associated LOD AbstractMesh.
  87275. */
  87276. InstancedMesh.prototype.getLOD = function (camera) {
  87277. if (!camera) {
  87278. return this;
  87279. }
  87280. var boundingInfo = this.getBoundingInfo();
  87281. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  87282. if (this._currentLOD === this.sourceMesh) {
  87283. return this;
  87284. }
  87285. return this._currentLOD;
  87286. };
  87287. /** @hidden */
  87288. InstancedMesh.prototype._syncSubMeshes = function () {
  87289. this.releaseSubMeshes();
  87290. if (this._sourceMesh.subMeshes) {
  87291. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  87292. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  87293. }
  87294. }
  87295. return this;
  87296. };
  87297. /** @hidden */
  87298. InstancedMesh.prototype._generatePointsArray = function () {
  87299. return this._sourceMesh._generatePointsArray();
  87300. };
  87301. /**
  87302. * Creates a new InstancedMesh from the current mesh.
  87303. * - name (string) : the cloned mesh name
  87304. * - newParent (optional Node) : the optional Node to parent the clone to.
  87305. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87306. *
  87307. * Returns the clone.
  87308. */
  87309. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  87310. var result = this._sourceMesh.createInstance(name);
  87311. // Deep copy
  87312. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  87313. // Bounding info
  87314. this.refreshBoundingInfo();
  87315. // Parent
  87316. if (newParent) {
  87317. result.parent = newParent;
  87318. }
  87319. if (!doNotCloneChildren) {
  87320. // Children
  87321. for (var index = 0; index < this.getScene().meshes.length; index++) {
  87322. var mesh = this.getScene().meshes[index];
  87323. if (mesh.parent === this) {
  87324. mesh.clone(mesh.name, result);
  87325. }
  87326. }
  87327. }
  87328. result.computeWorldMatrix(true);
  87329. return result;
  87330. };
  87331. /**
  87332. * Disposes the InstancedMesh.
  87333. * Returns nothing.
  87334. */
  87335. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  87336. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  87337. // Remove from mesh
  87338. this._sourceMesh.removeInstance(this);
  87339. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  87340. };
  87341. return InstancedMesh;
  87342. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  87343. /***/ }),
  87344. /***/ "./Meshes/linesMesh.ts":
  87345. /*!*****************************!*\
  87346. !*** ./Meshes/linesMesh.ts ***!
  87347. \*****************************/
  87348. /*! exports provided: LinesMesh, InstancedLinesMesh */
  87349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87350. "use strict";
  87351. __webpack_require__.r(__webpack_exports__);
  87352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  87353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  87354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  87355. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87356. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  87357. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  87358. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  87359. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  87360. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  87361. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  87362. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  87363. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  87364. /**
  87365. * Line mesh
  87366. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87367. */
  87368. var LinesMesh = /** @class */ (function (_super) {
  87369. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  87370. /**
  87371. * Creates a new LinesMesh
  87372. * @param name defines the name
  87373. * @param scene defines the hosting scene
  87374. * @param parent defines the parent mesh if any
  87375. * @param source defines the optional source LinesMesh used to clone data from
  87376. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87377. * When false, achieved by calling a clone(), also passing False.
  87378. * This will make creation of children, recursive.
  87379. * @param useVertexColor defines if this LinesMesh supports vertex color
  87380. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87381. */
  87382. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  87383. /**
  87384. * If vertex color should be applied to the mesh
  87385. */
  87386. useVertexColor,
  87387. /**
  87388. * If vertex alpha should be applied to the mesh
  87389. */
  87390. useVertexAlpha) {
  87391. if (scene === void 0) { scene = null; }
  87392. if (parent === void 0) { parent = null; }
  87393. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  87394. _this.useVertexColor = useVertexColor;
  87395. _this.useVertexAlpha = useVertexAlpha;
  87396. /**
  87397. * Color of the line (Default: White)
  87398. */
  87399. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  87400. /**
  87401. * Alpha of the line (Default: 1)
  87402. */
  87403. _this.alpha = 1;
  87404. if (source) {
  87405. _this.color = source.color.clone();
  87406. _this.alpha = source.alpha;
  87407. _this.useVertexColor = source.useVertexColor;
  87408. _this.useVertexAlpha = source.useVertexAlpha;
  87409. }
  87410. _this.intersectionThreshold = 0.1;
  87411. var defines = [];
  87412. var options = {
  87413. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  87414. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "world", "viewProjection"],
  87415. needAlphaBlending: true,
  87416. defines: defines
  87417. };
  87418. if (useVertexAlpha === false) {
  87419. options.needAlphaBlending = false;
  87420. }
  87421. if (!useVertexColor) {
  87422. options.uniforms.push("color");
  87423. }
  87424. else {
  87425. options.defines.push("#define VERTEXCOLOR");
  87426. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  87427. }
  87428. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  87429. return _this;
  87430. }
  87431. LinesMesh.prototype._addClipPlaneDefine = function (label) {
  87432. var define = "#define " + label;
  87433. var index = this._colorShader.options.defines.indexOf(define);
  87434. if (index !== -1) {
  87435. return;
  87436. }
  87437. this._colorShader.options.defines.push(define);
  87438. };
  87439. LinesMesh.prototype._removeClipPlaneDefine = function (label) {
  87440. var define = "#define " + label;
  87441. var index = this._colorShader.options.defines.indexOf(define);
  87442. if (index === -1) {
  87443. return;
  87444. }
  87445. this._colorShader.options.defines.splice(index, 1);
  87446. };
  87447. LinesMesh.prototype.isReady = function () {
  87448. var scene = this.getScene();
  87449. // Clip planes
  87450. scene.clipPlane ? this._addClipPlaneDefine("CLIPPLANE") : this._removeClipPlaneDefine("CLIPPLANE");
  87451. scene.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2");
  87452. scene.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3");
  87453. scene.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4");
  87454. if (!this._colorShader.isReady()) {
  87455. return false;
  87456. }
  87457. return _super.prototype.isReady.call(this);
  87458. };
  87459. /**
  87460. * Returns the string "LineMesh"
  87461. */
  87462. LinesMesh.prototype.getClassName = function () {
  87463. return "LinesMesh";
  87464. };
  87465. Object.defineProperty(LinesMesh.prototype, "material", {
  87466. /**
  87467. * @hidden
  87468. */
  87469. get: function () {
  87470. return this._colorShader;
  87471. },
  87472. /**
  87473. * @hidden
  87474. */
  87475. set: function (value) {
  87476. // Do nothing
  87477. },
  87478. enumerable: true,
  87479. configurable: true
  87480. });
  87481. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  87482. /**
  87483. * @hidden
  87484. */
  87485. get: function () {
  87486. return false;
  87487. },
  87488. enumerable: true,
  87489. configurable: true
  87490. });
  87491. /** @hidden */
  87492. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  87493. if (!this._geometry) {
  87494. return this;
  87495. }
  87496. var colorEffect = this._colorShader.getEffect();
  87497. // VBOs
  87498. this._geometry._bind(colorEffect);
  87499. // Color
  87500. if (!this.useVertexColor) {
  87501. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  87502. }
  87503. // Clip planes
  87504. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__["MaterialHelper"].BindClipPlane(colorEffect, this.getScene());
  87505. return this;
  87506. };
  87507. /** @hidden */
  87508. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  87509. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  87510. return this;
  87511. }
  87512. var engine = this.getScene().getEngine();
  87513. // Draw order
  87514. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  87515. return this;
  87516. };
  87517. /**
  87518. * Disposes of the line mesh
  87519. * @param doNotRecurse If children should be disposed
  87520. */
  87521. LinesMesh.prototype.dispose = function (doNotRecurse) {
  87522. this._colorShader.dispose(false, false, true);
  87523. _super.prototype.dispose.call(this, doNotRecurse);
  87524. };
  87525. /**
  87526. * Returns a new LineMesh object cloned from the current one.
  87527. */
  87528. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  87529. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  87530. };
  87531. /**
  87532. * Creates a new InstancedLinesMesh object from the mesh model.
  87533. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87534. * @param name defines the name of the new instance
  87535. * @returns a new InstancedLinesMesh
  87536. */
  87537. LinesMesh.prototype.createInstance = function (name) {
  87538. return new InstancedLinesMesh(name, this);
  87539. };
  87540. return LinesMesh;
  87541. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  87542. /**
  87543. * Creates an instance based on a source LinesMesh
  87544. */
  87545. var InstancedLinesMesh = /** @class */ (function (_super) {
  87546. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  87547. function InstancedLinesMesh(name, source) {
  87548. var _this = _super.call(this, name, source) || this;
  87549. _this.intersectionThreshold = source.intersectionThreshold;
  87550. return _this;
  87551. }
  87552. /**
  87553. * Returns the string "InstancedLinesMesh".
  87554. */
  87555. InstancedLinesMesh.prototype.getClassName = function () {
  87556. return "InstancedLinesMesh";
  87557. };
  87558. return InstancedLinesMesh;
  87559. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  87560. /***/ }),
  87561. /***/ "./Meshes/mesh.ts":
  87562. /*!************************!*\
  87563. !*** ./Meshes/mesh.ts ***!
  87564. \************************/
  87565. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  87566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87567. "use strict";
  87568. __webpack_require__.r(__webpack_exports__);
  87569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  87570. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  87571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  87572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  87573. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  87574. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  87575. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  87576. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  87577. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  87578. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87579. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  87580. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  87581. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  87582. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  87583. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  87584. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  87585. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  87586. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  87587. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  87588. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  87589. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  87590. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  87591. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  87592. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  87593. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  87594. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  87595. /**
  87596. * Class used to represent a specific level of detail of a mesh
  87597. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87598. */
  87599. var MeshLODLevel = /** @class */ (function () {
  87600. /**
  87601. * Creates a new LOD level
  87602. * @param distance defines the distance where this level should star being displayed
  87603. * @param mesh defines the mesh to use to render this level
  87604. */
  87605. function MeshLODLevel(
  87606. /** Defines the distance where this level should star being displayed */
  87607. distance,
  87608. /** Defines the mesh to use to render this level */
  87609. mesh) {
  87610. this.distance = distance;
  87611. this.mesh = mesh;
  87612. }
  87613. return MeshLODLevel;
  87614. }());
  87615. /**
  87616. * @hidden
  87617. **/
  87618. var _CreationDataStorage = /** @class */ (function () {
  87619. function _CreationDataStorage() {
  87620. }
  87621. return _CreationDataStorage;
  87622. }());
  87623. /**
  87624. * @hidden
  87625. **/
  87626. var _InstanceDataStorage = /** @class */ (function () {
  87627. function _InstanceDataStorage() {
  87628. this.visibleInstances = {};
  87629. this.batchCache = new _InstancesBatch();
  87630. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  87631. }
  87632. return _InstanceDataStorage;
  87633. }());
  87634. /**
  87635. * @hidden
  87636. **/
  87637. var _InstancesBatch = /** @class */ (function () {
  87638. function _InstancesBatch() {
  87639. this.mustReturn = false;
  87640. this.visibleInstances = new Array();
  87641. this.renderSelf = new Array();
  87642. this.hardwareInstancedRendering = new Array();
  87643. }
  87644. return _InstancesBatch;
  87645. }());
  87646. /**
  87647. * Class used to represent renderable models
  87648. */
  87649. var Mesh = /** @class */ (function (_super) {
  87650. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  87651. /**
  87652. * @constructor
  87653. * @param name The value used by scene.getMeshByName() to do a lookup.
  87654. * @param scene The scene to add this mesh to.
  87655. * @param parent The parent of this mesh, if it has one
  87656. * @param source An optional Mesh from which geometry is shared, cloned.
  87657. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87658. * When false, achieved by calling a clone(), also passing False.
  87659. * This will make creation of children, recursive.
  87660. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87661. */
  87662. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  87663. if (scene === void 0) { scene = null; }
  87664. if (parent === void 0) { parent = null; }
  87665. if (source === void 0) { source = null; }
  87666. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  87667. var _this = _super.call(this, name, scene) || this;
  87668. // Members
  87669. /**
  87670. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87671. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87672. */
  87673. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  87674. /**
  87675. * Gets the list of instances created from this mesh
  87676. * it is not supposed to be modified manually.
  87677. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87678. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87679. */
  87680. _this.instances = new Array();
  87681. _this._LODLevels = new Array();
  87682. // Morph
  87683. _this._morphTargetManager = null;
  87684. // Private
  87685. /** @hidden */
  87686. _this._creationDataStorage = null;
  87687. /** @hidden */
  87688. _this._geometry = null;
  87689. /** @hidden */
  87690. _this._instanceDataStorage = new _InstanceDataStorage();
  87691. _this._effectiveMaterial = null;
  87692. /** @hidden */
  87693. _this._shouldGenerateFlatShading = false;
  87694. _this._preActivateId = -1;
  87695. // Use by builder only to know what orientation were the mesh build in.
  87696. /** @hidden */
  87697. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  87698. /**
  87699. * Use this property to change the original side orientation defined at construction time
  87700. */
  87701. _this.overrideMaterialSideOrientation = null;
  87702. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  87703. // Will be used to save a source mesh reference, If any
  87704. _this._source = null;
  87705. // Will be used to for fast cloned mesh lookup
  87706. _this.meshMap = null;
  87707. /** @hidden */
  87708. _this._isMesh = true;
  87709. scene = _this.getScene();
  87710. if (source) {
  87711. // Geometry
  87712. if (source._geometry) {
  87713. source._geometry.applyToMesh(_this);
  87714. }
  87715. // Deep copy
  87716. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  87717. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  87718. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  87719. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  87720. "onDisposeObservable"
  87721. ], ["_poseMatrix"]);
  87722. // Source mesh
  87723. _this._source = source;
  87724. if (scene.useClonedMeshhMap) {
  87725. if (!source.meshMap) {
  87726. source.meshMap = {};
  87727. }
  87728. source.meshMap[_this.uniqueId] = _this;
  87729. }
  87730. // Construction Params
  87731. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  87732. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  87733. _this._creationDataStorage = source._creationDataStorage;
  87734. // Animation ranges
  87735. if (_this._source._ranges) {
  87736. var ranges = _this._source._ranges;
  87737. for (var name in ranges) {
  87738. if (!ranges.hasOwnProperty(name)) {
  87739. continue;
  87740. }
  87741. if (!ranges[name]) {
  87742. continue;
  87743. }
  87744. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  87745. }
  87746. }
  87747. // Metadata
  87748. if (source.metadata && source.metadata.clone) {
  87749. _this.metadata = source.metadata.clone();
  87750. }
  87751. else {
  87752. _this.metadata = source.metadata;
  87753. }
  87754. // Tags
  87755. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  87756. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  87757. }
  87758. // Parent
  87759. _this.parent = source.parent;
  87760. // Pivot
  87761. _this.setPivotMatrix(source.getPivotMatrix());
  87762. _this.id = name + "." + source.id;
  87763. // Material
  87764. _this.material = source.material;
  87765. var index;
  87766. if (!doNotCloneChildren) {
  87767. // Children
  87768. var directDescendants = source.getDescendants(true);
  87769. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  87770. var child = directDescendants[index_1];
  87771. if (child.clone) {
  87772. child.clone(name + "." + child.name, _this);
  87773. }
  87774. }
  87775. }
  87776. // Physics clone
  87777. var physicsEngine = _this.getScene().getPhysicsEngine();
  87778. if (clonePhysicsImpostor && physicsEngine) {
  87779. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  87780. if (impostor) {
  87781. _this.physicsImpostor = impostor.clone(_this);
  87782. }
  87783. }
  87784. // Particles
  87785. for (index = 0; index < scene.particleSystems.length; index++) {
  87786. var system = scene.particleSystems[index];
  87787. if (system.emitter === source) {
  87788. system.clone(system.name, _this);
  87789. }
  87790. }
  87791. _this.refreshBoundingInfo();
  87792. _this.computeWorldMatrix(true);
  87793. }
  87794. // Parent
  87795. if (parent !== null) {
  87796. _this.parent = parent;
  87797. }
  87798. _this._instanceDataStorage.hardwareInstancedRendering = _this.getEngine().getCaps().instancedArrays;
  87799. return _this;
  87800. }
  87801. /**
  87802. * Gets the default side orientation.
  87803. * @param orientation the orientation to value to attempt to get
  87804. * @returns the default orientation
  87805. * @hidden
  87806. */
  87807. Mesh._GetDefaultSideOrientation = function (orientation) {
  87808. return orientation || Mesh.FRONTSIDE; // works as Mesh.FRONTSIDE is 0
  87809. };
  87810. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  87811. /**
  87812. * An event triggered before rendering the mesh
  87813. */
  87814. get: function () {
  87815. if (!this._onBeforeRenderObservable) {
  87816. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87817. }
  87818. return this._onBeforeRenderObservable;
  87819. },
  87820. enumerable: true,
  87821. configurable: true
  87822. });
  87823. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  87824. /**
  87825. * An event triggered before binding the mesh
  87826. */
  87827. get: function () {
  87828. if (!this._onBeforeBindObservable) {
  87829. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87830. }
  87831. return this._onBeforeBindObservable;
  87832. },
  87833. enumerable: true,
  87834. configurable: true
  87835. });
  87836. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  87837. /**
  87838. * An event triggered after rendering the mesh
  87839. */
  87840. get: function () {
  87841. if (!this._onAfterRenderObservable) {
  87842. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87843. }
  87844. return this._onAfterRenderObservable;
  87845. },
  87846. enumerable: true,
  87847. configurable: true
  87848. });
  87849. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  87850. /**
  87851. * An event triggered before drawing the mesh
  87852. */
  87853. get: function () {
  87854. if (!this._onBeforeDrawObservable) {
  87855. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87856. }
  87857. return this._onBeforeDrawObservable;
  87858. },
  87859. enumerable: true,
  87860. configurable: true
  87861. });
  87862. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  87863. /**
  87864. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87865. */
  87866. set: function (callback) {
  87867. if (this._onBeforeDrawObserver) {
  87868. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  87869. }
  87870. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  87871. },
  87872. enumerable: true,
  87873. configurable: true
  87874. });
  87875. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  87876. /**
  87877. * Gets or sets the morph target manager
  87878. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87879. */
  87880. get: function () {
  87881. return this._morphTargetManager;
  87882. },
  87883. set: function (value) {
  87884. if (this._morphTargetManager === value) {
  87885. return;
  87886. }
  87887. this._morphTargetManager = value;
  87888. this._syncGeometryWithMorphTargetManager();
  87889. },
  87890. enumerable: true,
  87891. configurable: true
  87892. });
  87893. Object.defineProperty(Mesh.prototype, "source", {
  87894. /**
  87895. * Gets the source mesh (the one used to clone this one from)
  87896. */
  87897. get: function () {
  87898. return this._source;
  87899. },
  87900. enumerable: true,
  87901. configurable: true
  87902. });
  87903. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  87904. /**
  87905. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87906. */
  87907. get: function () {
  87908. return this._unIndexed;
  87909. },
  87910. set: function (value) {
  87911. if (this._unIndexed !== value) {
  87912. this._unIndexed = value;
  87913. this._markSubMeshesAsAttributesDirty();
  87914. }
  87915. },
  87916. enumerable: true,
  87917. configurable: true
  87918. });
  87919. // Methods
  87920. /**
  87921. * Gets the class name
  87922. * @returns the string "Mesh".
  87923. */
  87924. Mesh.prototype.getClassName = function () {
  87925. return "Mesh";
  87926. };
  87927. /**
  87928. * Returns a description of this mesh
  87929. * @param fullDetails define if full details about this mesh must be used
  87930. * @returns a descriptive string representing this mesh
  87931. */
  87932. Mesh.prototype.toString = function (fullDetails) {
  87933. var ret = _super.prototype.toString.call(this, fullDetails);
  87934. ret += ", n vertices: " + this.getTotalVertices();
  87935. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  87936. if (this.animations) {
  87937. for (var i = 0; i < this.animations.length; i++) {
  87938. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  87939. }
  87940. }
  87941. if (fullDetails) {
  87942. if (this._geometry) {
  87943. var ib = this.getIndices();
  87944. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87945. if (vb && ib) {
  87946. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  87947. }
  87948. }
  87949. else {
  87950. ret += ", flat shading: UNKNOWN";
  87951. }
  87952. }
  87953. return ret;
  87954. };
  87955. /** @hidden */
  87956. Mesh.prototype._unBindEffect = function () {
  87957. _super.prototype._unBindEffect.call(this);
  87958. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  87959. var instance = _a[_i];
  87960. instance._unBindEffect();
  87961. }
  87962. };
  87963. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  87964. /**
  87965. * Gets a boolean indicating if this mesh has LOD
  87966. */
  87967. get: function () {
  87968. return this._LODLevels.length > 0;
  87969. },
  87970. enumerable: true,
  87971. configurable: true
  87972. });
  87973. /**
  87974. * Gets the list of MeshLODLevel associated with the current mesh
  87975. * @returns an array of MeshLODLevel
  87976. */
  87977. Mesh.prototype.getLODLevels = function () {
  87978. return this._LODLevels;
  87979. };
  87980. Mesh.prototype._sortLODLevels = function () {
  87981. this._LODLevels.sort(function (a, b) {
  87982. if (a.distance < b.distance) {
  87983. return 1;
  87984. }
  87985. if (a.distance > b.distance) {
  87986. return -1;
  87987. }
  87988. return 0;
  87989. });
  87990. };
  87991. /**
  87992. * Add a mesh as LOD level triggered at the given distance.
  87993. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87994. * @param distance The distance from the center of the object to show this level
  87995. * @param mesh The mesh to be added as LOD level (can be null)
  87996. * @return This mesh (for chaining)
  87997. */
  87998. Mesh.prototype.addLODLevel = function (distance, mesh) {
  87999. if (mesh && mesh._masterMesh) {
  88000. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  88001. return this;
  88002. }
  88003. var level = new MeshLODLevel(distance, mesh);
  88004. this._LODLevels.push(level);
  88005. if (mesh) {
  88006. mesh._masterMesh = this;
  88007. }
  88008. this._sortLODLevels();
  88009. return this;
  88010. };
  88011. /**
  88012. * Returns the LOD level mesh at the passed distance or null if not found.
  88013. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88014. * @param distance The distance from the center of the object to show this level
  88015. * @returns a Mesh or `null`
  88016. */
  88017. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  88018. for (var index = 0; index < this._LODLevels.length; index++) {
  88019. var level = this._LODLevels[index];
  88020. if (level.distance === distance) {
  88021. return level.mesh;
  88022. }
  88023. }
  88024. return null;
  88025. };
  88026. /**
  88027. * Remove a mesh from the LOD array
  88028. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88029. * @param mesh defines the mesh to be removed
  88030. * @return This mesh (for chaining)
  88031. */
  88032. Mesh.prototype.removeLODLevel = function (mesh) {
  88033. for (var index = 0; index < this._LODLevels.length; index++) {
  88034. if (this._LODLevels[index].mesh === mesh) {
  88035. this._LODLevels.splice(index, 1);
  88036. if (mesh) {
  88037. mesh._masterMesh = null;
  88038. }
  88039. }
  88040. }
  88041. this._sortLODLevels();
  88042. return this;
  88043. };
  88044. /**
  88045. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  88046. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  88047. * @param camera defines the camera to use to compute distance
  88048. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  88049. * @return This mesh (for chaining)
  88050. */
  88051. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  88052. if (!this._LODLevels || this._LODLevels.length === 0) {
  88053. return this;
  88054. }
  88055. var bSphere;
  88056. if (boundingSphere) {
  88057. bSphere = boundingSphere;
  88058. }
  88059. else {
  88060. var boundingInfo = this.getBoundingInfo();
  88061. bSphere = boundingInfo.boundingSphere;
  88062. }
  88063. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  88064. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  88065. if (this.onLODLevelSelection) {
  88066. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  88067. }
  88068. return this;
  88069. }
  88070. for (var index = 0; index < this._LODLevels.length; index++) {
  88071. var level = this._LODLevels[index];
  88072. if (level.distance < distanceToCamera) {
  88073. if (level.mesh) {
  88074. level.mesh._preActivate();
  88075. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  88076. }
  88077. if (this.onLODLevelSelection) {
  88078. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  88079. }
  88080. return level.mesh;
  88081. }
  88082. }
  88083. if (this.onLODLevelSelection) {
  88084. this.onLODLevelSelection(distanceToCamera, this, this);
  88085. }
  88086. return this;
  88087. };
  88088. Object.defineProperty(Mesh.prototype, "geometry", {
  88089. /**
  88090. * Gets the mesh internal Geometry object
  88091. */
  88092. get: function () {
  88093. return this._geometry;
  88094. },
  88095. enumerable: true,
  88096. configurable: true
  88097. });
  88098. /**
  88099. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  88100. * @returns the total number of vertices
  88101. */
  88102. Mesh.prototype.getTotalVertices = function () {
  88103. if (this._geometry === null || this._geometry === undefined) {
  88104. return 0;
  88105. }
  88106. return this._geometry.getTotalVertices();
  88107. };
  88108. /**
  88109. * Returns the content of an associated vertex buffer
  88110. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88111. * - VertexBuffer.PositionKind
  88112. * - VertexBuffer.UVKind
  88113. * - VertexBuffer.UV2Kind
  88114. * - VertexBuffer.UV3Kind
  88115. * - VertexBuffer.UV4Kind
  88116. * - VertexBuffer.UV5Kind
  88117. * - VertexBuffer.UV6Kind
  88118. * - VertexBuffer.ColorKind
  88119. * - VertexBuffer.MatricesIndicesKind
  88120. * - VertexBuffer.MatricesIndicesExtraKind
  88121. * - VertexBuffer.MatricesWeightsKind
  88122. * - VertexBuffer.MatricesWeightsExtraKind
  88123. * @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
  88124. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  88125. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  88126. */
  88127. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  88128. if (!this._geometry) {
  88129. return null;
  88130. }
  88131. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  88132. };
  88133. /**
  88134. * Returns the mesh VertexBuffer object from the requested `kind`
  88135. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88136. * - VertexBuffer.PositionKind
  88137. * - VertexBuffer.UVKind
  88138. * - VertexBuffer.UV2Kind
  88139. * - VertexBuffer.UV3Kind
  88140. * - VertexBuffer.UV4Kind
  88141. * - VertexBuffer.UV5Kind
  88142. * - VertexBuffer.UV6Kind
  88143. * - VertexBuffer.ColorKind
  88144. * - VertexBuffer.MatricesIndicesKind
  88145. * - VertexBuffer.MatricesIndicesExtraKind
  88146. * - VertexBuffer.MatricesWeightsKind
  88147. * - VertexBuffer.MatricesWeightsExtraKind
  88148. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  88149. */
  88150. Mesh.prototype.getVertexBuffer = function (kind) {
  88151. if (!this._geometry) {
  88152. return null;
  88153. }
  88154. return this._geometry.getVertexBuffer(kind);
  88155. };
  88156. /**
  88157. * Tests if a specific vertex buffer is associated with this mesh
  88158. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88159. * - VertexBuffer.PositionKind
  88160. * - VertexBuffer.UVKind
  88161. * - VertexBuffer.UV2Kind
  88162. * - VertexBuffer.UV3Kind
  88163. * - VertexBuffer.UV4Kind
  88164. * - VertexBuffer.UV5Kind
  88165. * - VertexBuffer.UV6Kind
  88166. * - VertexBuffer.ColorKind
  88167. * - VertexBuffer.MatricesIndicesKind
  88168. * - VertexBuffer.MatricesIndicesExtraKind
  88169. * - VertexBuffer.MatricesWeightsKind
  88170. * - VertexBuffer.MatricesWeightsExtraKind
  88171. * @returns a boolean
  88172. */
  88173. Mesh.prototype.isVerticesDataPresent = function (kind) {
  88174. if (!this._geometry) {
  88175. if (this._delayInfo) {
  88176. return this._delayInfo.indexOf(kind) !== -1;
  88177. }
  88178. return false;
  88179. }
  88180. return this._geometry.isVerticesDataPresent(kind);
  88181. };
  88182. /**
  88183. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  88184. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  88185. * - VertexBuffer.PositionKind
  88186. * - VertexBuffer.UVKind
  88187. * - VertexBuffer.UV2Kind
  88188. * - VertexBuffer.UV3Kind
  88189. * - VertexBuffer.UV4Kind
  88190. * - VertexBuffer.UV5Kind
  88191. * - VertexBuffer.UV6Kind
  88192. * - VertexBuffer.ColorKind
  88193. * - VertexBuffer.MatricesIndicesKind
  88194. * - VertexBuffer.MatricesIndicesExtraKind
  88195. * - VertexBuffer.MatricesWeightsKind
  88196. * - VertexBuffer.MatricesWeightsExtraKind
  88197. * @returns a boolean
  88198. */
  88199. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  88200. if (!this._geometry) {
  88201. if (this._delayInfo) {
  88202. return this._delayInfo.indexOf(kind) !== -1;
  88203. }
  88204. return false;
  88205. }
  88206. return this._geometry.isVertexBufferUpdatable(kind);
  88207. };
  88208. /**
  88209. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  88210. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  88211. * - VertexBuffer.PositionKind
  88212. * - VertexBuffer.UVKind
  88213. * - VertexBuffer.UV2Kind
  88214. * - VertexBuffer.UV3Kind
  88215. * - VertexBuffer.UV4Kind
  88216. * - VertexBuffer.UV5Kind
  88217. * - VertexBuffer.UV6Kind
  88218. * - VertexBuffer.ColorKind
  88219. * - VertexBuffer.MatricesIndicesKind
  88220. * - VertexBuffer.MatricesIndicesExtraKind
  88221. * - VertexBuffer.MatricesWeightsKind
  88222. * - VertexBuffer.MatricesWeightsExtraKind
  88223. * @returns an array of strings
  88224. */
  88225. Mesh.prototype.getVerticesDataKinds = function () {
  88226. if (!this._geometry) {
  88227. var result = new Array();
  88228. if (this._delayInfo) {
  88229. this._delayInfo.forEach(function (kind) {
  88230. result.push(kind);
  88231. });
  88232. }
  88233. return result;
  88234. }
  88235. return this._geometry.getVerticesDataKinds();
  88236. };
  88237. /**
  88238. * Returns a positive integer : the total number of indices in this mesh geometry.
  88239. * @returns the numner of indices or zero if the mesh has no geometry.
  88240. */
  88241. Mesh.prototype.getTotalIndices = function () {
  88242. if (!this._geometry) {
  88243. return 0;
  88244. }
  88245. return this._geometry.getTotalIndices();
  88246. };
  88247. /**
  88248. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88249. * @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.
  88250. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88251. * @returns the indices array or an empty array if the mesh has no geometry
  88252. */
  88253. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  88254. if (!this._geometry) {
  88255. return [];
  88256. }
  88257. return this._geometry.getIndices(copyWhenShared, forceCopy);
  88258. };
  88259. Object.defineProperty(Mesh.prototype, "isBlocked", {
  88260. get: function () {
  88261. return this._masterMesh !== null && this._masterMesh !== undefined;
  88262. },
  88263. enumerable: true,
  88264. configurable: true
  88265. });
  88266. /**
  88267. * Determine if the current mesh is ready to be rendered
  88268. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88269. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  88270. * @returns true if all associated assets are ready (material, textures, shaders)
  88271. */
  88272. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  88273. if (completeCheck === void 0) { completeCheck = false; }
  88274. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  88275. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  88276. return false;
  88277. }
  88278. if (!_super.prototype.isReady.call(this, completeCheck)) {
  88279. return false;
  88280. }
  88281. if (!this.subMeshes || this.subMeshes.length === 0) {
  88282. return true;
  88283. }
  88284. if (!completeCheck) {
  88285. return true;
  88286. }
  88287. var engine = this.getEngine();
  88288. var scene = this.getScene();
  88289. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  88290. this.computeWorldMatrix();
  88291. var mat = this.material || scene.defaultMaterial;
  88292. if (mat) {
  88293. if (mat._storeEffectOnSubMeshes) {
  88294. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  88295. var subMesh = _a[_i];
  88296. var effectiveMaterial = subMesh.getMaterial();
  88297. if (effectiveMaterial) {
  88298. if (effectiveMaterial._storeEffectOnSubMeshes) {
  88299. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  88300. return false;
  88301. }
  88302. }
  88303. else {
  88304. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  88305. return false;
  88306. }
  88307. }
  88308. }
  88309. }
  88310. }
  88311. else {
  88312. if (!mat.isReady(this, hardwareInstancedRendering)) {
  88313. return false;
  88314. }
  88315. }
  88316. }
  88317. // Shadows
  88318. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  88319. var light = _c[_b];
  88320. var generator = light.getShadowGenerator();
  88321. if (generator) {
  88322. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  88323. var subMesh = _e[_d];
  88324. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  88325. return false;
  88326. }
  88327. }
  88328. }
  88329. }
  88330. // LOD
  88331. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  88332. var lod = _g[_f];
  88333. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  88334. return false;
  88335. }
  88336. }
  88337. return true;
  88338. };
  88339. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  88340. /**
  88341. * 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.
  88342. */
  88343. get: function () {
  88344. return this._areNormalsFrozen;
  88345. },
  88346. enumerable: true,
  88347. configurable: true
  88348. });
  88349. /**
  88350. * 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.
  88351. * @returns the current mesh
  88352. */
  88353. Mesh.prototype.freezeNormals = function () {
  88354. this._areNormalsFrozen = true;
  88355. return this;
  88356. };
  88357. /**
  88358. * 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
  88359. * @returns the current mesh
  88360. */
  88361. Mesh.prototype.unfreezeNormals = function () {
  88362. this._areNormalsFrozen = false;
  88363. return this;
  88364. };
  88365. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  88366. /**
  88367. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88368. */
  88369. set: function (count) {
  88370. this._instanceDataStorage.overridenInstanceCount = count;
  88371. },
  88372. enumerable: true,
  88373. configurable: true
  88374. });
  88375. // Methods
  88376. /** @hidden */
  88377. Mesh.prototype._preActivate = function () {
  88378. var sceneRenderId = this.getScene().getRenderId();
  88379. if (this._preActivateId === sceneRenderId) {
  88380. return this;
  88381. }
  88382. this._preActivateId = sceneRenderId;
  88383. this._instanceDataStorage.visibleInstances = null;
  88384. return this;
  88385. };
  88386. /** @hidden */
  88387. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  88388. if (this._instanceDataStorage.visibleInstances) {
  88389. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  88390. }
  88391. return this;
  88392. };
  88393. /** @hidden */
  88394. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  88395. if (!this._instanceDataStorage.visibleInstances) {
  88396. this._instanceDataStorage.visibleInstances = {
  88397. defaultRenderId: renderId,
  88398. selfDefaultRenderId: this._renderId
  88399. };
  88400. }
  88401. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  88402. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  88403. }
  88404. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  88405. return this;
  88406. };
  88407. /**
  88408. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88409. * This means the mesh underlying bounding box and sphere are recomputed.
  88410. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88411. * @returns the current mesh
  88412. */
  88413. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  88414. if (applySkeleton === void 0) { applySkeleton = false; }
  88415. if (this._boundingInfo && this._boundingInfo.isLocked) {
  88416. return this;
  88417. }
  88418. var bias = this.geometry ? this.geometry.boundingBias : null;
  88419. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  88420. return this;
  88421. };
  88422. /** @hidden */
  88423. Mesh.prototype._createGlobalSubMesh = function (force) {
  88424. var totalVertices = this.getTotalVertices();
  88425. if (!totalVertices || !this.getIndices()) {
  88426. return null;
  88427. }
  88428. // Check if we need to recreate the submeshes
  88429. if (this.subMeshes && this.subMeshes.length > 0) {
  88430. var ib = this.getIndices();
  88431. if (!ib) {
  88432. return null;
  88433. }
  88434. var totalIndices = ib.length;
  88435. var needToRecreate = false;
  88436. if (force) {
  88437. needToRecreate = true;
  88438. }
  88439. else {
  88440. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  88441. var submesh = _a[_i];
  88442. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  88443. needToRecreate = true;
  88444. break;
  88445. }
  88446. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  88447. needToRecreate = true;
  88448. break;
  88449. }
  88450. }
  88451. }
  88452. if (!needToRecreate) {
  88453. return this.subMeshes[0];
  88454. }
  88455. }
  88456. this.releaseSubMeshes();
  88457. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  88458. };
  88459. /**
  88460. * This function will subdivide the mesh into multiple submeshes
  88461. * @param count defines the expected number of submeshes
  88462. */
  88463. Mesh.prototype.subdivide = function (count) {
  88464. if (count < 1) {
  88465. return;
  88466. }
  88467. var totalIndices = this.getTotalIndices();
  88468. var subdivisionSize = (totalIndices / count) | 0;
  88469. var offset = 0;
  88470. // Ensure that subdivisionSize is a multiple of 3
  88471. while (subdivisionSize % 3 !== 0) {
  88472. subdivisionSize++;
  88473. }
  88474. this.releaseSubMeshes();
  88475. for (var index = 0; index < count; index++) {
  88476. if (offset >= totalIndices) {
  88477. break;
  88478. }
  88479. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  88480. offset += subdivisionSize;
  88481. }
  88482. this.synchronizeInstances();
  88483. };
  88484. /**
  88485. * Copy a FloatArray into a specific associated vertex buffer
  88486. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88487. * - VertexBuffer.PositionKind
  88488. * - VertexBuffer.UVKind
  88489. * - VertexBuffer.UV2Kind
  88490. * - VertexBuffer.UV3Kind
  88491. * - VertexBuffer.UV4Kind
  88492. * - VertexBuffer.UV5Kind
  88493. * - VertexBuffer.UV6Kind
  88494. * - VertexBuffer.ColorKind
  88495. * - VertexBuffer.MatricesIndicesKind
  88496. * - VertexBuffer.MatricesIndicesExtraKind
  88497. * - VertexBuffer.MatricesWeightsKind
  88498. * - VertexBuffer.MatricesWeightsExtraKind
  88499. * @param data defines the data source
  88500. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88501. * @param stride defines the data stride size (can be null)
  88502. * @returns the current mesh
  88503. */
  88504. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  88505. if (updatable === void 0) { updatable = false; }
  88506. if (!this._geometry) {
  88507. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  88508. vertexData.set(data, kind);
  88509. var scene = this.getScene();
  88510. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  88511. }
  88512. else {
  88513. this._geometry.setVerticesData(kind, data, updatable, stride);
  88514. }
  88515. return this;
  88516. };
  88517. /**
  88518. * Flags an associated vertex buffer as updatable
  88519. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88520. * - VertexBuffer.PositionKind
  88521. * - VertexBuffer.UVKind
  88522. * - VertexBuffer.UV2Kind
  88523. * - VertexBuffer.UV3Kind
  88524. * - VertexBuffer.UV4Kind
  88525. * - VertexBuffer.UV5Kind
  88526. * - VertexBuffer.UV6Kind
  88527. * - VertexBuffer.ColorKind
  88528. * - VertexBuffer.MatricesIndicesKind
  88529. * - VertexBuffer.MatricesIndicesExtraKind
  88530. * - VertexBuffer.MatricesWeightsKind
  88531. * - VertexBuffer.MatricesWeightsExtraKind
  88532. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88533. */
  88534. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  88535. if (updatable === void 0) { updatable = true; }
  88536. var vb = this.getVertexBuffer(kind);
  88537. if (!vb || vb.isUpdatable() === updatable) {
  88538. return;
  88539. }
  88540. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  88541. };
  88542. /**
  88543. * Sets the mesh global Vertex Buffer
  88544. * @param buffer defines the buffer to use
  88545. * @returns the current mesh
  88546. */
  88547. Mesh.prototype.setVerticesBuffer = function (buffer) {
  88548. if (!this._geometry) {
  88549. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  88550. }
  88551. this._geometry.setVerticesBuffer(buffer);
  88552. return this;
  88553. };
  88554. /**
  88555. * Update a specific associated vertex buffer
  88556. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88557. * - VertexBuffer.PositionKind
  88558. * - VertexBuffer.UVKind
  88559. * - VertexBuffer.UV2Kind
  88560. * - VertexBuffer.UV3Kind
  88561. * - VertexBuffer.UV4Kind
  88562. * - VertexBuffer.UV5Kind
  88563. * - VertexBuffer.UV6Kind
  88564. * - VertexBuffer.ColorKind
  88565. * - VertexBuffer.MatricesIndicesKind
  88566. * - VertexBuffer.MatricesIndicesExtraKind
  88567. * - VertexBuffer.MatricesWeightsKind
  88568. * - VertexBuffer.MatricesWeightsExtraKind
  88569. * @param data defines the data source
  88570. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88571. * @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)
  88572. * @returns the current mesh
  88573. */
  88574. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  88575. if (!this._geometry) {
  88576. return this;
  88577. }
  88578. if (!makeItUnique) {
  88579. this._geometry.updateVerticesData(kind, data, updateExtends);
  88580. }
  88581. else {
  88582. this.makeGeometryUnique();
  88583. this.updateVerticesData(kind, data, updateExtends, false);
  88584. }
  88585. return this;
  88586. };
  88587. /**
  88588. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88589. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88590. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88591. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88592. * @returns the current mesh
  88593. */
  88594. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  88595. if (computeNormals === void 0) { computeNormals = true; }
  88596. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88597. if (!positions) {
  88598. return this;
  88599. }
  88600. positionFunction(positions);
  88601. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  88602. if (computeNormals) {
  88603. var indices = this.getIndices();
  88604. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88605. if (!normals) {
  88606. return this;
  88607. }
  88608. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  88609. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  88610. }
  88611. return this;
  88612. };
  88613. /**
  88614. * Creates a un-shared specific occurence of the geometry for the mesh.
  88615. * @returns the current mesh
  88616. */
  88617. Mesh.prototype.makeGeometryUnique = function () {
  88618. if (!this._geometry) {
  88619. return this;
  88620. }
  88621. var oldGeometry = this._geometry;
  88622. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  88623. oldGeometry.releaseForMesh(this, true);
  88624. geometry.applyToMesh(this);
  88625. return this;
  88626. };
  88627. /**
  88628. * Set the index buffer of this mesh
  88629. * @param indices defines the source data
  88630. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88631. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88632. * @returns the current mesh
  88633. */
  88634. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  88635. if (totalVertices === void 0) { totalVertices = null; }
  88636. if (updatable === void 0) { updatable = false; }
  88637. if (!this._geometry) {
  88638. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  88639. vertexData.indices = indices;
  88640. var scene = this.getScene();
  88641. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  88642. }
  88643. else {
  88644. this._geometry.setIndices(indices, totalVertices, updatable);
  88645. }
  88646. return this;
  88647. };
  88648. /**
  88649. * Update the current index buffer
  88650. * @param indices defines the source data
  88651. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88652. * @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)
  88653. * @returns the current mesh
  88654. */
  88655. Mesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  88656. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  88657. if (!this._geometry) {
  88658. return this;
  88659. }
  88660. this._geometry.updateIndices(indices, offset, gpuMemoryOnly);
  88661. return this;
  88662. };
  88663. /**
  88664. * Invert the geometry to move from a right handed system to a left handed one.
  88665. * @returns the current mesh
  88666. */
  88667. Mesh.prototype.toLeftHanded = function () {
  88668. if (!this._geometry) {
  88669. return this;
  88670. }
  88671. this._geometry.toLeftHanded();
  88672. return this;
  88673. };
  88674. /** @hidden */
  88675. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  88676. if (!this._geometry) {
  88677. return this;
  88678. }
  88679. var engine = this.getScene().getEngine();
  88680. // Wireframe
  88681. var indexToBind;
  88682. if (this._unIndexed) {
  88683. indexToBind = null;
  88684. }
  88685. else {
  88686. switch (fillMode) {
  88687. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  88688. indexToBind = null;
  88689. break;
  88690. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  88691. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  88692. break;
  88693. default:
  88694. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  88695. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  88696. break;
  88697. }
  88698. }
  88699. // VBOs
  88700. this._geometry._bind(effect, indexToBind);
  88701. return this;
  88702. };
  88703. /** @hidden */
  88704. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  88705. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  88706. return this;
  88707. }
  88708. if (this._onBeforeDrawObservable) {
  88709. this._onBeforeDrawObservable.notifyObservers(this);
  88710. }
  88711. var scene = this.getScene();
  88712. var engine = scene.getEngine();
  88713. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  88714. // or triangles as points
  88715. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  88716. }
  88717. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  88718. // Triangles as wireframe
  88719. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  88720. }
  88721. else {
  88722. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  88723. }
  88724. return this;
  88725. };
  88726. /**
  88727. * Registers for this mesh a javascript function called just before the rendering process
  88728. * @param func defines the function to call before rendering this mesh
  88729. * @returns the current mesh
  88730. */
  88731. Mesh.prototype.registerBeforeRender = function (func) {
  88732. this.onBeforeRenderObservable.add(func);
  88733. return this;
  88734. };
  88735. /**
  88736. * Disposes a previously registered javascript function called before the rendering
  88737. * @param func defines the function to remove
  88738. * @returns the current mesh
  88739. */
  88740. Mesh.prototype.unregisterBeforeRender = function (func) {
  88741. this.onBeforeRenderObservable.removeCallback(func);
  88742. return this;
  88743. };
  88744. /**
  88745. * Registers for this mesh a javascript function called just after the rendering is complete
  88746. * @param func defines the function to call after rendering this mesh
  88747. * @returns the current mesh
  88748. */
  88749. Mesh.prototype.registerAfterRender = function (func) {
  88750. this.onAfterRenderObservable.add(func);
  88751. return this;
  88752. };
  88753. /**
  88754. * Disposes a previously registered javascript function called after the rendering.
  88755. * @param func defines the function to remove
  88756. * @returns the current mesh
  88757. */
  88758. Mesh.prototype.unregisterAfterRender = function (func) {
  88759. this.onAfterRenderObservable.removeCallback(func);
  88760. return this;
  88761. };
  88762. /** @hidden */
  88763. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  88764. if (this._instanceDataStorage.isFrozen && this._instanceDataStorage.previousBatch) {
  88765. return this._instanceDataStorage.previousBatch;
  88766. }
  88767. var scene = this.getScene();
  88768. var batchCache = this._instanceDataStorage.batchCache;
  88769. batchCache.mustReturn = false;
  88770. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  88771. batchCache.visibleInstances[subMeshId] = null;
  88772. if (this._instanceDataStorage.visibleInstances) {
  88773. var visibleInstances = this._instanceDataStorage.visibleInstances;
  88774. var currentRenderId = scene.getRenderId();
  88775. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  88776. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  88777. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  88778. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  88779. }
  88780. }
  88781. batchCache.hardwareInstancedRendering[subMeshId] = this._instanceDataStorage.hardwareInstancedRendering && (batchCache.visibleInstances[subMeshId] !== null) && (batchCache.visibleInstances[subMeshId] !== undefined);
  88782. this._instanceDataStorage.previousBatch = batchCache;
  88783. return batchCache;
  88784. };
  88785. /** @hidden */
  88786. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  88787. var visibleInstances = batch.visibleInstances[subMesh._id];
  88788. if (!visibleInstances) {
  88789. return this;
  88790. }
  88791. var instanceStorage = this._instanceDataStorage;
  88792. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  88793. var instancesBuffer = instanceStorage.instancesBuffer;
  88794. if (!instanceStorage.isFrozen || !instanceStorage.instancesData) {
  88795. var matricesCount = visibleInstances.length + 1;
  88796. var bufferSize = matricesCount * 16 * 4;
  88797. while (instanceStorage.instancesBufferSize < bufferSize) {
  88798. instanceStorage.instancesBufferSize *= 2;
  88799. }
  88800. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  88801. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  88802. }
  88803. }
  88804. var offset = 0;
  88805. var instancesCount = 0;
  88806. var world = this._effectiveMesh.getWorldMatrix();
  88807. if (batch.renderSelf[subMesh._id]) {
  88808. world.copyToArray(instanceStorage.instancesData, offset);
  88809. offset += 16;
  88810. instancesCount++;
  88811. }
  88812. if (visibleInstances) {
  88813. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  88814. var instance = visibleInstances[instanceIndex];
  88815. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  88816. offset += 16;
  88817. instancesCount++;
  88818. }
  88819. }
  88820. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  88821. if (instancesBuffer) {
  88822. instancesBuffer.dispose();
  88823. }
  88824. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  88825. instanceStorage.instancesBuffer = instancesBuffer;
  88826. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  88827. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  88828. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  88829. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  88830. }
  88831. else {
  88832. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  88833. }
  88834. this._bind(subMesh, effect, fillMode);
  88835. this._draw(subMesh, fillMode, instancesCount);
  88836. engine.unbindInstanceAttributes();
  88837. return this;
  88838. };
  88839. /** @hidden */
  88840. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  88841. var scene = this.getScene();
  88842. var engine = scene.getEngine();
  88843. if (hardwareInstancedRendering) {
  88844. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  88845. }
  88846. else {
  88847. if (batch.renderSelf[subMesh._id]) {
  88848. // Draw
  88849. if (onBeforeDraw) {
  88850. onBeforeDraw(false, this._effectiveMesh.getWorldMatrix(), effectiveMaterial);
  88851. }
  88852. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  88853. }
  88854. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  88855. if (visibleInstancesForSubMesh) {
  88856. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  88857. var instance = visibleInstancesForSubMesh[instanceIndex];
  88858. // World
  88859. var world = instance.getWorldMatrix();
  88860. if (onBeforeDraw) {
  88861. onBeforeDraw(true, world, effectiveMaterial);
  88862. }
  88863. // Draw
  88864. this._draw(subMesh, fillMode);
  88865. }
  88866. }
  88867. }
  88868. return this;
  88869. };
  88870. /** @hidden */
  88871. Mesh.prototype._freeze = function () {
  88872. this._instanceDataStorage.isFrozen = true;
  88873. if (!this.subMeshes) {
  88874. return;
  88875. }
  88876. // Prepare batches
  88877. for (var index = 0; index < this.subMeshes.length; index++) {
  88878. this._getInstancesRenderList(index);
  88879. }
  88880. };
  88881. /** @hidden */
  88882. Mesh.prototype._unFreeze = function () {
  88883. this._instanceDataStorage.isFrozen = false;
  88884. };
  88885. /**
  88886. * 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
  88887. * @param subMesh defines the subMesh to render
  88888. * @param enableAlphaMode defines if alpha mode can be changed
  88889. * @returns the current mesh
  88890. */
  88891. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  88892. if (this._checkOcclusionQuery()) {
  88893. return this;
  88894. }
  88895. var scene = this.getScene();
  88896. // Managing instances
  88897. var batch = this._getInstancesRenderList(subMesh._id);
  88898. if (batch.mustReturn) {
  88899. return this;
  88900. }
  88901. // Checking geometry state
  88902. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  88903. return this;
  88904. }
  88905. if (this._onBeforeRenderObservable) {
  88906. this._onBeforeRenderObservable.notifyObservers(this);
  88907. }
  88908. var engine = scene.getEngine();
  88909. var hardwareInstancedRendering = batch.hardwareInstancedRendering[subMesh._id];
  88910. var instanceDataStorage = this._instanceDataStorage;
  88911. // Material
  88912. if (!instanceDataStorage.isFrozen || !this._effectiveMaterial) {
  88913. var material = subMesh.getMaterial();
  88914. if (!material) {
  88915. return this;
  88916. }
  88917. this._effectiveMaterial = material;
  88918. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  88919. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  88920. return this;
  88921. }
  88922. }
  88923. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  88924. return this;
  88925. }
  88926. }
  88927. // Alpha mode
  88928. if (enableAlphaMode) {
  88929. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  88930. }
  88931. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  88932. var step = _a[_i];
  88933. step.action(this, subMesh, batch);
  88934. }
  88935. var effect;
  88936. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  88937. effect = subMesh.effect;
  88938. }
  88939. else {
  88940. effect = this._effectiveMaterial.getEffect();
  88941. }
  88942. if (!effect) {
  88943. return this;
  88944. }
  88945. var effectiveMesh = this._effectiveMesh;
  88946. var sideOrientation;
  88947. if (!instanceDataStorage.isFrozen) {
  88948. sideOrientation = this.overrideMaterialSideOrientation;
  88949. if (sideOrientation == null) {
  88950. sideOrientation = this._effectiveMaterial.sideOrientation;
  88951. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  88952. 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);
  88953. }
  88954. }
  88955. instanceDataStorage.sideOrientation = sideOrientation;
  88956. }
  88957. else {
  88958. sideOrientation = instanceDataStorage.sideOrientation;
  88959. }
  88960. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  88961. if (this._effectiveMaterial.forceDepthWrite) {
  88962. engine.setDepthWrite(true);
  88963. }
  88964. // Bind
  88965. 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);
  88966. if (this._onBeforeBindObservable) {
  88967. this._onBeforeBindObservable.notifyObservers(this);
  88968. }
  88969. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  88970. this._bind(subMesh, effect, fillMode);
  88971. }
  88972. var world = effectiveMesh.getWorldMatrix();
  88973. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  88974. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  88975. }
  88976. else {
  88977. this._effectiveMaterial.bind(world, this);
  88978. }
  88979. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  88980. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  88981. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  88982. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  88983. }
  88984. // Draw
  88985. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  88986. // Unbind
  88987. this._effectiveMaterial.unbind();
  88988. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  88989. var step = _c[_b];
  88990. step.action(this, subMesh, batch);
  88991. }
  88992. if (this._onAfterRenderObservable) {
  88993. this._onAfterRenderObservable.notifyObservers(this);
  88994. }
  88995. return this;
  88996. };
  88997. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  88998. if (isInstance && effectiveMaterial) {
  88999. effectiveMaterial.bindOnlyWorldMatrix(world);
  89000. }
  89001. };
  89002. /**
  89003. * Renormalize the mesh and patch it up if there are no weights
  89004. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89005. * However in the case of zero weights then we set just a single influence to 1.
  89006. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89007. */
  89008. Mesh.prototype.cleanMatrixWeights = function () {
  89009. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  89010. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  89011. this.normalizeSkinWeightsAndExtra();
  89012. }
  89013. else {
  89014. this.normalizeSkinFourWeights();
  89015. }
  89016. }
  89017. };
  89018. // faster 4 weight version.
  89019. Mesh.prototype.normalizeSkinFourWeights = function () {
  89020. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  89021. var numWeights = matricesWeights.length;
  89022. for (var a = 0; a < numWeights; a += 4) {
  89023. // accumulate weights
  89024. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  89025. // check for invalid weight and just set it to 1.
  89026. if (t === 0) {
  89027. matricesWeights[a] = 1;
  89028. }
  89029. else {
  89030. // renormalize so everything adds to 1 use reciprical
  89031. var recip = 1 / t;
  89032. matricesWeights[a] *= recip;
  89033. matricesWeights[a + 1] *= recip;
  89034. matricesWeights[a + 2] *= recip;
  89035. matricesWeights[a + 3] *= recip;
  89036. }
  89037. }
  89038. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  89039. };
  89040. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  89041. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  89042. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  89043. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  89044. var numWeights = matricesWeights.length;
  89045. for (var a = 0; a < numWeights; a += 4) {
  89046. // accumulate weights
  89047. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  89048. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  89049. // check for invalid weight and just set it to 1.
  89050. if (t === 0) {
  89051. matricesWeights[a] = 1;
  89052. }
  89053. else {
  89054. // renormalize so everything adds to 1 use reciprical
  89055. var recip = 1 / t;
  89056. matricesWeights[a] *= recip;
  89057. matricesWeights[a + 1] *= recip;
  89058. matricesWeights[a + 2] *= recip;
  89059. matricesWeights[a + 3] *= recip;
  89060. // same goes for extras
  89061. matricesWeightsExtra[a] *= recip;
  89062. matricesWeightsExtra[a + 1] *= recip;
  89063. matricesWeightsExtra[a + 2] *= recip;
  89064. matricesWeightsExtra[a + 3] *= recip;
  89065. }
  89066. }
  89067. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  89068. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  89069. };
  89070. /**
  89071. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89072. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89073. * the user know there was an issue with importing the mesh
  89074. * @returns a validation object with skinned, valid and report string
  89075. */
  89076. Mesh.prototype.validateSkinning = function () {
  89077. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  89078. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  89079. if (matricesWeights === null || this.skeleton == null) {
  89080. return { skinned: false, valid: true, report: "not skinned" };
  89081. }
  89082. var numWeights = matricesWeights.length;
  89083. var numberNotSorted = 0;
  89084. var missingWeights = 0;
  89085. var maxUsedWeights = 0;
  89086. var numberNotNormalized = 0;
  89087. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  89088. var usedWeightCounts = new Array();
  89089. for (var a = 0; a <= numInfluences; a++) {
  89090. usedWeightCounts[a] = 0;
  89091. }
  89092. var toleranceEpsilon = 0.001;
  89093. for (var a = 0; a < numWeights; a += 4) {
  89094. var lastWeight = matricesWeights[a];
  89095. var t = lastWeight;
  89096. var usedWeights = t === 0 ? 0 : 1;
  89097. for (var b = 1; b < numInfluences; b++) {
  89098. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  89099. if (d > lastWeight) {
  89100. numberNotSorted++;
  89101. }
  89102. if (d !== 0) {
  89103. usedWeights++;
  89104. }
  89105. t += d;
  89106. lastWeight = d;
  89107. }
  89108. // count the buffer weights usage
  89109. usedWeightCounts[usedWeights]++;
  89110. // max influences
  89111. if (usedWeights > maxUsedWeights) {
  89112. maxUsedWeights = usedWeights;
  89113. }
  89114. // check for invalid weight and just set it to 1.
  89115. if (t === 0) {
  89116. missingWeights++;
  89117. }
  89118. else {
  89119. // renormalize so everything adds to 1 use reciprical
  89120. var recip = 1 / t;
  89121. var tolerance = 0;
  89122. for (b = 0; b < numInfluences; b++) {
  89123. if (b < 4) {
  89124. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  89125. }
  89126. else {
  89127. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  89128. }
  89129. }
  89130. // arbitary epsilon value for dicdating not normalized
  89131. if (tolerance > toleranceEpsilon) {
  89132. numberNotNormalized++;
  89133. }
  89134. }
  89135. }
  89136. // validate bone indices are in range of the skeleton
  89137. var numBones = this.skeleton.bones.length;
  89138. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  89139. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  89140. var numBadBoneIndices = 0;
  89141. for (var a = 0; a < numWeights; a++) {
  89142. for (var b = 0; b < numInfluences; b++) {
  89143. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  89144. if (index >= numBones || index < 0) {
  89145. numBadBoneIndices++;
  89146. }
  89147. }
  89148. }
  89149. // log mesh stats
  89150. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  89151. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  89152. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  89153. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  89154. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  89155. };
  89156. /** @hidden */
  89157. Mesh.prototype._checkDelayState = function () {
  89158. var scene = this.getScene();
  89159. if (this._geometry) {
  89160. this._geometry.load(scene);
  89161. }
  89162. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  89163. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  89164. this._queueLoad(scene);
  89165. }
  89166. return this;
  89167. };
  89168. Mesh.prototype._queueLoad = function (scene) {
  89169. var _this = this;
  89170. scene._addPendingData(this);
  89171. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  89172. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  89173. if (data instanceof ArrayBuffer) {
  89174. _this._delayLoadingFunction(data, _this);
  89175. }
  89176. else {
  89177. _this._delayLoadingFunction(JSON.parse(data), _this);
  89178. }
  89179. _this.instances.forEach(function (instance) {
  89180. instance._syncSubMeshes();
  89181. });
  89182. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  89183. scene._removePendingData(_this);
  89184. }, function () { }, scene.offlineProvider, getBinaryData);
  89185. return this;
  89186. };
  89187. /**
  89188. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89189. * A mesh is in the frustum if its bounding box intersects the frustum
  89190. * @param frustumPlanes defines the frustum to test
  89191. * @returns true if the mesh is in the frustum planes
  89192. */
  89193. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  89194. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  89195. return false;
  89196. }
  89197. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  89198. return false;
  89199. }
  89200. this._checkDelayState();
  89201. return true;
  89202. };
  89203. /**
  89204. * Sets the mesh material by the material or multiMaterial `id` property
  89205. * @param id is a string identifying the material or the multiMaterial
  89206. * @returns the current mesh
  89207. */
  89208. Mesh.prototype.setMaterialByID = function (id) {
  89209. var materials = this.getScene().materials;
  89210. var index;
  89211. for (index = materials.length - 1; index > -1; index--) {
  89212. if (materials[index].id === id) {
  89213. this.material = materials[index];
  89214. return this;
  89215. }
  89216. }
  89217. // Multi
  89218. var multiMaterials = this.getScene().multiMaterials;
  89219. for (index = multiMaterials.length - 1; index > -1; index--) {
  89220. if (multiMaterials[index].id === id) {
  89221. this.material = multiMaterials[index];
  89222. return this;
  89223. }
  89224. }
  89225. return this;
  89226. };
  89227. /**
  89228. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89229. * @returns an array of IAnimatable
  89230. */
  89231. Mesh.prototype.getAnimatables = function () {
  89232. var results = new Array();
  89233. if (this.material) {
  89234. results.push(this.material);
  89235. }
  89236. if (this.skeleton) {
  89237. results.push(this.skeleton);
  89238. }
  89239. return results;
  89240. };
  89241. /**
  89242. * Modifies the mesh geometry according to the passed transformation matrix.
  89243. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89244. * The mesh normals are modified using the same transformation.
  89245. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89246. * @param transform defines the transform matrix to use
  89247. * @see http://doc.babylonjs.com/resources/baking_transformations
  89248. * @returns the current mesh
  89249. */
  89250. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  89251. // Position
  89252. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  89253. return this;
  89254. }
  89255. var submeshes = this.subMeshes.splice(0);
  89256. this._resetPointsArrayCache();
  89257. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89258. var temp = new Array();
  89259. var index;
  89260. for (index = 0; index < data.length; index += 3) {
  89261. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  89262. }
  89263. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  89264. // Normals
  89265. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  89266. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  89267. temp = [];
  89268. for (index = 0; index < data.length; index += 3) {
  89269. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  89270. }
  89271. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  89272. }
  89273. // flip faces?
  89274. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  89275. this.flipFaces();
  89276. }
  89277. // Restore submeshes
  89278. this.releaseSubMeshes();
  89279. this.subMeshes = submeshes;
  89280. return this;
  89281. };
  89282. /**
  89283. * Modifies the mesh geometry according to its own current World Matrix.
  89284. * The mesh World Matrix is then reset.
  89285. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89286. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89287. * @see http://doc.babylonjs.com/resources/baking_transformations
  89288. * @returns the current mesh
  89289. */
  89290. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  89291. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  89292. this.scaling.copyFromFloats(1, 1, 1);
  89293. this.position.copyFromFloats(0, 0, 0);
  89294. this.rotation.copyFromFloats(0, 0, 0);
  89295. //only if quaternion is already set
  89296. if (this.rotationQuaternion) {
  89297. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  89298. }
  89299. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  89300. return this;
  89301. };
  89302. Object.defineProperty(Mesh.prototype, "_positions", {
  89303. // Cache
  89304. /** @hidden */
  89305. get: function () {
  89306. if (this._geometry) {
  89307. return this._geometry._positions;
  89308. }
  89309. return null;
  89310. },
  89311. enumerable: true,
  89312. configurable: true
  89313. });
  89314. /** @hidden */
  89315. Mesh.prototype._resetPointsArrayCache = function () {
  89316. if (this._geometry) {
  89317. this._geometry._resetPointsArrayCache();
  89318. }
  89319. return this;
  89320. };
  89321. /** @hidden */
  89322. Mesh.prototype._generatePointsArray = function () {
  89323. if (this._geometry) {
  89324. return this._geometry._generatePointsArray();
  89325. }
  89326. return false;
  89327. };
  89328. /**
  89329. * Returns a new Mesh object generated from the current mesh properties.
  89330. * This method must not get confused with createInstance()
  89331. * @param name is a string, the name given to the new mesh
  89332. * @param newParent can be any Node object (default `null`)
  89333. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89334. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89335. * @returns a new mesh
  89336. */
  89337. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  89338. if (name === void 0) { name = ""; }
  89339. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  89340. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  89341. };
  89342. /**
  89343. * Releases resources associated with this mesh.
  89344. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89345. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89346. */
  89347. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  89348. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  89349. this.morphTargetManager = null;
  89350. if (this._geometry) {
  89351. this._geometry.releaseForMesh(this, true);
  89352. }
  89353. if (this._onBeforeDrawObservable) {
  89354. this._onBeforeDrawObservable.clear();
  89355. }
  89356. if (this._onBeforeBindObservable) {
  89357. this._onBeforeBindObservable.clear();
  89358. }
  89359. if (this._onBeforeRenderObservable) {
  89360. this._onBeforeRenderObservable.clear();
  89361. }
  89362. if (this._onAfterRenderObservable) {
  89363. this._onAfterRenderObservable.clear();
  89364. }
  89365. // Sources
  89366. if (this._scene.useClonedMeshhMap) {
  89367. if (this.meshMap) {
  89368. for (var uniqueId in this.meshMap) {
  89369. var mesh = this.meshMap[uniqueId];
  89370. if (mesh) {
  89371. mesh._source = null;
  89372. this.meshMap[uniqueId] = undefined;
  89373. }
  89374. }
  89375. }
  89376. if (this._source && this._source.meshMap) {
  89377. this._source.meshMap[this.uniqueId] = undefined;
  89378. }
  89379. }
  89380. else {
  89381. var meshes = this.getScene().meshes;
  89382. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  89383. var abstractMesh = meshes_1[_i];
  89384. var mesh = abstractMesh;
  89385. if (mesh._source && mesh._source === this) {
  89386. mesh._source = null;
  89387. }
  89388. }
  89389. }
  89390. this._source = null;
  89391. // Instances
  89392. if (this._instanceDataStorage.instancesBuffer) {
  89393. this._instanceDataStorage.instancesBuffer.dispose();
  89394. this._instanceDataStorage.instancesBuffer = null;
  89395. }
  89396. while (this.instances.length) {
  89397. this.instances[0].dispose();
  89398. }
  89399. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  89400. };
  89401. /**
  89402. * Modifies the mesh geometry according to a displacement map.
  89403. * 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.
  89404. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89405. * @param url is a string, the URL from the image file is to be downloaded.
  89406. * @param minHeight is the lower limit of the displacement.
  89407. * @param maxHeight is the upper limit of the displacement.
  89408. * @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.
  89409. * @param uvOffset is an optional vector2 used to offset UV.
  89410. * @param uvScale is an optional vector2 used to scale UV.
  89411. * @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.
  89412. * @returns the Mesh.
  89413. */
  89414. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  89415. var _this = this;
  89416. if (forceUpdate === void 0) { forceUpdate = false; }
  89417. var scene = this.getScene();
  89418. var onload = function (img) {
  89419. // Getting height map data
  89420. var canvas = document.createElement("canvas");
  89421. var context = canvas.getContext("2d");
  89422. var heightMapWidth = img.width;
  89423. var heightMapHeight = img.height;
  89424. canvas.width = heightMapWidth;
  89425. canvas.height = heightMapHeight;
  89426. context.drawImage(img, 0, 0);
  89427. // Create VertexData from map data
  89428. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  89429. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  89430. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  89431. //execute success callback, if set
  89432. if (onSuccess) {
  89433. onSuccess(_this);
  89434. }
  89435. };
  89436. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  89437. return this;
  89438. };
  89439. /**
  89440. * Modifies the mesh geometry according to a displacementMap buffer.
  89441. * 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.
  89442. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89443. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89444. * @param heightMapWidth is the width of the buffer image.
  89445. * @param heightMapHeight is the height of the buffer image.
  89446. * @param minHeight is the lower limit of the displacement.
  89447. * @param maxHeight is the upper limit of the displacement.
  89448. * @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.
  89449. * @param uvOffset is an optional vector2 used to offset UV.
  89450. * @param uvScale is an optional vector2 used to scale UV.
  89451. * @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.
  89452. * @returns the Mesh.
  89453. */
  89454. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  89455. if (forceUpdate === void 0) { forceUpdate = false; }
  89456. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  89457. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  89458. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  89459. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  89460. return this;
  89461. }
  89462. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  89463. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  89464. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  89465. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  89466. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  89467. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  89468. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  89469. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  89470. for (var index = 0; index < positions.length; index += 3) {
  89471. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  89472. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  89473. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  89474. // Compute height
  89475. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  89476. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  89477. var pos = (u + v * heightMapWidth) * 4;
  89478. var r = buffer[pos] / 255.0;
  89479. var g = buffer[pos + 1] / 255.0;
  89480. var b = buffer[pos + 2] / 255.0;
  89481. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  89482. normal.normalize();
  89483. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  89484. position = position.add(normal);
  89485. position.toArray(positions, index);
  89486. }
  89487. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  89488. if (forceUpdate) {
  89489. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  89490. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  89491. }
  89492. else {
  89493. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  89494. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  89495. }
  89496. return this;
  89497. };
  89498. /**
  89499. * Modify the mesh to get a flat shading rendering.
  89500. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89501. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89502. * @returns current mesh
  89503. */
  89504. Mesh.prototype.convertToFlatShadedMesh = function () {
  89505. var kinds = this.getVerticesDataKinds();
  89506. var vbs = {};
  89507. var data = {};
  89508. var newdata = {};
  89509. var updatableNormals = false;
  89510. var kindIndex;
  89511. var kind;
  89512. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89513. kind = kinds[kindIndex];
  89514. var vertexBuffer = this.getVertexBuffer(kind);
  89515. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  89516. updatableNormals = vertexBuffer.isUpdatable();
  89517. kinds.splice(kindIndex, 1);
  89518. kindIndex--;
  89519. continue;
  89520. }
  89521. vbs[kind] = vertexBuffer;
  89522. data[kind] = vbs[kind].getData();
  89523. newdata[kind] = [];
  89524. }
  89525. // Save previous submeshes
  89526. var previousSubmeshes = this.subMeshes.slice(0);
  89527. var indices = this.getIndices();
  89528. var totalIndices = this.getTotalIndices();
  89529. // Generating unique vertices per face
  89530. var index;
  89531. for (index = 0; index < totalIndices; index++) {
  89532. var vertexIndex = indices[index];
  89533. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89534. kind = kinds[kindIndex];
  89535. var stride = vbs[kind].getStrideSize();
  89536. for (var offset = 0; offset < stride; offset++) {
  89537. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  89538. }
  89539. }
  89540. }
  89541. // Updating faces & normal
  89542. var normals = [];
  89543. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  89544. for (index = 0; index < totalIndices; index += 3) {
  89545. indices[index] = index;
  89546. indices[index + 1] = index + 1;
  89547. indices[index + 2] = index + 2;
  89548. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  89549. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  89550. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  89551. var p1p2 = p1.subtract(p2);
  89552. var p3p2 = p3.subtract(p2);
  89553. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  89554. // Store same normals for every vertex
  89555. for (var localIndex = 0; localIndex < 3; localIndex++) {
  89556. normals.push(normal.x);
  89557. normals.push(normal.y);
  89558. normals.push(normal.z);
  89559. }
  89560. }
  89561. this.setIndices(indices);
  89562. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  89563. // Updating vertex buffers
  89564. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89565. kind = kinds[kindIndex];
  89566. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  89567. }
  89568. // Updating submeshes
  89569. this.releaseSubMeshes();
  89570. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  89571. var previousOne = previousSubmeshes[submeshIndex];
  89572. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  89573. }
  89574. this.synchronizeInstances();
  89575. return this;
  89576. };
  89577. /**
  89578. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89579. * In other words, more vertices, no more indices and a single bigger VBO.
  89580. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89581. * @returns current mesh
  89582. */
  89583. Mesh.prototype.convertToUnIndexedMesh = function () {
  89584. var kinds = this.getVerticesDataKinds();
  89585. var vbs = {};
  89586. var data = {};
  89587. var newdata = {};
  89588. var kindIndex;
  89589. var kind;
  89590. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89591. kind = kinds[kindIndex];
  89592. var vertexBuffer = this.getVertexBuffer(kind);
  89593. vbs[kind] = vertexBuffer;
  89594. data[kind] = vbs[kind].getData();
  89595. newdata[kind] = [];
  89596. }
  89597. // Save previous submeshes
  89598. var previousSubmeshes = this.subMeshes.slice(0);
  89599. var indices = this.getIndices();
  89600. var totalIndices = this.getTotalIndices();
  89601. // Generating unique vertices per face
  89602. var index;
  89603. for (index = 0; index < totalIndices; index++) {
  89604. var vertexIndex = indices[index];
  89605. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89606. kind = kinds[kindIndex];
  89607. var stride = vbs[kind].getStrideSize();
  89608. for (var offset = 0; offset < stride; offset++) {
  89609. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  89610. }
  89611. }
  89612. }
  89613. // Updating indices
  89614. for (index = 0; index < totalIndices; index += 3) {
  89615. indices[index] = index;
  89616. indices[index + 1] = index + 1;
  89617. indices[index + 2] = index + 2;
  89618. }
  89619. this.setIndices(indices);
  89620. // Updating vertex buffers
  89621. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89622. kind = kinds[kindIndex];
  89623. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  89624. }
  89625. // Updating submeshes
  89626. this.releaseSubMeshes();
  89627. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  89628. var previousOne = previousSubmeshes[submeshIndex];
  89629. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  89630. }
  89631. this._unIndexed = true;
  89632. this.synchronizeInstances();
  89633. return this;
  89634. };
  89635. /**
  89636. * Inverses facet orientations.
  89637. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89638. * @param flipNormals will also inverts the normals
  89639. * @returns current mesh
  89640. */
  89641. Mesh.prototype.flipFaces = function (flipNormals) {
  89642. if (flipNormals === void 0) { flipNormals = false; }
  89643. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  89644. var i;
  89645. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  89646. for (i = 0; i < vertex_data.normals.length; i++) {
  89647. vertex_data.normals[i] *= -1;
  89648. }
  89649. }
  89650. if (vertex_data.indices) {
  89651. var temp;
  89652. for (i = 0; i < vertex_data.indices.length; i += 3) {
  89653. // reassign indices
  89654. temp = vertex_data.indices[i + 1];
  89655. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  89656. vertex_data.indices[i + 2] = temp;
  89657. }
  89658. }
  89659. vertex_data.applyToMesh(this);
  89660. return this;
  89661. };
  89662. /**
  89663. * Increase the number of facets and hence vertices in a mesh
  89664. * Vertex normals are interpolated from existing vertex normals
  89665. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89666. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89667. */
  89668. Mesh.prototype.increaseVertices = function (numberPerEdge) {
  89669. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  89670. var uvs = vertex_data.uvs;
  89671. var currentIndices = vertex_data.indices;
  89672. var positions = vertex_data.positions;
  89673. var normals = vertex_data.normals;
  89674. if (currentIndices === null || positions === null || normals === null || uvs === null) {
  89675. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  89676. }
  89677. else {
  89678. var segments = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
  89679. var tempIndices = new Array();
  89680. for (var i = 0; i < segments + 1; i++) {
  89681. tempIndices[i] = new Array();
  89682. }
  89683. var a; //vertex index of one end of a side
  89684. var b; //vertex index of other end of the side
  89685. var deltaPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  89686. var deltaNormal = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  89687. var deltaUV = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 0);
  89688. var indices = new Array();
  89689. var vertexIndex = new Array();
  89690. var side = new Array();
  89691. var len;
  89692. var positionPtr = positions.length;
  89693. var uvPtr = uvs.length;
  89694. for (var i = 0; i < currentIndices.length; i += 3) {
  89695. vertexIndex[0] = currentIndices[i];
  89696. vertexIndex[1] = currentIndices[i + 1];
  89697. vertexIndex[2] = currentIndices[i + 2];
  89698. for (var j = 0; j < 3; j++) {
  89699. a = vertexIndex[j];
  89700. b = vertexIndex[(j + 1) % 3];
  89701. if (side[a] === undefined && side[b] === undefined) {
  89702. side[a] = new Array();
  89703. side[b] = new Array();
  89704. }
  89705. else {
  89706. if (side[a] === undefined) {
  89707. side[a] = new Array();
  89708. }
  89709. if (side[b] === undefined) {
  89710. side[b] = new Array();
  89711. }
  89712. }
  89713. if (side[a][b] === undefined && side[b][a] === undefined) {
  89714. side[a][b] = [];
  89715. deltaPosition.x = (positions[3 * b] - positions[3 * a]) / segments;
  89716. deltaPosition.y = (positions[3 * b + 1] - positions[3 * a + 1]) / segments;
  89717. deltaPosition.z = (positions[3 * b + 2] - positions[3 * a + 2]) / segments;
  89718. deltaNormal.x = (normals[3 * b] - normals[3 * a]) / segments;
  89719. deltaNormal.y = (normals[3 * b + 1] - normals[3 * a + 1]) / segments;
  89720. deltaNormal.z = (normals[3 * b + 2] - normals[3 * a + 2]) / segments;
  89721. deltaUV.x = (uvs[2 * b] - uvs[2 * a]) / segments;
  89722. deltaUV.y = (uvs[2 * b + 1] - uvs[2 * a + 1]) / segments;
  89723. side[a][b].push(a);
  89724. for (var k = 1; k < segments; k++) {
  89725. side[a][b].push(positions.length / 3);
  89726. positions[positionPtr] = positions[3 * a] + k * deltaPosition.x;
  89727. normals[positionPtr++] = normals[3 * a] + k * deltaNormal.x;
  89728. positions[positionPtr] = positions[3 * a + 1] + k * deltaPosition.y;
  89729. normals[positionPtr++] = normals[3 * a + 1] + k * deltaNormal.y;
  89730. positions[positionPtr] = positions[3 * a + 2] + k * deltaPosition.z;
  89731. normals[positionPtr++] = normals[3 * a + 2] + k * deltaNormal.z;
  89732. uvs[uvPtr++] = uvs[2 * a] + k * deltaUV.x;
  89733. uvs[uvPtr++] = uvs[2 * a + 1] + k * deltaUV.y;
  89734. }
  89735. side[a][b].push(b);
  89736. side[b][a] = new Array();
  89737. len = side[a][b].length;
  89738. for (var idx = 0; idx < len; idx++) {
  89739. side[b][a][idx] = side[a][b][len - 1 - idx];
  89740. }
  89741. }
  89742. }
  89743. //Calculate positions, normals and uvs of new internal vertices
  89744. tempIndices[0][0] = currentIndices[i];
  89745. tempIndices[1][0] = side[currentIndices[i]][currentIndices[i + 1]][1];
  89746. tempIndices[1][1] = side[currentIndices[i]][currentIndices[i + 2]][1];
  89747. for (var k = 2; k < segments; k++) {
  89748. tempIndices[k][0] = side[currentIndices[i]][currentIndices[i + 1]][k];
  89749. tempIndices[k][k] = side[currentIndices[i]][currentIndices[i + 2]][k];
  89750. deltaPosition.x = (positions[3 * tempIndices[k][k]] - positions[3 * tempIndices[k][0]]) / k;
  89751. deltaPosition.y = (positions[3 * tempIndices[k][k] + 1] - positions[3 * tempIndices[k][0] + 1]) / k;
  89752. deltaPosition.z = (positions[3 * tempIndices[k][k] + 2] - positions[3 * tempIndices[k][0] + 2]) / k;
  89753. deltaNormal.x = (normals[3 * tempIndices[k][k]] - normals[3 * tempIndices[k][0]]) / k;
  89754. deltaNormal.y = (normals[3 * tempIndices[k][k] + 1] - normals[3 * tempIndices[k][0] + 1]) / k;
  89755. deltaNormal.z = (normals[3 * tempIndices[k][k] + 2] - normals[3 * tempIndices[k][0] + 2]) / k;
  89756. deltaUV.x = (uvs[2 * tempIndices[k][k]] - uvs[2 * tempIndices[k][0]]) / k;
  89757. deltaUV.y = (uvs[2 * tempIndices[k][k] + 1] - uvs[2 * tempIndices[k][0] + 1]) / k;
  89758. for (var j = 1; j < k; j++) {
  89759. tempIndices[k][j] = positions.length / 3;
  89760. positions[positionPtr] = positions[3 * tempIndices[k][0]] + j * deltaPosition.x;
  89761. normals[positionPtr++] = normals[3 * tempIndices[k][0]] + j * deltaNormal.x;
  89762. positions[positionPtr] = positions[3 * tempIndices[k][0] + 1] + j * deltaPosition.y;
  89763. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 1] + j * deltaNormal.y;
  89764. positions[positionPtr] = positions[3 * tempIndices[k][0] + 2] + j * deltaPosition.z;
  89765. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 2] + j * deltaNormal.z;
  89766. uvs[uvPtr++] = uvs[2 * tempIndices[k][0]] + j * deltaUV.x;
  89767. uvs[uvPtr++] = uvs[2 * tempIndices[k][0] + 1] + j * deltaUV.y;
  89768. }
  89769. }
  89770. tempIndices[segments] = side[currentIndices[i + 1]][currentIndices[i + 2]];
  89771. // reform indices
  89772. indices.push(tempIndices[0][0], tempIndices[1][0], tempIndices[1][1]);
  89773. for (var k = 1; k < segments; k++) {
  89774. for (var j = 0; j < k; j++) {
  89775. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  89776. indices.push(tempIndices[k][j], tempIndices[k + 1][j + 1], tempIndices[k][j + 1]);
  89777. }
  89778. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  89779. }
  89780. }
  89781. vertex_data.indices = indices;
  89782. vertex_data.applyToMesh(this);
  89783. }
  89784. };
  89785. /**
  89786. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89787. * This will undo any application of covertToFlatShadedMesh
  89788. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89789. */
  89790. Mesh.prototype.forceSharedVertices = function () {
  89791. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  89792. var currentUVs = vertex_data.uvs;
  89793. var currentIndices = vertex_data.indices;
  89794. var currentPositions = vertex_data.positions;
  89795. var currentNormals = vertex_data.normals;
  89796. if (currentIndices === null || currentPositions === null || currentNormals === null || currentUVs === null) {
  89797. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  89798. }
  89799. else {
  89800. var positions = new Array();
  89801. var indices = new Array();
  89802. var uvs = new Array();
  89803. var pstring = new Array(); //lists facet vertex positions (a,b,c) as string "a|b|c"
  89804. var indexPtr = 0; // pointer to next available index value
  89805. var uniquePositions = new Array(); // unique vertex positions
  89806. var ptr; // pointer to element in uniquePositions
  89807. var facet;
  89808. for (var i = 0; i < currentIndices.length; i += 3) {
  89809. facet = [currentIndices[i], currentIndices[i + 1], currentIndices[i + 2]]; //facet vertex indices
  89810. pstring = new Array();
  89811. for (var j = 0; j < 3; j++) {
  89812. pstring[j] = "";
  89813. for (var k = 0; k < 3; k++) {
  89814. //small values make 0
  89815. if (Math.abs(currentPositions[3 * facet[j] + k]) < 0.00000001) {
  89816. currentPositions[3 * facet[j] + k] = 0;
  89817. }
  89818. pstring[j] += currentPositions[3 * facet[j] + k] + "|";
  89819. }
  89820. pstring[j] = pstring[j].slice(0, -1);
  89821. }
  89822. //check facet vertices to see that none are repeated
  89823. // do not process any facet that has a repeated vertex, ie is a line
  89824. if (!(pstring[0] == pstring[1] || pstring[0] == pstring[2] || pstring[1] == pstring[2])) {
  89825. //for each facet position check if already listed in uniquePositions
  89826. // if not listed add to uniquePositions and set index pointer
  89827. // if listed use its index in uniquePositions and new index pointer
  89828. for (var j = 0; j < 3; j++) {
  89829. ptr = uniquePositions.indexOf(pstring[j]);
  89830. if (ptr < 0) {
  89831. uniquePositions.push(pstring[j]);
  89832. ptr = indexPtr++;
  89833. //not listed so add individual x, y, z coordinates to positions
  89834. for (var k = 0; k < 3; k++) {
  89835. positions.push(currentPositions[3 * facet[j] + k]);
  89836. }
  89837. for (var k = 0; k < 2; k++) {
  89838. uvs.push(currentUVs[2 * facet[j] + k]);
  89839. }
  89840. }
  89841. // add new index pointer to indices array
  89842. indices.push(ptr);
  89843. }
  89844. }
  89845. }
  89846. var normals = new Array();
  89847. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  89848. //create new vertex data object and update
  89849. vertex_data.positions = positions;
  89850. vertex_data.indices = indices;
  89851. vertex_data.normals = normals;
  89852. vertex_data.uvs = uvs;
  89853. vertex_data.applyToMesh(this);
  89854. }
  89855. };
  89856. // Instances
  89857. /** @hidden */
  89858. Mesh._instancedMeshFactory = function (name, mesh) {
  89859. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  89860. };
  89861. /** @hidden */
  89862. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  89863. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  89864. };
  89865. /**
  89866. * Creates a new InstancedMesh object from the mesh model.
  89867. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89868. * @param name defines the name of the new instance
  89869. * @returns a new InstancedMesh
  89870. */
  89871. Mesh.prototype.createInstance = function (name) {
  89872. return Mesh._instancedMeshFactory(name, this);
  89873. };
  89874. /**
  89875. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89876. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89877. * @returns the current mesh
  89878. */
  89879. Mesh.prototype.synchronizeInstances = function () {
  89880. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  89881. var instance = this.instances[instanceIndex];
  89882. instance._syncSubMeshes();
  89883. }
  89884. return this;
  89885. };
  89886. /**
  89887. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89888. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89889. * This should be used together with the simplification to avoid disappearing triangles.
  89890. * @param successCallback an optional success callback to be called after the optimization finished.
  89891. * @returns the current mesh
  89892. */
  89893. Mesh.prototype.optimizeIndices = function (successCallback) {
  89894. var _this = this;
  89895. var indices = this.getIndices();
  89896. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89897. if (!positions || !indices) {
  89898. return this;
  89899. }
  89900. var vectorPositions = new Array();
  89901. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  89902. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  89903. }
  89904. var dupes = new Array();
  89905. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  89906. var realPos = vectorPositions.length - 1 - iteration;
  89907. var testedPosition = vectorPositions[realPos];
  89908. for (var j = 0; j < realPos; ++j) {
  89909. var againstPosition = vectorPositions[j];
  89910. if (testedPosition.equals(againstPosition)) {
  89911. dupes[realPos] = j;
  89912. break;
  89913. }
  89914. }
  89915. }, function () {
  89916. for (var i = 0; i < indices.length; ++i) {
  89917. indices[i] = dupes[indices[i]] || indices[i];
  89918. }
  89919. //indices are now reordered
  89920. var originalSubMeshes = _this.subMeshes.slice(0);
  89921. _this.setIndices(indices);
  89922. _this.subMeshes = originalSubMeshes;
  89923. if (successCallback) {
  89924. successCallback(_this);
  89925. }
  89926. });
  89927. return this;
  89928. };
  89929. /**
  89930. * Serialize current mesh
  89931. * @param serializationObject defines the object which will receive the serialization data
  89932. */
  89933. Mesh.prototype.serialize = function (serializationObject) {
  89934. serializationObject.name = this.name;
  89935. serializationObject.id = this.id;
  89936. serializationObject.type = this.getClassName();
  89937. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  89938. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  89939. }
  89940. serializationObject.position = this.position.asArray();
  89941. if (this.rotationQuaternion) {
  89942. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  89943. }
  89944. else if (this.rotation) {
  89945. serializationObject.rotation = this.rotation.asArray();
  89946. }
  89947. serializationObject.scaling = this.scaling.asArray();
  89948. if (this._postMultiplyPivotMatrix) {
  89949. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  89950. }
  89951. else {
  89952. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  89953. }
  89954. serializationObject.isEnabled = this.isEnabled(false);
  89955. serializationObject.isVisible = this.isVisible;
  89956. serializationObject.infiniteDistance = this.infiniteDistance;
  89957. serializationObject.pickable = this.isPickable;
  89958. serializationObject.receiveShadows = this.receiveShadows;
  89959. serializationObject.billboardMode = this.billboardMode;
  89960. serializationObject.visibility = this.visibility;
  89961. serializationObject.checkCollisions = this.checkCollisions;
  89962. serializationObject.isBlocker = this.isBlocker;
  89963. // Parent
  89964. if (this.parent) {
  89965. serializationObject.parentId = this.parent.id;
  89966. }
  89967. // Geometry
  89968. serializationObject.isUnIndexed = this.isUnIndexed;
  89969. var geometry = this._geometry;
  89970. if (geometry) {
  89971. var geometryId = geometry.id;
  89972. serializationObject.geometryId = geometryId;
  89973. // SubMeshes
  89974. serializationObject.subMeshes = [];
  89975. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  89976. var subMesh = this.subMeshes[subIndex];
  89977. serializationObject.subMeshes.push({
  89978. materialIndex: subMesh.materialIndex,
  89979. verticesStart: subMesh.verticesStart,
  89980. verticesCount: subMesh.verticesCount,
  89981. indexStart: subMesh.indexStart,
  89982. indexCount: subMesh.indexCount
  89983. });
  89984. }
  89985. }
  89986. // Material
  89987. if (this.material) {
  89988. serializationObject.materialId = this.material.id;
  89989. }
  89990. else {
  89991. this.material = null;
  89992. }
  89993. // Morph targets
  89994. if (this.morphTargetManager) {
  89995. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  89996. }
  89997. // Skeleton
  89998. if (this.skeleton) {
  89999. serializationObject.skeletonId = this.skeleton.id;
  90000. }
  90001. // Physics
  90002. //TODO implement correct serialization for physics impostors.
  90003. if (this.getScene()._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_21__["SceneComponentConstants"].NAME_PHYSICSENGINE)) {
  90004. var impostor = this.getPhysicsImpostor();
  90005. if (impostor) {
  90006. serializationObject.physicsMass = impostor.getParam("mass");
  90007. serializationObject.physicsFriction = impostor.getParam("friction");
  90008. serializationObject.physicsRestitution = impostor.getParam("mass");
  90009. serializationObject.physicsImpostor = impostor.type;
  90010. }
  90011. }
  90012. // Metadata
  90013. if (this.metadata) {
  90014. serializationObject.metadata = this.metadata;
  90015. }
  90016. // Instances
  90017. serializationObject.instances = [];
  90018. for (var index = 0; index < this.instances.length; index++) {
  90019. var instance = this.instances[index];
  90020. if (instance.doNotSerialize) {
  90021. continue;
  90022. }
  90023. var serializationInstance = {
  90024. name: instance.name,
  90025. id: instance.id,
  90026. position: instance.position.asArray(),
  90027. scaling: instance.scaling.asArray()
  90028. };
  90029. if (instance.parent) {
  90030. serializationInstance.parentId = instance.parent.id;
  90031. }
  90032. if (instance.rotationQuaternion) {
  90033. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  90034. }
  90035. else if (instance.rotation) {
  90036. serializationInstance.rotation = instance.rotation.asArray();
  90037. }
  90038. serializationObject.instances.push(serializationInstance);
  90039. // Animations
  90040. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  90041. serializationInstance.ranges = instance.serializeAnimationRanges();
  90042. }
  90043. //
  90044. // Animations
  90045. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  90046. serializationObject.ranges = this.serializeAnimationRanges();
  90047. // Layer mask
  90048. serializationObject.layerMask = this.layerMask;
  90049. // Alpha
  90050. serializationObject.alphaIndex = this.alphaIndex;
  90051. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  90052. // Overlay
  90053. serializationObject.overlayAlpha = this.overlayAlpha;
  90054. serializationObject.overlayColor = this.overlayColor.asArray();
  90055. serializationObject.renderOverlay = this.renderOverlay;
  90056. // Fog
  90057. serializationObject.applyFog = this.applyFog;
  90058. // Action Manager
  90059. if (this.actionManager) {
  90060. serializationObject.actions = this.actionManager.serialize(this.name);
  90061. }
  90062. };
  90063. /** @hidden */
  90064. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  90065. if (!this.geometry) {
  90066. return;
  90067. }
  90068. this._markSubMeshesAsAttributesDirty();
  90069. var morphTargetManager = this._morphTargetManager;
  90070. if (morphTargetManager && morphTargetManager.vertexCount) {
  90071. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  90072. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  90073. this.morphTargetManager = null;
  90074. return;
  90075. }
  90076. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  90077. var morphTarget = morphTargetManager.getActiveTarget(index);
  90078. var positions = morphTarget.getPositions();
  90079. if (!positions) {
  90080. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  90081. return;
  90082. }
  90083. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  90084. var normals = morphTarget.getNormals();
  90085. if (normals) {
  90086. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  90087. }
  90088. var tangents = morphTarget.getTangents();
  90089. if (tangents) {
  90090. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  90091. }
  90092. }
  90093. }
  90094. else {
  90095. var index = 0;
  90096. // Positions
  90097. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  90098. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  90099. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  90100. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  90101. }
  90102. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  90103. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  90104. }
  90105. index++;
  90106. }
  90107. }
  90108. };
  90109. /**
  90110. * Returns a new Mesh object parsed from the source provided.
  90111. * @param parsedMesh is the source
  90112. * @param scene defines the hosting scene
  90113. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90114. * @returns a new Mesh
  90115. */
  90116. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  90117. var mesh;
  90118. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  90119. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  90120. }
  90121. else {
  90122. mesh = new Mesh(parsedMesh.name, scene);
  90123. }
  90124. mesh.id = parsedMesh.id;
  90125. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  90126. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  90127. }
  90128. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  90129. if (parsedMesh.metadata !== undefined) {
  90130. mesh.metadata = parsedMesh.metadata;
  90131. }
  90132. if (parsedMesh.rotationQuaternion) {
  90133. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  90134. }
  90135. else if (parsedMesh.rotation) {
  90136. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  90137. }
  90138. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  90139. if (parsedMesh.localMatrix) {
  90140. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  90141. }
  90142. else if (parsedMesh.pivotMatrix) {
  90143. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  90144. }
  90145. mesh.setEnabled(parsedMesh.isEnabled);
  90146. mesh.isVisible = parsedMesh.isVisible;
  90147. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  90148. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  90149. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  90150. if (parsedMesh.applyFog !== undefined) {
  90151. mesh.applyFog = parsedMesh.applyFog;
  90152. }
  90153. if (parsedMesh.pickable !== undefined) {
  90154. mesh.isPickable = parsedMesh.pickable;
  90155. }
  90156. if (parsedMesh.alphaIndex !== undefined) {
  90157. mesh.alphaIndex = parsedMesh.alphaIndex;
  90158. }
  90159. mesh.receiveShadows = parsedMesh.receiveShadows;
  90160. mesh.billboardMode = parsedMesh.billboardMode;
  90161. if (parsedMesh.visibility !== undefined) {
  90162. mesh.visibility = parsedMesh.visibility;
  90163. }
  90164. mesh.checkCollisions = parsedMesh.checkCollisions;
  90165. if (parsedMesh.isBlocker !== undefined) {
  90166. mesh.isBlocker = parsedMesh.isBlocker;
  90167. }
  90168. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  90169. // freezeWorldMatrix
  90170. if (parsedMesh.freezeWorldMatrix) {
  90171. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  90172. }
  90173. // Parent
  90174. if (parsedMesh.parentId) {
  90175. mesh._waitingParentId = parsedMesh.parentId;
  90176. }
  90177. // Actions
  90178. if (parsedMesh.actions !== undefined) {
  90179. mesh._waitingActions = parsedMesh.actions;
  90180. }
  90181. // Overlay
  90182. if (parsedMesh.overlayAlpha !== undefined) {
  90183. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  90184. }
  90185. if (parsedMesh.overlayColor !== undefined) {
  90186. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  90187. }
  90188. if (parsedMesh.renderOverlay !== undefined) {
  90189. mesh.renderOverlay = parsedMesh.renderOverlay;
  90190. }
  90191. // Geometry
  90192. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  90193. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  90194. if (parsedMesh.delayLoadingFile) {
  90195. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  90196. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  90197. 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));
  90198. if (parsedMesh._binaryInfo) {
  90199. mesh._binaryInfo = parsedMesh._binaryInfo;
  90200. }
  90201. mesh._delayInfo = [];
  90202. if (parsedMesh.hasUVs) {
  90203. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  90204. }
  90205. if (parsedMesh.hasUVs2) {
  90206. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  90207. }
  90208. if (parsedMesh.hasUVs3) {
  90209. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  90210. }
  90211. if (parsedMesh.hasUVs4) {
  90212. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  90213. }
  90214. if (parsedMesh.hasUVs5) {
  90215. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  90216. }
  90217. if (parsedMesh.hasUVs6) {
  90218. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  90219. }
  90220. if (parsedMesh.hasColors) {
  90221. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  90222. }
  90223. if (parsedMesh.hasMatricesIndices) {
  90224. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  90225. }
  90226. if (parsedMesh.hasMatricesWeights) {
  90227. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  90228. }
  90229. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  90230. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  90231. mesh._checkDelayState();
  90232. }
  90233. }
  90234. else {
  90235. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  90236. }
  90237. // Material
  90238. if (parsedMesh.materialId) {
  90239. mesh.setMaterialByID(parsedMesh.materialId);
  90240. }
  90241. else {
  90242. mesh.material = null;
  90243. }
  90244. // Morph targets
  90245. if (parsedMesh.morphTargetManagerId > -1) {
  90246. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  90247. }
  90248. // Skeleton
  90249. if (parsedMesh.skeletonId > -1) {
  90250. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  90251. if (parsedMesh.numBoneInfluencers) {
  90252. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  90253. }
  90254. }
  90255. // Animations
  90256. if (parsedMesh.animations) {
  90257. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  90258. var parsedAnimation = parsedMesh.animations[animationIndex];
  90259. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  90260. if (internalClass) {
  90261. mesh.animations.push(internalClass.Parse(parsedAnimation));
  90262. }
  90263. }
  90264. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  90265. }
  90266. if (parsedMesh.autoAnimate) {
  90267. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  90268. }
  90269. // Layer Mask
  90270. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  90271. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  90272. }
  90273. else {
  90274. mesh.layerMask = 0x0FFFFFFF;
  90275. }
  90276. // Physics
  90277. if (parsedMesh.physicsImpostor) {
  90278. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  90279. }
  90280. // Instances
  90281. if (parsedMesh.instances) {
  90282. for (var index = 0; index < parsedMesh.instances.length; index++) {
  90283. var parsedInstance = parsedMesh.instances[index];
  90284. var instance = mesh.createInstance(parsedInstance.name);
  90285. if (parsedInstance.id) {
  90286. instance.id = parsedInstance.id;
  90287. }
  90288. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  90289. if (parsedInstance.tags) {
  90290. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  90291. }
  90292. else {
  90293. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  90294. }
  90295. }
  90296. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  90297. if (parsedInstance.parentId) {
  90298. instance._waitingParentId = parsedInstance.parentId;
  90299. }
  90300. if (parsedInstance.rotationQuaternion) {
  90301. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  90302. }
  90303. else if (parsedInstance.rotation) {
  90304. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  90305. }
  90306. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  90307. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  90308. instance.checkCollisions = parsedInstance.checkCollisions;
  90309. }
  90310. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  90311. instance.isPickable = parsedInstance.pickable;
  90312. }
  90313. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  90314. instance.showBoundingBox = parsedInstance.showBoundingBox;
  90315. }
  90316. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  90317. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  90318. }
  90319. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  90320. instance.alphaIndex = parsedInstance.alphaIndex;
  90321. }
  90322. // Physics
  90323. if (parsedInstance.physicsImpostor) {
  90324. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  90325. }
  90326. // Animation
  90327. if (parsedInstance.animations) {
  90328. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  90329. parsedAnimation = parsedInstance.animations[animationIndex];
  90330. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  90331. if (internalClass) {
  90332. instance.animations.push(internalClass.Parse(parsedAnimation));
  90333. }
  90334. }
  90335. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  90336. if (parsedInstance.autoAnimate) {
  90337. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  90338. }
  90339. }
  90340. }
  90341. }
  90342. return mesh;
  90343. };
  90344. /**
  90345. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90346. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90347. * @param name defines the name of the mesh to create
  90348. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90349. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90350. * @param closePath creates a seam between the first and the last points of each path of the path array
  90351. * @param offset is taken in account only if the `pathArray` is containing a single path
  90352. * @param scene defines the hosting scene
  90353. * @param updatable defines if the mesh must be flagged as updatable
  90354. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90355. * @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)
  90356. * @returns a new Mesh
  90357. */
  90358. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  90359. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90360. };
  90361. /**
  90362. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90363. * @param name defines the name of the mesh to create
  90364. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90365. * @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
  90366. * @param scene defines the hosting scene
  90367. * @param updatable defines if the mesh must be flagged as updatable
  90368. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90369. * @returns a new Mesh
  90370. */
  90371. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  90372. if (scene === void 0) { scene = null; }
  90373. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90374. };
  90375. /**
  90376. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90377. * @param name defines the name of the mesh to create
  90378. * @param size sets the size (float) of each box side (default 1)
  90379. * @param scene defines the hosting scene
  90380. * @param updatable defines if the mesh must be flagged as updatable
  90381. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90382. * @returns a new Mesh
  90383. */
  90384. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  90385. if (scene === void 0) { scene = null; }
  90386. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90387. };
  90388. /**
  90389. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90390. * @param name defines the name of the mesh to create
  90391. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90392. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90393. * @param scene defines the hosting scene
  90394. * @param updatable defines if the mesh must be flagged as updatable
  90395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90396. * @returns a new Mesh
  90397. */
  90398. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  90399. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90400. };
  90401. /**
  90402. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90403. * @param name defines the name of the mesh to create
  90404. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90405. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90406. * @param scene defines the hosting scene
  90407. * @returns a new Mesh
  90408. */
  90409. Mesh.CreateHemisphere = function (name, segments, diameter, scene) {
  90410. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90411. };
  90412. /**
  90413. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90414. * @param name defines the name of the mesh to create
  90415. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90416. * @param diameterTop set the top cap diameter (floats, default 1)
  90417. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90418. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90419. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90420. * @param scene defines the hosting scene
  90421. * @param updatable defines if the mesh must be flagged as updatable
  90422. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90423. * @returns a new Mesh
  90424. */
  90425. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  90426. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90427. };
  90428. // Torus (Code from SharpDX.org)
  90429. /**
  90430. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90431. * @param name defines the name of the mesh to create
  90432. * @param diameter sets the diameter size (float) of the torus (default 1)
  90433. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90434. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90435. * @param scene defines the hosting scene
  90436. * @param updatable defines if the mesh must be flagged as updatable
  90437. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90438. * @returns a new Mesh
  90439. */
  90440. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  90441. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90442. };
  90443. /**
  90444. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90445. * @param name defines the name of the mesh to create
  90446. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90447. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90448. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90449. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90450. * @param p the number of windings on X axis (positive integers, default 2)
  90451. * @param q the number of windings on Y axis (positive integers, default 3)
  90452. * @param scene defines the hosting scene
  90453. * @param updatable defines if the mesh must be flagged as updatable
  90454. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90455. * @returns a new Mesh
  90456. */
  90457. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  90458. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90459. };
  90460. /**
  90461. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90462. * @param name defines the name of the mesh to create
  90463. * @param points is an array successive Vector3
  90464. * @param scene defines the hosting scene
  90465. * @param updatable defines if the mesh must be flagged as updatable
  90466. * @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).
  90467. * @returns a new Mesh
  90468. */
  90469. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  90470. if (scene === void 0) { scene = null; }
  90471. if (updatable === void 0) { updatable = false; }
  90472. if (instance === void 0) { instance = null; }
  90473. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90474. };
  90475. /**
  90476. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90477. * @param name defines the name of the mesh to create
  90478. * @param points is an array successive Vector3
  90479. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90480. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90481. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90482. * @param scene defines the hosting scene
  90483. * @param updatable defines if the mesh must be flagged as updatable
  90484. * @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)
  90485. * @returns a new Mesh
  90486. */
  90487. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  90488. if (scene === void 0) { scene = null; }
  90489. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90490. };
  90491. /**
  90492. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90493. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90494. * 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.
  90495. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90496. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90497. * Remember you can only change the shape positions, not their number when updating a polygon.
  90498. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90499. * @param name defines the name of the mesh to create
  90500. * @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
  90501. * @param scene defines the hosting scene
  90502. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90503. * @param updatable defines if the mesh must be flagged as updatable
  90504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90505. * @param earcutInjection can be used to inject your own earcut reference
  90506. * @returns a new Mesh
  90507. */
  90508. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  90509. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90510. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90511. };
  90512. /**
  90513. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90514. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90515. * @param name defines the name of the mesh to create
  90516. * @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
  90517. * @param depth defines the height of extrusion
  90518. * @param scene defines the hosting scene
  90519. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90520. * @param updatable defines if the mesh must be flagged as updatable
  90521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90522. * @param earcutInjection can be used to inject your own earcut reference
  90523. * @returns a new Mesh
  90524. */
  90525. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  90526. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90527. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90528. };
  90529. /**
  90530. * Creates an extruded shape mesh.
  90531. * 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
  90532. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90533. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90534. * @param name defines the name of the mesh to create
  90535. * @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
  90536. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90537. * @param scale is the value to scale the shape
  90538. * @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
  90539. * @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
  90540. * @param scene defines the hosting scene
  90541. * @param updatable defines if the mesh must be flagged as updatable
  90542. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90543. * @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)
  90544. * @returns a new Mesh
  90545. */
  90546. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  90547. if (scene === void 0) { scene = null; }
  90548. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90549. };
  90550. /**
  90551. * Creates an custom extruded shape mesh.
  90552. * The custom extrusion is a parametric shape.
  90553. * It has no predefined shape. Its final shape will depend on the input parameters.
  90554. * Please consider using the same method from the MeshBuilder class instead
  90555. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90556. * @param name defines the name of the mesh to create
  90557. * @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
  90558. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90559. * @param scaleFunction is a custom Javascript function called on each path point
  90560. * @param rotationFunction is a custom Javascript function called on each path point
  90561. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90562. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90563. * @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
  90564. * @param scene defines the hosting scene
  90565. * @param updatable defines if the mesh must be flagged as updatable
  90566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90567. * @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)
  90568. * @returns a new Mesh
  90569. */
  90570. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  90571. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90572. };
  90573. /**
  90574. * Creates lathe mesh.
  90575. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90576. * Please consider using the same method from the MeshBuilder class instead
  90577. * @param name defines the name of the mesh to create
  90578. * @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
  90579. * @param radius is the radius value of the lathe
  90580. * @param tessellation is the side number of the lathe.
  90581. * @param scene defines the hosting scene
  90582. * @param updatable defines if the mesh must be flagged as updatable
  90583. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90584. * @returns a new Mesh
  90585. */
  90586. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  90587. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90588. };
  90589. /**
  90590. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90591. * @param name defines the name of the mesh to create
  90592. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90593. * @param scene defines the hosting scene
  90594. * @param updatable defines if the mesh must be flagged as updatable
  90595. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90596. * @returns a new Mesh
  90597. */
  90598. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  90599. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90600. };
  90601. /**
  90602. * Creates a ground mesh.
  90603. * Please consider using the same method from the MeshBuilder class instead
  90604. * @param name defines the name of the mesh to create
  90605. * @param width set the width of the ground
  90606. * @param height set the height of the ground
  90607. * @param subdivisions sets the number of subdivisions per side
  90608. * @param scene defines the hosting scene
  90609. * @param updatable defines if the mesh must be flagged as updatable
  90610. * @returns a new Mesh
  90611. */
  90612. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  90613. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90614. };
  90615. /**
  90616. * Creates a tiled ground mesh.
  90617. * Please consider using the same method from the MeshBuilder class instead
  90618. * @param name defines the name of the mesh to create
  90619. * @param xmin set the ground minimum X coordinate
  90620. * @param zmin set the ground minimum Y coordinate
  90621. * @param xmax set the ground maximum X coordinate
  90622. * @param zmax set the ground maximum Z coordinate
  90623. * @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
  90624. * @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
  90625. * @param scene defines the hosting scene
  90626. * @param updatable defines if the mesh must be flagged as updatable
  90627. * @returns a new Mesh
  90628. */
  90629. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  90630. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90631. };
  90632. /**
  90633. * Creates a ground mesh from a height map.
  90634. * Please consider using the same method from the MeshBuilder class instead
  90635. * @see http://doc.babylonjs.com/babylon101/height_map
  90636. * @param name defines the name of the mesh to create
  90637. * @param url sets the URL of the height map image resource
  90638. * @param width set the ground width size
  90639. * @param height set the ground height size
  90640. * @param subdivisions sets the number of subdivision per side
  90641. * @param minHeight is the minimum altitude on the ground
  90642. * @param maxHeight is the maximum altitude on the ground
  90643. * @param scene defines the hosting scene
  90644. * @param updatable defines if the mesh must be flagged as updatable
  90645. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90646. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90647. * @returns a new Mesh
  90648. */
  90649. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  90650. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90651. };
  90652. /**
  90653. * Creates a tube mesh.
  90654. * The tube is a parametric shape.
  90655. * It has no predefined shape. Its final shape will depend on the input parameters.
  90656. * Please consider using the same method from the MeshBuilder class instead
  90657. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90658. * @param name defines the name of the mesh to create
  90659. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90660. * @param radius sets the tube radius size
  90661. * @param tessellation is the number of sides on the tubular surface
  90662. * @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
  90663. * @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
  90664. * @param scene defines the hosting scene
  90665. * @param updatable defines if the mesh must be flagged as updatable
  90666. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90667. * @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)
  90668. * @returns a new Mesh
  90669. */
  90670. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  90671. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90672. };
  90673. /**
  90674. * Creates a polyhedron mesh.
  90675. * Please consider using the same method from the MeshBuilder class instead.
  90676. * * 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
  90677. * * The parameter `size` (positive float, default 1) sets the polygon size
  90678. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90679. * * 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`
  90680. * * 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
  90681. * * 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)`)
  90682. * * 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
  90683. * * 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
  90684. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90685. * * 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
  90686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90687. * @param name defines the name of the mesh to create
  90688. * @param options defines the options used to create the mesh
  90689. * @param scene defines the hosting scene
  90690. * @returns a new Mesh
  90691. */
  90692. Mesh.CreatePolyhedron = function (name, options, scene) {
  90693. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90694. };
  90695. /**
  90696. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90697. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90698. * * 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`)
  90699. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90700. * * 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
  90701. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90702. * * 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
  90703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90704. * @param name defines the name of the mesh
  90705. * @param options defines the options used to create the mesh
  90706. * @param scene defines the hosting scene
  90707. * @returns a new Mesh
  90708. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90709. */
  90710. Mesh.CreateIcoSphere = function (name, options, scene) {
  90711. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90712. };
  90713. /**
  90714. * Creates a decal mesh.
  90715. * Please consider using the same method from the MeshBuilder class instead.
  90716. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90717. * @param name defines the name of the mesh
  90718. * @param sourceMesh defines the mesh receiving the decal
  90719. * @param position sets the position of the decal in world coordinates
  90720. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90721. * @param size sets the decal scaling
  90722. * @param angle sets the angle to rotate the decal
  90723. * @returns a new Mesh
  90724. */
  90725. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  90726. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90727. };
  90728. // Skeletons
  90729. /**
  90730. * Prepare internal position array for software CPU skinning
  90731. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90732. */
  90733. Mesh.prototype.setPositionsForCPUSkinning = function () {
  90734. if (!this._sourcePositions) {
  90735. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  90736. if (!source) {
  90737. return this._sourcePositions;
  90738. }
  90739. this._sourcePositions = new Float32Array(source);
  90740. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  90741. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  90742. }
  90743. }
  90744. return this._sourcePositions;
  90745. };
  90746. /**
  90747. * Prepare internal normal array for software CPU skinning
  90748. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90749. */
  90750. Mesh.prototype.setNormalsForCPUSkinning = function () {
  90751. if (!this._sourceNormals) {
  90752. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  90753. if (!source) {
  90754. return this._sourceNormals;
  90755. }
  90756. this._sourceNormals = new Float32Array(source);
  90757. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  90758. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  90759. }
  90760. }
  90761. return this._sourceNormals;
  90762. };
  90763. /**
  90764. * Updates the vertex buffer by applying transformation from the bones
  90765. * @param skeleton defines the skeleton to apply to current mesh
  90766. * @returns the current mesh
  90767. */
  90768. Mesh.prototype.applySkeleton = function (skeleton) {
  90769. if (!this.geometry) {
  90770. return this;
  90771. }
  90772. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  90773. return this;
  90774. }
  90775. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  90776. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  90777. return this;
  90778. }
  90779. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  90780. return this;
  90781. }
  90782. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  90783. return this;
  90784. }
  90785. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  90786. return this;
  90787. }
  90788. if (!this._sourcePositions) {
  90789. var submeshes = this.subMeshes.slice();
  90790. this.setPositionsForCPUSkinning();
  90791. this.subMeshes = submeshes;
  90792. }
  90793. if (!this._sourceNormals) {
  90794. this.setNormalsForCPUSkinning();
  90795. }
  90796. // positionsData checks for not being Float32Array will only pass at most once
  90797. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  90798. if (!positionsData) {
  90799. return this;
  90800. }
  90801. if (!(positionsData instanceof Float32Array)) {
  90802. positionsData = new Float32Array(positionsData);
  90803. }
  90804. // normalsData checks for not being Float32Array will only pass at most once
  90805. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  90806. if (!normalsData) {
  90807. return this;
  90808. }
  90809. if (!(normalsData instanceof Float32Array)) {
  90810. normalsData = new Float32Array(normalsData);
  90811. }
  90812. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  90813. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  90814. if (!matricesWeightsData || !matricesIndicesData) {
  90815. return this;
  90816. }
  90817. var needExtras = this.numBoneInfluencers > 4;
  90818. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  90819. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  90820. var skeletonMatrices = skeleton.getTransformMatrices(this);
  90821. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  90822. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  90823. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  90824. var matWeightIdx = 0;
  90825. var inf;
  90826. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  90827. var weight;
  90828. for (inf = 0; inf < 4; inf++) {
  90829. weight = matricesWeightsData[matWeightIdx + inf];
  90830. if (weight > 0) {
  90831. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  90832. finalMatrix.addToSelf(tempMatrix);
  90833. }
  90834. }
  90835. if (needExtras) {
  90836. for (inf = 0; inf < 4; inf++) {
  90837. weight = matricesWeightsExtraData[matWeightIdx + inf];
  90838. if (weight > 0) {
  90839. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  90840. finalMatrix.addToSelf(tempMatrix);
  90841. }
  90842. }
  90843. }
  90844. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  90845. tempVector3.toArray(positionsData, index);
  90846. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  90847. tempVector3.toArray(normalsData, index);
  90848. finalMatrix.reset();
  90849. }
  90850. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  90851. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  90852. return this;
  90853. };
  90854. // Tools
  90855. /**
  90856. * 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
  90857. * @param meshes defines the list of meshes to scan
  90858. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90859. */
  90860. Mesh.MinMax = function (meshes) {
  90861. var minVector = null;
  90862. var maxVector = null;
  90863. meshes.forEach(function (mesh) {
  90864. var boundingInfo = mesh.getBoundingInfo();
  90865. var boundingBox = boundingInfo.boundingBox;
  90866. if (!minVector || !maxVector) {
  90867. minVector = boundingBox.minimumWorld;
  90868. maxVector = boundingBox.maximumWorld;
  90869. }
  90870. else {
  90871. minVector.minimizeInPlace(boundingBox.minimumWorld);
  90872. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  90873. }
  90874. });
  90875. if (!minVector || !maxVector) {
  90876. return {
  90877. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  90878. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  90879. };
  90880. }
  90881. return {
  90882. min: minVector,
  90883. max: maxVector
  90884. };
  90885. };
  90886. /**
  90887. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90888. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90889. * @returns a vector3
  90890. */
  90891. Mesh.Center = function (meshesOrMinMaxVector) {
  90892. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  90893. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  90894. };
  90895. /**
  90896. * Merge the array of meshes into a single mesh for performance reasons.
  90897. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90898. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90899. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90900. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90901. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90902. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90903. * @returns a new mesh
  90904. */
  90905. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  90906. if (disposeSource === void 0) { disposeSource = true; }
  90907. var index;
  90908. if (!allow32BitsIndices) {
  90909. var totalVertices = 0;
  90910. // Counting vertices
  90911. for (index = 0; index < meshes.length; index++) {
  90912. if (meshes[index]) {
  90913. totalVertices += meshes[index].getTotalVertices();
  90914. if (totalVertices > 65536) {
  90915. _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");
  90916. return null;
  90917. }
  90918. }
  90919. }
  90920. }
  90921. if (multiMultiMaterials) {
  90922. var newMultiMaterial = null;
  90923. var subIndex;
  90924. var matIndex;
  90925. subdivideWithSubMeshes = false;
  90926. }
  90927. var materialArray = new Array();
  90928. var materialIndexArray = new Array();
  90929. // Merge
  90930. var vertexData = null;
  90931. var otherVertexData;
  90932. var indiceArray = new Array();
  90933. var source = null;
  90934. for (index = 0; index < meshes.length; index++) {
  90935. if (meshes[index]) {
  90936. var mesh = meshes[index];
  90937. var wm = mesh.computeWorldMatrix(true);
  90938. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  90939. otherVertexData.transform(wm);
  90940. if (vertexData) {
  90941. vertexData.merge(otherVertexData, allow32BitsIndices);
  90942. }
  90943. else {
  90944. vertexData = otherVertexData;
  90945. source = mesh;
  90946. }
  90947. if (subdivideWithSubMeshes) {
  90948. indiceArray.push(mesh.getTotalIndices());
  90949. }
  90950. if (multiMultiMaterials) {
  90951. if (mesh.material) {
  90952. var material = mesh.material;
  90953. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  90954. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  90955. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  90956. materialArray.push(material.subMaterials[matIndex]);
  90957. }
  90958. }
  90959. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  90960. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  90961. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  90962. }
  90963. }
  90964. else {
  90965. if (materialArray.indexOf(material) < 0) {
  90966. materialArray.push(material);
  90967. }
  90968. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  90969. materialIndexArray.push(materialArray.indexOf(material));
  90970. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  90971. }
  90972. }
  90973. }
  90974. else {
  90975. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  90976. materialIndexArray.push(0);
  90977. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  90978. }
  90979. }
  90980. }
  90981. }
  90982. }
  90983. source = source;
  90984. if (!meshSubclass) {
  90985. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  90986. }
  90987. vertexData.applyToMesh(meshSubclass);
  90988. // Setting properties
  90989. meshSubclass.checkCollisions = source.checkCollisions;
  90990. // Cleaning
  90991. if (disposeSource) {
  90992. for (index = 0; index < meshes.length; index++) {
  90993. if (meshes[index]) {
  90994. meshes[index].dispose();
  90995. }
  90996. }
  90997. }
  90998. // Subdivide
  90999. if (subdivideWithSubMeshes || multiMultiMaterials) {
  91000. //-- removal of global submesh
  91001. meshSubclass.releaseSubMeshes();
  91002. index = 0;
  91003. var offset = 0;
  91004. //-- apply subdivision according to index table
  91005. while (index < indiceArray.length) {
  91006. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  91007. offset += indiceArray[index];
  91008. index++;
  91009. }
  91010. }
  91011. if (multiMultiMaterials) {
  91012. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  91013. newMultiMaterial.subMaterials = materialArray;
  91014. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  91015. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  91016. }
  91017. meshSubclass.material = newMultiMaterial;
  91018. }
  91019. else {
  91020. meshSubclass.material = source.material;
  91021. }
  91022. return meshSubclass;
  91023. };
  91024. /** @hidden */
  91025. Mesh.prototype.addInstance = function (instance) {
  91026. instance._indexInSourceMeshInstanceArray = this.instances.length;
  91027. this.instances.push(instance);
  91028. };
  91029. /** @hidden */
  91030. Mesh.prototype.removeInstance = function (instance) {
  91031. // Remove from mesh
  91032. var index = instance._indexInSourceMeshInstanceArray;
  91033. if (index != -1) {
  91034. if (index !== this.instances.length - 1) {
  91035. var last = this.instances[this.instances.length - 1];
  91036. this.instances[index] = last;
  91037. last._indexInSourceMeshInstanceArray = index;
  91038. }
  91039. instance._indexInSourceMeshInstanceArray = -1;
  91040. this.instances.pop();
  91041. }
  91042. };
  91043. // Consts
  91044. /**
  91045. * Mesh side orientation : usually the external or front surface
  91046. */
  91047. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  91048. /**
  91049. * Mesh side orientation : usually the internal or back surface
  91050. */
  91051. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  91052. /**
  91053. * Mesh side orientation : both internal and external or front and back surfaces
  91054. */
  91055. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  91056. /**
  91057. * Mesh side orientation : by default, `FRONTSIDE`
  91058. */
  91059. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  91060. /**
  91061. * Mesh cap setting : no cap
  91062. */
  91063. Mesh.NO_CAP = 0;
  91064. /**
  91065. * Mesh cap setting : one cap at the beginning of the mesh
  91066. */
  91067. Mesh.CAP_START = 1;
  91068. /**
  91069. * Mesh cap setting : one cap at the end of the mesh
  91070. */
  91071. Mesh.CAP_END = 2;
  91072. /**
  91073. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  91074. */
  91075. Mesh.CAP_ALL = 3;
  91076. // Statics
  91077. /** @hidden */
  91078. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  91079. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  91080. };
  91081. return Mesh;
  91082. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  91083. /***/ }),
  91084. /***/ "./Meshes/mesh.vertexData.ts":
  91085. /*!***********************************!*\
  91086. !*** ./Meshes/mesh.vertexData.ts ***!
  91087. \***********************************/
  91088. /*! exports provided: VertexData */
  91089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91090. "use strict";
  91091. __webpack_require__.r(__webpack_exports__);
  91092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  91093. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  91094. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  91095. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  91096. /**
  91097. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  91098. */
  91099. var VertexData = /** @class */ (function () {
  91100. function VertexData() {
  91101. }
  91102. /**
  91103. * Uses the passed data array to set the set the values for the specified kind of data
  91104. * @param data a linear array of floating numbers
  91105. * @param kind the type of data that is being set, eg positions, colors etc
  91106. */
  91107. VertexData.prototype.set = function (data, kind) {
  91108. switch (kind) {
  91109. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  91110. this.positions = data;
  91111. break;
  91112. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  91113. this.normals = data;
  91114. break;
  91115. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  91116. this.tangents = data;
  91117. break;
  91118. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  91119. this.uvs = data;
  91120. break;
  91121. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  91122. this.uvs2 = data;
  91123. break;
  91124. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  91125. this.uvs3 = data;
  91126. break;
  91127. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  91128. this.uvs4 = data;
  91129. break;
  91130. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  91131. this.uvs5 = data;
  91132. break;
  91133. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  91134. this.uvs6 = data;
  91135. break;
  91136. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  91137. this.colors = data;
  91138. break;
  91139. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  91140. this.matricesIndices = data;
  91141. break;
  91142. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  91143. this.matricesWeights = data;
  91144. break;
  91145. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  91146. this.matricesIndicesExtra = data;
  91147. break;
  91148. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  91149. this.matricesWeightsExtra = data;
  91150. break;
  91151. }
  91152. };
  91153. /**
  91154. * Associates the vertexData to the passed Mesh.
  91155. * Sets it as updatable or not (default `false`)
  91156. * @param mesh the mesh the vertexData is applied to
  91157. * @param updatable when used and having the value true allows new data to update the vertexData
  91158. * @returns the VertexData
  91159. */
  91160. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  91161. this._applyTo(mesh, updatable);
  91162. return this;
  91163. };
  91164. /**
  91165. * Associates the vertexData to the passed Geometry.
  91166. * Sets it as updatable or not (default `false`)
  91167. * @param geometry the geometry the vertexData is applied to
  91168. * @param updatable when used and having the value true allows new data to update the vertexData
  91169. * @returns VertexData
  91170. */
  91171. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  91172. this._applyTo(geometry, updatable);
  91173. return this;
  91174. };
  91175. /**
  91176. * Updates the associated mesh
  91177. * @param mesh the mesh to be updated
  91178. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91179. * @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
  91180. * @returns VertexData
  91181. */
  91182. VertexData.prototype.updateMesh = function (mesh) {
  91183. this._update(mesh);
  91184. return this;
  91185. };
  91186. /**
  91187. * Updates the associated geometry
  91188. * @param geometry the geometry to be updated
  91189. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91190. * @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
  91191. * @returns VertexData.
  91192. */
  91193. VertexData.prototype.updateGeometry = function (geometry) {
  91194. this._update(geometry);
  91195. return this;
  91196. };
  91197. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  91198. if (updatable === void 0) { updatable = false; }
  91199. if (this.positions) {
  91200. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  91201. }
  91202. if (this.normals) {
  91203. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  91204. }
  91205. if (this.tangents) {
  91206. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  91207. }
  91208. if (this.uvs) {
  91209. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  91210. }
  91211. if (this.uvs2) {
  91212. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  91213. }
  91214. if (this.uvs3) {
  91215. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  91216. }
  91217. if (this.uvs4) {
  91218. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  91219. }
  91220. if (this.uvs5) {
  91221. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  91222. }
  91223. if (this.uvs6) {
  91224. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  91225. }
  91226. if (this.colors) {
  91227. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  91228. }
  91229. if (this.matricesIndices) {
  91230. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  91231. }
  91232. if (this.matricesWeights) {
  91233. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  91234. }
  91235. if (this.matricesIndicesExtra) {
  91236. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  91237. }
  91238. if (this.matricesWeightsExtra) {
  91239. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  91240. }
  91241. if (this.indices) {
  91242. meshOrGeometry.setIndices(this.indices, null, updatable);
  91243. }
  91244. else {
  91245. meshOrGeometry.setIndices([], null);
  91246. }
  91247. return this;
  91248. };
  91249. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  91250. if (this.positions) {
  91251. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  91252. }
  91253. if (this.normals) {
  91254. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  91255. }
  91256. if (this.tangents) {
  91257. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  91258. }
  91259. if (this.uvs) {
  91260. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  91261. }
  91262. if (this.uvs2) {
  91263. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  91264. }
  91265. if (this.uvs3) {
  91266. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  91267. }
  91268. if (this.uvs4) {
  91269. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  91270. }
  91271. if (this.uvs5) {
  91272. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  91273. }
  91274. if (this.uvs6) {
  91275. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  91276. }
  91277. if (this.colors) {
  91278. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  91279. }
  91280. if (this.matricesIndices) {
  91281. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  91282. }
  91283. if (this.matricesWeights) {
  91284. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  91285. }
  91286. if (this.matricesIndicesExtra) {
  91287. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  91288. }
  91289. if (this.matricesWeightsExtra) {
  91290. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  91291. }
  91292. if (this.indices) {
  91293. meshOrGeometry.setIndices(this.indices, null);
  91294. }
  91295. return this;
  91296. };
  91297. /**
  91298. * Transforms each position and each normal of the vertexData according to the passed Matrix
  91299. * @param matrix the transforming matrix
  91300. * @returns the VertexData
  91301. */
  91302. VertexData.prototype.transform = function (matrix) {
  91303. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  91304. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91305. var index;
  91306. if (this.positions) {
  91307. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91308. for (index = 0; index < this.positions.length; index += 3) {
  91309. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  91310. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  91311. this.positions[index] = transformed.x;
  91312. this.positions[index + 1] = transformed.y;
  91313. this.positions[index + 2] = transformed.z;
  91314. }
  91315. }
  91316. if (this.normals) {
  91317. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91318. for (index = 0; index < this.normals.length; index += 3) {
  91319. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  91320. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  91321. this.normals[index] = transformed.x;
  91322. this.normals[index + 1] = transformed.y;
  91323. this.normals[index + 2] = transformed.z;
  91324. }
  91325. }
  91326. if (this.tangents) {
  91327. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  91328. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  91329. for (index = 0; index < this.tangents.length; index += 4) {
  91330. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  91331. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  91332. this.tangents[index] = tangentTransformed.x;
  91333. this.tangents[index + 1] = tangentTransformed.y;
  91334. this.tangents[index + 2] = tangentTransformed.z;
  91335. this.tangents[index + 3] = tangentTransformed.w;
  91336. }
  91337. }
  91338. if (flip && this.indices) {
  91339. for (index = 0; index < this.indices.length; index += 3) {
  91340. var tmp = this.indices[index + 1];
  91341. this.indices[index + 1] = this.indices[index + 2];
  91342. this.indices[index + 2] = tmp;
  91343. }
  91344. }
  91345. return this;
  91346. };
  91347. /**
  91348. * Merges the passed VertexData into the current one
  91349. * @param other the VertexData to be merged into the current one
  91350. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  91351. * @returns the modified VertexData
  91352. */
  91353. VertexData.prototype.merge = function (other, use32BitsIndices) {
  91354. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  91355. this._validate();
  91356. other._validate();
  91357. if (!this.normals !== !other.normals ||
  91358. !this.tangents !== !other.tangents ||
  91359. !this.uvs !== !other.uvs ||
  91360. !this.uvs2 !== !other.uvs2 ||
  91361. !this.uvs3 !== !other.uvs3 ||
  91362. !this.uvs4 !== !other.uvs4 ||
  91363. !this.uvs5 !== !other.uvs5 ||
  91364. !this.uvs6 !== !other.uvs6 ||
  91365. !this.colors !== !other.colors ||
  91366. !this.matricesIndices !== !other.matricesIndices ||
  91367. !this.matricesWeights !== !other.matricesWeights ||
  91368. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  91369. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  91370. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  91371. }
  91372. if (other.indices) {
  91373. if (!this.indices) {
  91374. this.indices = [];
  91375. }
  91376. var offset = this.positions ? this.positions.length / 3 : 0;
  91377. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  91378. if (isSrcTypedArray) {
  91379. var len = this.indices.length + other.indices.length;
  91380. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  91381. temp.set(this.indices);
  91382. var decal = this.indices.length;
  91383. for (var index = 0; index < other.indices.length; index++) {
  91384. temp[decal + index] = other.indices[index] + offset;
  91385. }
  91386. this.indices = temp;
  91387. }
  91388. else {
  91389. for (var index = 0; index < other.indices.length; index++) {
  91390. this.indices.push(other.indices[index] + offset);
  91391. }
  91392. }
  91393. }
  91394. this.positions = this._mergeElement(this.positions, other.positions);
  91395. this.normals = this._mergeElement(this.normals, other.normals);
  91396. this.tangents = this._mergeElement(this.tangents, other.tangents);
  91397. this.uvs = this._mergeElement(this.uvs, other.uvs);
  91398. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  91399. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  91400. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  91401. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  91402. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  91403. this.colors = this._mergeElement(this.colors, other.colors);
  91404. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  91405. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  91406. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  91407. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  91408. return this;
  91409. };
  91410. VertexData.prototype._mergeElement = function (source, other) {
  91411. if (!source) {
  91412. return other;
  91413. }
  91414. if (!other) {
  91415. return source;
  91416. }
  91417. var len = other.length + source.length;
  91418. var isSrcTypedArray = source instanceof Float32Array;
  91419. var isOthTypedArray = other instanceof Float32Array;
  91420. // use non-loop method when the source is Float32Array
  91421. if (isSrcTypedArray) {
  91422. var ret32 = new Float32Array(len);
  91423. ret32.set(source);
  91424. ret32.set(other, source.length);
  91425. return ret32;
  91426. // source is number[], when other is also use concat
  91427. }
  91428. else if (!isOthTypedArray) {
  91429. return source.concat(other);
  91430. // source is a number[], but other is a Float32Array, loop required
  91431. }
  91432. else {
  91433. var ret = source.slice(0); // copy source to a separate array
  91434. for (var i = 0, len = other.length; i < len; i++) {
  91435. ret.push(other[i]);
  91436. }
  91437. return ret;
  91438. }
  91439. };
  91440. VertexData.prototype._validate = function () {
  91441. if (!this.positions) {
  91442. throw new Error("Positions are required");
  91443. }
  91444. var getElementCount = function (kind, values) {
  91445. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  91446. if ((values.length % stride) !== 0) {
  91447. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  91448. }
  91449. return values.length / stride;
  91450. };
  91451. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  91452. var validateElementCount = function (kind, values) {
  91453. var elementCount = getElementCount(kind, values);
  91454. if (elementCount !== positionsElementCount) {
  91455. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  91456. }
  91457. };
  91458. if (this.normals) {
  91459. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  91460. }
  91461. if (this.tangents) {
  91462. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  91463. }
  91464. if (this.uvs) {
  91465. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  91466. }
  91467. if (this.uvs2) {
  91468. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  91469. }
  91470. if (this.uvs3) {
  91471. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  91472. }
  91473. if (this.uvs4) {
  91474. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  91475. }
  91476. if (this.uvs5) {
  91477. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  91478. }
  91479. if (this.uvs6) {
  91480. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  91481. }
  91482. if (this.colors) {
  91483. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  91484. }
  91485. if (this.matricesIndices) {
  91486. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  91487. }
  91488. if (this.matricesWeights) {
  91489. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  91490. }
  91491. if (this.matricesIndicesExtra) {
  91492. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  91493. }
  91494. if (this.matricesWeightsExtra) {
  91495. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  91496. }
  91497. };
  91498. /**
  91499. * Serializes the VertexData
  91500. * @returns a serialized object
  91501. */
  91502. VertexData.prototype.serialize = function () {
  91503. var serializationObject = this.serialize();
  91504. if (this.positions) {
  91505. serializationObject.positions = this.positions;
  91506. }
  91507. if (this.normals) {
  91508. serializationObject.normals = this.normals;
  91509. }
  91510. if (this.tangents) {
  91511. serializationObject.tangents = this.tangents;
  91512. }
  91513. if (this.uvs) {
  91514. serializationObject.uvs = this.uvs;
  91515. }
  91516. if (this.uvs2) {
  91517. serializationObject.uvs2 = this.uvs2;
  91518. }
  91519. if (this.uvs3) {
  91520. serializationObject.uvs3 = this.uvs3;
  91521. }
  91522. if (this.uvs4) {
  91523. serializationObject.uvs4 = this.uvs4;
  91524. }
  91525. if (this.uvs5) {
  91526. serializationObject.uvs5 = this.uvs5;
  91527. }
  91528. if (this.uvs6) {
  91529. serializationObject.uvs6 = this.uvs6;
  91530. }
  91531. if (this.colors) {
  91532. serializationObject.colors = this.colors;
  91533. }
  91534. if (this.matricesIndices) {
  91535. serializationObject.matricesIndices = this.matricesIndices;
  91536. serializationObject.matricesIndices._isExpanded = true;
  91537. }
  91538. if (this.matricesWeights) {
  91539. serializationObject.matricesWeights = this.matricesWeights;
  91540. }
  91541. if (this.matricesIndicesExtra) {
  91542. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  91543. serializationObject.matricesIndicesExtra._isExpanded = true;
  91544. }
  91545. if (this.matricesWeightsExtra) {
  91546. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  91547. }
  91548. serializationObject.indices = this.indices;
  91549. return serializationObject;
  91550. };
  91551. // Statics
  91552. /**
  91553. * Extracts the vertexData from a mesh
  91554. * @param mesh the mesh from which to extract the VertexData
  91555. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  91556. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91557. * @returns the object VertexData associated to the passed mesh
  91558. */
  91559. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  91560. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  91561. };
  91562. /**
  91563. * Extracts the vertexData from the geometry
  91564. * @param geometry the geometry from which to extract the VertexData
  91565. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  91566. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91567. * @returns the object VertexData associated to the passed mesh
  91568. */
  91569. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  91570. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  91571. };
  91572. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  91573. var result = new VertexData();
  91574. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  91575. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  91576. }
  91577. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  91578. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  91579. }
  91580. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  91581. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  91582. }
  91583. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  91584. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  91585. }
  91586. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  91587. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  91588. }
  91589. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  91590. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  91591. }
  91592. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  91593. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  91594. }
  91595. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  91596. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  91597. }
  91598. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  91599. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  91600. }
  91601. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  91602. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  91603. }
  91604. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  91605. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  91606. }
  91607. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  91608. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  91609. }
  91610. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  91611. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  91612. }
  91613. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  91614. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  91615. }
  91616. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  91617. return result;
  91618. };
  91619. /**
  91620. * Creates the VertexData for a Ribbon
  91621. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  91622. * * pathArray array of paths, each of which an array of successive Vector3
  91623. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  91624. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  91625. * * 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
  91626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91627. * * 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)
  91628. * * 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)
  91629. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  91630. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  91631. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  91632. * @returns the VertexData of the ribbon
  91633. */
  91634. VertexData.CreateRibbon = function (options) {
  91635. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  91636. };
  91637. /**
  91638. * Creates the VertexData for a box
  91639. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91640. * * size sets the width, height and depth of the box to the value of size, optional default 1
  91641. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  91642. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  91643. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  91644. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91645. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91646. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91647. * * 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)
  91648. * * 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)
  91649. * @returns the VertexData of the box
  91650. */
  91651. VertexData.CreateBox = function (options) {
  91652. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  91653. };
  91654. /**
  91655. * Creates the VertexData for an ellipsoid, defaults to a sphere
  91656. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91657. * * segments sets the number of horizontal strips optional, default 32
  91658. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  91659. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  91660. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  91661. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  91662. * * 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
  91663. * * 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
  91664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91665. * * 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)
  91666. * * 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)
  91667. * @returns the VertexData of the ellipsoid
  91668. */
  91669. VertexData.CreateSphere = function (options) {
  91670. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  91671. };
  91672. /**
  91673. * Creates the VertexData for a cylinder, cone or prism
  91674. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91675. * * height sets the height (y direction) of the cylinder, optional, default 2
  91676. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  91677. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  91678. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  91679. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91680. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  91681. * * 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
  91682. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91683. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91684. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  91685. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  91686. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91687. * * 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)
  91688. * * 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)
  91689. * @returns the VertexData of the cylinder, cone or prism
  91690. */
  91691. VertexData.CreateCylinder = function (options) {
  91692. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  91693. };
  91694. /**
  91695. * Creates the VertexData for a torus
  91696. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91697. * * diameter the diameter of the torus, optional default 1
  91698. * * thickness the diameter of the tube forming the torus, optional default 0.5
  91699. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91700. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91701. * * 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)
  91702. * * 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)
  91703. * @returns the VertexData of the torus
  91704. */
  91705. VertexData.CreateTorus = function (options) {
  91706. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  91707. };
  91708. /**
  91709. * Creates the VertexData of the LineSystem
  91710. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  91711. * - lines an array of lines, each line being an array of successive Vector3
  91712. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  91713. * @returns the VertexData of the LineSystem
  91714. */
  91715. VertexData.CreateLineSystem = function (options) {
  91716. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  91717. };
  91718. /**
  91719. * Create the VertexData for a DashedLines
  91720. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  91721. * - points an array successive Vector3
  91722. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  91723. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  91724. * - dashNb the intended total number of dashes, optional, default 200
  91725. * @returns the VertexData for the DashedLines
  91726. */
  91727. VertexData.CreateDashedLines = function (options) {
  91728. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  91729. };
  91730. /**
  91731. * Creates the VertexData for a Ground
  91732. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91733. * - width the width (x direction) of the ground, optional, default 1
  91734. * - height the height (z direction) of the ground, optional, default 1
  91735. * - subdivisions the number of subdivisions per side, optional, default 1
  91736. * @returns the VertexData of the Ground
  91737. */
  91738. VertexData.CreateGround = function (options) {
  91739. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  91740. };
  91741. /**
  91742. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  91743. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91744. * * xmin the ground minimum X coordinate, optional, default -1
  91745. * * zmin the ground minimum Z coordinate, optional, default -1
  91746. * * xmax the ground maximum X coordinate, optional, default 1
  91747. * * zmax the ground maximum Z coordinate, optional, default 1
  91748. * * 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}
  91749. * * 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}
  91750. * @returns the VertexData of the TiledGround
  91751. */
  91752. VertexData.CreateTiledGround = function (options) {
  91753. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  91754. };
  91755. /**
  91756. * Creates the VertexData of the Ground designed from a heightmap
  91757. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  91758. * * width the width (x direction) of the ground
  91759. * * height the height (z direction) of the ground
  91760. * * subdivisions the number of subdivisions per side
  91761. * * minHeight the minimum altitude on the ground, optional, default 0
  91762. * * maxHeight the maximum altitude on the ground, optional default 1
  91763. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  91764. * * buffer the array holding the image color data
  91765. * * bufferWidth the width of image
  91766. * * bufferHeight the height of image
  91767. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  91768. * @returns the VertexData of the Ground designed from a heightmap
  91769. */
  91770. VertexData.CreateGroundFromHeightMap = function (options) {
  91771. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  91772. };
  91773. /**
  91774. * Creates the VertexData for a Plane
  91775. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91776. * * size sets the width and height of the plane to the value of size, optional default 1
  91777. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91778. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91780. * * 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)
  91781. * * 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)
  91782. * @returns the VertexData of the box
  91783. */
  91784. VertexData.CreatePlane = function (options) {
  91785. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  91786. };
  91787. /**
  91788. * Creates the VertexData of the Disc or regular Polygon
  91789. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91790. * * radius the radius of the disc, optional default 0.5
  91791. * * tessellation the number of polygon sides, optional, default 64
  91792. * * 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
  91793. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91794. * * 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)
  91795. * * 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)
  91796. * @returns the VertexData of the box
  91797. */
  91798. VertexData.CreateDisc = function (options) {
  91799. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  91800. };
  91801. /**
  91802. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91803. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91804. * @param polygon a mesh built from polygonTriangulation.build()
  91805. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91806. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91807. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91808. * @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)
  91809. * @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)
  91810. * @returns the VertexData of the Polygon
  91811. */
  91812. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  91813. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  91814. };
  91815. /**
  91816. * Creates the VertexData of the IcoSphere
  91817. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91818. * * radius the radius of the IcoSphere, optional default 1
  91819. * * radiusX allows stretching in the x direction, optional, default radius
  91820. * * radiusY allows stretching in the y direction, optional, default radius
  91821. * * radiusZ allows stretching in the z direction, optional, default radius
  91822. * * flat when true creates a flat shaded mesh, optional, default true
  91823. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91824. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91825. * * 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)
  91826. * * 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)
  91827. * @returns the VertexData of the IcoSphere
  91828. */
  91829. VertexData.CreateIcoSphere = function (options) {
  91830. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  91831. };
  91832. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  91833. /**
  91834. * Creates the VertexData for a Polyhedron
  91835. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91836. * * type provided types are:
  91837. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91838. * * 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)
  91839. * * size the size of the IcoSphere, optional default 1
  91840. * * sizeX allows stretching in the x direction, optional, default size
  91841. * * sizeY allows stretching in the y direction, optional, default size
  91842. * * sizeZ allows stretching in the z direction, optional, default size
  91843. * * 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
  91844. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91845. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91846. * * flat when true creates a flat shaded mesh, optional, default true
  91847. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91848. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91849. * * 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)
  91850. * * 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)
  91851. * @returns the VertexData of the Polyhedron
  91852. */
  91853. VertexData.CreatePolyhedron = function (options) {
  91854. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  91855. };
  91856. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  91857. /**
  91858. * Creates the VertexData for a TorusKnot
  91859. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91860. * * radius the radius of the torus knot, optional, default 2
  91861. * * tube the thickness of the tube, optional, default 0.5
  91862. * * radialSegments the number of sides on each tube segments, optional, default 32
  91863. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91864. * * p the number of windings around the z axis, optional, default 2
  91865. * * q the number of windings around the x axis, optional, default 3
  91866. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91867. * * 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)
  91868. * * 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)
  91869. * @returns the VertexData of the Torus Knot
  91870. */
  91871. VertexData.CreateTorusKnot = function (options) {
  91872. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  91873. };
  91874. // Tools
  91875. /**
  91876. * Compute normals for given positions and indices
  91877. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91878. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91879. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91880. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91881. * * facetNormals : optional array of facet normals (vector3)
  91882. * * facetPositions : optional array of facet positions (vector3)
  91883. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91884. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91885. * * bInfo : optional bounding info, required for facetPartitioning computation
  91886. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91887. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91888. * * useRightHandedSystem: optional boolean to for right handed system computation
  91889. * * depthSort : optional boolean to enable the facet depth sort computation
  91890. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91891. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91892. */
  91893. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  91894. // temporary scalar variables
  91895. var index = 0; // facet index
  91896. var p1p2x = 0.0; // p1p2 vector x coordinate
  91897. var p1p2y = 0.0; // p1p2 vector y coordinate
  91898. var p1p2z = 0.0; // p1p2 vector z coordinate
  91899. var p3p2x = 0.0; // p3p2 vector x coordinate
  91900. var p3p2y = 0.0; // p3p2 vector y coordinate
  91901. var p3p2z = 0.0; // p3p2 vector z coordinate
  91902. var faceNormalx = 0.0; // facet normal x coordinate
  91903. var faceNormaly = 0.0; // facet normal y coordinate
  91904. var faceNormalz = 0.0; // facet normal z coordinate
  91905. var length = 0.0; // facet normal length before normalization
  91906. var v1x = 0; // vector1 x index in the positions array
  91907. var v1y = 0; // vector1 y index in the positions array
  91908. var v1z = 0; // vector1 z index in the positions array
  91909. var v2x = 0; // vector2 x index in the positions array
  91910. var v2y = 0; // vector2 y index in the positions array
  91911. var v2z = 0; // vector2 z index in the positions array
  91912. var v3x = 0; // vector3 x index in the positions array
  91913. var v3y = 0; // vector3 y index in the positions array
  91914. var v3z = 0; // vector3 z index in the positions array
  91915. var computeFacetNormals = false;
  91916. var computeFacetPositions = false;
  91917. var computeFacetPartitioning = false;
  91918. var computeDepthSort = false;
  91919. var faceNormalSign = 1;
  91920. var ratio = 0;
  91921. var distanceTo = null;
  91922. if (options) {
  91923. computeFacetNormals = (options.facetNormals) ? true : false;
  91924. computeFacetPositions = (options.facetPositions) ? true : false;
  91925. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  91926. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  91927. ratio = options.ratio || 0;
  91928. computeDepthSort = (options.depthSort) ? true : false;
  91929. distanceTo = (options.distanceTo);
  91930. if (computeDepthSort) {
  91931. if (distanceTo === undefined) {
  91932. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91933. }
  91934. var depthSortedFacets = options.depthSortedFacets;
  91935. }
  91936. }
  91937. // facetPartitioning reinit if needed
  91938. var xSubRatio = 0;
  91939. var ySubRatio = 0;
  91940. var zSubRatio = 0;
  91941. var subSq = 0;
  91942. if (computeFacetPartitioning && options && options.bbSize) {
  91943. var ox = 0; // X partitioning index for facet position
  91944. var oy = 0; // Y partinioning index for facet position
  91945. var oz = 0; // Z partinioning index for facet position
  91946. var b1x = 0; // X partitioning index for facet v1 vertex
  91947. var b1y = 0; // Y partitioning index for facet v1 vertex
  91948. var b1z = 0; // z partitioning index for facet v1 vertex
  91949. var b2x = 0; // X partitioning index for facet v2 vertex
  91950. var b2y = 0; // Y partitioning index for facet v2 vertex
  91951. var b2z = 0; // Z partitioning index for facet v2 vertex
  91952. var b3x = 0; // X partitioning index for facet v3 vertex
  91953. var b3y = 0; // Y partitioning index for facet v3 vertex
  91954. var b3z = 0; // Z partitioning index for facet v3 vertex
  91955. var block_idx_o = 0; // facet barycenter block index
  91956. var block_idx_v1 = 0; // v1 vertex block index
  91957. var block_idx_v2 = 0; // v2 vertex block index
  91958. var block_idx_v3 = 0; // v3 vertex block index
  91959. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  91960. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  91961. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  91962. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  91963. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  91964. subSq = options.subDiv.max * options.subDiv.max;
  91965. options.facetPartitioning.length = 0;
  91966. }
  91967. // reset the normals
  91968. for (index = 0; index < positions.length; index++) {
  91969. normals[index] = 0.0;
  91970. }
  91971. // Loop : 1 indice triplet = 1 facet
  91972. var nbFaces = (indices.length / 3) | 0;
  91973. for (index = 0; index < nbFaces; index++) {
  91974. // get the indexes of the coordinates of each vertex of the facet
  91975. v1x = indices[index * 3] * 3;
  91976. v1y = v1x + 1;
  91977. v1z = v1x + 2;
  91978. v2x = indices[index * 3 + 1] * 3;
  91979. v2y = v2x + 1;
  91980. v2z = v2x + 2;
  91981. v3x = indices[index * 3 + 2] * 3;
  91982. v3y = v3x + 1;
  91983. v3z = v3x + 2;
  91984. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  91985. p1p2y = positions[v1y] - positions[v2y];
  91986. p1p2z = positions[v1z] - positions[v2z];
  91987. p3p2x = positions[v3x] - positions[v2x];
  91988. p3p2y = positions[v3y] - positions[v2y];
  91989. p3p2z = positions[v3z] - positions[v2z];
  91990. // compute the face normal with the cross product
  91991. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  91992. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  91993. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  91994. // normalize this normal and store it in the array facetData
  91995. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  91996. length = (length === 0) ? 1.0 : length;
  91997. faceNormalx /= length;
  91998. faceNormaly /= length;
  91999. faceNormalz /= length;
  92000. if (computeFacetNormals && options) {
  92001. options.facetNormals[index].x = faceNormalx;
  92002. options.facetNormals[index].y = faceNormaly;
  92003. options.facetNormals[index].z = faceNormalz;
  92004. }
  92005. if (computeFacetPositions && options) {
  92006. // compute and the facet barycenter coordinates in the array facetPositions
  92007. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  92008. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  92009. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  92010. }
  92011. if (computeFacetPartitioning && options) {
  92012. // store the facet indexes in arrays in the main facetPartitioning array :
  92013. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  92014. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  92015. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  92016. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  92017. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  92018. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  92019. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  92020. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  92021. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  92022. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  92023. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  92024. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  92025. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  92026. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  92027. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  92028. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  92029. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  92030. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  92031. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  92032. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  92033. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  92034. // push each facet index in each block containing the vertex
  92035. options.facetPartitioning[block_idx_v1].push(index);
  92036. if (block_idx_v2 != block_idx_v1) {
  92037. options.facetPartitioning[block_idx_v2].push(index);
  92038. }
  92039. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  92040. options.facetPartitioning[block_idx_v3].push(index);
  92041. }
  92042. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  92043. options.facetPartitioning[block_idx_o].push(index);
  92044. }
  92045. }
  92046. if (computeDepthSort && options && options.facetPositions) {
  92047. var dsf = depthSortedFacets[index];
  92048. dsf.ind = index * 3;
  92049. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  92050. }
  92051. // compute the normals anyway
  92052. normals[v1x] += faceNormalx; // accumulate all the normals per face
  92053. normals[v1y] += faceNormaly;
  92054. normals[v1z] += faceNormalz;
  92055. normals[v2x] += faceNormalx;
  92056. normals[v2y] += faceNormaly;
  92057. normals[v2z] += faceNormalz;
  92058. normals[v3x] += faceNormalx;
  92059. normals[v3y] += faceNormaly;
  92060. normals[v3z] += faceNormalz;
  92061. }
  92062. // last normalization of each normal
  92063. for (index = 0; index < normals.length / 3; index++) {
  92064. faceNormalx = normals[index * 3];
  92065. faceNormaly = normals[index * 3 + 1];
  92066. faceNormalz = normals[index * 3 + 2];
  92067. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  92068. length = (length === 0) ? 1.0 : length;
  92069. faceNormalx /= length;
  92070. faceNormaly /= length;
  92071. faceNormalz /= length;
  92072. normals[index * 3] = faceNormalx;
  92073. normals[index * 3 + 1] = faceNormaly;
  92074. normals[index * 3 + 2] = faceNormalz;
  92075. }
  92076. };
  92077. /** @hidden */
  92078. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  92079. var li = indices.length;
  92080. var ln = normals.length;
  92081. var i;
  92082. var n;
  92083. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  92084. switch (sideOrientation) {
  92085. case VertexData.FRONTSIDE:
  92086. // nothing changed
  92087. break;
  92088. case VertexData.BACKSIDE:
  92089. var tmp;
  92090. // indices
  92091. for (i = 0; i < li; i += 3) {
  92092. tmp = indices[i];
  92093. indices[i] = indices[i + 2];
  92094. indices[i + 2] = tmp;
  92095. }
  92096. // normals
  92097. for (n = 0; n < ln; n++) {
  92098. normals[n] = -normals[n];
  92099. }
  92100. break;
  92101. case VertexData.DOUBLESIDE:
  92102. // positions
  92103. var lp = positions.length;
  92104. var l = lp / 3;
  92105. for (var p = 0; p < lp; p++) {
  92106. positions[lp + p] = positions[p];
  92107. }
  92108. // indices
  92109. for (i = 0; i < li; i += 3) {
  92110. indices[i + li] = indices[i + 2] + l;
  92111. indices[i + 1 + li] = indices[i + 1] + l;
  92112. indices[i + 2 + li] = indices[i] + l;
  92113. }
  92114. // normals
  92115. for (n = 0; n < ln; n++) {
  92116. normals[ln + n] = -normals[n];
  92117. }
  92118. // uvs
  92119. var lu = uvs.length;
  92120. var u = 0;
  92121. for (u = 0; u < lu; u++) {
  92122. uvs[u + lu] = uvs[u];
  92123. }
  92124. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  92125. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  92126. u = 0;
  92127. for (i = 0; i < lu / 2; i++) {
  92128. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  92129. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  92130. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  92131. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  92132. u += 2;
  92133. }
  92134. break;
  92135. }
  92136. };
  92137. /**
  92138. * Applies VertexData created from the imported parameters to the geometry
  92139. * @param parsedVertexData the parsed data from an imported file
  92140. * @param geometry the geometry to apply the VertexData to
  92141. */
  92142. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  92143. var vertexData = new VertexData();
  92144. // positions
  92145. var positions = parsedVertexData.positions;
  92146. if (positions) {
  92147. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  92148. }
  92149. // normals
  92150. var normals = parsedVertexData.normals;
  92151. if (normals) {
  92152. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  92153. }
  92154. // tangents
  92155. var tangents = parsedVertexData.tangents;
  92156. if (tangents) {
  92157. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  92158. }
  92159. // uvs
  92160. var uvs = parsedVertexData.uvs;
  92161. if (uvs) {
  92162. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  92163. }
  92164. // uv2s
  92165. var uv2s = parsedVertexData.uv2s;
  92166. if (uv2s) {
  92167. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  92168. }
  92169. // uv3s
  92170. var uv3s = parsedVertexData.uv3s;
  92171. if (uv3s) {
  92172. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  92173. }
  92174. // uv4s
  92175. var uv4s = parsedVertexData.uv4s;
  92176. if (uv4s) {
  92177. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  92178. }
  92179. // uv5s
  92180. var uv5s = parsedVertexData.uv5s;
  92181. if (uv5s) {
  92182. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  92183. }
  92184. // uv6s
  92185. var uv6s = parsedVertexData.uv6s;
  92186. if (uv6s) {
  92187. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  92188. }
  92189. // colors
  92190. var colors = parsedVertexData.colors;
  92191. if (colors) {
  92192. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  92193. }
  92194. // matricesIndices
  92195. var matricesIndices = parsedVertexData.matricesIndices;
  92196. if (matricesIndices) {
  92197. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  92198. }
  92199. // matricesWeights
  92200. var matricesWeights = parsedVertexData.matricesWeights;
  92201. if (matricesWeights) {
  92202. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  92203. }
  92204. // indices
  92205. var indices = parsedVertexData.indices;
  92206. if (indices) {
  92207. vertexData.indices = indices;
  92208. }
  92209. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  92210. };
  92211. /**
  92212. * Mesh side orientation : usually the external or front surface
  92213. */
  92214. VertexData.FRONTSIDE = 0;
  92215. /**
  92216. * Mesh side orientation : usually the internal or back surface
  92217. */
  92218. VertexData.BACKSIDE = 1;
  92219. /**
  92220. * Mesh side orientation : both internal and external or front and back surfaces
  92221. */
  92222. VertexData.DOUBLESIDE = 2;
  92223. /**
  92224. * Mesh side orientation : by default, `FRONTSIDE`
  92225. */
  92226. VertexData.DEFAULTSIDE = 0;
  92227. return VertexData;
  92228. }());
  92229. /***/ }),
  92230. /***/ "./Meshes/meshBuilder.ts":
  92231. /*!*******************************!*\
  92232. !*** ./Meshes/meshBuilder.ts ***!
  92233. \*******************************/
  92234. /*! exports provided: MeshBuilder */
  92235. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92236. "use strict";
  92237. __webpack_require__.r(__webpack_exports__);
  92238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  92239. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  92240. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  92241. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  92242. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  92243. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  92244. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  92245. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  92246. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  92247. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  92248. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  92249. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  92250. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  92251. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  92252. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  92253. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  92254. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  92255. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  92256. /**
  92257. * Class containing static functions to help procedurally build meshes
  92258. */
  92259. var MeshBuilder = /** @class */ (function () {
  92260. function MeshBuilder() {
  92261. }
  92262. /**
  92263. * Creates a box mesh
  92264. * * The parameter `size` sets the size (float) of each box side (default 1)
  92265. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  92266. * * 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)
  92267. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  92268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92269. * * 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
  92270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92271. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  92272. * @param name defines the name of the mesh
  92273. * @param options defines the options used to create the mesh
  92274. * @param scene defines the hosting scene
  92275. * @returns the box mesh
  92276. */
  92277. MeshBuilder.CreateBox = function (name, options, scene) {
  92278. if (scene === void 0) { scene = null; }
  92279. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  92280. };
  92281. /**
  92282. * Creates a sphere mesh
  92283. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  92284. * * 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`)
  92285. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  92286. * * 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
  92287. * * 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)
  92288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92289. * * 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
  92290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92291. * @param name defines the name of the mesh
  92292. * @param options defines the options used to create the mesh
  92293. * @param scene defines the hosting scene
  92294. * @returns the sphere mesh
  92295. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  92296. */
  92297. MeshBuilder.CreateSphere = function (name, options, scene) {
  92298. if (scene === void 0) { scene = null; }
  92299. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  92300. };
  92301. /**
  92302. * Creates a plane polygonal mesh. By default, this is a disc
  92303. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92304. * * 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
  92305. * * 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
  92306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92307. * * 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
  92308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92309. * @param name defines the name of the mesh
  92310. * @param options defines the options used to create the mesh
  92311. * @param scene defines the hosting scene
  92312. * @returns the plane polygonal mesh
  92313. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92314. */
  92315. MeshBuilder.CreateDisc = function (name, options, scene) {
  92316. if (scene === void 0) { scene = null; }
  92317. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  92318. };
  92319. /**
  92320. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  92321. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  92322. * * 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`)
  92323. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  92324. * * 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
  92325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92326. * * 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
  92327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92328. * @param name defines the name of the mesh
  92329. * @param options defines the options used to create the mesh
  92330. * @param scene defines the hosting scene
  92331. * @returns the icosahedron mesh
  92332. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  92333. */
  92334. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  92335. if (scene === void 0) { scene = null; }
  92336. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  92337. };
  92338. /**
  92339. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  92340. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  92341. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  92342. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  92343. * * 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
  92344. * * 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
  92345. * * 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
  92346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92347. * * 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
  92348. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92349. * * 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
  92350. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  92351. * * 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
  92352. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  92353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92354. * @param name defines the name of the mesh
  92355. * @param options defines the options used to create the mesh
  92356. * @param scene defines the hosting scene
  92357. * @returns the ribbon mesh
  92358. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  92359. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92360. */
  92361. MeshBuilder.CreateRibbon = function (name, options, scene) {
  92362. if (scene === void 0) { scene = null; }
  92363. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  92364. };
  92365. /**
  92366. * Creates a cylinder or a cone mesh
  92367. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  92368. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  92369. * * 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.
  92370. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  92371. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  92372. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  92373. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  92374. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  92375. * * 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).
  92376. * * 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
  92377. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  92378. * * 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
  92379. * * 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.
  92380. * * If `enclose` is false, a ring surface is one element.
  92381. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  92382. * * 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
  92383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92384. * * 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
  92385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92386. * @param name defines the name of the mesh
  92387. * @param options defines the options used to create the mesh
  92388. * @param scene defines the hosting scene
  92389. * @returns the cylinder mesh
  92390. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  92391. */
  92392. MeshBuilder.CreateCylinder = function (name, options, scene) {
  92393. if (scene === void 0) { scene = null; }
  92394. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  92395. };
  92396. /**
  92397. * Creates a torus mesh
  92398. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  92399. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  92400. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  92401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92402. * * 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
  92403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92404. * @param name defines the name of the mesh
  92405. * @param options defines the options used to create the mesh
  92406. * @param scene defines the hosting scene
  92407. * @returns the torus mesh
  92408. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  92409. */
  92410. MeshBuilder.CreateTorus = function (name, options, scene) {
  92411. if (scene === void 0) { scene = null; }
  92412. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  92413. };
  92414. /**
  92415. * Creates a torus knot mesh
  92416. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  92417. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  92418. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  92419. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  92420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92421. * * 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
  92422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92423. * @param name defines the name of the mesh
  92424. * @param options defines the options used to create the mesh
  92425. * @param scene defines the hosting scene
  92426. * @returns the torus knot mesh
  92427. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  92428. */
  92429. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  92430. if (scene === void 0) { scene = null; }
  92431. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  92432. };
  92433. /**
  92434. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  92435. * * 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
  92436. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  92437. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  92438. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  92439. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  92440. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  92441. * * 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
  92442. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  92443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  92445. * @param name defines the name of the new line system
  92446. * @param options defines the options used to create the line system
  92447. * @param scene defines the hosting scene
  92448. * @returns a new line system mesh
  92449. */
  92450. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  92451. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  92452. };
  92453. /**
  92454. * Creates a line mesh
  92455. * 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
  92456. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  92457. * * The parameter `points` is an array successive Vector3
  92458. * * 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
  92459. * * The optional parameter `colors` is an array of successive Color4, one per line point
  92460. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  92461. * * When updating an instance, remember that only point positions can change, not the number of points
  92462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  92464. * @param name defines the name of the new line system
  92465. * @param options defines the options used to create the line system
  92466. * @param scene defines the hosting scene
  92467. * @returns a new line mesh
  92468. */
  92469. MeshBuilder.CreateLines = function (name, options, scene) {
  92470. if (scene === void 0) { scene = null; }
  92471. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  92472. };
  92473. /**
  92474. * Creates a dashed line mesh
  92475. * * 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
  92476. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  92477. * * The parameter `points` is an array successive Vector3
  92478. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  92479. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  92480. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92481. * * 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
  92482. * * When updating an instance, remember that only point positions can change, not the number of points
  92483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92484. * @param name defines the name of the mesh
  92485. * @param options defines the options used to create the mesh
  92486. * @param scene defines the hosting scene
  92487. * @returns the dashed line mesh
  92488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  92489. */
  92490. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  92491. if (scene === void 0) { scene = null; }
  92492. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  92493. };
  92494. /**
  92495. * 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.
  92496. * * 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.
  92497. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  92498. * * 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.
  92499. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  92500. * * 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
  92501. * * 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
  92502. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  92503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92504. * * 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
  92505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  92506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92507. * @param name defines the name of the mesh
  92508. * @param options defines the options used to create the mesh
  92509. * @param scene defines the hosting scene
  92510. * @returns the extruded shape mesh
  92511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92513. */
  92514. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  92515. if (scene === void 0) { scene = null; }
  92516. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  92517. };
  92518. /**
  92519. * Creates an custom extruded shape mesh.
  92520. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  92521. * * 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.
  92522. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  92523. * * 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
  92524. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  92525. * * 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
  92526. * * It must returns a float value that will be the scale value applied to the shape on each path point
  92527. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92528. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  92529. * * 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
  92530. * * 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
  92531. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  92532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92533. * * 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
  92534. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92536. * @param name defines the name of the mesh
  92537. * @param options defines the options used to create the mesh
  92538. * @param scene defines the hosting scene
  92539. * @returns the custom extruded shape mesh
  92540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  92541. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92543. */
  92544. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  92545. if (scene === void 0) { scene = null; }
  92546. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  92547. };
  92548. /**
  92549. * Creates lathe mesh.
  92550. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  92551. * * 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
  92552. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  92553. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  92554. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  92555. * * 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
  92556. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  92557. * * 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
  92558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92559. * * 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
  92560. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92562. * @param name defines the name of the mesh
  92563. * @param options defines the options used to create the mesh
  92564. * @param scene defines the hosting scene
  92565. * @returns the lathe mesh
  92566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  92567. */
  92568. MeshBuilder.CreateLathe = function (name, options, scene) {
  92569. if (scene === void 0) { scene = null; }
  92570. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  92571. };
  92572. /**
  92573. * Creates a plane mesh
  92574. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92575. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92576. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92578. * * 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
  92579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92580. * @param name defines the name of the mesh
  92581. * @param options defines the options used to create the mesh
  92582. * @param scene defines the hosting scene
  92583. * @returns the plane mesh
  92584. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92585. */
  92586. MeshBuilder.CreatePlane = function (name, options, scene) {
  92587. if (scene === void 0) { scene = null; }
  92588. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  92589. };
  92590. /**
  92591. * Creates a ground mesh
  92592. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  92593. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  92594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92595. * @param name defines the name of the mesh
  92596. * @param options defines the options used to create the mesh
  92597. * @param scene defines the hosting scene
  92598. * @returns the ground mesh
  92599. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  92600. */
  92601. MeshBuilder.CreateGround = function (name, options, scene) {
  92602. if (scene === void 0) { scene = null; }
  92603. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  92604. };
  92605. /**
  92606. * Creates a tiled ground mesh
  92607. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  92608. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  92609. * * 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
  92610. * * 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
  92611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92612. * @param name defines the name of the mesh
  92613. * @param options defines the options used to create the mesh
  92614. * @param scene defines the hosting scene
  92615. * @returns the tiled ground mesh
  92616. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  92617. */
  92618. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  92619. if (scene === void 0) { scene = null; }
  92620. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  92621. };
  92622. /**
  92623. * Creates a ground mesh from a height map
  92624. * * The parameter `url` sets the URL of the height map image resource.
  92625. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  92626. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  92627. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  92628. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  92629. * * 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.
  92630. * * 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).
  92631. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92633. * @param name defines the name of the mesh
  92634. * @param url defines the url to the height map
  92635. * @param options defines the options used to create the mesh
  92636. * @param scene defines the hosting scene
  92637. * @returns the ground mesh
  92638. * @see https://doc.babylonjs.com/babylon101/height_map
  92639. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  92640. */
  92641. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  92642. if (scene === void 0) { scene = null; }
  92643. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  92644. };
  92645. /**
  92646. * Creates a polygon mesh
  92647. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  92648. * * 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
  92649. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92651. * * 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)
  92652. * * Remember you can only change the shape positions, not their number when updating a polygon
  92653. * @param name defines the name of the mesh
  92654. * @param options defines the options used to create the mesh
  92655. * @param scene defines the hosting scene
  92656. * @param earcutInjection can be used to inject your own earcut reference
  92657. * @returns the polygon mesh
  92658. */
  92659. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  92660. if (scene === void 0) { scene = null; }
  92661. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92662. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  92663. };
  92664. /**
  92665. * Creates an extruded polygon mesh, with depth in the Y direction.
  92666. * * 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)
  92667. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  92668. * @param name defines the name of the mesh
  92669. * @param options defines the options used to create the mesh
  92670. * @param scene defines the hosting scene
  92671. * @param earcutInjection can be used to inject your own earcut reference
  92672. * @returns the polygon mesh
  92673. */
  92674. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  92675. if (scene === void 0) { scene = null; }
  92676. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92677. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  92678. };
  92679. /**
  92680. * Creates a tube mesh.
  92681. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  92682. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  92683. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  92684. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  92685. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  92686. * * 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)
  92687. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  92688. * * 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
  92689. * * 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
  92690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92691. * * 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
  92692. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92694. * @param name defines the name of the mesh
  92695. * @param options defines the options used to create the mesh
  92696. * @param scene defines the hosting scene
  92697. * @returns the tube mesh
  92698. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92699. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  92700. */
  92701. MeshBuilder.CreateTube = function (name, options, scene) {
  92702. if (scene === void 0) { scene = null; }
  92703. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  92704. };
  92705. /**
  92706. * Creates a polyhedron mesh
  92707. * * 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
  92708. * * The parameter `size` (positive float, default 1) sets the polygon size
  92709. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92710. * * 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`
  92711. * * 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
  92712. * * 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)`)
  92713. * * 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
  92714. * * 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
  92715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92716. * * 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
  92717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92718. * @param name defines the name of the mesh
  92719. * @param options defines the options used to create the mesh
  92720. * @param scene defines the hosting scene
  92721. * @returns the polyhedron mesh
  92722. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  92723. */
  92724. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  92725. if (scene === void 0) { scene = null; }
  92726. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  92727. };
  92728. /**
  92729. * Creates a decal mesh.
  92730. * 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
  92731. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  92732. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  92733. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  92734. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  92735. * @param name defines the name of the mesh
  92736. * @param sourceMesh defines the mesh where the decal must be applied
  92737. * @param options defines the options used to create the mesh
  92738. * @param scene defines the hosting scene
  92739. * @returns the decal mesh
  92740. * @see https://doc.babylonjs.com/how_to/decals
  92741. */
  92742. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  92743. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  92744. };
  92745. return MeshBuilder;
  92746. }());
  92747. /***/ }),
  92748. /***/ "./Meshes/meshSimplification.ts":
  92749. /*!**************************************!*\
  92750. !*** ./Meshes/meshSimplification.ts ***!
  92751. \**************************************/
  92752. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  92753. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92754. "use strict";
  92755. __webpack_require__.r(__webpack_exports__);
  92756. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  92757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  92758. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  92759. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92760. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92761. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  92762. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  92763. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  92764. /**
  92765. * Class used to specify simplification options
  92766. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92767. */
  92768. var SimplificationSettings = /** @class */ (function () {
  92769. /**
  92770. * Creates a SimplificationSettings
  92771. * @param quality expected quality
  92772. * @param distance distance when this optimized version should be used
  92773. * @param optimizeMesh already optimized mesh
  92774. */
  92775. function SimplificationSettings(
  92776. /** expected quality */
  92777. quality,
  92778. /** distance when this optimized version should be used */
  92779. distance,
  92780. /** already optimized mesh */
  92781. optimizeMesh) {
  92782. this.quality = quality;
  92783. this.distance = distance;
  92784. this.optimizeMesh = optimizeMesh;
  92785. }
  92786. return SimplificationSettings;
  92787. }());
  92788. /**
  92789. * Queue used to order the simplification tasks
  92790. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92791. */
  92792. var SimplificationQueue = /** @class */ (function () {
  92793. /**
  92794. * Creates a new queue
  92795. */
  92796. function SimplificationQueue() {
  92797. this.running = false;
  92798. this._simplificationArray = [];
  92799. }
  92800. /**
  92801. * Adds a new simplification task
  92802. * @param task defines a task to add
  92803. */
  92804. SimplificationQueue.prototype.addTask = function (task) {
  92805. this._simplificationArray.push(task);
  92806. };
  92807. /**
  92808. * Execute next task
  92809. */
  92810. SimplificationQueue.prototype.executeNext = function () {
  92811. var task = this._simplificationArray.pop();
  92812. if (task) {
  92813. this.running = true;
  92814. this.runSimplification(task);
  92815. }
  92816. else {
  92817. this.running = false;
  92818. }
  92819. };
  92820. /**
  92821. * Execute a simplification task
  92822. * @param task defines the task to run
  92823. */
  92824. SimplificationQueue.prototype.runSimplification = function (task) {
  92825. var _this = this;
  92826. if (task.parallelProcessing) {
  92827. //parallel simplifier
  92828. task.settings.forEach(function (setting) {
  92829. var simplifier = _this.getSimplifier(task);
  92830. simplifier.simplify(setting, function (newMesh) {
  92831. task.mesh.addLODLevel(setting.distance, newMesh);
  92832. newMesh.isVisible = true;
  92833. //check if it is the last
  92834. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  92835. //all done, run the success callback.
  92836. task.successCallback();
  92837. }
  92838. _this.executeNext();
  92839. });
  92840. });
  92841. }
  92842. else {
  92843. //single simplifier.
  92844. var simplifier = this.getSimplifier(task);
  92845. var runDecimation = function (setting, callback) {
  92846. simplifier.simplify(setting, function (newMesh) {
  92847. task.mesh.addLODLevel(setting.distance, newMesh);
  92848. newMesh.isVisible = true;
  92849. //run the next quality level
  92850. callback();
  92851. });
  92852. };
  92853. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  92854. runDecimation(task.settings[loop.index], function () {
  92855. loop.executeNext();
  92856. });
  92857. }, function () {
  92858. //execution ended, run the success callback.
  92859. if (task.successCallback) {
  92860. task.successCallback();
  92861. }
  92862. _this.executeNext();
  92863. });
  92864. }
  92865. };
  92866. SimplificationQueue.prototype.getSimplifier = function (task) {
  92867. switch (task.simplificationType) {
  92868. case SimplificationType.QUADRATIC:
  92869. default:
  92870. return new QuadraticErrorSimplification(task.mesh);
  92871. }
  92872. };
  92873. return SimplificationQueue;
  92874. }());
  92875. /**
  92876. * The implemented types of simplification
  92877. * At the moment only Quadratic Error Decimation is implemented
  92878. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92879. */
  92880. var SimplificationType;
  92881. (function (SimplificationType) {
  92882. /** Quadratic error decimation */
  92883. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  92884. })(SimplificationType || (SimplificationType = {}));
  92885. var DecimationTriangle = /** @class */ (function () {
  92886. function DecimationTriangle(vertices) {
  92887. this.vertices = vertices;
  92888. this.error = new Array(4);
  92889. this.deleted = false;
  92890. this.isDirty = false;
  92891. this.deletePending = false;
  92892. this.borderFactor = 0;
  92893. }
  92894. return DecimationTriangle;
  92895. }());
  92896. var DecimationVertex = /** @class */ (function () {
  92897. function DecimationVertex(position, id) {
  92898. this.position = position;
  92899. this.id = id;
  92900. this.isBorder = true;
  92901. this.q = new QuadraticMatrix();
  92902. this.triangleCount = 0;
  92903. this.triangleStart = 0;
  92904. this.originalOffsets = [];
  92905. }
  92906. DecimationVertex.prototype.updatePosition = function (newPosition) {
  92907. this.position.copyFrom(newPosition);
  92908. };
  92909. return DecimationVertex;
  92910. }());
  92911. var QuadraticMatrix = /** @class */ (function () {
  92912. function QuadraticMatrix(data) {
  92913. this.data = new Array(10);
  92914. for (var i = 0; i < 10; ++i) {
  92915. if (data && data[i]) {
  92916. this.data[i] = data[i];
  92917. }
  92918. else {
  92919. this.data[i] = 0;
  92920. }
  92921. }
  92922. }
  92923. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  92924. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  92925. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  92926. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  92927. return det;
  92928. };
  92929. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  92930. for (var i = 0; i < 10; ++i) {
  92931. this.data[i] += matrix.data[i];
  92932. }
  92933. };
  92934. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  92935. for (var i = 0; i < 10; ++i) {
  92936. this.data[i] += data[i];
  92937. }
  92938. };
  92939. QuadraticMatrix.prototype.add = function (matrix) {
  92940. var m = new QuadraticMatrix();
  92941. for (var i = 0; i < 10; ++i) {
  92942. m.data[i] = this.data[i] + matrix.data[i];
  92943. }
  92944. return m;
  92945. };
  92946. QuadraticMatrix.FromData = function (a, b, c, d) {
  92947. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  92948. };
  92949. //returning an array to avoid garbage collection
  92950. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  92951. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  92952. };
  92953. return QuadraticMatrix;
  92954. }());
  92955. var Reference = /** @class */ (function () {
  92956. function Reference(vertexId, triangleId) {
  92957. this.vertexId = vertexId;
  92958. this.triangleId = triangleId;
  92959. }
  92960. return Reference;
  92961. }());
  92962. /**
  92963. * An implementation of the Quadratic Error simplification algorithm.
  92964. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  92965. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  92966. * @author RaananW
  92967. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92968. */
  92969. var QuadraticErrorSimplification = /** @class */ (function () {
  92970. function QuadraticErrorSimplification(_mesh) {
  92971. this._mesh = _mesh;
  92972. this.syncIterations = 5000;
  92973. this.aggressiveness = 7;
  92974. this.decimationIterations = 100;
  92975. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  92976. }
  92977. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  92978. var _this = this;
  92979. this.initDecimatedMesh();
  92980. //iterating through the submeshes array, one after the other.
  92981. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  92982. _this.initWithMesh(loop.index, function () {
  92983. _this.runDecimation(settings, loop.index, function () {
  92984. loop.executeNext();
  92985. });
  92986. }, settings.optimizeMesh);
  92987. }, function () {
  92988. setTimeout(function () {
  92989. successCallback(_this._reconstructedMesh);
  92990. }, 0);
  92991. });
  92992. };
  92993. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  92994. var _this = this;
  92995. var targetCount = ~~(this.triangles.length * settings.quality);
  92996. var deletedTriangles = 0;
  92997. var triangleCount = this.triangles.length;
  92998. var iterationFunction = function (iteration, callback) {
  92999. setTimeout(function () {
  93000. if (iteration % 5 === 0) {
  93001. _this.updateMesh(iteration === 0);
  93002. }
  93003. for (var i = 0; i < _this.triangles.length; ++i) {
  93004. _this.triangles[i].isDirty = false;
  93005. }
  93006. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  93007. var trianglesIterator = function (i) {
  93008. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  93009. var t = _this.triangles[tIdx];
  93010. if (!t) {
  93011. return;
  93012. }
  93013. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  93014. return;
  93015. }
  93016. for (var j = 0; j < 3; ++j) {
  93017. if (t.error[j] < threshold) {
  93018. var deleted0 = [];
  93019. var deleted1 = [];
  93020. var v0 = t.vertices[j];
  93021. var v1 = t.vertices[(j + 1) % 3];
  93022. if (v0.isBorder || v1.isBorder) {
  93023. continue;
  93024. }
  93025. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  93026. // var n = Vector3.Zero();
  93027. // var uv = Vector2.Zero();
  93028. // var color = new Color4(0, 0, 0, 1);
  93029. _this.calculateError(v0, v1, p);
  93030. var delTr = new Array();
  93031. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  93032. continue;
  93033. }
  93034. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  93035. continue;
  93036. }
  93037. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  93038. continue;
  93039. }
  93040. var uniqueArray = new Array();
  93041. delTr.forEach(function (deletedT) {
  93042. if (uniqueArray.indexOf(deletedT) === -1) {
  93043. deletedT.deletePending = true;
  93044. uniqueArray.push(deletedT);
  93045. }
  93046. });
  93047. if (uniqueArray.length % 2 !== 0) {
  93048. continue;
  93049. }
  93050. v0.q = v1.q.add(v0.q);
  93051. v0.updatePosition(p);
  93052. var tStart = _this.references.length;
  93053. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  93054. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  93055. var tCount = _this.references.length - tStart;
  93056. if (tCount <= v0.triangleCount) {
  93057. if (tCount) {
  93058. for (var c = 0; c < tCount; c++) {
  93059. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  93060. }
  93061. }
  93062. }
  93063. else {
  93064. v0.triangleStart = tStart;
  93065. }
  93066. v0.triangleCount = tCount;
  93067. break;
  93068. }
  93069. }
  93070. };
  93071. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  93072. }, 0);
  93073. };
  93074. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  93075. if (triangleCount - deletedTriangles <= targetCount) {
  93076. loop.breakLoop();
  93077. }
  93078. else {
  93079. iterationFunction(loop.index, function () {
  93080. loop.executeNext();
  93081. });
  93082. }
  93083. }, function () {
  93084. setTimeout(function () {
  93085. //reconstruct this part of the mesh
  93086. _this.reconstructMesh(submeshIndex);
  93087. successCallback();
  93088. }, 0);
  93089. });
  93090. };
  93091. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  93092. var _this = this;
  93093. this.vertices = [];
  93094. this.triangles = [];
  93095. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  93096. var indices = this._mesh.getIndices();
  93097. var submesh = this._mesh.subMeshes[submeshIndex];
  93098. var findInVertices = function (positionToSearch) {
  93099. if (optimizeMesh) {
  93100. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  93101. if (_this.vertices[ii].position.equals(positionToSearch)) {
  93102. return _this.vertices[ii];
  93103. }
  93104. }
  93105. }
  93106. return null;
  93107. };
  93108. var vertexReferences = [];
  93109. var vertexInit = function (i) {
  93110. if (!positionData) {
  93111. return;
  93112. }
  93113. var offset = i + submesh.verticesStart;
  93114. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  93115. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  93116. vertex.originalOffsets.push(offset);
  93117. if (vertex.id === _this.vertices.length) {
  93118. _this.vertices.push(vertex);
  93119. }
  93120. vertexReferences.push(vertex.id);
  93121. };
  93122. //var totalVertices = mesh.getTotalVertices();
  93123. var totalVertices = submesh.verticesCount;
  93124. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  93125. var indicesInit = function (i) {
  93126. if (!indices) {
  93127. return;
  93128. }
  93129. var offset = (submesh.indexStart / 3) + i;
  93130. var pos = (offset * 3);
  93131. var i0 = indices[pos + 0];
  93132. var i1 = indices[pos + 1];
  93133. var i2 = indices[pos + 2];
  93134. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  93135. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  93136. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  93137. var triangle = new DecimationTriangle([v0, v1, v2]);
  93138. triangle.originalOffset = pos;
  93139. _this.triangles.push(triangle);
  93140. };
  93141. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  93142. _this.init(callback);
  93143. });
  93144. });
  93145. };
  93146. QuadraticErrorSimplification.prototype.init = function (callback) {
  93147. var _this = this;
  93148. var triangleInit1 = function (i) {
  93149. var t = _this.triangles[i];
  93150. 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();
  93151. for (var j = 0; j < 3; j++) {
  93152. 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))));
  93153. }
  93154. };
  93155. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  93156. var triangleInit2 = function (i) {
  93157. var t = _this.triangles[i];
  93158. for (var j = 0; j < 3; ++j) {
  93159. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  93160. }
  93161. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  93162. };
  93163. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  93164. callback();
  93165. });
  93166. });
  93167. };
  93168. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  93169. var newTriangles = [];
  93170. var i;
  93171. for (i = 0; i < this.vertices.length; ++i) {
  93172. this.vertices[i].triangleCount = 0;
  93173. }
  93174. var t;
  93175. var j;
  93176. for (i = 0; i < this.triangles.length; ++i) {
  93177. if (!this.triangles[i].deleted) {
  93178. t = this.triangles[i];
  93179. for (j = 0; j < 3; ++j) {
  93180. t.vertices[j].triangleCount = 1;
  93181. }
  93182. newTriangles.push(t);
  93183. }
  93184. }
  93185. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  93186. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  93187. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  93188. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  93189. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  93190. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  93191. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  93192. var vertexCount = 0;
  93193. for (i = 0; i < this.vertices.length; ++i) {
  93194. var vertex = this.vertices[i];
  93195. vertex.id = vertexCount;
  93196. if (vertex.triangleCount) {
  93197. vertex.originalOffsets.forEach(function (originalOffset) {
  93198. if (!normalData) {
  93199. return;
  93200. }
  93201. newPositionData.push(vertex.position.x);
  93202. newPositionData.push(vertex.position.y);
  93203. newPositionData.push(vertex.position.z);
  93204. newNormalData.push(normalData[originalOffset * 3]);
  93205. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  93206. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  93207. if (uvs && uvs.length) {
  93208. newUVsData.push(uvs[(originalOffset * 2)]);
  93209. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  93210. }
  93211. if (colorsData && colorsData.length) {
  93212. newColorsData.push(colorsData[(originalOffset * 4)]);
  93213. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  93214. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  93215. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  93216. }
  93217. ++vertexCount;
  93218. });
  93219. }
  93220. }
  93221. var startingIndex = this._reconstructedMesh.getTotalIndices();
  93222. var startingVertex = this._reconstructedMesh.getTotalVertices();
  93223. var submeshesArray = this._reconstructedMesh.subMeshes;
  93224. this._reconstructedMesh.subMeshes = [];
  93225. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  93226. var originalIndices = this._mesh.getIndices();
  93227. for (i = 0; i < newTriangles.length; ++i) {
  93228. t = newTriangles[i]; //now get the new referencing point for each vertex
  93229. [0, 1, 2].forEach(function (idx) {
  93230. var id = originalIndices[t.originalOffset + idx];
  93231. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  93232. if (offset < 0) {
  93233. offset = 0;
  93234. }
  93235. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  93236. });
  93237. }
  93238. //overwriting the old vertex buffers and indices.
  93239. this._reconstructedMesh.setIndices(newIndicesArray);
  93240. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  93241. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  93242. if (newUVsData.length > 0) {
  93243. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  93244. }
  93245. if (newColorsData.length > 0) {
  93246. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  93247. }
  93248. //create submesh
  93249. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  93250. if (submeshIndex > 0) {
  93251. this._reconstructedMesh.subMeshes = [];
  93252. submeshesArray.forEach(function (submesh) {
  93253. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  93254. });
  93255. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  93256. }
  93257. };
  93258. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  93259. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  93260. this._reconstructedMesh.material = this._mesh.material;
  93261. this._reconstructedMesh.parent = this._mesh.parent;
  93262. this._reconstructedMesh.isVisible = false;
  93263. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  93264. };
  93265. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  93266. for (var i = 0; i < vertex1.triangleCount; ++i) {
  93267. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  93268. if (t.deleted) {
  93269. continue;
  93270. }
  93271. var s = this.references[vertex1.triangleStart + i].vertexId;
  93272. var v1 = t.vertices[(s + 1) % 3];
  93273. var v2 = t.vertices[(s + 2) % 3];
  93274. if ((v1 === vertex2 || v2 === vertex2)) {
  93275. deletedArray[i] = true;
  93276. delTr.push(t);
  93277. continue;
  93278. }
  93279. var d1 = v1.position.subtract(point);
  93280. d1 = d1.normalize();
  93281. var d2 = v2.position.subtract(point);
  93282. d2 = d2.normalize();
  93283. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  93284. return true;
  93285. }
  93286. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  93287. deletedArray[i] = false;
  93288. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  93289. return true;
  93290. }
  93291. }
  93292. return false;
  93293. };
  93294. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  93295. var newDeleted = deletedTriangles;
  93296. for (var i = 0; i < vertex.triangleCount; ++i) {
  93297. var ref = this.references[vertex.triangleStart + i];
  93298. var t = this.triangles[ref.triangleId];
  93299. if (t.deleted) {
  93300. continue;
  93301. }
  93302. if (deletedArray[i] && t.deletePending) {
  93303. t.deleted = true;
  93304. newDeleted++;
  93305. continue;
  93306. }
  93307. t.vertices[ref.vertexId] = origVertex;
  93308. t.isDirty = true;
  93309. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  93310. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  93311. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  93312. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  93313. this.references.push(ref);
  93314. }
  93315. return newDeleted;
  93316. };
  93317. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  93318. for (var i = 0; i < this.vertices.length; ++i) {
  93319. var vCount = [];
  93320. var vId = [];
  93321. var v = this.vertices[i];
  93322. var j;
  93323. for (j = 0; j < v.triangleCount; ++j) {
  93324. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  93325. for (var ii = 0; ii < 3; ii++) {
  93326. var ofs = 0;
  93327. var vv = triangle.vertices[ii];
  93328. while (ofs < vCount.length) {
  93329. if (vId[ofs] === vv.id) {
  93330. break;
  93331. }
  93332. ++ofs;
  93333. }
  93334. if (ofs === vCount.length) {
  93335. vCount.push(1);
  93336. vId.push(vv.id);
  93337. }
  93338. else {
  93339. vCount[ofs]++;
  93340. }
  93341. }
  93342. }
  93343. for (j = 0; j < vCount.length; ++j) {
  93344. if (vCount[j] === 1) {
  93345. this.vertices[vId[j]].isBorder = true;
  93346. }
  93347. else {
  93348. this.vertices[vId[j]].isBorder = false;
  93349. }
  93350. }
  93351. }
  93352. };
  93353. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  93354. if (identifyBorders === void 0) { identifyBorders = false; }
  93355. var i;
  93356. if (!identifyBorders) {
  93357. var newTrianglesVector = [];
  93358. for (i = 0; i < this.triangles.length; ++i) {
  93359. if (!this.triangles[i].deleted) {
  93360. newTrianglesVector.push(this.triangles[i]);
  93361. }
  93362. }
  93363. this.triangles = newTrianglesVector;
  93364. }
  93365. for (i = 0; i < this.vertices.length; ++i) {
  93366. this.vertices[i].triangleCount = 0;
  93367. this.vertices[i].triangleStart = 0;
  93368. }
  93369. var t;
  93370. var j;
  93371. var v;
  93372. for (i = 0; i < this.triangles.length; ++i) {
  93373. t = this.triangles[i];
  93374. for (j = 0; j < 3; ++j) {
  93375. v = t.vertices[j];
  93376. v.triangleCount++;
  93377. }
  93378. }
  93379. var tStart = 0;
  93380. for (i = 0; i < this.vertices.length; ++i) {
  93381. this.vertices[i].triangleStart = tStart;
  93382. tStart += this.vertices[i].triangleCount;
  93383. this.vertices[i].triangleCount = 0;
  93384. }
  93385. var newReferences = new Array(this.triangles.length * 3);
  93386. for (i = 0; i < this.triangles.length; ++i) {
  93387. t = this.triangles[i];
  93388. for (j = 0; j < 3; ++j) {
  93389. v = t.vertices[j];
  93390. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  93391. v.triangleCount++;
  93392. }
  93393. }
  93394. this.references = newReferences;
  93395. if (identifyBorders) {
  93396. this.identifyBorder();
  93397. }
  93398. };
  93399. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  93400. var x = point.x;
  93401. var y = point.y;
  93402. var z = point.z;
  93403. 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
  93404. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  93405. };
  93406. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  93407. var q = vertex1.q.add(vertex2.q);
  93408. var border = vertex1.isBorder && vertex2.isBorder;
  93409. var error = 0;
  93410. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  93411. if (qDet !== 0 && !border) {
  93412. if (!pointResult) {
  93413. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  93414. }
  93415. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  93416. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  93417. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  93418. error = this.vertexError(q, pointResult);
  93419. }
  93420. else {
  93421. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  93422. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  93423. var error1 = this.vertexError(q, vertex1.position);
  93424. var error2 = this.vertexError(q, vertex2.position);
  93425. var error3 = this.vertexError(q, p3);
  93426. error = Math.min(error1, error2, error3);
  93427. if (error === error1) {
  93428. if (pointResult) {
  93429. pointResult.copyFrom(vertex1.position);
  93430. }
  93431. }
  93432. else if (error === error2) {
  93433. if (pointResult) {
  93434. pointResult.copyFrom(vertex2.position);
  93435. }
  93436. }
  93437. else {
  93438. if (pointResult) {
  93439. pointResult.copyFrom(p3);
  93440. }
  93441. }
  93442. }
  93443. return error;
  93444. };
  93445. return QuadraticErrorSimplification;
  93446. }());
  93447. /***/ }),
  93448. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  93449. /*!****************************************************!*\
  93450. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  93451. \****************************************************/
  93452. /*! exports provided: SimplicationQueueSceneComponent */
  93453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93454. "use strict";
  93455. __webpack_require__.r(__webpack_exports__);
  93456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  93457. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  93458. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  93459. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  93460. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  93461. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  93462. get: function () {
  93463. if (!this._simplificationQueue) {
  93464. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  93465. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  93466. if (!component) {
  93467. component = new SimplicationQueueSceneComponent(this);
  93468. this._addComponent(component);
  93469. }
  93470. }
  93471. return this._simplificationQueue;
  93472. },
  93473. set: function (value) {
  93474. this._simplificationQueue = value;
  93475. },
  93476. enumerable: true,
  93477. configurable: true
  93478. });
  93479. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  93480. if (parallelProcessing === void 0) { parallelProcessing = true; }
  93481. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  93482. this.getScene().simplificationQueue.addTask({
  93483. settings: settings,
  93484. parallelProcessing: parallelProcessing,
  93485. mesh: this,
  93486. simplificationType: simplificationType,
  93487. successCallback: successCallback
  93488. });
  93489. return this;
  93490. };
  93491. /**
  93492. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  93493. * created in a scene
  93494. */
  93495. var SimplicationQueueSceneComponent = /** @class */ (function () {
  93496. /**
  93497. * Creates a new instance of the component for the given scene
  93498. * @param scene Defines the scene to register the component in
  93499. */
  93500. function SimplicationQueueSceneComponent(scene) {
  93501. /**
  93502. * The component name helpfull to identify the component in the list of scene components.
  93503. */
  93504. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  93505. this.scene = scene;
  93506. }
  93507. /**
  93508. * Registers the component in a given scene
  93509. */
  93510. SimplicationQueueSceneComponent.prototype.register = function () {
  93511. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  93512. };
  93513. /**
  93514. * Rebuilds the elements related to this component in case of
  93515. * context lost for instance.
  93516. */
  93517. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  93518. // Nothing to do for this component
  93519. };
  93520. /**
  93521. * Disposes the component and the associated ressources
  93522. */
  93523. SimplicationQueueSceneComponent.prototype.dispose = function () {
  93524. // Nothing to do for this component
  93525. };
  93526. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  93527. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  93528. this.scene._simplificationQueue.executeNext();
  93529. }
  93530. };
  93531. return SimplicationQueueSceneComponent;
  93532. }());
  93533. /***/ }),
  93534. /***/ "./Meshes/polygonMesh.ts":
  93535. /*!*******************************!*\
  93536. !*** ./Meshes/polygonMesh.ts ***!
  93537. \*******************************/
  93538. /*! exports provided: Polygon, PolygonMeshBuilder */
  93539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93540. "use strict";
  93541. __webpack_require__.r(__webpack_exports__);
  93542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  93543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  93544. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93545. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93546. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93547. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  93548. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  93549. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  93550. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  93551. /**
  93552. * Vector2 wth index property
  93553. */
  93554. var IndexedVector2 = /** @class */ (function (_super) {
  93555. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  93556. function IndexedVector2(original,
  93557. /** Index of the vector2 */
  93558. index) {
  93559. var _this = _super.call(this, original.x, original.y) || this;
  93560. _this.index = index;
  93561. return _this;
  93562. }
  93563. return IndexedVector2;
  93564. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  93565. /**
  93566. * Defines points to create a polygon
  93567. */
  93568. var PolygonPoints = /** @class */ (function () {
  93569. function PolygonPoints() {
  93570. this.elements = new Array();
  93571. }
  93572. PolygonPoints.prototype.add = function (originalPoints) {
  93573. var _this = this;
  93574. var result = new Array();
  93575. originalPoints.forEach(function (point) {
  93576. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  93577. var newPoint = new IndexedVector2(point, _this.elements.length);
  93578. result.push(newPoint);
  93579. _this.elements.push(newPoint);
  93580. }
  93581. });
  93582. return result;
  93583. };
  93584. PolygonPoints.prototype.computeBounds = function () {
  93585. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  93586. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  93587. this.elements.forEach(function (point) {
  93588. // x
  93589. if (point.x < lmin.x) {
  93590. lmin.x = point.x;
  93591. }
  93592. else if (point.x > lmax.x) {
  93593. lmax.x = point.x;
  93594. }
  93595. // y
  93596. if (point.y < lmin.y) {
  93597. lmin.y = point.y;
  93598. }
  93599. else if (point.y > lmax.y) {
  93600. lmax.y = point.y;
  93601. }
  93602. });
  93603. return {
  93604. min: lmin,
  93605. max: lmax,
  93606. width: lmax.x - lmin.x,
  93607. height: lmax.y - lmin.y
  93608. };
  93609. };
  93610. return PolygonPoints;
  93611. }());
  93612. /**
  93613. * Polygon
  93614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93615. */
  93616. var Polygon = /** @class */ (function () {
  93617. function Polygon() {
  93618. }
  93619. /**
  93620. * Creates a rectangle
  93621. * @param xmin bottom X coord
  93622. * @param ymin bottom Y coord
  93623. * @param xmax top X coord
  93624. * @param ymax top Y coord
  93625. * @returns points that make the resulting rectation
  93626. */
  93627. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  93628. return [
  93629. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  93630. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  93631. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  93632. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  93633. ];
  93634. };
  93635. /**
  93636. * Creates a circle
  93637. * @param radius radius of circle
  93638. * @param cx scale in x
  93639. * @param cy scale in y
  93640. * @param numberOfSides number of sides that make up the circle
  93641. * @returns points that make the resulting circle
  93642. */
  93643. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  93644. if (cx === void 0) { cx = 0; }
  93645. if (cy === void 0) { cy = 0; }
  93646. if (numberOfSides === void 0) { numberOfSides = 32; }
  93647. var result = new Array();
  93648. var angle = 0;
  93649. var increment = (Math.PI * 2) / numberOfSides;
  93650. for (var i = 0; i < numberOfSides; i++) {
  93651. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  93652. angle -= increment;
  93653. }
  93654. return result;
  93655. };
  93656. /**
  93657. * Creates a polygon from input string
  93658. * @param input Input polygon data
  93659. * @returns the parsed points
  93660. */
  93661. Polygon.Parse = function (input) {
  93662. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  93663. var i, result = [];
  93664. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  93665. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  93666. }
  93667. return result;
  93668. };
  93669. /**
  93670. * Starts building a polygon from x and y coordinates
  93671. * @param x x coordinate
  93672. * @param y y coordinate
  93673. * @returns the started path2
  93674. */
  93675. Polygon.StartingAt = function (x, y) {
  93676. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  93677. };
  93678. return Polygon;
  93679. }());
  93680. /**
  93681. * Builds a polygon
  93682. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  93683. */
  93684. var PolygonMeshBuilder = /** @class */ (function () {
  93685. /**
  93686. * Creates a PolygonMeshBuilder
  93687. * @param name name of the builder
  93688. * @param contours Path of the polygon
  93689. * @param scene scene to add to when creating the mesh
  93690. * @param earcutInjection can be used to inject your own earcut reference
  93691. */
  93692. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  93693. if (earcutInjection === void 0) { earcutInjection = earcut; }
  93694. this._points = new PolygonPoints();
  93695. this._outlinepoints = new PolygonPoints();
  93696. this._holes = new Array();
  93697. this._epoints = new Array();
  93698. this._eholes = new Array();
  93699. this.bjsEarcut = earcutInjection;
  93700. this._name = name;
  93701. this._scene = scene || _Engines_engine__WEBPACK_IMPORTED_MODULE_6__["Engine"].LastCreatedScene;
  93702. var points;
  93703. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  93704. points = contours.getPoints();
  93705. }
  93706. else {
  93707. points = contours;
  93708. }
  93709. this._addToepoint(points);
  93710. this._points.add(points);
  93711. this._outlinepoints.add(points);
  93712. if (typeof this.bjsEarcut === 'undefined') {
  93713. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  93714. }
  93715. }
  93716. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  93717. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  93718. var p = points_1[_i];
  93719. this._epoints.push(p.x, p.y);
  93720. }
  93721. };
  93722. /**
  93723. * Adds a whole within the polygon
  93724. * @param hole Array of points defining the hole
  93725. * @returns this
  93726. */
  93727. PolygonMeshBuilder.prototype.addHole = function (hole) {
  93728. this._points.add(hole);
  93729. var holepoints = new PolygonPoints();
  93730. holepoints.add(hole);
  93731. this._holes.push(holepoints);
  93732. this._eholes.push(this._epoints.length / 2);
  93733. this._addToepoint(hole);
  93734. return this;
  93735. };
  93736. /**
  93737. * Creates the polygon
  93738. * @param updatable If the mesh should be updatable
  93739. * @param depth The depth of the mesh created
  93740. * @returns the created mesh
  93741. */
  93742. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  93743. if (updatable === void 0) { updatable = false; }
  93744. if (depth === void 0) { depth = 0; }
  93745. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  93746. var vertexData = this.buildVertexData(depth);
  93747. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, vertexData.positions, updatable);
  93748. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, vertexData.normals, updatable);
  93749. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, vertexData.uvs, updatable);
  93750. result.setIndices(vertexData.indices);
  93751. return result;
  93752. };
  93753. /**
  93754. * Creates the polygon
  93755. * @param depth The depth of the mesh created
  93756. * @returns the created VertexData
  93757. */
  93758. PolygonMeshBuilder.prototype.buildVertexData = function (depth) {
  93759. var _this = this;
  93760. if (depth === void 0) { depth = 0; }
  93761. var result = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  93762. var normals = new Array();
  93763. var positions = new Array();
  93764. var uvs = new Array();
  93765. var bounds = this._points.computeBounds();
  93766. this._points.elements.forEach(function (p) {
  93767. normals.push(0, 1.0, 0);
  93768. positions.push(p.x, 0, p.y);
  93769. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  93770. });
  93771. var indices = new Array();
  93772. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  93773. for (var i = 0; i < res.length; i++) {
  93774. indices.push(res[i]);
  93775. }
  93776. if (depth > 0) {
  93777. var positionscount = (positions.length / 3); //get the current pointcount
  93778. this._points.elements.forEach(function (p) {
  93779. normals.push(0, -1.0, 0);
  93780. positions.push(p.x, -depth, p.y);
  93781. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  93782. });
  93783. var totalCount = indices.length;
  93784. for (var i = 0; i < totalCount; i += 3) {
  93785. var i0 = indices[i + 0];
  93786. var i1 = indices[i + 1];
  93787. var i2 = indices[i + 2];
  93788. indices.push(i2 + positionscount);
  93789. indices.push(i1 + positionscount);
  93790. indices.push(i0 + positionscount);
  93791. }
  93792. //Add the sides
  93793. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  93794. this._holes.forEach(function (hole) {
  93795. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  93796. });
  93797. }
  93798. result.indices = indices;
  93799. result.positions = positions;
  93800. result.normals = normals;
  93801. result.uvs = uvs;
  93802. return result;
  93803. };
  93804. /**
  93805. * Adds a side to the polygon
  93806. * @param positions points that make the polygon
  93807. * @param normals normals of the polygon
  93808. * @param uvs uvs of the polygon
  93809. * @param indices indices of the polygon
  93810. * @param bounds bounds of the polygon
  93811. * @param points points of the polygon
  93812. * @param depth depth of the polygon
  93813. * @param flip flip of the polygon
  93814. */
  93815. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  93816. var StartIndex = positions.length / 3;
  93817. var ulength = 0;
  93818. for (var i = 0; i < points.elements.length; i++) {
  93819. var p = points.elements[i];
  93820. var p1;
  93821. if ((i + 1) > points.elements.length - 1) {
  93822. p1 = points.elements[0];
  93823. }
  93824. else {
  93825. p1 = points.elements[i + 1];
  93826. }
  93827. positions.push(p.x, 0, p.y);
  93828. positions.push(p.x, -depth, p.y);
  93829. positions.push(p1.x, 0, p1.y);
  93830. positions.push(p1.x, -depth, p1.y);
  93831. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  93832. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  93833. var v3 = v2.subtract(v1);
  93834. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  93835. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  93836. vn = vn.normalize();
  93837. uvs.push(ulength / bounds.width, 0);
  93838. uvs.push(ulength / bounds.width, 1);
  93839. ulength += v3.length();
  93840. uvs.push((ulength / bounds.width), 0);
  93841. uvs.push((ulength / bounds.width), 1);
  93842. if (!flip) {
  93843. normals.push(-vn.x, -vn.y, -vn.z);
  93844. normals.push(-vn.x, -vn.y, -vn.z);
  93845. normals.push(-vn.x, -vn.y, -vn.z);
  93846. normals.push(-vn.x, -vn.y, -vn.z);
  93847. indices.push(StartIndex);
  93848. indices.push(StartIndex + 1);
  93849. indices.push(StartIndex + 2);
  93850. indices.push(StartIndex + 1);
  93851. indices.push(StartIndex + 3);
  93852. indices.push(StartIndex + 2);
  93853. }
  93854. else {
  93855. normals.push(vn.x, vn.y, vn.z);
  93856. normals.push(vn.x, vn.y, vn.z);
  93857. normals.push(vn.x, vn.y, vn.z);
  93858. normals.push(vn.x, vn.y, vn.z);
  93859. indices.push(StartIndex);
  93860. indices.push(StartIndex + 2);
  93861. indices.push(StartIndex + 1);
  93862. indices.push(StartIndex + 1);
  93863. indices.push(StartIndex + 2);
  93864. indices.push(StartIndex + 3);
  93865. }
  93866. StartIndex += 4;
  93867. }
  93868. };
  93869. return PolygonMeshBuilder;
  93870. }());
  93871. /***/ }),
  93872. /***/ "./Meshes/subMesh.ts":
  93873. /*!***************************!*\
  93874. !*** ./Meshes/subMesh.ts ***!
  93875. \***************************/
  93876. /*! exports provided: BaseSubMesh, SubMesh */
  93877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93878. "use strict";
  93879. __webpack_require__.r(__webpack_exports__);
  93880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  93881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  93882. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93883. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  93884. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  93885. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  93886. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  93887. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  93888. /**
  93889. * Base class for submeshes
  93890. */
  93891. var BaseSubMesh = /** @class */ (function () {
  93892. function BaseSubMesh() {
  93893. /** @hidden */
  93894. this._materialDefines = null;
  93895. /** @hidden */
  93896. this._materialEffect = null;
  93897. }
  93898. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  93899. /**
  93900. * Gets associated effect
  93901. */
  93902. get: function () {
  93903. return this._materialEffect;
  93904. },
  93905. enumerable: true,
  93906. configurable: true
  93907. });
  93908. /**
  93909. * Sets associated effect (effect used to render this submesh)
  93910. * @param effect defines the effect to associate with
  93911. * @param defines defines the set of defines used to compile this effect
  93912. */
  93913. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  93914. if (defines === void 0) { defines = null; }
  93915. if (this._materialEffect === effect) {
  93916. if (!effect) {
  93917. this._materialDefines = null;
  93918. }
  93919. return;
  93920. }
  93921. this._materialDefines = defines;
  93922. this._materialEffect = effect;
  93923. };
  93924. return BaseSubMesh;
  93925. }());
  93926. /**
  93927. * Defines a subdivision inside a mesh
  93928. */
  93929. var SubMesh = /** @class */ (function (_super) {
  93930. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  93931. /**
  93932. * Creates a new submesh
  93933. * @param materialIndex defines the material index to use
  93934. * @param verticesStart defines vertex index start
  93935. * @param verticesCount defines vertices count
  93936. * @param indexStart defines index start
  93937. * @param indexCount defines indices count
  93938. * @param mesh defines the parent mesh
  93939. * @param renderingMesh defines an optional rendering mesh
  93940. * @param createBoundingBox defines if bounding box should be created for this submesh
  93941. */
  93942. function SubMesh(
  93943. /** the material index to use */
  93944. materialIndex,
  93945. /** vertex index start */
  93946. verticesStart,
  93947. /** vertices count */
  93948. verticesCount,
  93949. /** index start */
  93950. indexStart,
  93951. /** indices count */
  93952. indexCount, mesh, renderingMesh, createBoundingBox) {
  93953. if (createBoundingBox === void 0) { createBoundingBox = true; }
  93954. var _this = _super.call(this) || this;
  93955. _this.materialIndex = materialIndex;
  93956. _this.verticesStart = verticesStart;
  93957. _this.verticesCount = verticesCount;
  93958. _this.indexStart = indexStart;
  93959. _this.indexCount = indexCount;
  93960. /** @hidden */
  93961. _this._linesIndexCount = 0;
  93962. _this._linesIndexBuffer = null;
  93963. /** @hidden */
  93964. _this._lastColliderWorldVertices = null;
  93965. /** @hidden */
  93966. _this._lastColliderTransformMatrix = null;
  93967. /** @hidden */
  93968. _this._renderId = 0;
  93969. /** @hidden */
  93970. _this._alphaIndex = 0;
  93971. /** @hidden */
  93972. _this._distanceToCamera = 0;
  93973. _this._currentMaterial = null;
  93974. _this._mesh = mesh;
  93975. _this._renderingMesh = renderingMesh || mesh;
  93976. mesh.subMeshes.push(_this);
  93977. _this._trianglePlanes = [];
  93978. _this._id = mesh.subMeshes.length - 1;
  93979. if (createBoundingBox) {
  93980. _this.refreshBoundingInfo();
  93981. mesh.computeWorldMatrix(true);
  93982. }
  93983. return _this;
  93984. }
  93985. /**
  93986. * Add a new submesh to a mesh
  93987. * @param materialIndex defines the material index to use
  93988. * @param verticesStart defines vertex index start
  93989. * @param verticesCount defines vertices count
  93990. * @param indexStart defines index start
  93991. * @param indexCount defines indices count
  93992. * @param mesh defines the parent mesh
  93993. * @param renderingMesh defines an optional rendering mesh
  93994. * @param createBoundingBox defines if bounding box should be created for this submesh
  93995. * @returns the new submesh
  93996. */
  93997. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  93998. if (createBoundingBox === void 0) { createBoundingBox = true; }
  93999. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  94000. };
  94001. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  94002. /**
  94003. * Returns true if this submesh covers the entire parent mesh
  94004. * @ignorenaming
  94005. */
  94006. get: function () {
  94007. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  94008. },
  94009. enumerable: true,
  94010. configurable: true
  94011. });
  94012. /**
  94013. * Returns the submesh BoudingInfo object
  94014. * @returns current bounding info (or mesh's one if the submesh is global)
  94015. */
  94016. SubMesh.prototype.getBoundingInfo = function () {
  94017. if (this.IsGlobal) {
  94018. return this._mesh.getBoundingInfo();
  94019. }
  94020. return this._boundingInfo;
  94021. };
  94022. /**
  94023. * Sets the submesh BoundingInfo
  94024. * @param boundingInfo defines the new bounding info to use
  94025. * @returns the SubMesh
  94026. */
  94027. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  94028. this._boundingInfo = boundingInfo;
  94029. return this;
  94030. };
  94031. /**
  94032. * Returns the mesh of the current submesh
  94033. * @return the parent mesh
  94034. */
  94035. SubMesh.prototype.getMesh = function () {
  94036. return this._mesh;
  94037. };
  94038. /**
  94039. * Returns the rendering mesh of the submesh
  94040. * @returns the rendering mesh (could be different from parent mesh)
  94041. */
  94042. SubMesh.prototype.getRenderingMesh = function () {
  94043. return this._renderingMesh;
  94044. };
  94045. /**
  94046. * Returns the submesh material
  94047. * @returns null or the current material
  94048. */
  94049. SubMesh.prototype.getMaterial = function () {
  94050. var rootMaterial = this._renderingMesh.material;
  94051. if (rootMaterial === null || rootMaterial === undefined) {
  94052. return this._mesh.getScene().defaultMaterial;
  94053. }
  94054. else if (rootMaterial.getSubMaterial) {
  94055. var multiMaterial = rootMaterial;
  94056. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  94057. if (this._currentMaterial !== effectiveMaterial) {
  94058. this._currentMaterial = effectiveMaterial;
  94059. this._materialDefines = null;
  94060. }
  94061. return effectiveMaterial;
  94062. }
  94063. return rootMaterial;
  94064. };
  94065. // Methods
  94066. /**
  94067. * Sets a new updated BoundingInfo object to the submesh
  94068. * @returns the SubMesh
  94069. */
  94070. SubMesh.prototype.refreshBoundingInfo = function () {
  94071. this._lastColliderWorldVertices = null;
  94072. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  94073. return this;
  94074. }
  94075. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  94076. if (!data) {
  94077. this._boundingInfo = this._mesh.getBoundingInfo();
  94078. return this;
  94079. }
  94080. var indices = this._renderingMesh.getIndices();
  94081. var extend;
  94082. //is this the only submesh?
  94083. if (this.indexStart === 0 && this.indexCount === indices.length) {
  94084. var boundingInfo = this._renderingMesh.getBoundingInfo();
  94085. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  94086. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  94087. }
  94088. else {
  94089. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  94090. }
  94091. if (this._boundingInfo) {
  94092. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  94093. }
  94094. else {
  94095. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  94096. }
  94097. return this;
  94098. };
  94099. /** @hidden */
  94100. SubMesh.prototype._checkCollision = function (collider) {
  94101. var boundingInfo = this.getBoundingInfo();
  94102. return boundingInfo._checkCollision(collider);
  94103. };
  94104. /**
  94105. * Updates the submesh BoundingInfo
  94106. * @param world defines the world matrix to use to update the bounding info
  94107. * @returns the submesh
  94108. */
  94109. SubMesh.prototype.updateBoundingInfo = function (world) {
  94110. var boundingInfo = this.getBoundingInfo();
  94111. if (!boundingInfo) {
  94112. this.refreshBoundingInfo();
  94113. boundingInfo = this.getBoundingInfo();
  94114. }
  94115. boundingInfo.update(world);
  94116. return this;
  94117. };
  94118. /**
  94119. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94120. * @param frustumPlanes defines the frustum planes
  94121. * @returns true if the submesh is intersecting with the frustum
  94122. */
  94123. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  94124. var boundingInfo = this.getBoundingInfo();
  94125. if (!boundingInfo) {
  94126. return false;
  94127. }
  94128. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  94129. };
  94130. /**
  94131. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94132. * @param frustumPlanes defines the frustum planes
  94133. * @returns true if the submesh is inside the frustum
  94134. */
  94135. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  94136. var boundingInfo = this.getBoundingInfo();
  94137. if (!boundingInfo) {
  94138. return false;
  94139. }
  94140. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  94141. };
  94142. /**
  94143. * Renders the submesh
  94144. * @param enableAlphaMode defines if alpha needs to be used
  94145. * @returns the submesh
  94146. */
  94147. SubMesh.prototype.render = function (enableAlphaMode) {
  94148. this._renderingMesh.render(this, enableAlphaMode);
  94149. return this;
  94150. };
  94151. /**
  94152. * @hidden
  94153. */
  94154. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  94155. if (!this._linesIndexBuffer) {
  94156. var linesIndices = [];
  94157. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  94158. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  94159. }
  94160. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  94161. this._linesIndexCount = linesIndices.length;
  94162. }
  94163. return this._linesIndexBuffer;
  94164. };
  94165. /**
  94166. * Checks if the submesh intersects with a ray
  94167. * @param ray defines the ray to test
  94168. * @returns true is the passed ray intersects the submesh bounding box
  94169. */
  94170. SubMesh.prototype.canIntersects = function (ray) {
  94171. var boundingInfo = this.getBoundingInfo();
  94172. if (!boundingInfo) {
  94173. return false;
  94174. }
  94175. return ray.intersectsBox(boundingInfo.boundingBox);
  94176. };
  94177. /**
  94178. * Intersects current submesh with a ray
  94179. * @param ray defines the ray to test
  94180. * @param positions defines mesh's positions array
  94181. * @param indices defines mesh's indices array
  94182. * @param fastCheck defines if only bounding info should be used
  94183. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94184. * @returns intersection info or null if no intersection
  94185. */
  94186. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  94187. var material = this.getMaterial();
  94188. if (!material) {
  94189. return null;
  94190. }
  94191. switch (material.fillMode) {
  94192. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  94193. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  94194. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  94195. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  94196. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  94197. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  94198. return null;
  94199. }
  94200. // LineMesh first as it's also a Mesh...
  94201. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  94202. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  94203. }
  94204. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  94205. };
  94206. /** @hidden */
  94207. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  94208. var intersectInfo = null;
  94209. // Line test
  94210. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  94211. var p0 = positions[indices[index]];
  94212. var p1 = positions[indices[index + 1]];
  94213. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  94214. if (length < 0) {
  94215. continue;
  94216. }
  94217. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  94218. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  94219. intersectInfo.faceId = index / 2;
  94220. if (fastCheck) {
  94221. break;
  94222. }
  94223. }
  94224. }
  94225. return intersectInfo;
  94226. };
  94227. /** @hidden */
  94228. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  94229. var intersectInfo = null;
  94230. // Triangles test
  94231. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  94232. var p0 = positions[indices[index]];
  94233. var p1 = positions[indices[index + 1]];
  94234. var p2 = positions[indices[index + 2]];
  94235. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  94236. continue;
  94237. }
  94238. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  94239. if (currentIntersectInfo) {
  94240. if (currentIntersectInfo.distance < 0) {
  94241. continue;
  94242. }
  94243. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  94244. intersectInfo = currentIntersectInfo;
  94245. intersectInfo.faceId = index / 3;
  94246. if (fastCheck) {
  94247. break;
  94248. }
  94249. }
  94250. }
  94251. }
  94252. return intersectInfo;
  94253. };
  94254. /** @hidden */
  94255. SubMesh.prototype._rebuild = function () {
  94256. if (this._linesIndexBuffer) {
  94257. this._linesIndexBuffer = null;
  94258. }
  94259. };
  94260. // Clone
  94261. /**
  94262. * Creates a new submesh from the passed mesh
  94263. * @param newMesh defines the new hosting mesh
  94264. * @param newRenderingMesh defines an optional rendering mesh
  94265. * @returns the new submesh
  94266. */
  94267. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  94268. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  94269. if (!this.IsGlobal) {
  94270. var boundingInfo = this.getBoundingInfo();
  94271. if (!boundingInfo) {
  94272. return result;
  94273. }
  94274. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  94275. }
  94276. return result;
  94277. };
  94278. // Dispose
  94279. /**
  94280. * Release associated resources
  94281. */
  94282. SubMesh.prototype.dispose = function () {
  94283. if (this._linesIndexBuffer) {
  94284. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  94285. this._linesIndexBuffer = null;
  94286. }
  94287. // Remove from mesh
  94288. var index = this._mesh.subMeshes.indexOf(this);
  94289. this._mesh.subMeshes.splice(index, 1);
  94290. };
  94291. /**
  94292. * Gets the class name
  94293. * @returns the string "SubMesh".
  94294. */
  94295. SubMesh.prototype.getClassName = function () {
  94296. return "SubMesh";
  94297. };
  94298. // Statics
  94299. /**
  94300. * Creates a new submesh from indices data
  94301. * @param materialIndex the index of the main mesh material
  94302. * @param startIndex the index where to start the copy in the mesh indices array
  94303. * @param indexCount the number of indices to copy then from the startIndex
  94304. * @param mesh the main mesh to create the submesh from
  94305. * @param renderingMesh the optional rendering mesh
  94306. * @returns a new submesh
  94307. */
  94308. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  94309. var minVertexIndex = Number.MAX_VALUE;
  94310. var maxVertexIndex = -Number.MAX_VALUE;
  94311. var whatWillRender = (renderingMesh || mesh);
  94312. var indices = whatWillRender.getIndices();
  94313. for (var index = startIndex; index < startIndex + indexCount; index++) {
  94314. var vertexIndex = indices[index];
  94315. if (vertexIndex < minVertexIndex) {
  94316. minVertexIndex = vertexIndex;
  94317. }
  94318. if (vertexIndex > maxVertexIndex) {
  94319. maxVertexIndex = vertexIndex;
  94320. }
  94321. }
  94322. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  94323. };
  94324. return SubMesh;
  94325. }(BaseSubMesh));
  94326. /***/ }),
  94327. /***/ "./Meshes/trailMesh.ts":
  94328. /*!*****************************!*\
  94329. !*** ./Meshes/trailMesh.ts ***!
  94330. \*****************************/
  94331. /*! exports provided: TrailMesh */
  94332. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94333. "use strict";
  94334. __webpack_require__.r(__webpack_exports__);
  94335. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  94336. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  94337. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  94338. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94339. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  94340. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  94341. /**
  94342. * Class used to create a trail following a mesh
  94343. */
  94344. var TrailMesh = /** @class */ (function (_super) {
  94345. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  94346. /**
  94347. * @constructor
  94348. * @param name The value used by scene.getMeshByName() to do a lookup.
  94349. * @param generator The mesh to generate a trail.
  94350. * @param scene The scene to add this mesh to.
  94351. * @param diameter Diameter of trailing mesh. Default is 1.
  94352. * @param length Length of trailing mesh. Default is 60.
  94353. * @param autoStart Automatically start trailing mesh. Default true.
  94354. */
  94355. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  94356. if (diameter === void 0) { diameter = 1; }
  94357. if (length === void 0) { length = 60; }
  94358. if (autoStart === void 0) { autoStart = true; }
  94359. var _this = _super.call(this, name, scene) || this;
  94360. _this._sectionPolygonPointsCount = 4;
  94361. _this._running = false;
  94362. _this._autoStart = autoStart;
  94363. _this._generator = generator;
  94364. _this._diameter = diameter;
  94365. _this._length = length;
  94366. _this._sectionVectors = [];
  94367. _this._sectionNormalVectors = [];
  94368. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  94369. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  94370. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  94371. }
  94372. _this._createMesh();
  94373. return _this;
  94374. }
  94375. /**
  94376. * "TrailMesh"
  94377. * @returns "TrailMesh"
  94378. */
  94379. TrailMesh.prototype.getClassName = function () {
  94380. return "TrailMesh";
  94381. };
  94382. TrailMesh.prototype._createMesh = function () {
  94383. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  94384. var positions = [];
  94385. var normals = [];
  94386. var indices = [];
  94387. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  94388. if (this._generator._boundingInfo) {
  94389. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  94390. }
  94391. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  94392. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  94393. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  94394. }
  94395. for (var i = 1; i <= this._length; i++) {
  94396. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  94397. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  94398. }
  94399. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  94400. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  94401. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  94402. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  94403. }
  94404. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  94405. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  94406. }
  94407. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  94408. data.positions = positions;
  94409. data.normals = normals;
  94410. data.indices = indices;
  94411. data.applyToMesh(this, true);
  94412. if (this._autoStart) {
  94413. this.start();
  94414. }
  94415. };
  94416. /**
  94417. * Start trailing mesh.
  94418. */
  94419. TrailMesh.prototype.start = function () {
  94420. var _this = this;
  94421. if (!this._running) {
  94422. this._running = true;
  94423. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  94424. _this.update();
  94425. });
  94426. }
  94427. };
  94428. /**
  94429. * Stop trailing mesh.
  94430. */
  94431. TrailMesh.prototype.stop = function () {
  94432. if (this._beforeRenderObserver && this._running) {
  94433. this._running = false;
  94434. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  94435. }
  94436. };
  94437. /**
  94438. * Update trailing mesh geometry.
  94439. */
  94440. TrailMesh.prototype.update = function () {
  94441. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  94442. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  94443. var wm = this._generator.getWorldMatrix();
  94444. if (positions && normals) {
  94445. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  94446. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  94447. }
  94448. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  94449. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  94450. }
  94451. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  94452. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  94453. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  94454. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  94455. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  94456. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  94457. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  94458. }
  94459. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  94460. positions[l + 3 * i] = this._sectionVectors[i].x;
  94461. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  94462. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  94463. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  94464. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  94465. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  94466. }
  94467. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  94468. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  94469. }
  94470. };
  94471. /**
  94472. * Returns a new TrailMesh object.
  94473. * @param name is a string, the name given to the new mesh
  94474. * @param newGenerator use new generator object for cloned trail mesh
  94475. * @returns a new mesh
  94476. */
  94477. TrailMesh.prototype.clone = function (name, newGenerator) {
  94478. if (name === void 0) { name = ""; }
  94479. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  94480. };
  94481. /**
  94482. * Serializes this trail mesh
  94483. * @param serializationObject object to write serialization to
  94484. */
  94485. TrailMesh.prototype.serialize = function (serializationObject) {
  94486. _super.prototype.serialize.call(this, serializationObject);
  94487. };
  94488. /**
  94489. * Parses a serialized trail mesh
  94490. * @param parsedMesh the serialized mesh
  94491. * @param scene the scene to create the trail mesh in
  94492. * @returns the created trail mesh
  94493. */
  94494. TrailMesh.Parse = function (parsedMesh, scene) {
  94495. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  94496. };
  94497. return TrailMesh;
  94498. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  94499. /***/ }),
  94500. /***/ "./Meshes/transformNode.ts":
  94501. /*!*********************************!*\
  94502. !*** ./Meshes/transformNode.ts ***!
  94503. \*********************************/
  94504. /*! exports provided: TransformNode */
  94505. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94506. "use strict";
  94507. __webpack_require__.r(__webpack_exports__);
  94508. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  94509. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  94510. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  94511. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  94512. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94513. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  94514. /**
  94515. * 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.
  94516. * @see https://doc.babylonjs.com/how_to/transformnode
  94517. */
  94518. var TransformNode = /** @class */ (function (_super) {
  94519. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  94520. function TransformNode(name, scene, isPure) {
  94521. if (scene === void 0) { scene = null; }
  94522. if (isPure === void 0) { isPure = true; }
  94523. var _this = _super.call(this, name, scene) || this;
  94524. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  94525. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  94526. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  94527. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  94528. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  94529. // Properties
  94530. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94531. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94532. _this._rotationQuaternion = null;
  94533. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  94534. _this._isDirty = false;
  94535. _this._transformToBoneReferal = null;
  94536. _this._billboardMode = TransformNode.BILLBOARDMODE_NONE;
  94537. _this._preserveParentRotationForBillboard = false;
  94538. /**
  94539. * 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
  94540. */
  94541. _this.scalingDeterminant = 1;
  94542. _this._infiniteDistance = false;
  94543. /**
  94544. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94545. * By default the system will update normals to compensate
  94546. */
  94547. _this.ignoreNonUniformScaling = false;
  94548. /**
  94549. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  94550. */
  94551. _this.reIntegrateRotationIntoRotationQuaternion = false;
  94552. // Cache
  94553. /** @hidden */
  94554. _this._poseMatrix = null;
  94555. /** @hidden */
  94556. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  94557. _this._usePivotMatrix = false;
  94558. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94559. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  94560. _this._postMultiplyPivotMatrix = false;
  94561. _this._isWorldMatrixFrozen = false;
  94562. /** @hidden */
  94563. _this._indexInSceneTransformNodesArray = -1;
  94564. /**
  94565. * An event triggered after the world matrix is updated
  94566. */
  94567. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  94568. _this._nonUniformScaling = false;
  94569. if (isPure) {
  94570. _this.getScene().addTransformNode(_this);
  94571. }
  94572. return _this;
  94573. }
  94574. Object.defineProperty(TransformNode.prototype, "billboardMode", {
  94575. /**
  94576. * Gets or sets the billboard mode. Default is 0.
  94577. *
  94578. * | Value | Type | Description |
  94579. * | --- | --- | --- |
  94580. * | 0 | BILLBOARDMODE_NONE | |
  94581. * | 1 | BILLBOARDMODE_X | |
  94582. * | 2 | BILLBOARDMODE_Y | |
  94583. * | 4 | BILLBOARDMODE_Z | |
  94584. * | 7 | BILLBOARDMODE_ALL | |
  94585. *
  94586. */
  94587. get: function () {
  94588. return this._billboardMode;
  94589. },
  94590. set: function (value) {
  94591. if (this._billboardMode === value) {
  94592. return;
  94593. }
  94594. this._billboardMode = value;
  94595. },
  94596. enumerable: true,
  94597. configurable: true
  94598. });
  94599. Object.defineProperty(TransformNode.prototype, "preserveParentRotationForBillboard", {
  94600. /**
  94601. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94602. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94603. */
  94604. get: function () {
  94605. return this._preserveParentRotationForBillboard;
  94606. },
  94607. set: function (value) {
  94608. if (value === this._preserveParentRotationForBillboard) {
  94609. return;
  94610. }
  94611. this._preserveParentRotationForBillboard = value;
  94612. },
  94613. enumerable: true,
  94614. configurable: true
  94615. });
  94616. Object.defineProperty(TransformNode.prototype, "infiniteDistance", {
  94617. /**
  94618. * Gets or sets the distance of the object to max, often used by skybox
  94619. */
  94620. get: function () {
  94621. return this._infiniteDistance;
  94622. },
  94623. set: function (value) {
  94624. if (this._infiniteDistance === value) {
  94625. return;
  94626. }
  94627. this._infiniteDistance = value;
  94628. },
  94629. enumerable: true,
  94630. configurable: true
  94631. });
  94632. /**
  94633. * Gets a string identifying the name of the class
  94634. * @returns "TransformNode" string
  94635. */
  94636. TransformNode.prototype.getClassName = function () {
  94637. return "TransformNode";
  94638. };
  94639. Object.defineProperty(TransformNode.prototype, "position", {
  94640. /**
  94641. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94642. */
  94643. get: function () {
  94644. return this._position;
  94645. },
  94646. set: function (newPosition) {
  94647. this._position = newPosition;
  94648. this._isDirty = true;
  94649. },
  94650. enumerable: true,
  94651. configurable: true
  94652. });
  94653. Object.defineProperty(TransformNode.prototype, "rotation", {
  94654. /**
  94655. * 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)).
  94656. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94657. */
  94658. get: function () {
  94659. return this._rotation;
  94660. },
  94661. set: function (newRotation) {
  94662. this._rotation = newRotation;
  94663. this._rotationQuaternion = null;
  94664. this._isDirty = true;
  94665. },
  94666. enumerable: true,
  94667. configurable: true
  94668. });
  94669. Object.defineProperty(TransformNode.prototype, "scaling", {
  94670. /**
  94671. * 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)).
  94672. */
  94673. get: function () {
  94674. return this._scaling;
  94675. },
  94676. set: function (newScaling) {
  94677. this._scaling = newScaling;
  94678. this._isDirty = true;
  94679. },
  94680. enumerable: true,
  94681. configurable: true
  94682. });
  94683. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  94684. /**
  94685. * 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).
  94686. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94687. */
  94688. get: function () {
  94689. return this._rotationQuaternion;
  94690. },
  94691. set: function (quaternion) {
  94692. this._rotationQuaternion = quaternion;
  94693. //reset the rotation vector.
  94694. if (quaternion) {
  94695. this._rotation.setAll(0.0);
  94696. }
  94697. this._isDirty = true;
  94698. },
  94699. enumerable: true,
  94700. configurable: true
  94701. });
  94702. Object.defineProperty(TransformNode.prototype, "forward", {
  94703. /**
  94704. * The forward direction of that transform in world space.
  94705. */
  94706. get: function () {
  94707. 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()));
  94708. },
  94709. enumerable: true,
  94710. configurable: true
  94711. });
  94712. Object.defineProperty(TransformNode.prototype, "up", {
  94713. /**
  94714. * The up direction of that transform in world space.
  94715. */
  94716. get: function () {
  94717. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  94718. },
  94719. enumerable: true,
  94720. configurable: true
  94721. });
  94722. Object.defineProperty(TransformNode.prototype, "right", {
  94723. /**
  94724. * The right direction of that transform in world space.
  94725. */
  94726. get: function () {
  94727. 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()));
  94728. },
  94729. enumerable: true,
  94730. configurable: true
  94731. });
  94732. /**
  94733. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94734. * @param matrix the matrix to copy the pose from
  94735. * @returns this TransformNode.
  94736. */
  94737. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  94738. if (!this._poseMatrix) {
  94739. this._poseMatrix = matrix.clone();
  94740. return this;
  94741. }
  94742. this._poseMatrix.copyFrom(matrix);
  94743. return this;
  94744. };
  94745. /**
  94746. * Returns the mesh Pose matrix.
  94747. * @returns the pose matrix
  94748. */
  94749. TransformNode.prototype.getPoseMatrix = function () {
  94750. if (!this._poseMatrix) {
  94751. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  94752. }
  94753. return this._poseMatrix;
  94754. };
  94755. /** @hidden */
  94756. TransformNode.prototype._isSynchronized = function () {
  94757. var cache = this._cache;
  94758. if (this.billboardMode !== cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  94759. return false;
  94760. }
  94761. if (cache.pivotMatrixUpdated) {
  94762. return false;
  94763. }
  94764. if (this.infiniteDistance) {
  94765. return false;
  94766. }
  94767. if (!cache.position.equals(this._position)) {
  94768. return false;
  94769. }
  94770. if (this._rotationQuaternion) {
  94771. if (!cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  94772. return false;
  94773. }
  94774. }
  94775. else if (!cache.rotation.equals(this._rotation)) {
  94776. return false;
  94777. }
  94778. if (!cache.scaling.equals(this._scaling)) {
  94779. return false;
  94780. }
  94781. return true;
  94782. };
  94783. /** @hidden */
  94784. TransformNode.prototype._initCache = function () {
  94785. _super.prototype._initCache.call(this);
  94786. var cache = this._cache;
  94787. cache.localMatrixUpdated = false;
  94788. cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94789. cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94790. cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94791. cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  94792. cache.billboardMode = -1;
  94793. cache.infiniteDistance = false;
  94794. };
  94795. /**
  94796. * Flag the transform node as dirty (Forcing it to update everything)
  94797. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94798. * @returns this transform node
  94799. */
  94800. TransformNode.prototype.markAsDirty = function (property) {
  94801. this._currentRenderId = Number.MAX_VALUE;
  94802. this._isDirty = true;
  94803. return this;
  94804. };
  94805. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  94806. /**
  94807. * Returns the current mesh absolute position.
  94808. * Returns a Vector3.
  94809. */
  94810. get: function () {
  94811. return this._absolutePosition;
  94812. },
  94813. enumerable: true,
  94814. configurable: true
  94815. });
  94816. /**
  94817. * Sets a new matrix to apply before all other transformation
  94818. * @param matrix defines the transform matrix
  94819. * @returns the current TransformNode
  94820. */
  94821. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  94822. return this.setPivotMatrix(matrix, false);
  94823. };
  94824. /**
  94825. * Sets a new pivot matrix to the current node
  94826. * @param matrix defines the new pivot matrix to use
  94827. * @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
  94828. * @returns the current TransformNode
  94829. */
  94830. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  94831. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  94832. this._pivotMatrix.copyFrom(matrix);
  94833. this._usePivotMatrix = !this._pivotMatrix.isIdentity();
  94834. this._cache.pivotMatrixUpdated = true;
  94835. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  94836. if (this._postMultiplyPivotMatrix) {
  94837. if (!this._pivotMatrixInverse) {
  94838. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  94839. }
  94840. else {
  94841. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  94842. }
  94843. }
  94844. return this;
  94845. };
  94846. /**
  94847. * Returns the mesh pivot matrix.
  94848. * Default : Identity.
  94849. * @returns the matrix
  94850. */
  94851. TransformNode.prototype.getPivotMatrix = function () {
  94852. return this._pivotMatrix;
  94853. };
  94854. /**
  94855. * Prevents the World matrix to be computed any longer.
  94856. * @returns the TransformNode.
  94857. */
  94858. TransformNode.prototype.freezeWorldMatrix = function () {
  94859. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  94860. this.computeWorldMatrix(true);
  94861. this._isWorldMatrixFrozen = true;
  94862. return this;
  94863. };
  94864. /**
  94865. * Allows back the World matrix computation.
  94866. * @returns the TransformNode.
  94867. */
  94868. TransformNode.prototype.unfreezeWorldMatrix = function () {
  94869. this._isWorldMatrixFrozen = false;
  94870. this.computeWorldMatrix(true);
  94871. return this;
  94872. };
  94873. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  94874. /**
  94875. * True if the World matrix has been frozen.
  94876. */
  94877. get: function () {
  94878. return this._isWorldMatrixFrozen;
  94879. },
  94880. enumerable: true,
  94881. configurable: true
  94882. });
  94883. /**
  94884. * Retuns the mesh absolute position in the World.
  94885. * @returns a Vector3.
  94886. */
  94887. TransformNode.prototype.getAbsolutePosition = function () {
  94888. this.computeWorldMatrix();
  94889. return this._absolutePosition;
  94890. };
  94891. /**
  94892. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94893. * @param absolutePosition the absolute position to set
  94894. * @returns the TransformNode.
  94895. */
  94896. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  94897. if (!absolutePosition) {
  94898. return this;
  94899. }
  94900. var absolutePositionX;
  94901. var absolutePositionY;
  94902. var absolutePositionZ;
  94903. if (absolutePosition.x === undefined) {
  94904. if (arguments.length < 3) {
  94905. return this;
  94906. }
  94907. absolutePositionX = arguments[0];
  94908. absolutePositionY = arguments[1];
  94909. absolutePositionZ = arguments[2];
  94910. }
  94911. else {
  94912. absolutePositionX = absolutePosition.x;
  94913. absolutePositionY = absolutePosition.y;
  94914. absolutePositionZ = absolutePosition.z;
  94915. }
  94916. if (this.parent) {
  94917. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94918. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  94919. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  94920. }
  94921. else {
  94922. this.position.x = absolutePositionX;
  94923. this.position.y = absolutePositionY;
  94924. this.position.z = absolutePositionZ;
  94925. }
  94926. return this;
  94927. };
  94928. /**
  94929. * Sets the mesh position in its local space.
  94930. * @param vector3 the position to set in localspace
  94931. * @returns the TransformNode.
  94932. */
  94933. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  94934. this.computeWorldMatrix();
  94935. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  94936. return this;
  94937. };
  94938. /**
  94939. * Returns the mesh position in the local space from the current World matrix values.
  94940. * @returns a new Vector3.
  94941. */
  94942. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  94943. this.computeWorldMatrix();
  94944. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94945. this._localMatrix.invertToRef(invLocalWorldMatrix);
  94946. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  94947. };
  94948. /**
  94949. * Translates the mesh along the passed Vector3 in its local space.
  94950. * @param vector3 the distance to translate in localspace
  94951. * @returns the TransformNode.
  94952. */
  94953. TransformNode.prototype.locallyTranslate = function (vector3) {
  94954. this.computeWorldMatrix(true);
  94955. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  94956. return this;
  94957. };
  94958. /**
  94959. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94960. * @param targetPoint the position (must be in same space as current mesh) to look at
  94961. * @param yawCor optional yaw (y-axis) correction in radians
  94962. * @param pitchCor optional pitch (x-axis) correction in radians
  94963. * @param rollCor optional roll (z-axis) correction in radians
  94964. * @param space the choosen space of the target
  94965. * @returns the TransformNode.
  94966. */
  94967. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  94968. if (yawCor === void 0) { yawCor = 0; }
  94969. if (pitchCor === void 0) { pitchCor = 0; }
  94970. if (rollCor === void 0) { rollCor = 0; }
  94971. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  94972. var dv = TransformNode._lookAtVectorCache;
  94973. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  94974. targetPoint.subtractToRef(pos, dv);
  94975. this.setDirection(dv, yawCor, pitchCor, rollCor);
  94976. // Correct for parent's rotation offset
  94977. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  94978. if (this.rotationQuaternion) {
  94979. // Get local rotation matrix of the looking object
  94980. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94981. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  94982. // Offset rotation by parent's inverted rotation matrix to correct in world space
  94983. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94984. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  94985. parentRotationMatrix.invert();
  94986. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  94987. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  94988. }
  94989. else {
  94990. // Get local rotation matrix of the looking object
  94991. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94992. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  94993. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94994. quaternionRotation.toRotationMatrix(rotationMatrix);
  94995. // Offset rotation by parent's inverted rotation matrix to correct in world space
  94996. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94997. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  94998. parentRotationMatrix.invert();
  94999. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  95000. quaternionRotation.fromRotationMatrix(rotationMatrix);
  95001. quaternionRotation.toEulerAnglesToRef(this.rotation);
  95002. }
  95003. }
  95004. return this;
  95005. };
  95006. /**
  95007. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95008. * This Vector3 is expressed in the World space.
  95009. * @param localAxis axis to rotate
  95010. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95011. */
  95012. TransformNode.prototype.getDirection = function (localAxis) {
  95013. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  95014. this.getDirectionToRef(localAxis, result);
  95015. return result;
  95016. };
  95017. /**
  95018. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95019. * localAxis is expressed in the mesh local space.
  95020. * result is computed in the Wordl space from the mesh World matrix.
  95021. * @param localAxis axis to rotate
  95022. * @param result the resulting transformnode
  95023. * @returns this TransformNode.
  95024. */
  95025. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  95026. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  95027. return this;
  95028. };
  95029. /**
  95030. * Sets this transform node rotation to the given local axis.
  95031. * @param localAxis the axis in local space
  95032. * @param yawCor optional yaw (y-axis) correction in radians
  95033. * @param pitchCor optional pitch (x-axis) correction in radians
  95034. * @param rollCor optional roll (z-axis) correction in radians
  95035. * @returns this TransformNode
  95036. */
  95037. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  95038. if (yawCor === void 0) { yawCor = 0; }
  95039. if (pitchCor === void 0) { pitchCor = 0; }
  95040. if (rollCor === void 0) { rollCor = 0; }
  95041. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  95042. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  95043. var pitch = -Math.atan2(localAxis.y, len);
  95044. if (this.rotationQuaternion) {
  95045. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  95046. }
  95047. else {
  95048. this.rotation.x = pitch + pitchCor;
  95049. this.rotation.y = yaw + yawCor;
  95050. this.rotation.z = rollCor;
  95051. }
  95052. return this;
  95053. };
  95054. /**
  95055. * Sets a new pivot point to the current node
  95056. * @param point defines the new pivot point to use
  95057. * @param space defines if the point is in world or local space (local by default)
  95058. * @returns the current TransformNode
  95059. */
  95060. TransformNode.prototype.setPivotPoint = function (point, space) {
  95061. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  95062. if (this.getScene().getRenderId() == 0) {
  95063. this.computeWorldMatrix(true);
  95064. }
  95065. var wm = this.getWorldMatrix();
  95066. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  95067. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  95068. wm.invertToRef(tmat);
  95069. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  95070. }
  95071. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  95072. };
  95073. /**
  95074. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95075. * @returns the pivot point
  95076. */
  95077. TransformNode.prototype.getPivotPoint = function () {
  95078. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  95079. this.getPivotPointToRef(point);
  95080. return point;
  95081. };
  95082. /**
  95083. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95084. * @param result the vector3 to store the result
  95085. * @returns this TransformNode.
  95086. */
  95087. TransformNode.prototype.getPivotPointToRef = function (result) {
  95088. result.x = -this._pivotMatrix.m[12];
  95089. result.y = -this._pivotMatrix.m[13];
  95090. result.z = -this._pivotMatrix.m[14];
  95091. return this;
  95092. };
  95093. /**
  95094. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95095. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95096. */
  95097. TransformNode.prototype.getAbsolutePivotPoint = function () {
  95098. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  95099. this.getAbsolutePivotPointToRef(point);
  95100. return point;
  95101. };
  95102. /**
  95103. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95104. * @param result vector3 to store the result
  95105. * @returns this TransformNode.
  95106. */
  95107. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  95108. result.x = this._pivotMatrix.m[12];
  95109. result.y = this._pivotMatrix.m[13];
  95110. result.z = this._pivotMatrix.m[14];
  95111. this.getPivotPointToRef(result);
  95112. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  95113. return this;
  95114. };
  95115. /**
  95116. * Defines the passed node as the parent of the current node.
  95117. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95118. * @see https://doc.babylonjs.com/how_to/parenting
  95119. * @param node the node ot set as the parent
  95120. * @returns this TransformNode.
  95121. */
  95122. TransformNode.prototype.setParent = function (node) {
  95123. if (!node && !this.parent) {
  95124. return this;
  95125. }
  95126. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  95127. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  95128. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  95129. if (!node) {
  95130. if (this.parent && this.parent.computeWorldMatrix) {
  95131. this.parent.computeWorldMatrix(true);
  95132. }
  95133. this.computeWorldMatrix(true);
  95134. this.getWorldMatrix().decompose(scale, quatRotation, position);
  95135. }
  95136. else {
  95137. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  95138. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  95139. this.computeWorldMatrix(true);
  95140. node.computeWorldMatrix(true);
  95141. node.getWorldMatrix().invertToRef(invParentMatrix);
  95142. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  95143. diffMatrix.decompose(scale, quatRotation, position);
  95144. }
  95145. if (this.rotationQuaternion) {
  95146. this.rotationQuaternion.copyFrom(quatRotation);
  95147. }
  95148. else {
  95149. quatRotation.toEulerAnglesToRef(this.rotation);
  95150. }
  95151. this.scaling.copyFrom(scale);
  95152. this.position.copyFrom(position);
  95153. this.parent = node;
  95154. return this;
  95155. };
  95156. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  95157. /**
  95158. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95159. */
  95160. get: function () {
  95161. return this._nonUniformScaling;
  95162. },
  95163. enumerable: true,
  95164. configurable: true
  95165. });
  95166. /** @hidden */
  95167. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  95168. if (this._nonUniformScaling === value) {
  95169. return false;
  95170. }
  95171. this._nonUniformScaling = value;
  95172. return true;
  95173. };
  95174. /**
  95175. * Attach the current TransformNode to another TransformNode associated with a bone
  95176. * @param bone Bone affecting the TransformNode
  95177. * @param affectedTransformNode TransformNode associated with the bone
  95178. * @returns this object
  95179. */
  95180. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  95181. this._transformToBoneReferal = affectedTransformNode;
  95182. this.parent = bone;
  95183. if (bone.getWorldMatrix().determinant() < 0) {
  95184. this.scalingDeterminant *= -1;
  95185. }
  95186. return this;
  95187. };
  95188. /**
  95189. * Detach the transform node if its associated with a bone
  95190. * @returns this object
  95191. */
  95192. TransformNode.prototype.detachFromBone = function () {
  95193. if (!this.parent) {
  95194. return this;
  95195. }
  95196. if (this.parent.getWorldMatrix().determinant() < 0) {
  95197. this.scalingDeterminant *= -1;
  95198. }
  95199. this._transformToBoneReferal = null;
  95200. this.parent = null;
  95201. return this;
  95202. };
  95203. /**
  95204. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95205. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95206. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95207. * The passed axis is also normalized.
  95208. * @param axis the axis to rotate around
  95209. * @param amount the amount to rotate in radians
  95210. * @param space Space to rotate in (Default: local)
  95211. * @returns the TransformNode.
  95212. */
  95213. TransformNode.prototype.rotate = function (axis, amount, space) {
  95214. axis.normalize();
  95215. if (!this.rotationQuaternion) {
  95216. this.rotationQuaternion = this.rotation.toQuaternion();
  95217. this.rotation.setAll(0);
  95218. }
  95219. var rotationQuaternion;
  95220. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  95221. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  95222. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  95223. }
  95224. else {
  95225. if (this.parent) {
  95226. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  95227. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  95228. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  95229. }
  95230. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  95231. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  95232. }
  95233. return this;
  95234. };
  95235. /**
  95236. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95237. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95238. * The passed axis is also normalized. .
  95239. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95240. * @param point the point to rotate around
  95241. * @param axis the axis to rotate around
  95242. * @param amount the amount to rotate in radians
  95243. * @returns the TransformNode
  95244. */
  95245. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  95246. axis.normalize();
  95247. if (!this.rotationQuaternion) {
  95248. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  95249. this.rotation.setAll(0);
  95250. }
  95251. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  95252. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  95253. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  95254. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  95255. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  95256. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  95257. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  95258. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  95259. point.subtractToRef(this.position, tmpVector);
  95260. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  95261. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  95262. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  95263. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  95264. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  95265. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  95266. this.position.addInPlace(finalTranslation);
  95267. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  95268. return this;
  95269. };
  95270. /**
  95271. * Translates the mesh along the axis vector for the passed distance in the given space.
  95272. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95273. * @param axis the axis to translate in
  95274. * @param distance the distance to translate
  95275. * @param space Space to rotate in (Default: local)
  95276. * @returns the TransformNode.
  95277. */
  95278. TransformNode.prototype.translate = function (axis, distance, space) {
  95279. var displacementVector = axis.scale(distance);
  95280. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  95281. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  95282. this.setPositionWithLocalVector(tempV3);
  95283. }
  95284. else {
  95285. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  95286. }
  95287. return this;
  95288. };
  95289. /**
  95290. * Adds a rotation step to the mesh current rotation.
  95291. * x, y, z are Euler angles expressed in radians.
  95292. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95293. * This means this rotation is made in the mesh local space only.
  95294. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95295. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95296. * ```javascript
  95297. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95298. * ```
  95299. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95300. * 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.
  95301. * @param x Rotation to add
  95302. * @param y Rotation to add
  95303. * @param z Rotation to add
  95304. * @returns the TransformNode.
  95305. */
  95306. TransformNode.prototype.addRotation = function (x, y, z) {
  95307. var rotationQuaternion;
  95308. if (this.rotationQuaternion) {
  95309. rotationQuaternion = this.rotationQuaternion;
  95310. }
  95311. else {
  95312. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  95313. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  95314. }
  95315. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  95316. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  95317. rotationQuaternion.multiplyInPlace(accumulation);
  95318. if (!this.rotationQuaternion) {
  95319. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  95320. }
  95321. return this;
  95322. };
  95323. /**
  95324. * @hidden
  95325. */
  95326. TransformNode.prototype._getEffectiveParent = function () {
  95327. return this.parent;
  95328. };
  95329. /**
  95330. * Computes the world matrix of the node
  95331. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95332. * @returns the world matrix
  95333. */
  95334. TransformNode.prototype.computeWorldMatrix = function (force) {
  95335. var currentRenderId = this.getScene().getRenderId();
  95336. if (this._isWorldMatrixFrozen && !this._isDirty) {
  95337. return this._worldMatrix;
  95338. }
  95339. if (!this._isDirty && !force && this.isSynchronized()) {
  95340. this._currentRenderId = currentRenderId;
  95341. return this._worldMatrix;
  95342. }
  95343. this._updateCache();
  95344. var cache = this._cache;
  95345. cache.pivotMatrixUpdated = false;
  95346. cache.billboardMode = this.billboardMode;
  95347. cache.infiniteDistance = this.infiniteDistance;
  95348. this._currentRenderId = currentRenderId;
  95349. this._childUpdateId++;
  95350. this._isDirty = false;
  95351. var parent = this._getEffectiveParent();
  95352. var useBillboardPath = this._billboardMode !== TransformNode.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard;
  95353. var camera = this.getScene().activeCamera;
  95354. // Scaling
  95355. var scaling = cache.scaling;
  95356. var translation = cache.position;
  95357. // Translation
  95358. if (this._infiniteDistance) {
  95359. if (!this.parent && camera) {
  95360. var cameraWorldMatrix = camera.getWorldMatrix();
  95361. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  95362. translation.copyFromFloats(this._position.x + cameraGlobalPosition.x, this._position.y + cameraGlobalPosition.y, this._position.z + cameraGlobalPosition.z);
  95363. }
  95364. else {
  95365. translation.copyFrom(this._position);
  95366. }
  95367. }
  95368. else {
  95369. translation.copyFrom(this._position);
  95370. }
  95371. // Scaling
  95372. scaling.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
  95373. // Rotation
  95374. var rotation = cache.rotationQuaternion;
  95375. if (this._rotationQuaternion) {
  95376. if (this.reIntegrateRotationIntoRotationQuaternion) {
  95377. var len = this.rotation.lengthSquared();
  95378. if (len) {
  95379. this._rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z));
  95380. this._rotation.copyFromFloats(0, 0, 0);
  95381. }
  95382. }
  95383. rotation.copyFrom(this._rotationQuaternion);
  95384. }
  95385. else {
  95386. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, rotation);
  95387. cache.rotation.copyFrom(this._rotation);
  95388. }
  95389. // Compose
  95390. if (this._usePivotMatrix) {
  95391. var scaleMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  95392. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scaling.x, scaling.y, scaling.z, scaleMatrix);
  95393. // Rotation
  95394. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  95395. rotation.toRotationMatrix(rotationMatrix);
  95396. // Composing transformations
  95397. this._pivotMatrix.multiplyToRef(scaleMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  95398. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(rotationMatrix, this._localMatrix);
  95399. // Post multiply inverse of pivotMatrix
  95400. if (this._postMultiplyPivotMatrix) {
  95401. this._localMatrix.multiplyToRef(this._pivotMatrixInverse, this._localMatrix);
  95402. }
  95403. this._localMatrix.addTranslationFromFloats(translation.x, translation.y, translation.z);
  95404. }
  95405. else {
  95406. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ComposeToRef(scaling, rotation, translation, this._localMatrix);
  95407. }
  95408. // Parent
  95409. if (parent && parent.getWorldMatrix) {
  95410. if (useBillboardPath) {
  95411. if (this._transformToBoneReferal) {
  95412. parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  95413. }
  95414. else {
  95415. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].copyFrom(parent.getWorldMatrix());
  95416. }
  95417. // Extract scaling and translation from parent
  95418. var translation_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5];
  95419. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[6];
  95420. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].decompose(scale, undefined, translation_1);
  95421. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scale.x, scale.y, scale.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  95422. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].setTranslation(translation_1);
  95423. this._localMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7], this._worldMatrix);
  95424. }
  95425. else {
  95426. if (this._transformToBoneReferal) {
  95427. this._localMatrix.multiplyToRef(parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  95428. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  95429. }
  95430. else {
  95431. this._localMatrix.multiplyToRef(parent.getWorldMatrix(), this._worldMatrix);
  95432. }
  95433. }
  95434. this._markSyncedWithParent();
  95435. }
  95436. else {
  95437. this._worldMatrix.copyFrom(this._localMatrix);
  95438. }
  95439. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  95440. if (useBillboardPath && camera) {
  95441. var storedTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  95442. this._worldMatrix.getTranslationToRef(storedTranslation); // Save translation
  95443. // Cancel camera rotation
  95444. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  95445. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  95446. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  95447. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  95448. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0].decompose(undefined, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0], undefined);
  95449. var eulerAngles = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  95450. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0].toEulerAnglesToRef(eulerAngles);
  95451. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) !== TransformNode.BILLBOARDMODE_X) {
  95452. eulerAngles.x = 0;
  95453. }
  95454. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) !== TransformNode.BILLBOARDMODE_Y) {
  95455. eulerAngles.y = 0;
  95456. }
  95457. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) !== TransformNode.BILLBOARDMODE_Z) {
  95458. eulerAngles.z = 0;
  95459. }
  95460. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  95461. }
  95462. this._worldMatrix.setTranslationFromFloats(0, 0, 0);
  95463. this._worldMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], this._worldMatrix);
  95464. // Restore translation
  95465. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  95466. }
  95467. // Normal matrix
  95468. if (!this.ignoreNonUniformScaling) {
  95469. if (this._scaling.isNonUniform) {
  95470. this._updateNonUniformScalingState(true);
  95471. }
  95472. else if (parent && parent._nonUniformScaling) {
  95473. this._updateNonUniformScalingState(parent._nonUniformScaling);
  95474. }
  95475. else {
  95476. this._updateNonUniformScalingState(false);
  95477. }
  95478. }
  95479. else {
  95480. this._updateNonUniformScalingState(false);
  95481. }
  95482. this._afterComputeWorldMatrix();
  95483. // Absolute position
  95484. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  95485. // Callbacks
  95486. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  95487. if (!this._poseMatrix) {
  95488. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  95489. }
  95490. // Cache the determinant
  95491. this._worldMatrixDeterminantIsDirty = true;
  95492. return this._worldMatrix;
  95493. };
  95494. TransformNode.prototype._afterComputeWorldMatrix = function () {
  95495. };
  95496. /**
  95497. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95498. * @param func callback function to add
  95499. *
  95500. * @returns the TransformNode.
  95501. */
  95502. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  95503. this.onAfterWorldMatrixUpdateObservable.add(func);
  95504. return this;
  95505. };
  95506. /**
  95507. * Removes a registered callback function.
  95508. * @param func callback function to remove
  95509. * @returns the TransformNode.
  95510. */
  95511. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  95512. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  95513. return this;
  95514. };
  95515. /**
  95516. * Gets the position of the current mesh in camera space
  95517. * @param camera defines the camera to use
  95518. * @returns a position
  95519. */
  95520. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  95521. if (camera === void 0) { camera = null; }
  95522. if (!camera) {
  95523. camera = this.getScene().activeCamera;
  95524. }
  95525. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  95526. };
  95527. /**
  95528. * Returns the distance from the mesh to the active camera
  95529. * @param camera defines the camera to use
  95530. * @returns the distance
  95531. */
  95532. TransformNode.prototype.getDistanceToCamera = function (camera) {
  95533. if (camera === void 0) { camera = null; }
  95534. if (!camera) {
  95535. camera = this.getScene().activeCamera;
  95536. }
  95537. return this.absolutePosition.subtract(camera.globalPosition).length();
  95538. };
  95539. /**
  95540. * Clone the current transform node
  95541. * @param name Name of the new clone
  95542. * @param newParent New parent for the clone
  95543. * @param doNotCloneChildren Do not clone children hierarchy
  95544. * @returns the new transform node
  95545. */
  95546. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  95547. var _this = this;
  95548. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  95549. result.name = name;
  95550. result.id = name;
  95551. if (newParent) {
  95552. result.parent = newParent;
  95553. }
  95554. if (!doNotCloneChildren) {
  95555. // Children
  95556. var directDescendants = this.getDescendants(true);
  95557. for (var index = 0; index < directDescendants.length; index++) {
  95558. var child = directDescendants[index];
  95559. if (child.clone) {
  95560. child.clone(name + "." + child.name, result);
  95561. }
  95562. }
  95563. }
  95564. return result;
  95565. };
  95566. /**
  95567. * Serializes the objects information.
  95568. * @param currentSerializationObject defines the object to serialize in
  95569. * @returns the serialized object
  95570. */
  95571. TransformNode.prototype.serialize = function (currentSerializationObject) {
  95572. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  95573. serializationObject.type = this.getClassName();
  95574. // Parent
  95575. if (this.parent) {
  95576. serializationObject.parentId = this.parent.id;
  95577. }
  95578. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  95579. serializationObject.isEnabled = this.isEnabled();
  95580. // Parent
  95581. if (this.parent) {
  95582. serializationObject.parentId = this.parent.id;
  95583. }
  95584. return serializationObject;
  95585. };
  95586. // Statics
  95587. /**
  95588. * Returns a new TransformNode object parsed from the source provided.
  95589. * @param parsedTransformNode is the source.
  95590. * @param scene the scne the object belongs to
  95591. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95592. * @returns a new TransformNode object parsed from the source provided.
  95593. */
  95594. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  95595. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  95596. if (parsedTransformNode.localMatrix) {
  95597. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  95598. }
  95599. else if (parsedTransformNode.pivotMatrix) {
  95600. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  95601. }
  95602. transformNode.setEnabled(parsedTransformNode.isEnabled);
  95603. // Parent
  95604. if (parsedTransformNode.parentId) {
  95605. transformNode._waitingParentId = parsedTransformNode.parentId;
  95606. }
  95607. return transformNode;
  95608. };
  95609. /**
  95610. * Get all child-transformNodes of this node
  95611. * @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
  95612. * @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
  95613. * @returns an array of TransformNode
  95614. */
  95615. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  95616. var results = [];
  95617. this._getDescendants(results, directDescendantsOnly, function (node) {
  95618. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  95619. });
  95620. return results;
  95621. };
  95622. /**
  95623. * Releases resources associated with this transform node.
  95624. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95625. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95626. */
  95627. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  95628. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  95629. // Animations
  95630. this.getScene().stopAnimation(this);
  95631. // Remove from scene
  95632. this.getScene().removeTransformNode(this);
  95633. this.onAfterWorldMatrixUpdateObservable.clear();
  95634. if (doNotRecurse) {
  95635. var transformNodes = this.getChildTransformNodes(true);
  95636. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  95637. var transformNode = transformNodes_1[_i];
  95638. transformNode.parent = null;
  95639. transformNode.computeWorldMatrix(true);
  95640. }
  95641. }
  95642. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  95643. };
  95644. // Statics
  95645. /**
  95646. * Object will not rotate to face the camera
  95647. */
  95648. TransformNode.BILLBOARDMODE_NONE = 0;
  95649. /**
  95650. * Object will rotate to face the camera but only on the x axis
  95651. */
  95652. TransformNode.BILLBOARDMODE_X = 1;
  95653. /**
  95654. * Object will rotate to face the camera but only on the y axis
  95655. */
  95656. TransformNode.BILLBOARDMODE_Y = 2;
  95657. /**
  95658. * Object will rotate to face the camera but only on the z axis
  95659. */
  95660. TransformNode.BILLBOARDMODE_Z = 4;
  95661. /**
  95662. * Object will rotate to face the camera
  95663. */
  95664. TransformNode.BILLBOARDMODE_ALL = 7;
  95665. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  95666. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  95667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  95669. ], TransformNode.prototype, "_position", void 0);
  95670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  95672. ], TransformNode.prototype, "_rotation", void 0);
  95673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  95675. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  95676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  95678. ], TransformNode.prototype, "_scaling", void 0);
  95679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("billboardMode")
  95681. ], TransformNode.prototype, "_billboardMode", void 0);
  95682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95684. ], TransformNode.prototype, "scalingDeterminant", void 0);
  95685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("infiniteDistance")
  95687. ], TransformNode.prototype, "_infiniteDistance", void 0);
  95688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95690. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  95691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95693. ], TransformNode.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0);
  95694. return TransformNode;
  95695. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  95696. /***/ }),
  95697. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  95698. /*!***************************************************************!*\
  95699. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  95700. \***************************************************************/
  95701. /*! exports provided: CubeMapToSphericalPolynomialTools */
  95702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95703. "use strict";
  95704. __webpack_require__.r(__webpack_exports__);
  95705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  95706. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  95707. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  95708. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  95709. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  95710. var FileFaceOrientation = /** @class */ (function () {
  95711. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  95712. this.name = name;
  95713. this.worldAxisForNormal = worldAxisForNormal;
  95714. this.worldAxisForFileX = worldAxisForFileX;
  95715. this.worldAxisForFileY = worldAxisForFileY;
  95716. }
  95717. return FileFaceOrientation;
  95718. }());
  95719. /**
  95720. * Helper class dealing with the extraction of spherical polynomial dataArray
  95721. * from a cube map.
  95722. */
  95723. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  95724. function CubeMapToSphericalPolynomialTools() {
  95725. }
  95726. /**
  95727. * Converts a texture to the according Spherical Polynomial data.
  95728. * This extracts the first 3 orders only as they are the only one used in the lighting.
  95729. *
  95730. * @param texture The texture to extract the information from.
  95731. * @return The Spherical Polynomial data.
  95732. */
  95733. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  95734. if (!texture.isCube) {
  95735. // Only supports cube Textures currently.
  95736. return null;
  95737. }
  95738. var size = texture.getSize().width;
  95739. var right = texture.readPixels(0);
  95740. var left = texture.readPixels(1);
  95741. var up;
  95742. var down;
  95743. if (texture.isRenderTarget) {
  95744. up = texture.readPixels(3);
  95745. down = texture.readPixels(2);
  95746. }
  95747. else {
  95748. up = texture.readPixels(2);
  95749. down = texture.readPixels(3);
  95750. }
  95751. var front = texture.readPixels(4);
  95752. var back = texture.readPixels(5);
  95753. var gammaSpace = texture.gammaSpace;
  95754. // Always read as RGBA.
  95755. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  95756. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95757. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  95758. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  95759. }
  95760. var cubeInfo = {
  95761. size: size,
  95762. right: right,
  95763. left: left,
  95764. up: up,
  95765. down: down,
  95766. front: front,
  95767. back: back,
  95768. format: format,
  95769. type: type,
  95770. gammaSpace: gammaSpace,
  95771. };
  95772. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  95773. };
  95774. /**
  95775. * Converts a cubemap to the according Spherical Polynomial data.
  95776. * This extracts the first 3 orders only as they are the only one used in the lighting.
  95777. *
  95778. * @param cubeInfo The Cube map to extract the information from.
  95779. * @return The Spherical Polynomial data.
  95780. */
  95781. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  95782. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  95783. var totalSolidAngle = 0.0;
  95784. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  95785. var du = 2.0 / cubeInfo.size;
  95786. var dv = du;
  95787. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  95788. var minUV = du * 0.5 - 1.0;
  95789. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  95790. var fileFace = this.FileFaces[faceIndex];
  95791. var dataArray = cubeInfo[fileFace.name];
  95792. var v = minUV;
  95793. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  95794. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  95795. // Because SP is still linear, so summation is fine in that basis.
  95796. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  95797. for (var y = 0; y < cubeInfo.size; y++) {
  95798. var u = minUV;
  95799. for (var x = 0; x < cubeInfo.size; x++) {
  95800. // World direction (not normalised)
  95801. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  95802. worldDirection.normalize();
  95803. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  95804. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  95805. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  95806. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  95807. // Handle Integer types.
  95808. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  95809. r /= 255;
  95810. g /= 255;
  95811. b /= 255;
  95812. }
  95813. // Handle Gamma space textures.
  95814. if (cubeInfo.gammaSpace) {
  95815. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  95816. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  95817. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  95818. }
  95819. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  95820. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  95821. totalSolidAngle += deltaSolidAngle;
  95822. u += du;
  95823. }
  95824. v += dv;
  95825. }
  95826. }
  95827. // Solid angle for entire sphere is 4*pi
  95828. var sphereSolidAngle = 4.0 * Math.PI;
  95829. // Adjust the solid angle to allow for how many faces we processed.
  95830. var facesProcessed = 6.0;
  95831. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  95832. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  95833. // This is needed because the numerical integration over the cube uses a
  95834. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  95835. // and also to compensate for accumulative error due to float precision in the summation.
  95836. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  95837. sphericalHarmonics.scale(correctionFactor);
  95838. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  95839. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  95840. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  95841. };
  95842. CubeMapToSphericalPolynomialTools.FileFaces = [
  95843. 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)),
  95844. 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)),
  95845. 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)),
  95846. 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)),
  95847. 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)),
  95848. 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
  95849. ];
  95850. return CubeMapToSphericalPolynomialTools;
  95851. }());
  95852. /***/ }),
  95853. /***/ "./Misc/HighDynamicRange/hdr.ts":
  95854. /*!**************************************!*\
  95855. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  95856. \**************************************/
  95857. /*! exports provided: HDRTools */
  95858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95859. "use strict";
  95860. __webpack_require__.r(__webpack_exports__);
  95861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  95862. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  95863. /**
  95864. * This groups tools to convert HDR texture to native colors array.
  95865. */
  95866. var HDRTools = /** @class */ (function () {
  95867. function HDRTools() {
  95868. }
  95869. HDRTools.Ldexp = function (mantissa, exponent) {
  95870. if (exponent > 1023) {
  95871. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  95872. }
  95873. if (exponent < -1074) {
  95874. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  95875. }
  95876. return mantissa * Math.pow(2, exponent);
  95877. };
  95878. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  95879. if (exponent > 0) { /*nonzero pixel*/
  95880. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  95881. float32array[index + 0] = red * exponent;
  95882. float32array[index + 1] = green * exponent;
  95883. float32array[index + 2] = blue * exponent;
  95884. }
  95885. else {
  95886. float32array[index + 0] = 0;
  95887. float32array[index + 1] = 0;
  95888. float32array[index + 2] = 0;
  95889. }
  95890. };
  95891. HDRTools.readStringLine = function (uint8array, startIndex) {
  95892. var line = "";
  95893. var character = "";
  95894. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  95895. character = String.fromCharCode(uint8array[i]);
  95896. if (character == "\n") {
  95897. break;
  95898. }
  95899. line += character;
  95900. }
  95901. return line;
  95902. };
  95903. /**
  95904. * Reads header information from an RGBE texture stored in a native array.
  95905. * More information on this format are available here:
  95906. * https://en.wikipedia.org/wiki/RGBE_image_format
  95907. *
  95908. * @param uint8array The binary file stored in native array.
  95909. * @return The header information.
  95910. */
  95911. HDRTools.RGBE_ReadHeader = function (uint8array) {
  95912. var height = 0;
  95913. var width = 0;
  95914. var line = this.readStringLine(uint8array, 0);
  95915. if (line[0] != '#' || line[1] != '?') {
  95916. throw "Bad HDR Format.";
  95917. }
  95918. var endOfHeader = false;
  95919. var findFormat = false;
  95920. var lineIndex = 0;
  95921. do {
  95922. lineIndex += (line.length + 1);
  95923. line = this.readStringLine(uint8array, lineIndex);
  95924. if (line == "FORMAT=32-bit_rle_rgbe") {
  95925. findFormat = true;
  95926. }
  95927. else if (line.length == 0) {
  95928. endOfHeader = true;
  95929. }
  95930. } while (!endOfHeader);
  95931. if (!findFormat) {
  95932. throw "HDR Bad header format, unsupported FORMAT";
  95933. }
  95934. lineIndex += (line.length + 1);
  95935. line = this.readStringLine(uint8array, lineIndex);
  95936. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  95937. var match = sizeRegexp.exec(line);
  95938. // TODO. Support +Y and -X if needed.
  95939. if (!match || match.length < 3) {
  95940. throw "HDR Bad header format, no size";
  95941. }
  95942. width = parseInt(match[2]);
  95943. height = parseInt(match[1]);
  95944. if (width < 8 || width > 0x7fff) {
  95945. throw "HDR Bad header format, unsupported size";
  95946. }
  95947. lineIndex += (line.length + 1);
  95948. return {
  95949. height: height,
  95950. width: width,
  95951. dataPosition: lineIndex
  95952. };
  95953. };
  95954. /**
  95955. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  95956. * This RGBE texture needs to store the information as a panorama.
  95957. *
  95958. * More information on this format are available here:
  95959. * https://en.wikipedia.org/wiki/RGBE_image_format
  95960. *
  95961. * @param buffer The binary file stored in an array buffer.
  95962. * @param size The expected size of the extracted cubemap.
  95963. * @return The Cube Map information.
  95964. */
  95965. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  95966. var uint8array = new Uint8Array(buffer);
  95967. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  95968. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  95969. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  95970. return cubeMapData;
  95971. };
  95972. /**
  95973. * Returns the pixels data extracted from an RGBE texture.
  95974. * This pixels will be stored left to right up to down in the R G B order in one array.
  95975. *
  95976. * More information on this format are available here:
  95977. * https://en.wikipedia.org/wiki/RGBE_image_format
  95978. *
  95979. * @param uint8array The binary file stored in an array buffer.
  95980. * @param hdrInfo The header information of the file.
  95981. * @return The pixels data in RGB right to left up to down order.
  95982. */
  95983. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  95984. // Keep for multi format supports.
  95985. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  95986. };
  95987. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  95988. var num_scanlines = hdrInfo.height;
  95989. var scanline_width = hdrInfo.width;
  95990. var a, b, c, d, count;
  95991. var dataIndex = hdrInfo.dataPosition;
  95992. var index = 0, endIndex = 0, i = 0;
  95993. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  95994. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  95995. // 3 channels of 4 bytes per pixel in float.
  95996. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  95997. var resultArray = new Float32Array(resultBuffer);
  95998. // read in each successive scanline
  95999. while (num_scanlines > 0) {
  96000. a = uint8array[dataIndex++];
  96001. b = uint8array[dataIndex++];
  96002. c = uint8array[dataIndex++];
  96003. d = uint8array[dataIndex++];
  96004. if (a != 2 || b != 2 || (c & 0x80)) {
  96005. // this file is not run length encoded
  96006. throw "HDR Bad header format, not RLE";
  96007. }
  96008. if (((c << 8) | d) != scanline_width) {
  96009. throw "HDR Bad header format, wrong scan line width";
  96010. }
  96011. index = 0;
  96012. // read each of the four channels for the scanline into the buffer
  96013. for (i = 0; i < 4; i++) {
  96014. endIndex = (i + 1) * scanline_width;
  96015. while (index < endIndex) {
  96016. a = uint8array[dataIndex++];
  96017. b = uint8array[dataIndex++];
  96018. if (a > 128) {
  96019. // a run of the same value
  96020. count = a - 128;
  96021. if ((count == 0) || (count > endIndex - index)) {
  96022. throw "HDR Bad Format, bad scanline data (run)";
  96023. }
  96024. while (count-- > 0) {
  96025. scanLineArray[index++] = b;
  96026. }
  96027. }
  96028. else {
  96029. // a non-run
  96030. count = a;
  96031. if ((count == 0) || (count > endIndex - index)) {
  96032. throw "HDR Bad Format, bad scanline data (non-run)";
  96033. }
  96034. scanLineArray[index++] = b;
  96035. if (--count > 0) {
  96036. for (var j = 0; j < count; j++) {
  96037. scanLineArray[index++] = uint8array[dataIndex++];
  96038. }
  96039. }
  96040. }
  96041. }
  96042. }
  96043. // now convert data from buffer into floats
  96044. for (i = 0; i < scanline_width; i++) {
  96045. a = scanLineArray[i];
  96046. b = scanLineArray[i + scanline_width];
  96047. c = scanLineArray[i + 2 * scanline_width];
  96048. d = scanLineArray[i + 3 * scanline_width];
  96049. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  96050. }
  96051. num_scanlines--;
  96052. }
  96053. return resultArray;
  96054. };
  96055. return HDRTools;
  96056. }());
  96057. /***/ }),
  96058. /***/ "./Misc/HighDynamicRange/index.ts":
  96059. /*!****************************************!*\
  96060. !*** ./Misc/HighDynamicRange/index.ts ***!
  96061. \****************************************/
  96062. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  96063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96064. "use strict";
  96065. __webpack_require__.r(__webpack_exports__);
  96066. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  96067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  96068. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  96069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  96070. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  96071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  96072. /***/ }),
  96073. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  96074. /*!****************************************************!*\
  96075. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  96076. \****************************************************/
  96077. /*! exports provided: PanoramaToCubeMapTools */
  96078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96079. "use strict";
  96080. __webpack_require__.r(__webpack_exports__);
  96081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  96082. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  96083. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  96084. /**
  96085. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  96086. */
  96087. var PanoramaToCubeMapTools = /** @class */ (function () {
  96088. function PanoramaToCubeMapTools() {
  96089. }
  96090. /**
  96091. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  96092. *
  96093. * @param float32Array The source data.
  96094. * @param inputWidth The width of the input panorama.
  96095. * @param inputHeight The height of the input panorama.
  96096. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  96097. * @return The cubemap data
  96098. */
  96099. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  96100. if (!float32Array) {
  96101. throw "ConvertPanoramaToCubemap: input cannot be null";
  96102. }
  96103. if (float32Array.length != inputWidth * inputHeight * 3) {
  96104. throw "ConvertPanoramaToCubemap: input size is wrong";
  96105. }
  96106. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  96107. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  96108. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  96109. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  96110. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  96111. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  96112. return {
  96113. front: textureFront,
  96114. back: textureBack,
  96115. left: textureLeft,
  96116. right: textureRight,
  96117. up: textureUp,
  96118. down: textureDown,
  96119. size: size,
  96120. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  96121. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  96122. gammaSpace: false,
  96123. };
  96124. };
  96125. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  96126. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  96127. var textureArray = new Float32Array(buffer);
  96128. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  96129. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  96130. var dy = 1 / texSize;
  96131. var fy = 0;
  96132. for (var y = 0; y < texSize; y++) {
  96133. var xv1 = faceData[0];
  96134. var xv2 = faceData[2];
  96135. for (var x = 0; x < texSize; x++) {
  96136. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  96137. v.normalize();
  96138. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  96139. // 3 channels per pixels
  96140. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  96141. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  96142. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  96143. xv1 = xv1.add(rotDX1);
  96144. xv2 = xv2.add(rotDX2);
  96145. }
  96146. fy += dy;
  96147. }
  96148. return textureArray;
  96149. };
  96150. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  96151. var theta = Math.atan2(vDir.z, vDir.x);
  96152. var phi = Math.acos(vDir.y);
  96153. while (theta < -Math.PI) {
  96154. theta += 2 * Math.PI;
  96155. }
  96156. while (theta > Math.PI) {
  96157. theta -= 2 * Math.PI;
  96158. }
  96159. var dx = theta / Math.PI;
  96160. var dy = phi / Math.PI;
  96161. // recenter.
  96162. dx = dx * 0.5 + 0.5;
  96163. var px = Math.round(dx * inputWidth);
  96164. if (px < 0) {
  96165. px = 0;
  96166. }
  96167. else if (px >= inputWidth) {
  96168. px = inputWidth - 1;
  96169. }
  96170. var py = Math.round(dy * inputHeight);
  96171. if (py < 0) {
  96172. py = 0;
  96173. }
  96174. else if (py >= inputHeight) {
  96175. py = inputHeight - 1;
  96176. }
  96177. var inputY = (inputHeight - py - 1);
  96178. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  96179. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  96180. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  96181. return {
  96182. r: r,
  96183. g: g,
  96184. b: b
  96185. };
  96186. };
  96187. PanoramaToCubeMapTools.FACE_FRONT = [
  96188. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  96189. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  96190. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  96191. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  96192. ];
  96193. PanoramaToCubeMapTools.FACE_BACK = [
  96194. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  96195. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  96196. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  96197. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  96198. ];
  96199. PanoramaToCubeMapTools.FACE_RIGHT = [
  96200. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  96201. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  96202. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  96203. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  96204. ];
  96205. PanoramaToCubeMapTools.FACE_LEFT = [
  96206. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  96207. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  96208. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  96209. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  96210. ];
  96211. PanoramaToCubeMapTools.FACE_DOWN = [
  96212. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  96213. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  96214. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  96215. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  96216. ];
  96217. PanoramaToCubeMapTools.FACE_UP = [
  96218. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  96219. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  96220. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  96221. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  96222. ];
  96223. return PanoramaToCubeMapTools;
  96224. }());
  96225. /***/ }),
  96226. /***/ "./Misc/andOrNotEvaluator.ts":
  96227. /*!***********************************!*\
  96228. !*** ./Misc/andOrNotEvaluator.ts ***!
  96229. \***********************************/
  96230. /*! exports provided: AndOrNotEvaluator */
  96231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96232. "use strict";
  96233. __webpack_require__.r(__webpack_exports__);
  96234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  96235. /**
  96236. * Class used to evalaute queries containing `and` and `or` operators
  96237. */
  96238. var AndOrNotEvaluator = /** @class */ (function () {
  96239. function AndOrNotEvaluator() {
  96240. }
  96241. /**
  96242. * Evaluate a query
  96243. * @param query defines the query to evaluate
  96244. * @param evaluateCallback defines the callback used to filter result
  96245. * @returns true if the query matches
  96246. */
  96247. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  96248. if (!query.match(/\([^\(\)]*\)/g)) {
  96249. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  96250. }
  96251. else {
  96252. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  96253. // remove parenthesis
  96254. r = r.slice(1, r.length - 1);
  96255. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  96256. });
  96257. }
  96258. if (query === "true") {
  96259. return true;
  96260. }
  96261. if (query === "false") {
  96262. return false;
  96263. }
  96264. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  96265. };
  96266. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  96267. evaluateCallback = evaluateCallback || (function (r) {
  96268. return r === "true" ? true : false;
  96269. });
  96270. var result;
  96271. var or = parenthesisContent.split("||");
  96272. for (var i in or) {
  96273. if (or.hasOwnProperty(i)) {
  96274. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  96275. var and = ori.split("&&");
  96276. if (and.length > 1) {
  96277. for (var j = 0; j < and.length; ++j) {
  96278. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  96279. if (andj !== "true" && andj !== "false") {
  96280. if (andj[0] === "!") {
  96281. result = !evaluateCallback(andj.substring(1));
  96282. }
  96283. else {
  96284. result = evaluateCallback(andj);
  96285. }
  96286. }
  96287. else {
  96288. result = andj === "true" ? true : false;
  96289. }
  96290. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  96291. ori = "false";
  96292. break;
  96293. }
  96294. }
  96295. }
  96296. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  96297. result = true;
  96298. break;
  96299. }
  96300. // result equals false (or undefined)
  96301. if (ori !== "true" && ori !== "false") {
  96302. if (ori[0] === "!") {
  96303. result = !evaluateCallback(ori.substring(1));
  96304. }
  96305. else {
  96306. result = evaluateCallback(ori);
  96307. }
  96308. }
  96309. else {
  96310. result = ori === "true" ? true : false;
  96311. }
  96312. }
  96313. }
  96314. // the whole parenthesis scope is replaced by 'true' or 'false'
  96315. return result ? "true" : "false";
  96316. };
  96317. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  96318. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  96319. // remove whitespaces
  96320. r = r.replace(/[\s]/g, function () { return ""; });
  96321. return r.length % 2 ? "!" : "";
  96322. });
  96323. booleanString = booleanString.trim();
  96324. if (booleanString === "!true") {
  96325. booleanString = "false";
  96326. }
  96327. else if (booleanString === "!false") {
  96328. booleanString = "true";
  96329. }
  96330. return booleanString;
  96331. };
  96332. return AndOrNotEvaluator;
  96333. }());
  96334. /***/ }),
  96335. /***/ "./Misc/arrayTools.ts":
  96336. /*!****************************!*\
  96337. !*** ./Misc/arrayTools.ts ***!
  96338. \****************************/
  96339. /*! exports provided: ArrayTools */
  96340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96341. "use strict";
  96342. __webpack_require__.r(__webpack_exports__);
  96343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  96344. /**
  96345. * Class containing a set of static utilities functions for arrays.
  96346. */
  96347. var ArrayTools = /** @class */ (function () {
  96348. function ArrayTools() {
  96349. }
  96350. /**
  96351. * Returns an array of the given size filled with element built from the given constructor and the paramters
  96352. * @param size the number of element to construct and put in the array
  96353. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  96354. * @returns a new array filled with new objects
  96355. */
  96356. ArrayTools.BuildArray = function (size, itemBuilder) {
  96357. var a = [];
  96358. for (var i = 0; i < size; ++i) {
  96359. a.push(itemBuilder());
  96360. }
  96361. return a;
  96362. };
  96363. return ArrayTools;
  96364. }());
  96365. /***/ }),
  96366. /***/ "./Misc/assetsManager.ts":
  96367. /*!*******************************!*\
  96368. !*** ./Misc/assetsManager.ts ***!
  96369. \*******************************/
  96370. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager */
  96371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96372. "use strict";
  96373. __webpack_require__.r(__webpack_exports__);
  96374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  96375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  96376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  96377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  96378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  96379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  96380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  96381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  96382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  96383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  96384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return EquiRectangularCubeTextureAssetTask; });
  96385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  96386. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96387. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  96388. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96389. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96390. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96391. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  96392. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  96393. /* harmony import */ var _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  96394. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96395. /**
  96396. * Defines the list of states available for a task inside a AssetsManager
  96397. */
  96398. var AssetTaskState;
  96399. (function (AssetTaskState) {
  96400. /**
  96401. * Initialization
  96402. */
  96403. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  96404. /**
  96405. * Running
  96406. */
  96407. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  96408. /**
  96409. * Done
  96410. */
  96411. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  96412. /**
  96413. * Error
  96414. */
  96415. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  96416. })(AssetTaskState || (AssetTaskState = {}));
  96417. /**
  96418. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  96419. */
  96420. var AbstractAssetTask = /** @class */ (function () {
  96421. /**
  96422. * Creates a new AssetsManager
  96423. * @param name defines the name of the task
  96424. */
  96425. function AbstractAssetTask(
  96426. /**
  96427. * Task name
  96428. */ name) {
  96429. this.name = name;
  96430. this._isCompleted = false;
  96431. this._taskState = AssetTaskState.INIT;
  96432. }
  96433. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  96434. /**
  96435. * Get if the task is completed
  96436. */
  96437. get: function () {
  96438. return this._isCompleted;
  96439. },
  96440. enumerable: true,
  96441. configurable: true
  96442. });
  96443. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  96444. /**
  96445. * Gets the current state of the task
  96446. */
  96447. get: function () {
  96448. return this._taskState;
  96449. },
  96450. enumerable: true,
  96451. configurable: true
  96452. });
  96453. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  96454. /**
  96455. * Gets the current error object (if task is in error)
  96456. */
  96457. get: function () {
  96458. return this._errorObject;
  96459. },
  96460. enumerable: true,
  96461. configurable: true
  96462. });
  96463. /**
  96464. * Internal only
  96465. * @hidden
  96466. */
  96467. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  96468. if (this._errorObject) {
  96469. return;
  96470. }
  96471. this._errorObject = {
  96472. message: message,
  96473. exception: exception
  96474. };
  96475. };
  96476. /**
  96477. * Execute the current task
  96478. * @param scene defines the scene where you want your assets to be loaded
  96479. * @param onSuccess is a callback called when the task is successfully executed
  96480. * @param onError is a callback called if an error occurs
  96481. */
  96482. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  96483. var _this = this;
  96484. this._taskState = AssetTaskState.RUNNING;
  96485. this.runTask(scene, function () {
  96486. _this.onDoneCallback(onSuccess, onError);
  96487. }, function (msg, exception) {
  96488. _this.onErrorCallback(onError, msg, exception);
  96489. });
  96490. };
  96491. /**
  96492. * Execute the current task
  96493. * @param scene defines the scene where you want your assets to be loaded
  96494. * @param onSuccess is a callback called when the task is successfully executed
  96495. * @param onError is a callback called if an error occurs
  96496. */
  96497. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96498. throw new Error("runTask is not implemented");
  96499. };
  96500. /**
  96501. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  96502. * This can be used with failed tasks that have the reason for failure fixed.
  96503. */
  96504. AbstractAssetTask.prototype.reset = function () {
  96505. this._taskState = AssetTaskState.INIT;
  96506. };
  96507. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  96508. this._taskState = AssetTaskState.ERROR;
  96509. this._errorObject = {
  96510. message: message,
  96511. exception: exception
  96512. };
  96513. if (this.onError) {
  96514. this.onError(this, message, exception);
  96515. }
  96516. onError();
  96517. };
  96518. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  96519. try {
  96520. this._taskState = AssetTaskState.DONE;
  96521. this._isCompleted = true;
  96522. if (this.onSuccess) {
  96523. this.onSuccess(this);
  96524. }
  96525. onSuccess();
  96526. }
  96527. catch (e) {
  96528. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  96529. }
  96530. };
  96531. return AbstractAssetTask;
  96532. }());
  96533. /**
  96534. * Class used to share progress information about assets loading
  96535. */
  96536. var AssetsProgressEvent = /** @class */ (function () {
  96537. /**
  96538. * Creates a AssetsProgressEvent
  96539. * @param remainingCount defines the number of remaining tasks to process
  96540. * @param totalCount defines the total number of tasks
  96541. * @param task defines the task that was just processed
  96542. */
  96543. function AssetsProgressEvent(remainingCount, totalCount, task) {
  96544. this.remainingCount = remainingCount;
  96545. this.totalCount = totalCount;
  96546. this.task = task;
  96547. }
  96548. return AssetsProgressEvent;
  96549. }());
  96550. /**
  96551. * Define a task used by AssetsManager to load meshes
  96552. */
  96553. var MeshAssetTask = /** @class */ (function (_super) {
  96554. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  96555. /**
  96556. * Creates a new MeshAssetTask
  96557. * @param name defines the name of the task
  96558. * @param meshesNames defines the list of mesh's names you want to load
  96559. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  96560. * @param sceneFilename defines the filename of the scene to load from
  96561. */
  96562. function MeshAssetTask(
  96563. /**
  96564. * Defines the name of the task
  96565. */
  96566. name,
  96567. /**
  96568. * Defines the list of mesh's names you want to load
  96569. */
  96570. meshesNames,
  96571. /**
  96572. * Defines the root url to use as a base to load your meshes and associated resources
  96573. */
  96574. rootUrl,
  96575. /**
  96576. * Defines the filename of the scene to load from
  96577. */
  96578. sceneFilename) {
  96579. var _this = _super.call(this, name) || this;
  96580. _this.name = name;
  96581. _this.meshesNames = meshesNames;
  96582. _this.rootUrl = rootUrl;
  96583. _this.sceneFilename = sceneFilename;
  96584. return _this;
  96585. }
  96586. /**
  96587. * Execute the current task
  96588. * @param scene defines the scene where you want your assets to be loaded
  96589. * @param onSuccess is a callback called when the task is successfully executed
  96590. * @param onError is a callback called if an error occurs
  96591. */
  96592. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96593. var _this = this;
  96594. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  96595. _this.loadedMeshes = meshes;
  96596. _this.loadedParticleSystems = particleSystems;
  96597. _this.loadedSkeletons = skeletons;
  96598. _this.loadedAnimationGroups = animationGroups;
  96599. onSuccess();
  96600. }, null, function (scene, message, exception) {
  96601. onError(message, exception);
  96602. });
  96603. };
  96604. return MeshAssetTask;
  96605. }(AbstractAssetTask));
  96606. /**
  96607. * Define a task used by AssetsManager to load text content
  96608. */
  96609. var TextFileAssetTask = /** @class */ (function (_super) {
  96610. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  96611. /**
  96612. * Creates a new TextFileAssetTask object
  96613. * @param name defines the name of the task
  96614. * @param url defines the location of the file to load
  96615. */
  96616. function TextFileAssetTask(
  96617. /**
  96618. * Defines the name of the task
  96619. */
  96620. name,
  96621. /**
  96622. * Defines the location of the file to load
  96623. */
  96624. url) {
  96625. var _this = _super.call(this, name) || this;
  96626. _this.name = name;
  96627. _this.url = url;
  96628. return _this;
  96629. }
  96630. /**
  96631. * Execute the current task
  96632. * @param scene defines the scene where you want your assets to be loaded
  96633. * @param onSuccess is a callback called when the task is successfully executed
  96634. * @param onError is a callback called if an error occurs
  96635. */
  96636. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96637. var _this = this;
  96638. scene._loadFile(this.url, function (data) {
  96639. _this.text = data;
  96640. onSuccess();
  96641. }, undefined, false, false, function (request, exception) {
  96642. if (request) {
  96643. onError(request.status + " " + request.statusText, exception);
  96644. }
  96645. });
  96646. };
  96647. return TextFileAssetTask;
  96648. }(AbstractAssetTask));
  96649. /**
  96650. * Define a task used by AssetsManager to load binary data
  96651. */
  96652. var BinaryFileAssetTask = /** @class */ (function (_super) {
  96653. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  96654. /**
  96655. * Creates a new BinaryFileAssetTask object
  96656. * @param name defines the name of the new task
  96657. * @param url defines the location of the file to load
  96658. */
  96659. function BinaryFileAssetTask(
  96660. /**
  96661. * Defines the name of the task
  96662. */
  96663. name,
  96664. /**
  96665. * Defines the location of the file to load
  96666. */
  96667. url) {
  96668. var _this = _super.call(this, name) || this;
  96669. _this.name = name;
  96670. _this.url = url;
  96671. return _this;
  96672. }
  96673. /**
  96674. * Execute the current task
  96675. * @param scene defines the scene where you want your assets to be loaded
  96676. * @param onSuccess is a callback called when the task is successfully executed
  96677. * @param onError is a callback called if an error occurs
  96678. */
  96679. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96680. var _this = this;
  96681. scene._loadFile(this.url, function (data) {
  96682. _this.data = data;
  96683. onSuccess();
  96684. }, undefined, true, true, function (request, exception) {
  96685. if (request) {
  96686. onError(request.status + " " + request.statusText, exception);
  96687. }
  96688. });
  96689. };
  96690. return BinaryFileAssetTask;
  96691. }(AbstractAssetTask));
  96692. /**
  96693. * Define a task used by AssetsManager to load images
  96694. */
  96695. var ImageAssetTask = /** @class */ (function (_super) {
  96696. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  96697. /**
  96698. * Creates a new ImageAssetTask
  96699. * @param name defines the name of the task
  96700. * @param url defines the location of the image to load
  96701. */
  96702. function ImageAssetTask(
  96703. /**
  96704. * Defines the name of the task
  96705. */
  96706. name,
  96707. /**
  96708. * Defines the location of the image to load
  96709. */
  96710. url) {
  96711. var _this = _super.call(this, name) || this;
  96712. _this.name = name;
  96713. _this.url = url;
  96714. return _this;
  96715. }
  96716. /**
  96717. * Execute the current task
  96718. * @param scene defines the scene where you want your assets to be loaded
  96719. * @param onSuccess is a callback called when the task is successfully executed
  96720. * @param onError is a callback called if an error occurs
  96721. */
  96722. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96723. var _this = this;
  96724. var img = new Image();
  96725. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  96726. img.onload = function () {
  96727. _this.image = img;
  96728. onSuccess();
  96729. };
  96730. img.onerror = function (err) {
  96731. onError("Error loading image", err);
  96732. };
  96733. img.src = this.url;
  96734. };
  96735. return ImageAssetTask;
  96736. }(AbstractAssetTask));
  96737. /**
  96738. * Define a task used by AssetsManager to load 2D textures
  96739. */
  96740. var TextureAssetTask = /** @class */ (function (_super) {
  96741. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  96742. /**
  96743. * Creates a new TextureAssetTask object
  96744. * @param name defines the name of the task
  96745. * @param url defines the location of the file to load
  96746. * @param noMipmap defines if mipmap should not be generated (default is false)
  96747. * @param invertY defines if texture must be inverted on Y axis (default is false)
  96748. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96749. */
  96750. function TextureAssetTask(
  96751. /**
  96752. * Defines the name of the task
  96753. */
  96754. name,
  96755. /**
  96756. * Defines the location of the file to load
  96757. */
  96758. url,
  96759. /**
  96760. * Defines if mipmap should not be generated (default is false)
  96761. */
  96762. noMipmap,
  96763. /**
  96764. * Defines if texture must be inverted on Y axis (default is false)
  96765. */
  96766. invertY,
  96767. /**
  96768. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96769. */
  96770. samplingMode) {
  96771. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  96772. var _this = _super.call(this, name) || this;
  96773. _this.name = name;
  96774. _this.url = url;
  96775. _this.noMipmap = noMipmap;
  96776. _this.invertY = invertY;
  96777. _this.samplingMode = samplingMode;
  96778. return _this;
  96779. }
  96780. /**
  96781. * Execute the current task
  96782. * @param scene defines the scene where you want your assets to be loaded
  96783. * @param onSuccess is a callback called when the task is successfully executed
  96784. * @param onError is a callback called if an error occurs
  96785. */
  96786. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96787. var onload = function () {
  96788. onSuccess();
  96789. };
  96790. var onerror = function (message, exception) {
  96791. onError(message, exception);
  96792. };
  96793. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  96794. };
  96795. return TextureAssetTask;
  96796. }(AbstractAssetTask));
  96797. /**
  96798. * Define a task used by AssetsManager to load cube textures
  96799. */
  96800. var CubeTextureAssetTask = /** @class */ (function (_super) {
  96801. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  96802. /**
  96803. * Creates a new CubeTextureAssetTask
  96804. * @param name defines the name of the task
  96805. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  96806. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  96807. * @param noMipmap defines if mipmaps should not be generated (default is false)
  96808. * @param files defines the explicit list of files (undefined by default)
  96809. */
  96810. function CubeTextureAssetTask(
  96811. /**
  96812. * Defines the name of the task
  96813. */
  96814. name,
  96815. /**
  96816. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  96817. */
  96818. url,
  96819. /**
  96820. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  96821. */
  96822. extensions,
  96823. /**
  96824. * Defines if mipmaps should not be generated (default is false)
  96825. */
  96826. noMipmap,
  96827. /**
  96828. * Defines the explicit list of files (undefined by default)
  96829. */
  96830. files) {
  96831. var _this = _super.call(this, name) || this;
  96832. _this.name = name;
  96833. _this.url = url;
  96834. _this.extensions = extensions;
  96835. _this.noMipmap = noMipmap;
  96836. _this.files = files;
  96837. return _this;
  96838. }
  96839. /**
  96840. * Execute the current task
  96841. * @param scene defines the scene where you want your assets to be loaded
  96842. * @param onSuccess is a callback called when the task is successfully executed
  96843. * @param onError is a callback called if an error occurs
  96844. */
  96845. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96846. var onload = function () {
  96847. onSuccess();
  96848. };
  96849. var onerror = function (message, exception) {
  96850. onError(message, exception);
  96851. };
  96852. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  96853. };
  96854. return CubeTextureAssetTask;
  96855. }(AbstractAssetTask));
  96856. /**
  96857. * Define a task used by AssetsManager to load HDR cube textures
  96858. */
  96859. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  96860. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  96861. /**
  96862. * Creates a new HDRCubeTextureAssetTask object
  96863. * @param name defines the name of the task
  96864. * @param url defines the location of the file to load
  96865. * @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.
  96866. * @param noMipmap defines if mipmaps should not be generated (default is false)
  96867. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  96868. * @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)
  96869. * @param reserved Internal use only
  96870. */
  96871. function HDRCubeTextureAssetTask(
  96872. /**
  96873. * Defines the name of the task
  96874. */
  96875. name,
  96876. /**
  96877. * Defines the location of the file to load
  96878. */
  96879. url,
  96880. /**
  96881. * Defines the desired size (the more it increases the longer the generation will be)
  96882. */
  96883. size,
  96884. /**
  96885. * Defines if mipmaps should not be generated (default is false)
  96886. */
  96887. noMipmap,
  96888. /**
  96889. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  96890. */
  96891. generateHarmonics,
  96892. /**
  96893. * 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)
  96894. */
  96895. gammaSpace,
  96896. /**
  96897. * Internal Use Only
  96898. */
  96899. reserved) {
  96900. if (noMipmap === void 0) { noMipmap = false; }
  96901. if (generateHarmonics === void 0) { generateHarmonics = true; }
  96902. if (gammaSpace === void 0) { gammaSpace = false; }
  96903. if (reserved === void 0) { reserved = false; }
  96904. var _this = _super.call(this, name) || this;
  96905. _this.name = name;
  96906. _this.url = url;
  96907. _this.size = size;
  96908. _this.noMipmap = noMipmap;
  96909. _this.generateHarmonics = generateHarmonics;
  96910. _this.gammaSpace = gammaSpace;
  96911. _this.reserved = reserved;
  96912. return _this;
  96913. }
  96914. /**
  96915. * Execute the current task
  96916. * @param scene defines the scene where you want your assets to be loaded
  96917. * @param onSuccess is a callback called when the task is successfully executed
  96918. * @param onError is a callback called if an error occurs
  96919. */
  96920. HDRCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96921. var onload = function () {
  96922. onSuccess();
  96923. };
  96924. var onerror = function (message, exception) {
  96925. onError(message, exception);
  96926. };
  96927. 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);
  96928. };
  96929. return HDRCubeTextureAssetTask;
  96930. }(AbstractAssetTask));
  96931. /**
  96932. * Define a task used by AssetsManager to load Equirectangular cube textures
  96933. */
  96934. var EquiRectangularCubeTextureAssetTask = /** @class */ (function (_super) {
  96935. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTextureAssetTask, _super);
  96936. /**
  96937. * Creates a new EquiRectangularCubeTextureAssetTask object
  96938. * @param name defines the name of the task
  96939. * @param url defines the location of the file to load
  96940. * @param size defines the desired size (the more it increases the longer the generation will be)
  96941. * If the size is omitted this implies you are using a preprocessed cubemap.
  96942. * @param noMipmap defines if mipmaps should not be generated (default is false)
  96943. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  96944. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  96945. * (default is true)
  96946. */
  96947. function EquiRectangularCubeTextureAssetTask(
  96948. /**
  96949. * Defines the name of the task
  96950. */
  96951. name,
  96952. /**
  96953. * Defines the location of the file to load
  96954. */
  96955. url,
  96956. /**
  96957. * Defines the desired size (the more it increases the longer the generation will be)
  96958. */
  96959. size,
  96960. /**
  96961. * Defines if mipmaps should not be generated (default is false)
  96962. */
  96963. noMipmap,
  96964. /**
  96965. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  96966. * but the standard material would require them in Gamma space) (default is true)
  96967. */
  96968. gammaSpace) {
  96969. if (noMipmap === void 0) { noMipmap = false; }
  96970. if (gammaSpace === void 0) { gammaSpace = true; }
  96971. var _this = _super.call(this, name) || this;
  96972. _this.name = name;
  96973. _this.url = url;
  96974. _this.size = size;
  96975. _this.noMipmap = noMipmap;
  96976. _this.gammaSpace = gammaSpace;
  96977. return _this;
  96978. }
  96979. /**
  96980. * Execute the current task
  96981. * @param scene defines the scene where you want your assets to be loaded
  96982. * @param onSuccess is a callback called when the task is successfully executed
  96983. * @param onError is a callback called if an error occurs
  96984. */
  96985. EquiRectangularCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96986. var onload = function () {
  96987. onSuccess();
  96988. };
  96989. var onerror = function (message, exception) {
  96990. onError(message, exception);
  96991. };
  96992. this.texture = new _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__["EquiRectangularCubeTexture"](this.url, scene, this.size, this.noMipmap, this.gammaSpace, onload, onerror);
  96993. };
  96994. return EquiRectangularCubeTextureAssetTask;
  96995. }(AbstractAssetTask));
  96996. /**
  96997. * This class can be used to easily import assets into a scene
  96998. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  96999. */
  97000. var AssetsManager = /** @class */ (function () {
  97001. /**
  97002. * Creates a new AssetsManager
  97003. * @param scene defines the scene to work on
  97004. */
  97005. function AssetsManager(scene) {
  97006. this._isLoading = false;
  97007. this._tasks = new Array();
  97008. this._waitingTasksCount = 0;
  97009. this._totalTasksCount = 0;
  97010. /**
  97011. * Observable called when all tasks are processed
  97012. */
  97013. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  97014. /**
  97015. * Observable called when a task had an error
  97016. */
  97017. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  97018. /**
  97019. * Observable called when all tasks were executed
  97020. */
  97021. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  97022. /**
  97023. * Observable called when a task is done (whatever the result is)
  97024. */
  97025. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  97026. /**
  97027. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  97028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97029. */
  97030. this.useDefaultLoadingScreen = true;
  97031. this._scene = scene;
  97032. }
  97033. /**
  97034. * Add a MeshAssetTask to the list of active tasks
  97035. * @param taskName defines the name of the new task
  97036. * @param meshesNames defines the name of meshes to load
  97037. * @param rootUrl defines the root url to use to locate files
  97038. * @param sceneFilename defines the filename of the scene file
  97039. * @returns a new MeshAssetTask object
  97040. */
  97041. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  97042. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  97043. this._tasks.push(task);
  97044. return task;
  97045. };
  97046. /**
  97047. * Add a TextFileAssetTask to the list of active tasks
  97048. * @param taskName defines the name of the new task
  97049. * @param url defines the url of the file to load
  97050. * @returns a new TextFileAssetTask object
  97051. */
  97052. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  97053. var task = new TextFileAssetTask(taskName, url);
  97054. this._tasks.push(task);
  97055. return task;
  97056. };
  97057. /**
  97058. * Add a BinaryFileAssetTask to the list of active tasks
  97059. * @param taskName defines the name of the new task
  97060. * @param url defines the url of the file to load
  97061. * @returns a new BinaryFileAssetTask object
  97062. */
  97063. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  97064. var task = new BinaryFileAssetTask(taskName, url);
  97065. this._tasks.push(task);
  97066. return task;
  97067. };
  97068. /**
  97069. * Add a ImageAssetTask to the list of active tasks
  97070. * @param taskName defines the name of the new task
  97071. * @param url defines the url of the file to load
  97072. * @returns a new ImageAssetTask object
  97073. */
  97074. AssetsManager.prototype.addImageTask = function (taskName, url) {
  97075. var task = new ImageAssetTask(taskName, url);
  97076. this._tasks.push(task);
  97077. return task;
  97078. };
  97079. /**
  97080. * Add a TextureAssetTask to the list of active tasks
  97081. * @param taskName defines the name of the new task
  97082. * @param url defines the url of the file to load
  97083. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  97084. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  97085. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  97086. * @returns a new TextureAssetTask object
  97087. */
  97088. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  97089. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  97090. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  97091. this._tasks.push(task);
  97092. return task;
  97093. };
  97094. /**
  97095. * Add a CubeTextureAssetTask to the list of active tasks
  97096. * @param taskName defines the name of the new task
  97097. * @param url defines the url of the file to load
  97098. * @param extensions defines the extension to use to load the cube map (can be null)
  97099. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  97100. * @param files defines the list of files to load (can be null)
  97101. * @returns a new CubeTextureAssetTask object
  97102. */
  97103. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  97104. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  97105. this._tasks.push(task);
  97106. return task;
  97107. };
  97108. /**
  97109. *
  97110. * Add a HDRCubeTextureAssetTask to the list of active tasks
  97111. * @param taskName defines the name of the new task
  97112. * @param url defines the url of the file to load
  97113. * @param size defines the size you want for the cubemap (can be null)
  97114. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  97115. * @param generateHarmonics defines if you want to automatically generate (true by default)
  97116. * @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)
  97117. * @param reserved Internal use only
  97118. * @returns a new HDRCubeTextureAssetTask object
  97119. */
  97120. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  97121. if (noMipmap === void 0) { noMipmap = false; }
  97122. if (generateHarmonics === void 0) { generateHarmonics = true; }
  97123. if (gammaSpace === void 0) { gammaSpace = false; }
  97124. if (reserved === void 0) { reserved = false; }
  97125. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  97126. this._tasks.push(task);
  97127. return task;
  97128. };
  97129. /**
  97130. *
  97131. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  97132. * @param taskName defines the name of the new task
  97133. * @param url defines the url of the file to load
  97134. * @param size defines the size you want for the cubemap (can be null)
  97135. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  97136. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  97137. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  97138. * @returns a new EquiRectangularCubeTextureAssetTask object
  97139. */
  97140. AssetsManager.prototype.addEquiRectangularCubeTextureAssetTask = function (taskName, url, size, noMipmap, gammaSpace) {
  97141. if (noMipmap === void 0) { noMipmap = false; }
  97142. if (gammaSpace === void 0) { gammaSpace = true; }
  97143. var task = new EquiRectangularCubeTextureAssetTask(taskName, url, size, noMipmap, gammaSpace);
  97144. this._tasks.push(task);
  97145. return task;
  97146. };
  97147. /**
  97148. * Remove a task from the assets manager.
  97149. * @param task the task to remove
  97150. */
  97151. AssetsManager.prototype.removeTask = function (task) {
  97152. var index = this._tasks.indexOf(task);
  97153. if (index > -1) {
  97154. this._tasks.splice(index, 1);
  97155. }
  97156. };
  97157. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  97158. this._waitingTasksCount--;
  97159. try {
  97160. if (this.onProgress) {
  97161. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  97162. }
  97163. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  97164. }
  97165. catch (e) {
  97166. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running progress callbacks.");
  97167. console.log(e);
  97168. }
  97169. if (this._waitingTasksCount === 0) {
  97170. try {
  97171. if (this.onFinish) {
  97172. this.onFinish(this._tasks);
  97173. }
  97174. // Let's remove successfull tasks
  97175. var currentTasks = this._tasks.slice();
  97176. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  97177. var task = currentTasks_1[_i];
  97178. if (task.taskState === AssetTaskState.DONE) {
  97179. var index = this._tasks.indexOf(task);
  97180. if (index > -1) {
  97181. this._tasks.splice(index, 1);
  97182. }
  97183. }
  97184. }
  97185. this.onTasksDoneObservable.notifyObservers(this._tasks);
  97186. }
  97187. catch (e) {
  97188. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running tasks-done callbacks.");
  97189. console.log(e);
  97190. }
  97191. this._isLoading = false;
  97192. this._scene.getEngine().hideLoadingUI();
  97193. }
  97194. };
  97195. AssetsManager.prototype._runTask = function (task) {
  97196. var _this = this;
  97197. var done = function () {
  97198. try {
  97199. if (_this.onTaskSuccess) {
  97200. _this.onTaskSuccess(task);
  97201. }
  97202. _this.onTaskSuccessObservable.notifyObservers(task);
  97203. _this._decreaseWaitingTasksCount(task);
  97204. }
  97205. catch (e) {
  97206. error("Error executing task success callbacks", e);
  97207. }
  97208. };
  97209. var error = function (message, exception) {
  97210. task._setErrorObject(message, exception);
  97211. if (_this.onTaskError) {
  97212. _this.onTaskError(task);
  97213. }
  97214. _this.onTaskErrorObservable.notifyObservers(task);
  97215. _this._decreaseWaitingTasksCount(task);
  97216. };
  97217. task.run(this._scene, done, error);
  97218. };
  97219. /**
  97220. * Reset the AssetsManager and remove all tasks
  97221. * @return the current instance of the AssetsManager
  97222. */
  97223. AssetsManager.prototype.reset = function () {
  97224. this._isLoading = false;
  97225. this._tasks = new Array();
  97226. return this;
  97227. };
  97228. /**
  97229. * Start the loading process
  97230. * @return the current instance of the AssetsManager
  97231. */
  97232. AssetsManager.prototype.load = function () {
  97233. if (this._isLoading) {
  97234. return this;
  97235. }
  97236. this._isLoading = true;
  97237. this._waitingTasksCount = this._tasks.length;
  97238. this._totalTasksCount = this._tasks.length;
  97239. if (this._waitingTasksCount === 0) {
  97240. this._isLoading = false;
  97241. if (this.onFinish) {
  97242. this.onFinish(this._tasks);
  97243. }
  97244. this.onTasksDoneObservable.notifyObservers(this._tasks);
  97245. return this;
  97246. }
  97247. if (this.useDefaultLoadingScreen) {
  97248. this._scene.getEngine().displayLoadingUI();
  97249. }
  97250. for (var index = 0; index < this._tasks.length; index++) {
  97251. var task = this._tasks[index];
  97252. if (task.taskState === AssetTaskState.INIT) {
  97253. this._runTask(task);
  97254. }
  97255. }
  97256. return this;
  97257. };
  97258. /**
  97259. * Start the loading process as an async operation
  97260. * @return a promise returning the list of failed tasks
  97261. */
  97262. AssetsManager.prototype.loadAsync = function () {
  97263. var _this = this;
  97264. return new Promise(function (resolve, reject) {
  97265. _this.onTasksDoneObservable.addOnce(function (remainingTasks) {
  97266. if (remainingTasks && remainingTasks.length) {
  97267. reject(remainingTasks);
  97268. }
  97269. else {
  97270. resolve();
  97271. }
  97272. });
  97273. });
  97274. };
  97275. return AssetsManager;
  97276. }());
  97277. /***/ }),
  97278. /***/ "./Misc/brdfTextureTools.ts":
  97279. /*!**********************************!*\
  97280. !*** ./Misc/brdfTextureTools.ts ***!
  97281. \**********************************/
  97282. /*! exports provided: BRDFTextureTools */
  97283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97284. "use strict";
  97285. __webpack_require__.r(__webpack_exports__);
  97286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return BRDFTextureTools; });
  97287. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97288. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97289. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  97290. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  97291. /**
  97292. * Class used to host texture specific utilities
  97293. */
  97294. var BRDFTextureTools = /** @class */ (function () {
  97295. function BRDFTextureTools() {
  97296. }
  97297. /**
  97298. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  97299. * @param texture the texture to expand.
  97300. */
  97301. BRDFTextureTools._ExpandDefaultBRDFTexture = function (texture) {
  97302. // Gets everything ready.
  97303. var engine = texture.getEngine();
  97304. var caps = engine.getCaps();
  97305. var expandTexture = false;
  97306. // If half float available we can uncompress the texture
  97307. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  97308. expandTexture = true;
  97309. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97310. }
  97311. // If full float available we can uncompress the texture
  97312. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  97313. expandTexture = true;
  97314. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT;
  97315. }
  97316. // Expand the texture if possible
  97317. if (expandTexture) {
  97318. // Do not use during decode.
  97319. texture.isReady = false;
  97320. // Simply run through the decode PP.
  97321. 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);
  97322. texture._isRGBD = false;
  97323. texture.invertY = false;
  97324. // Hold the output of the decoding.
  97325. var expandedTexture_1 = engine.createRenderTargetTexture(texture.width, {
  97326. generateDepthBuffer: false,
  97327. generateMipMaps: false,
  97328. generateStencilBuffer: false,
  97329. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  97330. type: texture.type,
  97331. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA
  97332. });
  97333. rgbdPostProcess_1.getEffect().executeWhenCompiled(function () {
  97334. // PP Render Pass
  97335. rgbdPostProcess_1.onApply = function (effect) {
  97336. effect._bindTexture("textureSampler", texture);
  97337. effect.setFloat2("scale", 1, 1);
  97338. };
  97339. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess_1], expandedTexture_1, true);
  97340. // Cleanup
  97341. engine.restoreDefaultFramebuffer();
  97342. engine._releaseTexture(texture);
  97343. engine._releaseFramebufferObjects(expandedTexture_1);
  97344. if (rgbdPostProcess_1) {
  97345. rgbdPostProcess_1.dispose();
  97346. }
  97347. // Internal Swap
  97348. expandedTexture_1._swapAndDie(texture);
  97349. // Ready to get rolling again.
  97350. texture.isReady = true;
  97351. });
  97352. }
  97353. };
  97354. /**
  97355. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  97356. * @param scene defines the hosting scene
  97357. * @returns the environment BRDF texture
  97358. */
  97359. BRDFTextureTools.GetEnvironmentBRDFTexture = function (scene) {
  97360. var _this = this;
  97361. if (!scene.environmentBRDFTexture) {
  97362. // Forces Delayed Texture Loading to prevent undefined error whilst setting RGBD values.
  97363. var useDelayedTextureLoading = scene.useDelayedTextureLoading;
  97364. scene.useDelayedTextureLoading = false;
  97365. 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);
  97366. texture._texture._isRGBD = true;
  97367. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97368. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  97369. scene.environmentBRDFTexture = texture;
  97370. scene.useDelayedTextureLoading = useDelayedTextureLoading;
  97371. texture.onLoadObservable.addOnce(function () {
  97372. _this._ExpandDefaultBRDFTexture(texture._texture);
  97373. });
  97374. }
  97375. return scene.environmentBRDFTexture;
  97376. };
  97377. 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==";
  97378. return BRDFTextureTools;
  97379. }());
  97380. /***/ }),
  97381. /***/ "./Misc/dds.ts":
  97382. /*!*********************!*\
  97383. !*** ./Misc/dds.ts ***!
  97384. \*********************/
  97385. /*! exports provided: DDSTools */
  97386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97387. "use strict";
  97388. __webpack_require__.r(__webpack_exports__);
  97389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  97390. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  97391. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  97392. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97393. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  97394. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  97395. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97396. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  97397. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  97398. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  97399. // All values and structures referenced from:
  97400. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  97401. var DDS_MAGIC = 0x20534444;
  97402. var
  97403. //DDSD_CAPS = 0x1,
  97404. //DDSD_HEIGHT = 0x2,
  97405. //DDSD_WIDTH = 0x4,
  97406. //DDSD_PITCH = 0x8,
  97407. //DDSD_PIXELFORMAT = 0x1000,
  97408. DDSD_MIPMAPCOUNT = 0x20000;
  97409. //DDSD_LINEARSIZE = 0x80000,
  97410. //DDSD_DEPTH = 0x800000;
  97411. // var DDSCAPS_COMPLEX = 0x8,
  97412. // DDSCAPS_MIPMAP = 0x400000,
  97413. // DDSCAPS_TEXTURE = 0x1000;
  97414. var DDSCAPS2_CUBEMAP = 0x200;
  97415. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  97416. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  97417. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  97418. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  97419. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  97420. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  97421. // DDSCAPS2_VOLUME = 0x200000;
  97422. var
  97423. //DDPF_ALPHAPIXELS = 0x1,
  97424. //DDPF_ALPHA = 0x2,
  97425. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  97426. //DDPF_YUV = 0x200,
  97427. DDPF_LUMINANCE = 0x20000;
  97428. function FourCCToInt32(value) {
  97429. return value.charCodeAt(0) +
  97430. (value.charCodeAt(1) << 8) +
  97431. (value.charCodeAt(2) << 16) +
  97432. (value.charCodeAt(3) << 24);
  97433. }
  97434. function Int32ToFourCC(value) {
  97435. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  97436. }
  97437. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  97438. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  97439. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  97440. var FOURCC_DX10 = FourCCToInt32("DX10");
  97441. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  97442. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  97443. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  97444. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  97445. var headerLengthInt = 31; // The header length in 32 bit ints
  97446. // Offsets into the header array
  97447. var off_magic = 0;
  97448. var off_size = 1;
  97449. var off_flags = 2;
  97450. var off_height = 3;
  97451. var off_width = 4;
  97452. var off_mipmapCount = 7;
  97453. var off_pfFlags = 20;
  97454. var off_pfFourCC = 21;
  97455. var off_RGBbpp = 22;
  97456. var off_RMask = 23;
  97457. var off_GMask = 24;
  97458. var off_BMask = 25;
  97459. var off_AMask = 26;
  97460. // var off_caps1 = 27;
  97461. var off_caps2 = 28;
  97462. // var off_caps3 = 29;
  97463. // var off_caps4 = 30;
  97464. var off_dxgiFormat = 32;
  97465. /**
  97466. * Class used to provide DDS decompression tools
  97467. */
  97468. var DDSTools = /** @class */ (function () {
  97469. function DDSTools() {
  97470. }
  97471. /**
  97472. * Gets DDS information from an array buffer
  97473. * @param arrayBuffer defines the array buffer to read data from
  97474. * @returns the DDS information
  97475. */
  97476. DDSTools.GetDDSInfo = function (arrayBuffer) {
  97477. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  97478. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  97479. var mipmapCount = 1;
  97480. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  97481. mipmapCount = Math.max(1, header[off_mipmapCount]);
  97482. }
  97483. var fourCC = header[off_pfFourCC];
  97484. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  97485. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97486. switch (fourCC) {
  97487. case FOURCC_D3DFMT_R16G16B16A16F:
  97488. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97489. break;
  97490. case FOURCC_D3DFMT_R32G32B32A32F:
  97491. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  97492. break;
  97493. case FOURCC_DX10:
  97494. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  97495. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97496. break;
  97497. }
  97498. }
  97499. return {
  97500. width: header[off_width],
  97501. height: header[off_height],
  97502. mipmapCount: mipmapCount,
  97503. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  97504. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  97505. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  97506. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  97507. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  97508. dxgiFormat: dxgiFormat,
  97509. textureType: textureType
  97510. };
  97511. };
  97512. DDSTools._ToHalfFloat = function (value) {
  97513. if (!DDSTools._FloatView) {
  97514. DDSTools._FloatView = new Float32Array(1);
  97515. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  97516. }
  97517. DDSTools._FloatView[0] = value;
  97518. var x = DDSTools._Int32View[0];
  97519. var bits = (x >> 16) & 0x8000; /* Get the sign */
  97520. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  97521. var e = (x >> 23) & 0xff; /* Using int is faster here */
  97522. /* If zero, or denormal, or exponent underflows too much for a denormal
  97523. * half, return signed zero. */
  97524. if (e < 103) {
  97525. return bits;
  97526. }
  97527. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  97528. if (e > 142) {
  97529. bits |= 0x7c00;
  97530. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  97531. * not Inf, so make sure we set one mantissa bit too. */
  97532. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  97533. return bits;
  97534. }
  97535. /* If exponent underflows but not too much, return a denormal */
  97536. if (e < 113) {
  97537. m |= 0x0800;
  97538. /* Extra rounding may overflow and set mantissa to 0 and exponent
  97539. * to 1, which is OK. */
  97540. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  97541. return bits;
  97542. }
  97543. bits |= ((e - 112) << 10) | (m >> 1);
  97544. bits += m & 1;
  97545. return bits;
  97546. };
  97547. DDSTools._FromHalfFloat = function (value) {
  97548. var s = (value & 0x8000) >> 15;
  97549. var e = (value & 0x7C00) >> 10;
  97550. var f = value & 0x03FF;
  97551. if (e === 0) {
  97552. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  97553. }
  97554. else if (e == 0x1F) {
  97555. return f ? NaN : ((s ? -1 : 1) * Infinity);
  97556. }
  97557. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  97558. };
  97559. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97560. var destArray = new Float32Array(dataLength);
  97561. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  97562. var index = 0;
  97563. for (var y = 0; y < height; y++) {
  97564. for (var x = 0; x < width; x++) {
  97565. var srcPos = (x + y * width) * 4;
  97566. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  97567. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  97568. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  97569. if (DDSTools.StoreLODInAlphaChannel) {
  97570. destArray[index + 3] = lod;
  97571. }
  97572. else {
  97573. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  97574. }
  97575. index += 4;
  97576. }
  97577. }
  97578. return destArray;
  97579. };
  97580. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97581. if (DDSTools.StoreLODInAlphaChannel) {
  97582. var destArray = new Uint16Array(dataLength);
  97583. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  97584. var index = 0;
  97585. for (var y = 0; y < height; y++) {
  97586. for (var x = 0; x < width; x++) {
  97587. var srcPos = (x + y * width) * 4;
  97588. destArray[index] = srcData[srcPos];
  97589. destArray[index + 1] = srcData[srcPos + 1];
  97590. destArray[index + 2] = srcData[srcPos + 2];
  97591. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  97592. index += 4;
  97593. }
  97594. }
  97595. return destArray;
  97596. }
  97597. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  97598. };
  97599. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97600. if (DDSTools.StoreLODInAlphaChannel) {
  97601. var destArray = new Float32Array(dataLength);
  97602. var srcData = new Float32Array(arrayBuffer, dataOffset);
  97603. var index = 0;
  97604. for (var y = 0; y < height; y++) {
  97605. for (var x = 0; x < width; x++) {
  97606. var srcPos = (x + y * width) * 4;
  97607. destArray[index] = srcData[srcPos];
  97608. destArray[index + 1] = srcData[srcPos + 1];
  97609. destArray[index + 2] = srcData[srcPos + 2];
  97610. destArray[index + 3] = lod;
  97611. index += 4;
  97612. }
  97613. }
  97614. return destArray;
  97615. }
  97616. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  97617. };
  97618. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97619. var destArray = new Uint8Array(dataLength);
  97620. var srcData = new Float32Array(arrayBuffer, dataOffset);
  97621. var index = 0;
  97622. for (var y = 0; y < height; y++) {
  97623. for (var x = 0; x < width; x++) {
  97624. var srcPos = (x + y * width) * 4;
  97625. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  97626. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  97627. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  97628. if (DDSTools.StoreLODInAlphaChannel) {
  97629. destArray[index + 3] = lod;
  97630. }
  97631. else {
  97632. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  97633. }
  97634. index += 4;
  97635. }
  97636. }
  97637. return destArray;
  97638. };
  97639. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97640. var destArray = new Uint8Array(dataLength);
  97641. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  97642. var index = 0;
  97643. for (var y = 0; y < height; y++) {
  97644. for (var x = 0; x < width; x++) {
  97645. var srcPos = (x + y * width) * 4;
  97646. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  97647. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  97648. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  97649. if (DDSTools.StoreLODInAlphaChannel) {
  97650. destArray[index + 3] = lod;
  97651. }
  97652. else {
  97653. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  97654. }
  97655. index += 4;
  97656. }
  97657. }
  97658. return destArray;
  97659. };
  97660. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  97661. var byteArray = new Uint8Array(dataLength);
  97662. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  97663. var index = 0;
  97664. for (var y = 0; y < height; y++) {
  97665. for (var x = 0; x < width; x++) {
  97666. var srcPos = (x + y * width) * 4;
  97667. byteArray[index] = srcData[srcPos + rOffset];
  97668. byteArray[index + 1] = srcData[srcPos + gOffset];
  97669. byteArray[index + 2] = srcData[srcPos + bOffset];
  97670. byteArray[index + 3] = srcData[srcPos + aOffset];
  97671. index += 4;
  97672. }
  97673. }
  97674. return byteArray;
  97675. };
  97676. DDSTools._ExtractLongWordOrder = function (value) {
  97677. if (value === 0 || value === 255 || value === -16777216) {
  97678. return 0;
  97679. }
  97680. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  97681. };
  97682. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  97683. var byteArray = new Uint8Array(dataLength);
  97684. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  97685. var index = 0;
  97686. for (var y = 0; y < height; y++) {
  97687. for (var x = 0; x < width; x++) {
  97688. var srcPos = (x + y * width) * 3;
  97689. byteArray[index] = srcData[srcPos + rOffset];
  97690. byteArray[index + 1] = srcData[srcPos + gOffset];
  97691. byteArray[index + 2] = srcData[srcPos + bOffset];
  97692. index += 3;
  97693. }
  97694. }
  97695. return byteArray;
  97696. };
  97697. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  97698. var byteArray = new Uint8Array(dataLength);
  97699. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  97700. var index = 0;
  97701. for (var y = 0; y < height; y++) {
  97702. for (var x = 0; x < width; x++) {
  97703. var srcPos = (x + y * width);
  97704. byteArray[index] = srcData[srcPos];
  97705. index++;
  97706. }
  97707. }
  97708. return byteArray;
  97709. };
  97710. /**
  97711. * Uploads DDS Levels to a Babylon Texture
  97712. * @hidden
  97713. */
  97714. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  97715. if (lodIndex === void 0) { lodIndex = -1; }
  97716. var sphericalPolynomialFaces = null;
  97717. if (info.sphericalPolynomial) {
  97718. sphericalPolynomialFaces = new Array();
  97719. }
  97720. var ext = engine.getCaps().s3tc;
  97721. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  97722. var fourCC, width, height, dataLength = 0, dataOffset;
  97723. var byteArray, mipmapCount, mip;
  97724. var internalCompressedFormat = 0;
  97725. var blockBytes = 1;
  97726. if (header[off_magic] !== DDS_MAGIC) {
  97727. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  97728. return;
  97729. }
  97730. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  97731. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  97732. return;
  97733. }
  97734. if (info.isCompressed && !ext) {
  97735. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  97736. return;
  97737. }
  97738. var bpp = header[off_RGBbpp];
  97739. dataOffset = header[off_size] + 4;
  97740. var computeFormats = false;
  97741. if (info.isFourCC) {
  97742. fourCC = header[off_pfFourCC];
  97743. switch (fourCC) {
  97744. case FOURCC_DXT1:
  97745. blockBytes = 8;
  97746. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  97747. break;
  97748. case FOURCC_DXT3:
  97749. blockBytes = 16;
  97750. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  97751. break;
  97752. case FOURCC_DXT5:
  97753. blockBytes = 16;
  97754. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  97755. break;
  97756. case FOURCC_D3DFMT_R16G16B16A16F:
  97757. computeFormats = true;
  97758. break;
  97759. case FOURCC_D3DFMT_R32G32B32A32F:
  97760. computeFormats = true;
  97761. break;
  97762. case FOURCC_DX10:
  97763. // There is an additionnal header so dataOffset need to be changed
  97764. dataOffset += 5 * 4; // 5 uints
  97765. var supported = false;
  97766. switch (info.dxgiFormat) {
  97767. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  97768. computeFormats = true;
  97769. supported = true;
  97770. break;
  97771. case DXGI_FORMAT_B8G8R8X8_UNORM:
  97772. info.isRGB = true;
  97773. info.isFourCC = false;
  97774. bpp = 32;
  97775. supported = true;
  97776. break;
  97777. }
  97778. if (supported) {
  97779. break;
  97780. }
  97781. default:
  97782. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  97783. return;
  97784. }
  97785. }
  97786. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  97787. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  97788. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  97789. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  97790. if (computeFormats) {
  97791. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  97792. }
  97793. mipmapCount = 1;
  97794. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  97795. mipmapCount = Math.max(1, header[off_mipmapCount]);
  97796. }
  97797. var startFace = currentFace || 0;
  97798. for (var face = startFace; face < faces; face++) {
  97799. width = header[off_width];
  97800. height = header[off_height];
  97801. for (mip = 0; mip < mipmapCount; ++mip) {
  97802. if (lodIndex === -1 || lodIndex === mip) {
  97803. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  97804. var i = (lodIndex === -1) ? mip : 0;
  97805. if (!info.isCompressed && info.isFourCC) {
  97806. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  97807. dataLength = width * height * 4;
  97808. var floatArray = null;
  97809. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  97810. if (bpp === 128) {
  97811. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97812. if (sphericalPolynomialFaces && i == 0) {
  97813. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  97814. }
  97815. }
  97816. else if (bpp === 64) {
  97817. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97818. if (sphericalPolynomialFaces && i == 0) {
  97819. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  97820. }
  97821. }
  97822. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97823. }
  97824. else {
  97825. if (bpp === 128) {
  97826. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  97827. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97828. if (sphericalPolynomialFaces && i == 0) {
  97829. sphericalPolynomialFaces.push(floatArray);
  97830. }
  97831. }
  97832. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  97833. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  97834. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97835. if (sphericalPolynomialFaces && i == 0) {
  97836. sphericalPolynomialFaces.push(floatArray);
  97837. }
  97838. }
  97839. else { // 64
  97840. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97841. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97842. if (sphericalPolynomialFaces && i == 0) {
  97843. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  97844. }
  97845. }
  97846. }
  97847. if (floatArray) {
  97848. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  97849. }
  97850. }
  97851. else if (info.isRGB) {
  97852. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97853. if (bpp === 24) {
  97854. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  97855. dataLength = width * height * 3;
  97856. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  97857. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  97858. }
  97859. else { // 32
  97860. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  97861. dataLength = width * height * 4;
  97862. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  97863. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  97864. }
  97865. }
  97866. else if (info.isLuminance) {
  97867. var unpackAlignment = engine._getUnpackAlignement();
  97868. var unpaddedRowSize = width;
  97869. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  97870. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  97871. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  97872. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  97873. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97874. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  97875. }
  97876. else {
  97877. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  97878. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  97879. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97880. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  97881. }
  97882. }
  97883. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  97884. width *= 0.5;
  97885. height *= 0.5;
  97886. width = Math.max(1.0, width);
  97887. height = Math.max(1.0, height);
  97888. }
  97889. if (currentFace !== undefined) {
  97890. // Loading a single face
  97891. break;
  97892. }
  97893. }
  97894. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  97895. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  97896. size: header[off_width],
  97897. right: sphericalPolynomialFaces[0],
  97898. left: sphericalPolynomialFaces[1],
  97899. up: sphericalPolynomialFaces[2],
  97900. down: sphericalPolynomialFaces[3],
  97901. front: sphericalPolynomialFaces[4],
  97902. back: sphericalPolynomialFaces[5],
  97903. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  97904. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  97905. gammaSpace: false,
  97906. });
  97907. }
  97908. else {
  97909. info.sphericalPolynomial = undefined;
  97910. }
  97911. };
  97912. /**
  97913. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  97914. */
  97915. DDSTools.StoreLODInAlphaChannel = false;
  97916. return DDSTools;
  97917. }());
  97918. /**
  97919. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  97920. * @param rootUrl defines the url where the file to load is located
  97921. * @param scene defines the current scene
  97922. * @param lodScale defines scale to apply to the mip map selection
  97923. * @param lodOffset defines offset to apply to the mip map selection
  97924. * @param onLoad defines an optional callback raised when the texture is loaded
  97925. * @param onError defines an optional callback raised if there is an issue to load the texture
  97926. * @param format defines the format of the data
  97927. * @param forcedExtension defines the extension to use to pick the right loader
  97928. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  97929. * @returns the cube texture as an InternalTexture
  97930. */
  97931. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  97932. var _this = this;
  97933. if (onLoad === void 0) { onLoad = null; }
  97934. if (onError === void 0) { onError = null; }
  97935. if (forcedExtension === void 0) { forcedExtension = null; }
  97936. if (createPolynomials === void 0) { createPolynomials = true; }
  97937. var callback = function (loadData) {
  97938. if (!loadData) {
  97939. if (onLoad) {
  97940. onLoad(null);
  97941. }
  97942. return;
  97943. }
  97944. var texture = loadData.texture;
  97945. if (!createPolynomials) {
  97946. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  97947. }
  97948. else if (loadData.info.sphericalPolynomial) {
  97949. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  97950. }
  97951. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  97952. if (_this.getCaps().textureLOD) {
  97953. // Do not add extra process if texture lod is supported.
  97954. if (onLoad) {
  97955. onLoad(texture);
  97956. }
  97957. return;
  97958. }
  97959. var mipSlices = 3;
  97960. var gl = _this._gl;
  97961. var width = loadData.width;
  97962. if (!width) {
  97963. return;
  97964. }
  97965. var textures = [];
  97966. for (var i = 0; i < mipSlices; i++) {
  97967. //compute LOD from even spacing in smoothness (matching shader calculation)
  97968. var smoothness = i / (mipSlices - 1);
  97969. var roughness = 1 - smoothness;
  97970. var minLODIndex = lodOffset; // roughness = 0
  97971. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  97972. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  97973. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  97974. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  97975. glTextureFromLod.type = texture.type;
  97976. glTextureFromLod.format = texture.format;
  97977. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  97978. glTextureFromLod.height = glTextureFromLod.width;
  97979. glTextureFromLod.isCube = true;
  97980. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  97981. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  97982. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  97983. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  97984. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  97985. if (loadData.isDDS) {
  97986. var info = loadData.info;
  97987. var data = loadData.data;
  97988. _this._unpackFlipY(info.isCompressed);
  97989. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  97990. }
  97991. else {
  97992. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  97993. }
  97994. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  97995. // Wrap in a base texture for easy binding.
  97996. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  97997. lodTexture.isCube = true;
  97998. lodTexture._texture = glTextureFromLod;
  97999. glTextureFromLod.isReady = true;
  98000. textures.push(lodTexture);
  98001. }
  98002. texture._lodTextureHigh = textures[2];
  98003. texture._lodTextureMid = textures[1];
  98004. texture._lodTextureLow = textures[0];
  98005. if (onLoad) {
  98006. onLoad(texture);
  98007. }
  98008. };
  98009. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  98010. };
  98011. /***/ }),
  98012. /***/ "./Misc/decorators.ts":
  98013. /*!****************************!*\
  98014. !*** ./Misc/decorators.ts ***!
  98015. \****************************/
  98016. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper */
  98017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98018. "use strict";
  98019. __webpack_require__.r(__webpack_exports__);
  98020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  98021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  98022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  98023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  98024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  98025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  98026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  98027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  98028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  98029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  98030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  98031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  98032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return serializeAsMatrix; });
  98033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  98034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  98035. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  98036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98037. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  98038. var __decoratorInitialStore = {};
  98039. var __mergedStore = {};
  98040. var _copySource = function (creationFunction, source, instanciate) {
  98041. var destination = creationFunction();
  98042. // Tags
  98043. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  98044. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  98045. }
  98046. var classStore = getMergedStore(destination);
  98047. // Properties
  98048. for (var property in classStore) {
  98049. var propertyDescriptor = classStore[property];
  98050. var sourceProperty = source[property];
  98051. var propertyType = propertyDescriptor.type;
  98052. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  98053. switch (propertyType) {
  98054. case 0: // Value
  98055. case 6: // Mesh reference
  98056. case 11: // Camera reference
  98057. destination[property] = sourceProperty;
  98058. break;
  98059. case 1: // Texture
  98060. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  98061. break;
  98062. case 2: // Color3
  98063. case 3: // FresnelParameters
  98064. case 4: // Vector2
  98065. case 5: // Vector3
  98066. case 7: // Color Curves
  98067. case 10: // Quaternion
  98068. case 12: // Matrix
  98069. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  98070. break;
  98071. }
  98072. }
  98073. }
  98074. return destination;
  98075. };
  98076. function getDirectStore(target) {
  98077. var classKey = target.getClassName();
  98078. if (!__decoratorInitialStore[classKey]) {
  98079. __decoratorInitialStore[classKey] = {};
  98080. }
  98081. return __decoratorInitialStore[classKey];
  98082. }
  98083. /**
  98084. * Return the list of properties flagged as serializable
  98085. * @param target: host object
  98086. */
  98087. function getMergedStore(target) {
  98088. var classKey = target.getClassName();
  98089. if (__mergedStore[classKey]) {
  98090. return __mergedStore[classKey];
  98091. }
  98092. __mergedStore[classKey] = {};
  98093. var store = __mergedStore[classKey];
  98094. var currentTarget = target;
  98095. var currentKey = classKey;
  98096. while (currentKey) {
  98097. var initialStore = __decoratorInitialStore[currentKey];
  98098. for (var property in initialStore) {
  98099. store[property] = initialStore[property];
  98100. }
  98101. var parent_1 = void 0;
  98102. var done = false;
  98103. do {
  98104. parent_1 = Object.getPrototypeOf(currentTarget);
  98105. if (!parent_1.getClassName) {
  98106. done = true;
  98107. break;
  98108. }
  98109. if (parent_1.getClassName() !== currentKey) {
  98110. break;
  98111. }
  98112. currentTarget = parent_1;
  98113. } while (parent_1);
  98114. if (done) {
  98115. break;
  98116. }
  98117. currentKey = parent_1.getClassName();
  98118. currentTarget = parent_1;
  98119. }
  98120. return store;
  98121. }
  98122. function generateSerializableMember(type, sourceName) {
  98123. return function (target, propertyKey) {
  98124. var classStore = getDirectStore(target);
  98125. if (!classStore[propertyKey]) {
  98126. classStore[propertyKey] = { type: type, sourceName: sourceName };
  98127. }
  98128. };
  98129. }
  98130. function generateExpandMember(setCallback, targetKey) {
  98131. if (targetKey === void 0) { targetKey = null; }
  98132. return function (target, propertyKey) {
  98133. var key = targetKey || ("_" + propertyKey);
  98134. Object.defineProperty(target, propertyKey, {
  98135. get: function () {
  98136. return this[key];
  98137. },
  98138. set: function (value) {
  98139. if (this[key] === value) {
  98140. return;
  98141. }
  98142. this[key] = value;
  98143. target[setCallback].apply(this);
  98144. },
  98145. enumerable: true,
  98146. configurable: true
  98147. });
  98148. };
  98149. }
  98150. function expandToProperty(callback, targetKey) {
  98151. if (targetKey === void 0) { targetKey = null; }
  98152. return generateExpandMember(callback, targetKey);
  98153. }
  98154. function serialize(sourceName) {
  98155. return generateSerializableMember(0, sourceName); // value member
  98156. }
  98157. function serializeAsTexture(sourceName) {
  98158. return generateSerializableMember(1, sourceName); // texture member
  98159. }
  98160. function serializeAsColor3(sourceName) {
  98161. return generateSerializableMember(2, sourceName); // color3 member
  98162. }
  98163. function serializeAsFresnelParameters(sourceName) {
  98164. return generateSerializableMember(3, sourceName); // fresnel parameters member
  98165. }
  98166. function serializeAsVector2(sourceName) {
  98167. return generateSerializableMember(4, sourceName); // vector2 member
  98168. }
  98169. function serializeAsVector3(sourceName) {
  98170. return generateSerializableMember(5, sourceName); // vector3 member
  98171. }
  98172. function serializeAsMeshReference(sourceName) {
  98173. return generateSerializableMember(6, sourceName); // mesh reference member
  98174. }
  98175. function serializeAsColorCurves(sourceName) {
  98176. return generateSerializableMember(7, sourceName); // color curves
  98177. }
  98178. function serializeAsColor4(sourceName) {
  98179. return generateSerializableMember(8, sourceName); // color 4
  98180. }
  98181. function serializeAsImageProcessingConfiguration(sourceName) {
  98182. return generateSerializableMember(9, sourceName); // image processing
  98183. }
  98184. function serializeAsQuaternion(sourceName) {
  98185. return generateSerializableMember(10, sourceName); // quaternion member
  98186. }
  98187. function serializeAsMatrix(sourceName) {
  98188. return generateSerializableMember(12, sourceName); // matrix member
  98189. }
  98190. /**
  98191. * Decorator used to define property that can be serialized as reference to a camera
  98192. * @param sourceName defines the name of the property to decorate
  98193. */
  98194. function serializeAsCameraReference(sourceName) {
  98195. return generateSerializableMember(11, sourceName); // camera reference member
  98196. }
  98197. /**
  98198. * Class used to help serialization objects
  98199. */
  98200. var SerializationHelper = /** @class */ (function () {
  98201. function SerializationHelper() {
  98202. }
  98203. /**
  98204. * Appends the serialized animations from the source animations
  98205. * @param source Source containing the animations
  98206. * @param destination Target to store the animations
  98207. */
  98208. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  98209. if (source.animations) {
  98210. destination.animations = [];
  98211. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  98212. var animation = source.animations[animationIndex];
  98213. destination.animations.push(animation.serialize());
  98214. }
  98215. }
  98216. };
  98217. /**
  98218. * Static function used to serialized a specific entity
  98219. * @param entity defines the entity to serialize
  98220. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  98221. * @returns a JSON compatible object representing the serialization of the entity
  98222. */
  98223. SerializationHelper.Serialize = function (entity, serializationObject) {
  98224. if (!serializationObject) {
  98225. serializationObject = {};
  98226. }
  98227. // Tags
  98228. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  98229. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  98230. }
  98231. var serializedProperties = getMergedStore(entity);
  98232. // Properties
  98233. for (var property in serializedProperties) {
  98234. var propertyDescriptor = serializedProperties[property];
  98235. var targetPropertyName = propertyDescriptor.sourceName || property;
  98236. var propertyType = propertyDescriptor.type;
  98237. var sourceProperty = entity[property];
  98238. if (sourceProperty !== undefined && sourceProperty !== null) {
  98239. switch (propertyType) {
  98240. case 0: // Value
  98241. serializationObject[targetPropertyName] = sourceProperty;
  98242. break;
  98243. case 1: // Texture
  98244. serializationObject[targetPropertyName] = sourceProperty.serialize();
  98245. break;
  98246. case 2: // Color3
  98247. serializationObject[targetPropertyName] = sourceProperty.asArray();
  98248. break;
  98249. case 3: // FresnelParameters
  98250. serializationObject[targetPropertyName] = sourceProperty.serialize();
  98251. break;
  98252. case 4: // Vector2
  98253. serializationObject[targetPropertyName] = sourceProperty.asArray();
  98254. break;
  98255. case 5: // Vector3
  98256. serializationObject[targetPropertyName] = sourceProperty.asArray();
  98257. break;
  98258. case 6: // Mesh reference
  98259. serializationObject[targetPropertyName] = sourceProperty.id;
  98260. break;
  98261. case 7: // Color Curves
  98262. serializationObject[targetPropertyName] = sourceProperty.serialize();
  98263. break;
  98264. case 8: // Color 4
  98265. serializationObject[targetPropertyName] = sourceProperty.asArray();
  98266. break;
  98267. case 9: // Image Processing
  98268. serializationObject[targetPropertyName] = sourceProperty.serialize();
  98269. break;
  98270. case 10: // Quaternion
  98271. serializationObject[targetPropertyName] = sourceProperty.asArray();
  98272. break;
  98273. case 11: // Camera reference
  98274. serializationObject[targetPropertyName] = sourceProperty.id;
  98275. case 12: // Matrix
  98276. serializationObject[targetPropertyName] = sourceProperty.asArray();
  98277. break;
  98278. }
  98279. }
  98280. }
  98281. return serializationObject;
  98282. };
  98283. /**
  98284. * Creates a new entity from a serialization data object
  98285. * @param creationFunction defines a function used to instanciated the new entity
  98286. * @param source defines the source serialization data
  98287. * @param scene defines the hosting scene
  98288. * @param rootUrl defines the root url for resources
  98289. * @returns a new entity
  98290. */
  98291. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  98292. if (rootUrl === void 0) { rootUrl = null; }
  98293. var destination = creationFunction();
  98294. if (!rootUrl) {
  98295. rootUrl = "";
  98296. }
  98297. // Tags
  98298. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  98299. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  98300. }
  98301. var classStore = getMergedStore(destination);
  98302. // Properties
  98303. for (var property in classStore) {
  98304. var propertyDescriptor = classStore[property];
  98305. var sourceProperty = source[propertyDescriptor.sourceName || property];
  98306. var propertyType = propertyDescriptor.type;
  98307. if (sourceProperty !== undefined && sourceProperty !== null) {
  98308. var dest = destination;
  98309. switch (propertyType) {
  98310. case 0: // Value
  98311. dest[property] = sourceProperty;
  98312. break;
  98313. case 1: // Texture
  98314. if (scene) {
  98315. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  98316. }
  98317. break;
  98318. case 2: // Color3
  98319. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  98320. break;
  98321. case 3: // FresnelParameters
  98322. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  98323. break;
  98324. case 4: // Vector2
  98325. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  98326. break;
  98327. case 5: // Vector3
  98328. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  98329. break;
  98330. case 6: // Mesh reference
  98331. if (scene) {
  98332. dest[property] = scene.getLastMeshByID(sourceProperty);
  98333. }
  98334. break;
  98335. case 7: // Color Curves
  98336. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  98337. break;
  98338. case 8: // Color 4
  98339. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  98340. break;
  98341. case 9: // Image Processing
  98342. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  98343. break;
  98344. case 10: // Quaternion
  98345. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  98346. break;
  98347. case 11: // Camera reference
  98348. if (scene) {
  98349. dest[property] = scene.getCameraByID(sourceProperty);
  98350. }
  98351. case 12: // Matrix
  98352. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(sourceProperty);
  98353. break;
  98354. }
  98355. }
  98356. }
  98357. return destination;
  98358. };
  98359. /**
  98360. * Clones an object
  98361. * @param creationFunction defines the function used to instanciate the new object
  98362. * @param source defines the source object
  98363. * @returns the cloned object
  98364. */
  98365. SerializationHelper.Clone = function (creationFunction, source) {
  98366. return _copySource(creationFunction, source, false);
  98367. };
  98368. /**
  98369. * Instanciates a new object based on a source one (some data will be shared between both object)
  98370. * @param creationFunction defines the function used to instanciate the new object
  98371. * @param source defines the source object
  98372. * @returns the new object
  98373. */
  98374. SerializationHelper.Instanciate = function (creationFunction, source) {
  98375. return _copySource(creationFunction, source, true);
  98376. };
  98377. /** hidden */
  98378. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  98379. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  98380. };
  98381. /** hidden */
  98382. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  98383. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  98384. };
  98385. /** hidden */
  98386. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  98387. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  98388. };
  98389. /** hidden */
  98390. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  98391. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  98392. };
  98393. return SerializationHelper;
  98394. }());
  98395. /***/ }),
  98396. /***/ "./Misc/deepCopier.ts":
  98397. /*!****************************!*\
  98398. !*** ./Misc/deepCopier.ts ***!
  98399. \****************************/
  98400. /*! exports provided: DeepCopier */
  98401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98402. "use strict";
  98403. __webpack_require__.r(__webpack_exports__);
  98404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  98405. var cloneValue = function (source, destinationObject) {
  98406. if (!source) {
  98407. return null;
  98408. }
  98409. if (source.getClassName && source.getClassName() === "Mesh") {
  98410. return null;
  98411. }
  98412. if (source.getClassName && source.getClassName() === "SubMesh") {
  98413. return source.clone(destinationObject);
  98414. }
  98415. else if (source.clone) {
  98416. return source.clone();
  98417. }
  98418. return null;
  98419. };
  98420. /**
  98421. * Class containing a set of static utilities functions for deep copy.
  98422. */
  98423. var DeepCopier = /** @class */ (function () {
  98424. function DeepCopier() {
  98425. }
  98426. /**
  98427. * Tries to copy an object by duplicating every property
  98428. * @param source defines the source object
  98429. * @param destination defines the target object
  98430. * @param doNotCopyList defines a list of properties to avoid
  98431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98432. */
  98433. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  98434. for (var prop in source) {
  98435. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  98436. continue;
  98437. }
  98438. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  98439. continue;
  98440. }
  98441. var sourceValue = source[prop];
  98442. var typeOfSourceValue = typeof sourceValue;
  98443. if (typeOfSourceValue === "function") {
  98444. continue;
  98445. }
  98446. try {
  98447. if (typeOfSourceValue === "object") {
  98448. if (sourceValue instanceof Array) {
  98449. destination[prop] = [];
  98450. if (sourceValue.length > 0) {
  98451. if (typeof sourceValue[0] == "object") {
  98452. for (var index = 0; index < sourceValue.length; index++) {
  98453. var clonedValue = cloneValue(sourceValue[index], destination);
  98454. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  98455. destination[prop].push(clonedValue);
  98456. }
  98457. }
  98458. }
  98459. else {
  98460. destination[prop] = sourceValue.slice(0);
  98461. }
  98462. }
  98463. }
  98464. else {
  98465. destination[prop] = cloneValue(sourceValue, destination);
  98466. }
  98467. }
  98468. else {
  98469. destination[prop] = sourceValue;
  98470. }
  98471. }
  98472. catch (e) {
  98473. // Just ignore error (it could be because of a read-only property)
  98474. }
  98475. }
  98476. };
  98477. return DeepCopier;
  98478. }());
  98479. /***/ }),
  98480. /***/ "./Misc/deferred.ts":
  98481. /*!**************************!*\
  98482. !*** ./Misc/deferred.ts ***!
  98483. \**************************/
  98484. /*! exports provided: Deferred */
  98485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98486. "use strict";
  98487. __webpack_require__.r(__webpack_exports__);
  98488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  98489. /**
  98490. * Wrapper class for promise with external resolve and reject.
  98491. */
  98492. var Deferred = /** @class */ (function () {
  98493. /**
  98494. * Constructor for this deferred object.
  98495. */
  98496. function Deferred() {
  98497. var _this = this;
  98498. this.promise = new Promise(function (resolve, reject) {
  98499. _this._resolve = resolve;
  98500. _this._reject = reject;
  98501. });
  98502. }
  98503. Object.defineProperty(Deferred.prototype, "resolve", {
  98504. /**
  98505. * The resolve method of the promise associated with this deferred object.
  98506. */
  98507. get: function () {
  98508. return this._resolve;
  98509. },
  98510. enumerable: true,
  98511. configurable: true
  98512. });
  98513. Object.defineProperty(Deferred.prototype, "reject", {
  98514. /**
  98515. * The reject method of the promise associated with this deferred object.
  98516. */
  98517. get: function () {
  98518. return this._reject;
  98519. },
  98520. enumerable: true,
  98521. configurable: true
  98522. });
  98523. return Deferred;
  98524. }());
  98525. /***/ }),
  98526. /***/ "./Misc/devTools.ts":
  98527. /*!**************************!*\
  98528. !*** ./Misc/devTools.ts ***!
  98529. \**************************/
  98530. /*! exports provided: _DevTools */
  98531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98532. "use strict";
  98533. __webpack_require__.r(__webpack_exports__);
  98534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  98535. /** @hidden */
  98536. var _DevTools = /** @class */ (function () {
  98537. function _DevTools() {
  98538. }
  98539. _DevTools.WarnImport = function (name) {
  98540. return name + " needs to be imported before as it contains a side-effect required by your code.";
  98541. };
  98542. return _DevTools;
  98543. }());
  98544. /***/ }),
  98545. /***/ "./Misc/domManagement.ts":
  98546. /*!*******************************!*\
  98547. !*** ./Misc/domManagement.ts ***!
  98548. \*******************************/
  98549. /*! exports provided: DomManagement */
  98550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98551. "use strict";
  98552. __webpack_require__.r(__webpack_exports__);
  98553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  98554. /**
  98555. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  98556. * Babylon.js
  98557. */
  98558. var DomManagement = /** @class */ (function () {
  98559. function DomManagement() {
  98560. }
  98561. /**
  98562. * Checks if the window object exists
  98563. * @returns true if the window object exists
  98564. */
  98565. DomManagement.IsWindowObjectExist = function () {
  98566. return (typeof window) !== "undefined";
  98567. };
  98568. /**
  98569. * Extracts text content from a DOM element hierarchy
  98570. * @param element defines the root element
  98571. * @returns a string
  98572. */
  98573. DomManagement.GetDOMTextContent = function (element) {
  98574. var result = "";
  98575. var child = element.firstChild;
  98576. while (child) {
  98577. if (child.nodeType === 3) {
  98578. result += child.textContent;
  98579. }
  98580. child = (child.nextSibling);
  98581. }
  98582. return result;
  98583. };
  98584. return DomManagement;
  98585. }());
  98586. /***/ }),
  98587. /***/ "./Misc/environmentTextureTools.ts":
  98588. /*!*****************************************!*\
  98589. !*** ./Misc/environmentTextureTools.ts ***!
  98590. \*****************************************/
  98591. /*! exports provided: EnvironmentTextureTools */
  98592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98593. "use strict";
  98594. __webpack_require__.r(__webpack_exports__);
  98595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  98596. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98597. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98598. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  98599. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  98600. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  98601. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  98602. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98603. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  98604. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  98605. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  98606. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  98607. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  98608. /**
  98609. * Sets of helpers addressing the serialization and deserialization of environment texture
  98610. * stored in a BabylonJS env file.
  98611. * Those files are usually stored as .env files.
  98612. */
  98613. var EnvironmentTextureTools = /** @class */ (function () {
  98614. function EnvironmentTextureTools() {
  98615. }
  98616. /**
  98617. * Gets the environment info from an env file.
  98618. * @param data The array buffer containing the .env bytes.
  98619. * @returns the environment file info (the json header) if successfully parsed.
  98620. */
  98621. EnvironmentTextureTools.GetEnvInfo = function (data) {
  98622. var dataView = new DataView(data);
  98623. var pos = 0;
  98624. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  98625. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  98626. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  98627. return null;
  98628. }
  98629. }
  98630. // Read json manifest - collect characters up to null terminator
  98631. var manifestString = '';
  98632. var charCode = 0x00;
  98633. while ((charCode = dataView.getUint8(pos++))) {
  98634. manifestString += String.fromCharCode(charCode);
  98635. }
  98636. var manifest = JSON.parse(manifestString);
  98637. if (manifest.specular) {
  98638. // Extend the header with the position of the payload.
  98639. manifest.specular.specularDataPosition = pos;
  98640. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  98641. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  98642. }
  98643. return manifest;
  98644. };
  98645. /**
  98646. * Creates an environment texture from a loaded cube texture.
  98647. * @param texture defines the cube texture to convert in env file
  98648. * @return a promise containing the environment data if succesfull.
  98649. */
  98650. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  98651. var _this = this;
  98652. var internalTexture = texture.getInternalTexture();
  98653. if (!internalTexture) {
  98654. return Promise.reject("The cube texture is invalid.");
  98655. }
  98656. if (!texture._prefiltered) {
  98657. return Promise.reject("The cube texture is invalid (not prefiltered).");
  98658. }
  98659. var engine = internalTexture.getEngine();
  98660. if (engine && engine.premultipliedAlpha) {
  98661. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  98662. }
  98663. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  98664. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  98665. }
  98666. var canvas = engine.getRenderingCanvas();
  98667. if (!canvas) {
  98668. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  98669. }
  98670. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  98671. if (!engine.getCaps().textureFloatRender) {
  98672. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  98673. if (!engine.getCaps().textureHalfFloatRender) {
  98674. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  98675. }
  98676. }
  98677. var cubeWidth = internalTexture.width;
  98678. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  98679. var specularTextures = {};
  98680. var promises = [];
  98681. // Read and collect all mipmaps data from the cube.
  98682. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  98683. mipmapsCount = Math.round(mipmapsCount);
  98684. var _loop_1 = function (i) {
  98685. var faceWidth = Math.pow(2, mipmapsCount - i);
  98686. var _loop_2 = function (face) {
  98687. var data = texture.readPixels(face, i);
  98688. // Creates a temp texture with the face data.
  98689. 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);
  98690. // And rgbdEncode them.
  98691. var promise = new Promise(function (resolve, reject) {
  98692. 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);
  98693. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  98694. rgbdPostProcess.onApply = function (effect) {
  98695. effect._bindTexture("textureSampler", tempTexture);
  98696. };
  98697. // As the process needs to happen on the main canvas, keep track of the current size
  98698. var currentW = engine.getRenderWidth();
  98699. var currentH = engine.getRenderHeight();
  98700. // Set the desired size for the texture
  98701. engine.setSize(faceWidth, faceWidth);
  98702. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  98703. // Reading datas from WebGL
  98704. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  98705. var fileReader = new FileReader();
  98706. fileReader.onload = function (event) {
  98707. var arrayBuffer = event.target.result;
  98708. specularTextures[i * 6 + face] = arrayBuffer;
  98709. resolve();
  98710. };
  98711. fileReader.readAsArrayBuffer(blob);
  98712. });
  98713. // Reapply the previous canvas size
  98714. engine.setSize(currentW, currentH);
  98715. });
  98716. });
  98717. promises.push(promise);
  98718. };
  98719. // All faces of the cube.
  98720. for (var face = 0; face < 6; face++) {
  98721. _loop_2(face);
  98722. }
  98723. };
  98724. for (var i = 0; i <= mipmapsCount; i++) {
  98725. _loop_1(i);
  98726. }
  98727. // Once all the textures haves been collected as RGBD stored in PNGs
  98728. return Promise.all(promises).then(function () {
  98729. // We can delete the hosting scene keeping track of all the creation objects
  98730. hostingScene.dispose();
  98731. // Creates the json header for the env texture
  98732. var info = {
  98733. version: 1,
  98734. width: cubeWidth,
  98735. irradiance: _this._CreateEnvTextureIrradiance(texture),
  98736. specular: {
  98737. mipmaps: [],
  98738. lodGenerationScale: texture.lodGenerationScale
  98739. }
  98740. };
  98741. // Sets the specular image data information
  98742. var position = 0;
  98743. for (var i = 0; i <= mipmapsCount; i++) {
  98744. for (var face = 0; face < 6; face++) {
  98745. var byteLength = specularTextures[i * 6 + face].byteLength;
  98746. info.specular.mipmaps.push({
  98747. length: byteLength,
  98748. position: position
  98749. });
  98750. position += byteLength;
  98751. }
  98752. }
  98753. // Encode the JSON as an array buffer
  98754. var infoString = JSON.stringify(info);
  98755. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  98756. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  98757. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  98758. infoView[i] = infoString.charCodeAt(i);
  98759. }
  98760. // Ends up with a null terminator for easier parsing
  98761. infoView[infoString.length] = 0x00;
  98762. // Computes the final required size and creates the storage
  98763. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  98764. var finalBuffer = new ArrayBuffer(totalSize);
  98765. var finalBufferView = new Uint8Array(finalBuffer);
  98766. var dataView = new DataView(finalBuffer);
  98767. // Copy the magic bytes identifying the file in
  98768. var pos = 0;
  98769. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  98770. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  98771. }
  98772. // Add the json info
  98773. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  98774. pos += infoBuffer.byteLength;
  98775. // Finally inserts the texture data
  98776. for (var i = 0; i <= mipmapsCount; i++) {
  98777. for (var face = 0; face < 6; face++) {
  98778. var dataBuffer = specularTextures[i * 6 + face];
  98779. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  98780. pos += dataBuffer.byteLength;
  98781. }
  98782. }
  98783. // Voila
  98784. return finalBuffer;
  98785. });
  98786. };
  98787. /**
  98788. * Creates a JSON representation of the spherical data.
  98789. * @param texture defines the texture containing the polynomials
  98790. * @return the JSON representation of the spherical info
  98791. */
  98792. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  98793. var polynmials = texture.sphericalPolynomial;
  98794. if (polynmials == null) {
  98795. return null;
  98796. }
  98797. return {
  98798. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  98799. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  98800. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  98801. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  98802. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  98803. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  98804. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  98805. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  98806. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  98807. };
  98808. };
  98809. /**
  98810. * Uploads the texture info contained in the env file to the GPU.
  98811. * @param texture defines the internal texture to upload to
  98812. * @param arrayBuffer defines the buffer cotaining the data to load
  98813. * @param info defines the texture info retrieved through the GetEnvInfo method
  98814. * @returns a promise
  98815. */
  98816. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  98817. if (info.version !== 1) {
  98818. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  98819. }
  98820. var specularInfo = info.specular;
  98821. if (!specularInfo) {
  98822. // Nothing else parsed so far
  98823. return Promise.resolve();
  98824. }
  98825. // Double checks the enclosed info
  98826. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  98827. mipmapsCount = Math.round(mipmapsCount) + 1;
  98828. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  98829. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  98830. }
  98831. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  98832. var imageData = new Array(mipmapsCount);
  98833. for (var i = 0; i < mipmapsCount; i++) {
  98834. imageData[i] = new Array(6);
  98835. for (var face = 0; face < 6; face++) {
  98836. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  98837. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  98838. }
  98839. }
  98840. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  98841. };
  98842. /**
  98843. * Uploads the levels of image data to the GPU.
  98844. * @param texture defines the internal texture to upload to
  98845. * @param imageData defines the array buffer views of image data [mipmap][face]
  98846. * @returns a promise
  98847. */
  98848. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  98849. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  98850. throw new Error("Texture size must be a power of two");
  98851. }
  98852. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  98853. // Gets everything ready.
  98854. var engine = texture.getEngine();
  98855. var expandTexture = false;
  98856. var generateNonLODTextures = false;
  98857. var rgbdPostProcess = null;
  98858. var cubeRtt = null;
  98859. var lodTextures = null;
  98860. var caps = engine.getCaps();
  98861. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  98862. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  98863. texture.generateMipMaps = true;
  98864. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  98865. // Add extra process if texture lod is not supported
  98866. if (!caps.textureLOD) {
  98867. expandTexture = false;
  98868. generateNonLODTextures = true;
  98869. lodTextures = {};
  98870. }
  98871. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  98872. else if (engine.webGLVersion < 2) {
  98873. expandTexture = false;
  98874. }
  98875. // If half float available we can uncompress the texture
  98876. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  98877. expandTexture = true;
  98878. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  98879. }
  98880. // If full float available we can uncompress the texture
  98881. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  98882. expandTexture = true;
  98883. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  98884. }
  98885. // Expand the texture if possible
  98886. if (expandTexture) {
  98887. // Simply run through the decode PP
  98888. 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);
  98889. texture._isRGBD = false;
  98890. texture.invertY = false;
  98891. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  98892. generateDepthBuffer: false,
  98893. generateMipMaps: true,
  98894. generateStencilBuffer: false,
  98895. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  98896. type: texture.type,
  98897. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  98898. });
  98899. }
  98900. else {
  98901. texture._isRGBD = true;
  98902. texture.invertY = true;
  98903. // In case of missing support, applies the same patch than DDS files.
  98904. if (generateNonLODTextures) {
  98905. var mipSlices = 3;
  98906. var scale = texture._lodGenerationScale;
  98907. var offset = texture._lodGenerationOffset;
  98908. for (var i = 0; i < mipSlices; i++) {
  98909. //compute LOD from even spacing in smoothness (matching shader calculation)
  98910. var smoothness = i / (mipSlices - 1);
  98911. var roughness = 1 - smoothness;
  98912. var minLODIndex = offset; // roughness = 0
  98913. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  98914. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  98915. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  98916. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  98917. glTextureFromLod.isCube = true;
  98918. glTextureFromLod.invertY = true;
  98919. glTextureFromLod.generateMipMaps = false;
  98920. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  98921. // Wrap in a base texture for easy binding.
  98922. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  98923. lodTexture.isCube = true;
  98924. lodTexture._texture = glTextureFromLod;
  98925. lodTextures[mipmapIndex] = lodTexture;
  98926. switch (i) {
  98927. case 0:
  98928. texture._lodTextureLow = lodTexture;
  98929. break;
  98930. case 1:
  98931. texture._lodTextureMid = lodTexture;
  98932. break;
  98933. case 2:
  98934. texture._lodTextureHigh = lodTexture;
  98935. break;
  98936. }
  98937. }
  98938. }
  98939. }
  98940. var promises = [];
  98941. var _loop_3 = function (i) {
  98942. var _loop_4 = function (face) {
  98943. // Constructs an image element from image data
  98944. var bytes = imageData[i][face];
  98945. var blob = new Blob([bytes], { type: 'image/png' });
  98946. var url = URL.createObjectURL(blob);
  98947. var image = new Image();
  98948. image.src = url;
  98949. // Enqueue promise to upload to the texture.
  98950. var promise = new Promise(function (resolve, reject) {
  98951. image.onload = function () {
  98952. if (expandTexture) {
  98953. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  98954. reject(message);
  98955. }, image);
  98956. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  98957. // Uncompress the data to a RTT
  98958. rgbdPostProcess.onApply = function (effect) {
  98959. effect._bindTexture("textureSampler", tempTexture_1);
  98960. effect.setFloat2("scale", 1, 1);
  98961. };
  98962. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  98963. // Cleanup
  98964. engine.restoreDefaultFramebuffer();
  98965. tempTexture_1.dispose();
  98966. window.URL.revokeObjectURL(url);
  98967. resolve();
  98968. });
  98969. }
  98970. else {
  98971. engine._uploadImageToTexture(texture, image, face, i);
  98972. // Upload the face to the non lod texture support
  98973. if (generateNonLODTextures) {
  98974. var lodTexture = lodTextures[i];
  98975. if (lodTexture) {
  98976. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  98977. }
  98978. }
  98979. resolve();
  98980. }
  98981. };
  98982. image.onerror = function (error) {
  98983. reject(error);
  98984. };
  98985. });
  98986. promises.push(promise);
  98987. };
  98988. // All faces
  98989. for (var face = 0; face < 6; face++) {
  98990. _loop_4(face);
  98991. }
  98992. };
  98993. // All mipmaps up to provided number of images
  98994. for (var i = 0; i < imageData.length; i++) {
  98995. _loop_3(i);
  98996. }
  98997. // Fill remaining mipmaps with black textures.
  98998. if (imageData.length < mipmapsCount) {
  98999. var data = void 0;
  99000. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  99001. var dataLength = size * size * 4;
  99002. switch (texture.type) {
  99003. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  99004. data = new Uint8Array(dataLength);
  99005. break;
  99006. }
  99007. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  99008. data = new Uint16Array(dataLength);
  99009. break;
  99010. }
  99011. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  99012. data = new Float32Array(dataLength);
  99013. break;
  99014. }
  99015. }
  99016. for (var i = imageData.length; i < mipmapsCount; i++) {
  99017. for (var face = 0; face < 6; face++) {
  99018. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  99019. }
  99020. }
  99021. }
  99022. // Once all done, finishes the cleanup and return
  99023. return Promise.all(promises).then(function () {
  99024. // Release temp RTT.
  99025. if (cubeRtt) {
  99026. engine._releaseFramebufferObjects(cubeRtt);
  99027. cubeRtt._swapAndDie(texture);
  99028. }
  99029. // Release temp Post Process.
  99030. if (rgbdPostProcess) {
  99031. rgbdPostProcess.dispose();
  99032. }
  99033. // Flag internal texture as ready in case they are in use.
  99034. if (generateNonLODTextures) {
  99035. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  99036. texture._lodTextureHigh._texture.isReady = true;
  99037. }
  99038. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  99039. texture._lodTextureMid._texture.isReady = true;
  99040. }
  99041. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  99042. texture._lodTextureLow._texture.isReady = true;
  99043. }
  99044. }
  99045. });
  99046. };
  99047. /**
  99048. * Uploads spherical polynomials information to the texture.
  99049. * @param texture defines the texture we are trying to upload the information to
  99050. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  99051. */
  99052. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  99053. if (info.version !== 1) {
  99054. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  99055. }
  99056. var irradianceInfo = info.irradiance;
  99057. if (!irradianceInfo) {
  99058. return;
  99059. }
  99060. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  99061. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  99062. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  99063. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  99064. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  99065. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  99066. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  99067. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  99068. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  99069. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  99070. texture._sphericalPolynomial = sp;
  99071. };
  99072. /** @hidden */
  99073. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  99074. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  99075. internalTexture._bufferViewArrayArray = data;
  99076. internalTexture._lodGenerationScale = lodScale;
  99077. internalTexture._lodGenerationOffset = lodOffset;
  99078. internalTexture._sphericalPolynomial = sphericalPolynomial;
  99079. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  99080. internalTexture.isReady = true;
  99081. });
  99082. };
  99083. /**
  99084. * Magic number identifying the env file.
  99085. */
  99086. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  99087. return EnvironmentTextureTools;
  99088. }());
  99089. // References the dependencies.
  99090. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  99091. /***/ }),
  99092. /***/ "./Misc/filesInput.ts":
  99093. /*!****************************!*\
  99094. !*** ./Misc/filesInput.ts ***!
  99095. \****************************/
  99096. /*! exports provided: FilesInput */
  99097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99098. "use strict";
  99099. __webpack_require__.r(__webpack_exports__);
  99100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  99101. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  99102. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99103. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  99104. /**
  99105. * Class used to help managing file picking and drag'n'drop
  99106. */
  99107. var FilesInput = /** @class */ (function () {
  99108. /**
  99109. * Creates a new FilesInput
  99110. * @param engine defines the rendering engine
  99111. * @param scene defines the hosting scene
  99112. * @param sceneLoadedCallback callback called when scene is loaded
  99113. * @param progressCallback callback called to track progress
  99114. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  99115. * @param textureLoadingCallback callback called when a texture is loading
  99116. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  99117. * @param onReloadCallback callback called when a reload is requested
  99118. * @param errorCallback callback call if an error occurs
  99119. */
  99120. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  99121. /**
  99122. * Callback called when a file is processed
  99123. */
  99124. this.onProcessFileCallback = function () { return true; };
  99125. this._engine = engine;
  99126. this._currentScene = scene;
  99127. this._sceneLoadedCallback = sceneLoadedCallback;
  99128. this._progressCallback = progressCallback;
  99129. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  99130. this._textureLoadingCallback = textureLoadingCallback;
  99131. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  99132. this._onReloadCallback = onReloadCallback;
  99133. this._errorCallback = errorCallback;
  99134. }
  99135. Object.defineProperty(FilesInput, "FilesToLoad", {
  99136. /**
  99137. * List of files ready to be loaded
  99138. */
  99139. get: function () {
  99140. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  99141. },
  99142. enumerable: true,
  99143. configurable: true
  99144. });
  99145. /**
  99146. * Calls this function to listen to drag'n'drop events on a specific DOM element
  99147. * @param elementToMonitor defines the DOM element to track
  99148. */
  99149. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  99150. var _this = this;
  99151. if (elementToMonitor) {
  99152. this._elementToMonitor = elementToMonitor;
  99153. this._dragEnterHandler = function (e) { _this.drag(e); };
  99154. this._dragOverHandler = function (e) { _this.drag(e); };
  99155. this._dropHandler = function (e) { _this.drop(e); };
  99156. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  99157. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  99158. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  99159. }
  99160. };
  99161. /**
  99162. * Release all associated resources
  99163. */
  99164. FilesInput.prototype.dispose = function () {
  99165. if (!this._elementToMonitor) {
  99166. return;
  99167. }
  99168. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  99169. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  99170. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  99171. };
  99172. FilesInput.prototype.renderFunction = function () {
  99173. if (this._additionalRenderLoopLogicCallback) {
  99174. this._additionalRenderLoopLogicCallback();
  99175. }
  99176. if (this._currentScene) {
  99177. if (this._textureLoadingCallback) {
  99178. var remaining = this._currentScene.getWaitingItemsCount();
  99179. if (remaining > 0) {
  99180. this._textureLoadingCallback(remaining);
  99181. }
  99182. }
  99183. this._currentScene.render();
  99184. }
  99185. };
  99186. FilesInput.prototype.drag = function (e) {
  99187. e.stopPropagation();
  99188. e.preventDefault();
  99189. };
  99190. FilesInput.prototype.drop = function (eventDrop) {
  99191. eventDrop.stopPropagation();
  99192. eventDrop.preventDefault();
  99193. this.loadFiles(eventDrop);
  99194. };
  99195. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  99196. var _this = this;
  99197. var reader = folder.createReader();
  99198. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  99199. reader.readEntries(function (entries) {
  99200. remaining.count += entries.length;
  99201. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  99202. var entry = entries_1[_i];
  99203. if (entry.isFile) {
  99204. entry.file(function (file) {
  99205. file.correctName = relativePath + file.name;
  99206. files.push(file);
  99207. if (--remaining.count === 0) {
  99208. callback();
  99209. }
  99210. });
  99211. }
  99212. else if (entry.isDirectory) {
  99213. _this._traverseFolder(entry, files, remaining, callback);
  99214. }
  99215. }
  99216. if (--remaining.count) {
  99217. callback();
  99218. }
  99219. });
  99220. };
  99221. FilesInput.prototype._processFiles = function (files) {
  99222. for (var i = 0; i < files.length; i++) {
  99223. var name = files[i].correctName.toLowerCase();
  99224. var extension = name.split('.').pop();
  99225. if (!this.onProcessFileCallback(files[i], name, extension)) {
  99226. continue;
  99227. }
  99228. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  99229. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  99230. this._sceneFileToLoad = files[i];
  99231. }
  99232. FilesInput.FilesToLoad[name] = files[i];
  99233. }
  99234. };
  99235. /**
  99236. * Load files from a drop event
  99237. * @param event defines the drop event to use as source
  99238. */
  99239. FilesInput.prototype.loadFiles = function (event) {
  99240. var _this = this;
  99241. // Handling data transfer via drag'n'drop
  99242. if (event && event.dataTransfer && event.dataTransfer.files) {
  99243. this._filesToLoad = event.dataTransfer.files;
  99244. }
  99245. // Handling files from input files
  99246. if (event && event.target && event.target.files) {
  99247. this._filesToLoad = event.target.files;
  99248. }
  99249. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  99250. return;
  99251. }
  99252. if (this._startingProcessingFilesCallback) {
  99253. this._startingProcessingFilesCallback(this._filesToLoad);
  99254. }
  99255. if (this._filesToLoad && this._filesToLoad.length > 0) {
  99256. var files_1 = new Array();
  99257. var folders = [];
  99258. var items = event.dataTransfer ? event.dataTransfer.items : null;
  99259. for (var i = 0; i < this._filesToLoad.length; i++) {
  99260. var fileToLoad = this._filesToLoad[i];
  99261. var name_1 = fileToLoad.name.toLowerCase();
  99262. var entry = void 0;
  99263. fileToLoad.correctName = name_1;
  99264. if (items) {
  99265. var item = items[i];
  99266. if (item.getAsEntry) {
  99267. entry = item.getAsEntry();
  99268. }
  99269. else if (item.webkitGetAsEntry) {
  99270. entry = item.webkitGetAsEntry();
  99271. }
  99272. }
  99273. if (!entry) {
  99274. files_1.push(fileToLoad);
  99275. }
  99276. else {
  99277. if (entry.isDirectory) {
  99278. folders.push(entry);
  99279. }
  99280. else {
  99281. files_1.push(fileToLoad);
  99282. }
  99283. }
  99284. }
  99285. if (folders.length === 0) {
  99286. this._processFiles(files_1);
  99287. this._processReload();
  99288. }
  99289. else {
  99290. var remaining = { count: folders.length };
  99291. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  99292. var folder = folders_1[_i];
  99293. this._traverseFolder(folder, files_1, remaining, function () {
  99294. _this._processFiles(files_1);
  99295. if (remaining.count === 0) {
  99296. _this._processReload();
  99297. }
  99298. });
  99299. }
  99300. }
  99301. }
  99302. };
  99303. FilesInput.prototype._processReload = function () {
  99304. if (this._onReloadCallback) {
  99305. this._onReloadCallback(this._sceneFileToLoad);
  99306. }
  99307. else {
  99308. this.reload();
  99309. }
  99310. };
  99311. /**
  99312. * Reload the current scene from the loaded files
  99313. */
  99314. FilesInput.prototype.reload = function () {
  99315. var _this = this;
  99316. // If a scene file has been provided
  99317. if (this._sceneFileToLoad) {
  99318. if (this._currentScene) {
  99319. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  99320. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  99321. }
  99322. this._engine.stopRenderLoop();
  99323. }
  99324. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  99325. if (_this._progressCallback) {
  99326. _this._progressCallback(progress);
  99327. }
  99328. }).then(function (scene) {
  99329. if (_this._currentScene) {
  99330. _this._currentScene.dispose();
  99331. }
  99332. _this._currentScene = scene;
  99333. if (_this._sceneLoadedCallback) {
  99334. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  99335. }
  99336. // Wait for textures and shaders to be ready
  99337. _this._currentScene.executeWhenReady(function () {
  99338. _this._engine.runRenderLoop(function () {
  99339. _this.renderFunction();
  99340. });
  99341. });
  99342. }).catch(function (error) {
  99343. if (_this._errorCallback) {
  99344. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  99345. }
  99346. });
  99347. }
  99348. else {
  99349. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  99350. }
  99351. };
  99352. return FilesInput;
  99353. }());
  99354. /***/ }),
  99355. /***/ "./Misc/filesInputStore.ts":
  99356. /*!*********************************!*\
  99357. !*** ./Misc/filesInputStore.ts ***!
  99358. \*********************************/
  99359. /*! exports provided: FilesInputStore */
  99360. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99361. "use strict";
  99362. __webpack_require__.r(__webpack_exports__);
  99363. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  99364. /**
  99365. * Class used to help managing file picking and drag'n'drop
  99366. * File Storage
  99367. */
  99368. var FilesInputStore = /** @class */ (function () {
  99369. function FilesInputStore() {
  99370. }
  99371. /**
  99372. * List of files ready to be loaded
  99373. */
  99374. FilesInputStore.FilesToLoad = {};
  99375. return FilesInputStore;
  99376. }());
  99377. /***/ }),
  99378. /***/ "./Misc/iInspectable.ts":
  99379. /*!******************************!*\
  99380. !*** ./Misc/iInspectable.ts ***!
  99381. \******************************/
  99382. /*! exports provided: InspectableType */
  99383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99384. "use strict";
  99385. __webpack_require__.r(__webpack_exports__);
  99386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return InspectableType; });
  99387. /**
  99388. * Enum that determines the text-wrapping mode to use.
  99389. */
  99390. var InspectableType;
  99391. (function (InspectableType) {
  99392. /**
  99393. * Checkbox for booleans
  99394. */
  99395. InspectableType[InspectableType["Checkbox"] = 0] = "Checkbox";
  99396. /**
  99397. * Sliders for numbers
  99398. */
  99399. InspectableType[InspectableType["Slider"] = 1] = "Slider";
  99400. /**
  99401. * Vector3
  99402. */
  99403. InspectableType[InspectableType["Vector3"] = 2] = "Vector3";
  99404. /**
  99405. * Quaternions
  99406. */
  99407. InspectableType[InspectableType["Quaternion"] = 3] = "Quaternion";
  99408. /**
  99409. * Color3
  99410. */
  99411. InspectableType[InspectableType["Color3"] = 4] = "Color3";
  99412. })(InspectableType || (InspectableType = {}));
  99413. /***/ }),
  99414. /***/ "./Misc/index.ts":
  99415. /*!***********************!*\
  99416. !*** ./Misc/index.ts ***!
  99417. \***********************/
  99418. /*! 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 */
  99419. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99420. "use strict";
  99421. __webpack_require__.r(__webpack_exports__);
  99422. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  99423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  99424. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  99425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  99426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  99427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  99428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  99429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  99430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  99431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  99432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  99433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  99434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  99435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["EquiRectangularCubeTextureAssetTask"]; });
  99436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  99437. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  99438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  99439. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  99440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  99441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  99442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  99443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  99444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  99445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  99446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  99447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  99448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  99449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  99450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  99451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  99452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMatrix"]; });
  99453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  99454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  99455. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  99456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  99457. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  99458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  99459. /* harmony import */ var _meshExploder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshExploder */ "./Misc/meshExploder.ts");
  99460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _meshExploder__WEBPACK_IMPORTED_MODULE_6__["MeshExploder"]; });
  99461. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  99462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_7__["FilesInput"]; });
  99463. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  99464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["CubeMapToSphericalPolynomialTools"]; });
  99465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["HDRTools"]; });
  99466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["PanoramaToCubeMapTools"]; });
  99467. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  99468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__["KhronosTextureContainer"]; });
  99469. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  99470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["EventState"]; });
  99471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observer"]; });
  99472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["MultiObserver"]; });
  99473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observable"]; });
  99474. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  99475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["PerformanceMonitor"]; });
  99476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["RollingAverage"]; });
  99477. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  99478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_12__["PromisePolyfill"]; });
  99479. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  99480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimization"]; });
  99481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["TextureOptimization"]; });
  99482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["HardwareScalingOptimization"]; });
  99483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ShadowsOptimization"]; });
  99484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["PostProcessesOptimization"]; });
  99485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["LensFlaresOptimization"]; });
  99486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["CustomOptimization"]; });
  99487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ParticlesOptimization"]; });
  99488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["RenderTargetsOptimization"]; });
  99489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["MergeMeshesOptimization"]; });
  99490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizerOptions"]; });
  99491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizer"]; });
  99492. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  99493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__["SceneSerializer"]; });
  99494. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  99495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArray"]; });
  99496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArrayNoDuplicate"]; });
  99497. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  99498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_16__["StringDictionary"]; });
  99499. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  99500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_17__["Tags"]; });
  99501. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  99502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_18__["TextureTools"]; });
  99503. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  99504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_19__["TGATools"]; });
  99505. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["ColorGradient"]; });
  99507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Color3Gradient"]; });
  99508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["FactorGradient"]; });
  99509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["LoadFileError"]; });
  99510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["RetryStrategy"]; });
  99511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Tools"]; });
  99512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["PerfCounter"]; });
  99513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["className"]; });
  99514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["AsyncLoop"]; });
  99515. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  99516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_21__["VideoRecorder"]; });
  99517. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  99518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["JoystickAxis"]; });
  99519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["VirtualJoystick"]; });
  99520. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  99521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_23__["WorkerPool"]; });
  99522. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  99523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_24__["Logger"]; });
  99524. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  99525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_25__["_TypeStore"]; });
  99526. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  99527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_26__["FilesInputStore"]; });
  99528. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  99529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_27__["DeepCopier"]; });
  99530. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  99531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_28__["PivotTools"]; });
  99532. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  99533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_29__["PrecisionDate"]; });
  99534. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  99535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_30__["ScreenshotTools"]; });
  99536. /* empty/unused harmony star reexport *//* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  99537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _webRequest__WEBPACK_IMPORTED_MODULE_31__["WebRequest"]; });
  99538. /* harmony import */ var _iInspectable__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./iInspectable */ "./Misc/iInspectable.ts");
  99539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _iInspectable__WEBPACK_IMPORTED_MODULE_32__["InspectableType"]; });
  99540. /***/ }),
  99541. /***/ "./Misc/khronosTextureContainer.ts":
  99542. /*!*****************************************!*\
  99543. !*** ./Misc/khronosTextureContainer.ts ***!
  99544. \*****************************************/
  99545. /*! exports provided: KhronosTextureContainer */
  99546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99547. "use strict";
  99548. __webpack_require__.r(__webpack_exports__);
  99549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  99550. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99551. /**
  99552. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99553. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99554. */
  99555. var KhronosTextureContainer = /** @class */ (function () {
  99556. /**
  99557. * Creates a new KhronosTextureContainer
  99558. * @param arrayBuffer contents of the KTX container file
  99559. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  99560. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  99561. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  99562. */
  99563. function KhronosTextureContainer(
  99564. /** contents of the KTX container file */
  99565. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  99566. this.arrayBuffer = arrayBuffer;
  99567. /**
  99568. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  99569. */
  99570. this.isInvalid = false;
  99571. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  99572. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  99573. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  99574. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  99575. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  99576. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  99577. this.isInvalid = true;
  99578. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  99579. return;
  99580. }
  99581. // load the reset of the header in native 32 bit uint
  99582. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  99583. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  99584. var endianness = headerDataView.getUint32(0, true);
  99585. var littleEndian = endianness === 0x04030201;
  99586. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  99587. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  99588. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  99589. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  99590. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  99591. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  99592. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  99593. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  99594. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  99595. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  99596. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  99597. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  99598. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  99599. if (this.glType !== 0) {
  99600. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  99601. return;
  99602. }
  99603. else {
  99604. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  99605. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  99606. }
  99607. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  99608. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  99609. return;
  99610. }
  99611. if (this.numberOfArrayElements !== 0) {
  99612. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  99613. return;
  99614. }
  99615. if (this.numberOfFaces !== facesExpected) {
  99616. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  99617. return;
  99618. }
  99619. // we now have a completely validated file, so could use existence of loadType as success
  99620. // would need to make this more elaborate & adjust checks above to support more than one load type
  99621. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  99622. }
  99623. /**
  99624. * Uploads KTX content to a Babylon Texture.
  99625. * It is assumed that the texture has already been created & is currently bound
  99626. * @hidden
  99627. */
  99628. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  99629. switch (this.loadType) {
  99630. case KhronosTextureContainer.COMPRESSED_2D:
  99631. this._upload2DCompressedLevels(texture, loadMipmaps);
  99632. break;
  99633. case KhronosTextureContainer.TEX_2D:
  99634. case KhronosTextureContainer.COMPRESSED_3D:
  99635. case KhronosTextureContainer.TEX_3D:
  99636. }
  99637. };
  99638. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  99639. // initialize width & height for level 1
  99640. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  99641. var width = this.pixelWidth;
  99642. var height = this.pixelHeight;
  99643. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  99644. for (var level = 0; level < mipmapCount; level++) {
  99645. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  99646. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  99647. for (var face = 0; face < this.numberOfFaces; face++) {
  99648. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  99649. var engine = texture.getEngine();
  99650. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  99651. dataOffset += imageSize; // add size of the image for the next face/mipmap
  99652. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  99653. }
  99654. width = Math.max(1.0, width * 0.5);
  99655. height = Math.max(1.0, height * 0.5);
  99656. }
  99657. };
  99658. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  99659. // load types
  99660. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  99661. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  99662. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  99663. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  99664. return KhronosTextureContainer;
  99665. }());
  99666. /***/ }),
  99667. /***/ "./Misc/logger.ts":
  99668. /*!************************!*\
  99669. !*** ./Misc/logger.ts ***!
  99670. \************************/
  99671. /*! exports provided: Logger */
  99672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99673. "use strict";
  99674. __webpack_require__.r(__webpack_exports__);
  99675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  99676. /**
  99677. * Logger used througouht the application to allow configuration of
  99678. * the log level required for the messages.
  99679. */
  99680. var Logger = /** @class */ (function () {
  99681. function Logger() {
  99682. }
  99683. Logger._AddLogEntry = function (entry) {
  99684. Logger._LogCache = entry + Logger._LogCache;
  99685. if (Logger.OnNewCacheEntry) {
  99686. Logger.OnNewCacheEntry(entry);
  99687. }
  99688. };
  99689. Logger._FormatMessage = function (message) {
  99690. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  99691. var date = new Date();
  99692. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  99693. };
  99694. Logger._LogDisabled = function (message) {
  99695. // nothing to do
  99696. };
  99697. Logger._LogEnabled = function (message) {
  99698. var formattedMessage = Logger._FormatMessage(message);
  99699. console.log("BJS - " + formattedMessage);
  99700. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  99701. Logger._AddLogEntry(entry);
  99702. };
  99703. Logger._WarnDisabled = function (message) {
  99704. // nothing to do
  99705. };
  99706. Logger._WarnEnabled = function (message) {
  99707. var formattedMessage = Logger._FormatMessage(message);
  99708. console.warn("BJS - " + formattedMessage);
  99709. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  99710. Logger._AddLogEntry(entry);
  99711. };
  99712. Logger._ErrorDisabled = function (message) {
  99713. // nothing to do
  99714. };
  99715. Logger._ErrorEnabled = function (message) {
  99716. Logger.errorsCount++;
  99717. var formattedMessage = Logger._FormatMessage(message);
  99718. console.error("BJS - " + formattedMessage);
  99719. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  99720. Logger._AddLogEntry(entry);
  99721. };
  99722. Object.defineProperty(Logger, "LogCache", {
  99723. /**
  99724. * Gets current log cache (list of logs)
  99725. */
  99726. get: function () {
  99727. return Logger._LogCache;
  99728. },
  99729. enumerable: true,
  99730. configurable: true
  99731. });
  99732. /**
  99733. * Clears the log cache
  99734. */
  99735. Logger.ClearLogCache = function () {
  99736. Logger._LogCache = "";
  99737. Logger.errorsCount = 0;
  99738. };
  99739. Object.defineProperty(Logger, "LogLevels", {
  99740. /**
  99741. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99742. */
  99743. set: function (level) {
  99744. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  99745. Logger.Log = Logger._LogEnabled;
  99746. }
  99747. else {
  99748. Logger.Log = Logger._LogDisabled;
  99749. }
  99750. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  99751. Logger.Warn = Logger._WarnEnabled;
  99752. }
  99753. else {
  99754. Logger.Warn = Logger._WarnDisabled;
  99755. }
  99756. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  99757. Logger.Error = Logger._ErrorEnabled;
  99758. }
  99759. else {
  99760. Logger.Error = Logger._ErrorDisabled;
  99761. }
  99762. },
  99763. enumerable: true,
  99764. configurable: true
  99765. });
  99766. /**
  99767. * No log
  99768. */
  99769. Logger.NoneLogLevel = 0;
  99770. /**
  99771. * Only message logs
  99772. */
  99773. Logger.MessageLogLevel = 1;
  99774. /**
  99775. * Only warning logs
  99776. */
  99777. Logger.WarningLogLevel = 2;
  99778. /**
  99779. * Only error logs
  99780. */
  99781. Logger.ErrorLogLevel = 4;
  99782. /**
  99783. * All logs
  99784. */
  99785. Logger.AllLogLevel = 7;
  99786. Logger._LogCache = "";
  99787. /**
  99788. * Gets a value indicating the number of loading errors
  99789. * @ignorenaming
  99790. */
  99791. Logger.errorsCount = 0;
  99792. /**
  99793. * Log a message to the console
  99794. */
  99795. Logger.Log = Logger._LogEnabled;
  99796. /**
  99797. * Write a warning message to the console
  99798. */
  99799. Logger.Warn = Logger._WarnEnabled;
  99800. /**
  99801. * Write an error message to the console
  99802. */
  99803. Logger.Error = Logger._ErrorEnabled;
  99804. return Logger;
  99805. }());
  99806. /***/ }),
  99807. /***/ "./Misc/meshExploder.ts":
  99808. /*!******************************!*\
  99809. !*** ./Misc/meshExploder.ts ***!
  99810. \******************************/
  99811. /*! exports provided: MeshExploder */
  99812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99813. "use strict";
  99814. __webpack_require__.r(__webpack_exports__);
  99815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return MeshExploder; });
  99816. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  99817. /**
  99818. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  99819. */
  99820. var MeshExploder = /** @class */ (function () {
  99821. /**
  99822. * Explodes meshes from a center mesh.
  99823. * @param meshes The meshes to explode.
  99824. * @param centerMesh The mesh to be center of explosion.
  99825. */
  99826. function MeshExploder(meshes, centerMesh) {
  99827. this._meshesOrigins = [];
  99828. this._toCenterVectors = [];
  99829. this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99830. this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99831. this._centerPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99832. this._meshes = meshes.slice();
  99833. if (centerMesh) {
  99834. this._centerMesh = centerMesh;
  99835. }
  99836. else {
  99837. this._setCenterMesh();
  99838. }
  99839. var centerMeshIndex = this._meshes.indexOf(this._centerMesh);
  99840. if (centerMeshIndex >= 0) {
  99841. this._meshes.splice(centerMeshIndex, 1);
  99842. }
  99843. this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
  99844. for (var index = 0; index < this._meshes.length; index++) {
  99845. if (this._meshes[index]) {
  99846. var mesh = this._meshes[index];
  99847. this._meshesOrigins[index] = mesh.getAbsolutePosition().clone();
  99848. this._toCenterVectors[index] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99849. if (mesh._boundingInfo && this._centerMesh._boundingInfo) {
  99850. mesh._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld, this._toCenterVectors[index]);
  99851. }
  99852. }
  99853. }
  99854. }
  99855. MeshExploder.prototype._setCenterMesh = function () {
  99856. var averageCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99857. var totalCenters = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99858. var shortestToCenter = Number.MAX_VALUE;
  99859. for (var index = 0; index < this._meshes.length; index++) {
  99860. if (this._meshes[index]) {
  99861. var mesh = this._meshes[index];
  99862. var boundingInfo = mesh.getBoundingInfo();
  99863. if (boundingInfo) {
  99864. totalCenters.addInPlace(boundingInfo.boundingBox.centerWorld);
  99865. }
  99866. }
  99867. }
  99868. averageCenter = totalCenters.scale(1 / this._meshes.length);
  99869. for (var index = 0; index < this._meshes.length; index++) {
  99870. if (this._meshes[index]) {
  99871. var mesh = this._meshes[index];
  99872. var boundingInfo = mesh.getBoundingInfo();
  99873. if (boundingInfo) {
  99874. var distanceToCenter = boundingInfo.boundingBox.centerWorld.subtract(averageCenter).lengthSquared();
  99875. if (distanceToCenter < shortestToCenter) {
  99876. this._centerMesh = mesh;
  99877. shortestToCenter = distanceToCenter;
  99878. }
  99879. }
  99880. }
  99881. }
  99882. };
  99883. /**
  99884. * Get class name
  99885. * @returns "MeshExploder"
  99886. */
  99887. MeshExploder.prototype.getClassName = function () {
  99888. return "MeshExploder";
  99889. };
  99890. /**
  99891. * "Exploded meshes"
  99892. * @returns Array of meshes with the centerMesh at index 0.
  99893. */
  99894. MeshExploder.prototype.getMeshes = function () {
  99895. var meshArray = this._meshes.slice();
  99896. meshArray.unshift(this._centerMesh);
  99897. return meshArray;
  99898. };
  99899. /**
  99900. * Explodes meshes giving a specific direction
  99901. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  99902. */
  99903. MeshExploder.prototype.explode = function (direction) {
  99904. if (direction === void 0) { direction = 1.0; }
  99905. for (var index = 0; index < this._meshes.length; index++) {
  99906. if (this._meshes[index] && this._meshesOrigins[index] && this._toCenterVectors[index]) {
  99907. this._toCenterVectors[index].scaleToRef(direction, this._scaledDirection);
  99908. this._meshesOrigins[index].addToRef(this._scaledDirection, this._newPosition);
  99909. this._meshes[index].setAbsolutePosition(this._newPosition);
  99910. }
  99911. }
  99912. this._centerMesh.setAbsolutePosition(this._centerPosition);
  99913. };
  99914. return MeshExploder;
  99915. }());
  99916. /***/ }),
  99917. /***/ "./Misc/observable.ts":
  99918. /*!****************************!*\
  99919. !*** ./Misc/observable.ts ***!
  99920. \****************************/
  99921. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  99922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99923. "use strict";
  99924. __webpack_require__.r(__webpack_exports__);
  99925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  99926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  99927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  99928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  99929. /**
  99930. * A class serves as a medium between the observable and its observers
  99931. */
  99932. var EventState = /** @class */ (function () {
  99933. /**
  99934. * Create a new EventState
  99935. * @param mask defines the mask associated with this state
  99936. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  99937. * @param target defines the original target of the state
  99938. * @param currentTarget defines the current target of the state
  99939. */
  99940. function EventState(mask, skipNextObservers, target, currentTarget) {
  99941. if (skipNextObservers === void 0) { skipNextObservers = false; }
  99942. this.initalize(mask, skipNextObservers, target, currentTarget);
  99943. }
  99944. /**
  99945. * Initialize the current event state
  99946. * @param mask defines the mask associated with this state
  99947. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  99948. * @param target defines the original target of the state
  99949. * @param currentTarget defines the current target of the state
  99950. * @returns the current event state
  99951. */
  99952. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  99953. if (skipNextObservers === void 0) { skipNextObservers = false; }
  99954. this.mask = mask;
  99955. this.skipNextObservers = skipNextObservers;
  99956. this.target = target;
  99957. this.currentTarget = currentTarget;
  99958. return this;
  99959. };
  99960. return EventState;
  99961. }());
  99962. /**
  99963. * Represent an Observer registered to a given Observable object.
  99964. */
  99965. var Observer = /** @class */ (function () {
  99966. /**
  99967. * Creates a new observer
  99968. * @param callback defines the callback to call when the observer is notified
  99969. * @param mask defines the mask of the observer (used to filter notifications)
  99970. * @param scope defines the current scope used to restore the JS context
  99971. */
  99972. function Observer(
  99973. /**
  99974. * Defines the callback to call when the observer is notified
  99975. */
  99976. callback,
  99977. /**
  99978. * Defines the mask of the observer (used to filter notifications)
  99979. */
  99980. mask,
  99981. /**
  99982. * Defines the current scope used to restore the JS context
  99983. */
  99984. scope) {
  99985. if (scope === void 0) { scope = null; }
  99986. this.callback = callback;
  99987. this.mask = mask;
  99988. this.scope = scope;
  99989. /** @hidden */
  99990. this._willBeUnregistered = false;
  99991. /**
  99992. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  99993. */
  99994. this.unregisterOnNextCall = false;
  99995. }
  99996. return Observer;
  99997. }());
  99998. /**
  99999. * Represent a list of observers registered to multiple Observables object.
  100000. */
  100001. var MultiObserver = /** @class */ (function () {
  100002. function MultiObserver() {
  100003. }
  100004. /**
  100005. * Release associated resources
  100006. */
  100007. MultiObserver.prototype.dispose = function () {
  100008. if (this._observers && this._observables) {
  100009. for (var index = 0; index < this._observers.length; index++) {
  100010. this._observables[index].remove(this._observers[index]);
  100011. }
  100012. }
  100013. this._observers = null;
  100014. this._observables = null;
  100015. };
  100016. /**
  100017. * Raise a callback when one of the observable will notify
  100018. * @param observables defines a list of observables to watch
  100019. * @param callback defines the callback to call on notification
  100020. * @param mask defines the mask used to filter notifications
  100021. * @param scope defines the current scope used to restore the JS context
  100022. * @returns the new MultiObserver
  100023. */
  100024. MultiObserver.Watch = function (observables, callback, mask, scope) {
  100025. if (mask === void 0) { mask = -1; }
  100026. if (scope === void 0) { scope = null; }
  100027. var result = new MultiObserver();
  100028. result._observers = new Array();
  100029. result._observables = observables;
  100030. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  100031. var observable = observables_1[_i];
  100032. var observer = observable.add(callback, mask, false, scope);
  100033. if (observer) {
  100034. result._observers.push(observer);
  100035. }
  100036. }
  100037. return result;
  100038. };
  100039. return MultiObserver;
  100040. }());
  100041. /**
  100042. * The Observable class is a simple implementation of the Observable pattern.
  100043. *
  100044. * 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.
  100045. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  100046. * 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).
  100047. * 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.
  100048. */
  100049. var Observable = /** @class */ (function () {
  100050. /**
  100051. * Creates a new observable
  100052. * @param onObserverAdded defines a callback to call when a new observer is added
  100053. */
  100054. function Observable(onObserverAdded) {
  100055. this._observers = new Array();
  100056. this._eventState = new EventState(0);
  100057. if (onObserverAdded) {
  100058. this._onObserverAdded = onObserverAdded;
  100059. }
  100060. }
  100061. /**
  100062. * Create a new Observer with the specified callback
  100063. * @param callback the callback that will be executed for that Observer
  100064. * @param mask the mask used to filter observers
  100065. * @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.
  100066. * @param scope optional scope for the callback to be called from
  100067. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  100068. * @returns the new observer created for the callback
  100069. */
  100070. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  100071. if (mask === void 0) { mask = -1; }
  100072. if (insertFirst === void 0) { insertFirst = false; }
  100073. if (scope === void 0) { scope = null; }
  100074. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  100075. if (!callback) {
  100076. return null;
  100077. }
  100078. var observer = new Observer(callback, mask, scope);
  100079. observer.unregisterOnNextCall = unregisterOnFirstCall;
  100080. if (insertFirst) {
  100081. this._observers.unshift(observer);
  100082. }
  100083. else {
  100084. this._observers.push(observer);
  100085. }
  100086. if (this._onObserverAdded) {
  100087. this._onObserverAdded(observer);
  100088. }
  100089. return observer;
  100090. };
  100091. /**
  100092. * Create a new Observer with the specified callback and unregisters after the next notification
  100093. * @param callback the callback that will be executed for that Observer
  100094. * @returns the new observer created for the callback
  100095. */
  100096. Observable.prototype.addOnce = function (callback) {
  100097. return this.add(callback, undefined, undefined, undefined, true);
  100098. };
  100099. /**
  100100. * Remove an Observer from the Observable object
  100101. * @param observer the instance of the Observer to remove
  100102. * @returns false if it doesn't belong to this Observable
  100103. */
  100104. Observable.prototype.remove = function (observer) {
  100105. if (!observer) {
  100106. return false;
  100107. }
  100108. var index = this._observers.indexOf(observer);
  100109. if (index !== -1) {
  100110. this._deferUnregister(observer);
  100111. return true;
  100112. }
  100113. return false;
  100114. };
  100115. /**
  100116. * Remove a callback from the Observable object
  100117. * @param callback the callback to remove
  100118. * @param scope optional scope. If used only the callbacks with this scope will be removed
  100119. * @returns false if it doesn't belong to this Observable
  100120. */
  100121. Observable.prototype.removeCallback = function (callback, scope) {
  100122. for (var index = 0; index < this._observers.length; index++) {
  100123. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  100124. this._deferUnregister(this._observers[index]);
  100125. return true;
  100126. }
  100127. }
  100128. return false;
  100129. };
  100130. Observable.prototype._deferUnregister = function (observer) {
  100131. var _this = this;
  100132. observer.unregisterOnNextCall = false;
  100133. observer._willBeUnregistered = true;
  100134. setTimeout(function () {
  100135. _this._remove(observer);
  100136. }, 0);
  100137. };
  100138. // This should only be called when not iterating over _observers to avoid callback skipping.
  100139. // Removes an observer from the _observer Array.
  100140. Observable.prototype._remove = function (observer) {
  100141. if (!observer) {
  100142. return false;
  100143. }
  100144. var index = this._observers.indexOf(observer);
  100145. if (index !== -1) {
  100146. this._observers.splice(index, 1);
  100147. return true;
  100148. }
  100149. return false;
  100150. };
  100151. /**
  100152. * Moves the observable to the top of the observer list making it get called first when notified
  100153. * @param observer the observer to move
  100154. */
  100155. Observable.prototype.makeObserverTopPriority = function (observer) {
  100156. this._remove(observer);
  100157. this._observers.unshift(observer);
  100158. };
  100159. /**
  100160. * Moves the observable to the bottom of the observer list making it get called last when notified
  100161. * @param observer the observer to move
  100162. */
  100163. Observable.prototype.makeObserverBottomPriority = function (observer) {
  100164. this._remove(observer);
  100165. this._observers.push(observer);
  100166. };
  100167. /**
  100168. * Notify all Observers by calling their respective callback with the given data
  100169. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  100170. * @param eventData defines the data to send to all observers
  100171. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  100172. * @param target defines the original target of the state
  100173. * @param currentTarget defines the current target of the state
  100174. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  100175. */
  100176. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  100177. if (mask === void 0) { mask = -1; }
  100178. if (!this._observers.length) {
  100179. return true;
  100180. }
  100181. var state = this._eventState;
  100182. state.mask = mask;
  100183. state.target = target;
  100184. state.currentTarget = currentTarget;
  100185. state.skipNextObservers = false;
  100186. state.lastReturnValue = eventData;
  100187. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  100188. var obs = _a[_i];
  100189. if (obs._willBeUnregistered) {
  100190. continue;
  100191. }
  100192. if (obs.mask & mask) {
  100193. if (obs.scope) {
  100194. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  100195. }
  100196. else {
  100197. state.lastReturnValue = obs.callback(eventData, state);
  100198. }
  100199. if (obs.unregisterOnNextCall) {
  100200. this._deferUnregister(obs);
  100201. }
  100202. }
  100203. if (state.skipNextObservers) {
  100204. return false;
  100205. }
  100206. }
  100207. return true;
  100208. };
  100209. /**
  100210. * Calling this will execute each callback, expecting it to be a promise or return a value.
  100211. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  100212. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  100213. * and it is crucial that all callbacks will be executed.
  100214. * The order of the callbacks is kept, callbacks are not executed parallel.
  100215. *
  100216. * @param eventData The data to be sent to each callback
  100217. * @param mask is used to filter observers defaults to -1
  100218. * @param target defines the callback target (see EventState)
  100219. * @param currentTarget defines he current object in the bubbling phase
  100220. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  100221. */
  100222. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  100223. var _this = this;
  100224. if (mask === void 0) { mask = -1; }
  100225. // create an empty promise
  100226. var p = Promise.resolve(eventData);
  100227. // no observers? return this promise.
  100228. if (!this._observers.length) {
  100229. return p;
  100230. }
  100231. var state = this._eventState;
  100232. state.mask = mask;
  100233. state.target = target;
  100234. state.currentTarget = currentTarget;
  100235. state.skipNextObservers = false;
  100236. // execute one callback after another (not using Promise.all, the order is important)
  100237. this._observers.forEach(function (obs) {
  100238. if (state.skipNextObservers) {
  100239. return;
  100240. }
  100241. if (obs._willBeUnregistered) {
  100242. return;
  100243. }
  100244. if (obs.mask & mask) {
  100245. if (obs.scope) {
  100246. p = p.then(function (lastReturnedValue) {
  100247. state.lastReturnValue = lastReturnedValue;
  100248. return obs.callback.apply(obs.scope, [eventData, state]);
  100249. });
  100250. }
  100251. else {
  100252. p = p.then(function (lastReturnedValue) {
  100253. state.lastReturnValue = lastReturnedValue;
  100254. return obs.callback(eventData, state);
  100255. });
  100256. }
  100257. if (obs.unregisterOnNextCall) {
  100258. _this._deferUnregister(obs);
  100259. }
  100260. }
  100261. });
  100262. // return the eventData
  100263. return p.then(function () { return eventData; });
  100264. };
  100265. /**
  100266. * Notify a specific observer
  100267. * @param observer defines the observer to notify
  100268. * @param eventData defines the data to be sent to each callback
  100269. * @param mask is used to filter observers defaults to -1
  100270. */
  100271. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  100272. if (mask === void 0) { mask = -1; }
  100273. var state = this._eventState;
  100274. state.mask = mask;
  100275. state.skipNextObservers = false;
  100276. observer.callback(eventData, state);
  100277. };
  100278. /**
  100279. * Gets a boolean indicating if the observable has at least one observer
  100280. * @returns true is the Observable has at least one Observer registered
  100281. */
  100282. Observable.prototype.hasObservers = function () {
  100283. return this._observers.length > 0;
  100284. };
  100285. /**
  100286. * Clear the list of observers
  100287. */
  100288. Observable.prototype.clear = function () {
  100289. this._observers = new Array();
  100290. this._onObserverAdded = null;
  100291. };
  100292. /**
  100293. * Clone the current observable
  100294. * @returns a new observable
  100295. */
  100296. Observable.prototype.clone = function () {
  100297. var result = new Observable();
  100298. result._observers = this._observers.slice(0);
  100299. return result;
  100300. };
  100301. /**
  100302. * Does this observable handles observer registered with a given mask
  100303. * @param mask defines the mask to be tested
  100304. * @return whether or not one observer registered with the given mask is handeled
  100305. **/
  100306. Observable.prototype.hasSpecificMask = function (mask) {
  100307. if (mask === void 0) { mask = -1; }
  100308. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  100309. var obs = _a[_i];
  100310. if (obs.mask & mask || obs.mask === mask) {
  100311. return true;
  100312. }
  100313. }
  100314. return false;
  100315. };
  100316. return Observable;
  100317. }());
  100318. /***/ }),
  100319. /***/ "./Misc/performanceMonitor.ts":
  100320. /*!************************************!*\
  100321. !*** ./Misc/performanceMonitor.ts ***!
  100322. \************************************/
  100323. /*! exports provided: PerformanceMonitor, RollingAverage */
  100324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100325. "use strict";
  100326. __webpack_require__.r(__webpack_exports__);
  100327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  100328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  100329. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  100330. /**
  100331. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  100332. */
  100333. var PerformanceMonitor = /** @class */ (function () {
  100334. /**
  100335. * constructor
  100336. * @param frameSampleSize The number of samples required to saturate the sliding window
  100337. */
  100338. function PerformanceMonitor(frameSampleSize) {
  100339. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  100340. this._enabled = true;
  100341. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  100342. }
  100343. /**
  100344. * Samples current frame
  100345. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  100346. */
  100347. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  100348. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  100349. if (!this._enabled) {
  100350. return;
  100351. }
  100352. if (this._lastFrameTimeMs != null) {
  100353. var dt = timeMs - this._lastFrameTimeMs;
  100354. this._rollingFrameTime.add(dt);
  100355. }
  100356. this._lastFrameTimeMs = timeMs;
  100357. };
  100358. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  100359. /**
  100360. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  100361. */
  100362. get: function () {
  100363. return this._rollingFrameTime.average;
  100364. },
  100365. enumerable: true,
  100366. configurable: true
  100367. });
  100368. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  100369. /**
  100370. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  100371. */
  100372. get: function () {
  100373. return this._rollingFrameTime.variance;
  100374. },
  100375. enumerable: true,
  100376. configurable: true
  100377. });
  100378. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  100379. /**
  100380. * Returns the frame time of the most recent frame
  100381. */
  100382. get: function () {
  100383. return this._rollingFrameTime.history(0);
  100384. },
  100385. enumerable: true,
  100386. configurable: true
  100387. });
  100388. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  100389. /**
  100390. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  100391. */
  100392. get: function () {
  100393. return 1000.0 / this._rollingFrameTime.average;
  100394. },
  100395. enumerable: true,
  100396. configurable: true
  100397. });
  100398. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  100399. /**
  100400. * Returns the average framerate in frames per second using the most recent frame time
  100401. */
  100402. get: function () {
  100403. var history = this._rollingFrameTime.history(0);
  100404. if (history === 0) {
  100405. return 0;
  100406. }
  100407. return 1000.0 / history;
  100408. },
  100409. enumerable: true,
  100410. configurable: true
  100411. });
  100412. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  100413. /**
  100414. * Returns true if enough samples have been taken to completely fill the sliding window
  100415. */
  100416. get: function () {
  100417. return this._rollingFrameTime.isSaturated();
  100418. },
  100419. enumerable: true,
  100420. configurable: true
  100421. });
  100422. /**
  100423. * Enables contributions to the sliding window sample set
  100424. */
  100425. PerformanceMonitor.prototype.enable = function () {
  100426. this._enabled = true;
  100427. };
  100428. /**
  100429. * Disables contributions to the sliding window sample set
  100430. * Samples will not be interpolated over the disabled period
  100431. */
  100432. PerformanceMonitor.prototype.disable = function () {
  100433. this._enabled = false;
  100434. //clear last sample to avoid interpolating over the disabled period when next enabled
  100435. this._lastFrameTimeMs = null;
  100436. };
  100437. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  100438. /**
  100439. * Returns true if sampling is enabled
  100440. */
  100441. get: function () {
  100442. return this._enabled;
  100443. },
  100444. enumerable: true,
  100445. configurable: true
  100446. });
  100447. /**
  100448. * Resets performance monitor
  100449. */
  100450. PerformanceMonitor.prototype.reset = function () {
  100451. //clear last sample to avoid interpolating over the disabled period when next enabled
  100452. this._lastFrameTimeMs = null;
  100453. //wipe record
  100454. this._rollingFrameTime.reset();
  100455. };
  100456. return PerformanceMonitor;
  100457. }());
  100458. /**
  100459. * RollingAverage
  100460. *
  100461. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  100462. */
  100463. var RollingAverage = /** @class */ (function () {
  100464. /**
  100465. * constructor
  100466. * @param length The number of samples required to saturate the sliding window
  100467. */
  100468. function RollingAverage(length) {
  100469. this._samples = new Array(length);
  100470. this.reset();
  100471. }
  100472. /**
  100473. * Adds a sample to the sample set
  100474. * @param v The sample value
  100475. */
  100476. RollingAverage.prototype.add = function (v) {
  100477. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  100478. var delta;
  100479. //we need to check if we've already wrapped round
  100480. if (this.isSaturated()) {
  100481. //remove bottom of stack from mean
  100482. var bottomValue = this._samples[this._pos];
  100483. delta = bottomValue - this.average;
  100484. this.average -= delta / (this._sampleCount - 1);
  100485. this._m2 -= delta * (bottomValue - this.average);
  100486. }
  100487. else {
  100488. this._sampleCount++;
  100489. }
  100490. //add new value to mean
  100491. delta = v - this.average;
  100492. this.average += delta / (this._sampleCount);
  100493. this._m2 += delta * (v - this.average);
  100494. //set the new variance
  100495. this.variance = this._m2 / (this._sampleCount - 1);
  100496. this._samples[this._pos] = v;
  100497. this._pos++;
  100498. this._pos %= this._samples.length; //positive wrap around
  100499. };
  100500. /**
  100501. * Returns previously added values or null if outside of history or outside the sliding window domain
  100502. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  100503. * @return Value previously recorded with add() or null if outside of range
  100504. */
  100505. RollingAverage.prototype.history = function (i) {
  100506. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  100507. return 0;
  100508. }
  100509. var i0 = this._wrapPosition(this._pos - 1.0);
  100510. return this._samples[this._wrapPosition(i0 - i)];
  100511. };
  100512. /**
  100513. * Returns true if enough samples have been taken to completely fill the sliding window
  100514. * @return true if sample-set saturated
  100515. */
  100516. RollingAverage.prototype.isSaturated = function () {
  100517. return this._sampleCount >= this._samples.length;
  100518. };
  100519. /**
  100520. * Resets the rolling average (equivalent to 0 samples taken so far)
  100521. */
  100522. RollingAverage.prototype.reset = function () {
  100523. this.average = 0;
  100524. this.variance = 0;
  100525. this._sampleCount = 0;
  100526. this._pos = 0;
  100527. this._m2 = 0;
  100528. };
  100529. /**
  100530. * Wraps a value around the sample range boundaries
  100531. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  100532. * @return Wrapped position in sample range
  100533. */
  100534. RollingAverage.prototype._wrapPosition = function (i) {
  100535. var max = this._samples.length;
  100536. return ((i % max) + max) % max;
  100537. };
  100538. return RollingAverage;
  100539. }());
  100540. /***/ }),
  100541. /***/ "./Misc/pivotTools.ts":
  100542. /*!****************************!*\
  100543. !*** ./Misc/pivotTools.ts ***!
  100544. \****************************/
  100545. /*! exports provided: PivotTools */
  100546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100547. "use strict";
  100548. __webpack_require__.r(__webpack_exports__);
  100549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  100550. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100551. /**
  100552. * Class containing a set of static utilities functions for managing Pivots
  100553. * @hidden
  100554. */
  100555. var PivotTools = /** @class */ (function () {
  100556. function PivotTools() {
  100557. }
  100558. /** @hidden */
  100559. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  100560. if (mesh && PivotTools._PivotCached === 0) {
  100561. // Save old pivot and set pivot to 0,0,0
  100562. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  100563. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  100564. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  100565. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  100566. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  100567. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  100568. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  100569. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  100570. }
  100571. }
  100572. PivotTools._PivotCached++;
  100573. };
  100574. /** @hidden */
  100575. PivotTools._RestorePivotPoint = function (mesh) {
  100576. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  100577. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  100578. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  100579. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  100580. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  100581. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  100582. }
  100583. this._PivotCached--;
  100584. };
  100585. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  100586. // store/remove pivot point should only be applied during their outermost calls
  100587. PivotTools._PivotCached = 0;
  100588. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  100589. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  100590. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  100591. return PivotTools;
  100592. }());
  100593. /***/ }),
  100594. /***/ "./Misc/precisionDate.ts":
  100595. /*!*******************************!*\
  100596. !*** ./Misc/precisionDate.ts ***!
  100597. \*******************************/
  100598. /*! exports provided: PrecisionDate */
  100599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100600. "use strict";
  100601. __webpack_require__.r(__webpack_exports__);
  100602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  100603. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  100604. /**
  100605. * Class containing a set of static utilities functions for precision date
  100606. */
  100607. var PrecisionDate = /** @class */ (function () {
  100608. function PrecisionDate() {
  100609. }
  100610. Object.defineProperty(PrecisionDate, "Now", {
  100611. /**
  100612. * Gets either window.performance.now() if supported or Date.now() else
  100613. */
  100614. get: function () {
  100615. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  100616. return window.performance.now();
  100617. }
  100618. return Date.now();
  100619. },
  100620. enumerable: true,
  100621. configurable: true
  100622. });
  100623. return PrecisionDate;
  100624. }());
  100625. /***/ }),
  100626. /***/ "./Misc/promise.ts":
  100627. /*!*************************!*\
  100628. !*** ./Misc/promise.ts ***!
  100629. \*************************/
  100630. /*! exports provided: PromisePolyfill */
  100631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100632. "use strict";
  100633. __webpack_require__.r(__webpack_exports__);
  100634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  100635. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100636. var PromiseStates;
  100637. (function (PromiseStates) {
  100638. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  100639. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  100640. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  100641. })(PromiseStates || (PromiseStates = {}));
  100642. var FulFillmentAgregator = /** @class */ (function () {
  100643. function FulFillmentAgregator() {
  100644. this.count = 0;
  100645. this.target = 0;
  100646. this.results = [];
  100647. }
  100648. return FulFillmentAgregator;
  100649. }());
  100650. var InternalPromise = /** @class */ (function () {
  100651. function InternalPromise(resolver) {
  100652. var _this = this;
  100653. this._state = PromiseStates.Pending;
  100654. this._children = new Array();
  100655. this._rejectWasConsumed = false;
  100656. if (!resolver) {
  100657. return;
  100658. }
  100659. try {
  100660. resolver(function (value) {
  100661. _this._resolve(value);
  100662. }, function (reason) {
  100663. _this._reject(reason);
  100664. });
  100665. }
  100666. catch (e) {
  100667. this._reject(e);
  100668. }
  100669. }
  100670. Object.defineProperty(InternalPromise.prototype, "_result", {
  100671. get: function () {
  100672. return this._resultValue;
  100673. },
  100674. set: function (value) {
  100675. this._resultValue = value;
  100676. if (this._parent && this._parent._result === undefined) {
  100677. this._parent._result = value;
  100678. }
  100679. },
  100680. enumerable: true,
  100681. configurable: true
  100682. });
  100683. InternalPromise.prototype.catch = function (onRejected) {
  100684. return this.then(undefined, onRejected);
  100685. };
  100686. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  100687. var _this = this;
  100688. var newPromise = new InternalPromise();
  100689. newPromise._onFulfilled = onFulfilled;
  100690. newPromise._onRejected = onRejected;
  100691. // Composition
  100692. this._children.push(newPromise);
  100693. newPromise._parent = this;
  100694. if (this._state !== PromiseStates.Pending) {
  100695. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  100696. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  100697. var returnedValue = newPromise._resolve(_this._result);
  100698. if (returnedValue !== undefined && returnedValue !== null) {
  100699. if (returnedValue._state !== undefined) {
  100700. var returnedPromise = returnedValue;
  100701. newPromise._children.push(returnedPromise);
  100702. returnedPromise._parent = newPromise;
  100703. newPromise = returnedPromise;
  100704. }
  100705. else {
  100706. newPromise._result = returnedValue;
  100707. }
  100708. }
  100709. }
  100710. else {
  100711. newPromise._reject(_this._reason);
  100712. }
  100713. });
  100714. }
  100715. return newPromise;
  100716. };
  100717. InternalPromise.prototype._moveChildren = function (children) {
  100718. var _this = this;
  100719. var _a;
  100720. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  100721. this._children.forEach(function (child) {
  100722. child._parent = _this;
  100723. });
  100724. if (this._state === PromiseStates.Fulfilled) {
  100725. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  100726. var child = _b[_i];
  100727. child._resolve(this._result);
  100728. }
  100729. }
  100730. else if (this._state === PromiseStates.Rejected) {
  100731. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  100732. var child = _d[_c];
  100733. child._reject(this._reason);
  100734. }
  100735. }
  100736. };
  100737. InternalPromise.prototype._resolve = function (value) {
  100738. try {
  100739. this._state = PromiseStates.Fulfilled;
  100740. var returnedValue = null;
  100741. if (this._onFulfilled) {
  100742. returnedValue = this._onFulfilled(value);
  100743. }
  100744. if (returnedValue !== undefined && returnedValue !== null) {
  100745. if (returnedValue._state !== undefined) {
  100746. // Transmit children
  100747. var returnedPromise = returnedValue;
  100748. returnedPromise._parent = this;
  100749. returnedPromise._moveChildren(this._children);
  100750. value = returnedPromise._result;
  100751. }
  100752. else {
  100753. value = returnedValue;
  100754. }
  100755. }
  100756. this._result = value;
  100757. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  100758. var child = _a[_i];
  100759. child._resolve(value);
  100760. }
  100761. this._children.length = 0;
  100762. delete this._onFulfilled;
  100763. delete this._onRejected;
  100764. }
  100765. catch (e) {
  100766. this._reject(e, true);
  100767. }
  100768. };
  100769. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  100770. if (onLocalThrow === void 0) { onLocalThrow = false; }
  100771. this._state = PromiseStates.Rejected;
  100772. this._reason = reason;
  100773. if (this._onRejected && !onLocalThrow) {
  100774. try {
  100775. this._onRejected(reason);
  100776. this._rejectWasConsumed = true;
  100777. }
  100778. catch (e) {
  100779. reason = e;
  100780. }
  100781. }
  100782. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  100783. var child = _a[_i];
  100784. if (this._rejectWasConsumed) {
  100785. child._resolve(null);
  100786. }
  100787. else {
  100788. child._reject(reason);
  100789. }
  100790. }
  100791. this._children.length = 0;
  100792. delete this._onFulfilled;
  100793. delete this._onRejected;
  100794. };
  100795. InternalPromise.resolve = function (value) {
  100796. var newPromise = new InternalPromise();
  100797. newPromise._resolve(value);
  100798. return newPromise;
  100799. };
  100800. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  100801. promise.then(function (value) {
  100802. agregator.results[index] = value;
  100803. agregator.count++;
  100804. if (agregator.count === agregator.target) {
  100805. agregator.rootPromise._resolve(agregator.results);
  100806. }
  100807. return null;
  100808. }, function (reason) {
  100809. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  100810. agregator.rootPromise._reject(reason);
  100811. }
  100812. });
  100813. };
  100814. InternalPromise.all = function (promises) {
  100815. var newPromise = new InternalPromise();
  100816. var agregator = new FulFillmentAgregator();
  100817. agregator.target = promises.length;
  100818. agregator.rootPromise = newPromise;
  100819. if (promises.length) {
  100820. for (var index = 0; index < promises.length; index++) {
  100821. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  100822. }
  100823. }
  100824. else {
  100825. newPromise._resolve([]);
  100826. }
  100827. return newPromise;
  100828. };
  100829. InternalPromise.race = function (promises) {
  100830. var newPromise = new InternalPromise();
  100831. if (promises.length) {
  100832. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  100833. var promise = promises_1[_i];
  100834. promise.then(function (value) {
  100835. if (newPromise) {
  100836. newPromise._resolve(value);
  100837. newPromise = null;
  100838. }
  100839. return null;
  100840. }, function (reason) {
  100841. if (newPromise) {
  100842. newPromise._reject(reason);
  100843. newPromise = null;
  100844. }
  100845. });
  100846. }
  100847. }
  100848. return newPromise;
  100849. };
  100850. return InternalPromise;
  100851. }());
  100852. /**
  100853. * Helper class that provides a small promise polyfill
  100854. */
  100855. var PromisePolyfill = /** @class */ (function () {
  100856. function PromisePolyfill() {
  100857. }
  100858. /**
  100859. * Static function used to check if the polyfill is required
  100860. * If this is the case then the function will inject the polyfill to window.Promise
  100861. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100862. */
  100863. PromisePolyfill.Apply = function (force) {
  100864. if (force === void 0) { force = false; }
  100865. if (force || typeof Promise === 'undefined') {
  100866. var root = window;
  100867. root.Promise = InternalPromise;
  100868. }
  100869. };
  100870. return PromisePolyfill;
  100871. }());
  100872. /***/ }),
  100873. /***/ "./Misc/sceneOptimizer.ts":
  100874. /*!********************************!*\
  100875. !*** ./Misc/sceneOptimizer.ts ***!
  100876. \********************************/
  100877. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  100878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100879. "use strict";
  100880. __webpack_require__.r(__webpack_exports__);
  100881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  100882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  100883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  100884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  100885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  100886. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  100887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  100888. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  100889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  100890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  100891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  100892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  100893. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100894. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100895. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  100896. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  100897. /**
  100898. * Defines the root class used to create scene optimization to use with SceneOptimizer
  100899. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100900. */
  100901. var SceneOptimization = /** @class */ (function () {
  100902. /**
  100903. * Creates the SceneOptimization object
  100904. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  100905. * @param desc defines the description associated with the optimization
  100906. */
  100907. function SceneOptimization(
  100908. /**
  100909. * Defines the priority of this optimization (0 by default which means first in the list)
  100910. */
  100911. priority) {
  100912. if (priority === void 0) { priority = 0; }
  100913. this.priority = priority;
  100914. }
  100915. /**
  100916. * Gets a string describing the action executed by the current optimization
  100917. * @returns description string
  100918. */
  100919. SceneOptimization.prototype.getDescription = function () {
  100920. return "";
  100921. };
  100922. /**
  100923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100924. * @param scene defines the current scene where to apply this optimization
  100925. * @param optimizer defines the current optimizer
  100926. * @returns true if everything that can be done was applied
  100927. */
  100928. SceneOptimization.prototype.apply = function (scene, optimizer) {
  100929. return true;
  100930. };
  100931. return SceneOptimization;
  100932. }());
  100933. /**
  100934. * Defines an optimization used to reduce the size of render target textures
  100935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100936. */
  100937. var TextureOptimization = /** @class */ (function (_super) {
  100938. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  100939. /**
  100940. * Creates the TextureOptimization object
  100941. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  100942. * @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
  100943. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  100944. */
  100945. function TextureOptimization(
  100946. /**
  100947. * Defines the priority of this optimization (0 by default which means first in the list)
  100948. */
  100949. priority,
  100950. /**
  100951. * 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
  100952. */
  100953. maximumSize,
  100954. /**
  100955. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  100956. */
  100957. step) {
  100958. if (priority === void 0) { priority = 0; }
  100959. if (maximumSize === void 0) { maximumSize = 1024; }
  100960. if (step === void 0) { step = 0.5; }
  100961. var _this = _super.call(this, priority) || this;
  100962. _this.priority = priority;
  100963. _this.maximumSize = maximumSize;
  100964. _this.step = step;
  100965. return _this;
  100966. }
  100967. /**
  100968. * Gets a string describing the action executed by the current optimization
  100969. * @returns description string
  100970. */
  100971. TextureOptimization.prototype.getDescription = function () {
  100972. return "Reducing render target texture size to " + this.maximumSize;
  100973. };
  100974. /**
  100975. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100976. * @param scene defines the current scene where to apply this optimization
  100977. * @param optimizer defines the current optimizer
  100978. * @returns true if everything that can be done was applied
  100979. */
  100980. TextureOptimization.prototype.apply = function (scene, optimizer) {
  100981. var allDone = true;
  100982. for (var index = 0; index < scene.textures.length; index++) {
  100983. var texture = scene.textures[index];
  100984. if (!texture.canRescale || texture.getContext) {
  100985. continue;
  100986. }
  100987. var currentSize = texture.getSize();
  100988. var maxDimension = Math.max(currentSize.width, currentSize.height);
  100989. if (maxDimension > this.maximumSize) {
  100990. texture.scale(this.step);
  100991. allDone = false;
  100992. }
  100993. }
  100994. return allDone;
  100995. };
  100996. return TextureOptimization;
  100997. }(SceneOptimization));
  100998. /**
  100999. * Defines an optimization used to increase or decrease the rendering resolution
  101000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101001. */
  101002. var HardwareScalingOptimization = /** @class */ (function (_super) {
  101003. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  101004. /**
  101005. * Creates the HardwareScalingOptimization object
  101006. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  101007. * @param maximumScale defines the maximum scale to use (2 by default)
  101008. * @param step defines the step to use between two passes (0.5 by default)
  101009. */
  101010. function HardwareScalingOptimization(
  101011. /**
  101012. * Defines the priority of this optimization (0 by default which means first in the list)
  101013. */
  101014. priority,
  101015. /**
  101016. * Defines the maximum scale to use (2 by default)
  101017. */
  101018. maximumScale,
  101019. /**
  101020. * Defines the step to use between two passes (0.5 by default)
  101021. */
  101022. step) {
  101023. if (priority === void 0) { priority = 0; }
  101024. if (maximumScale === void 0) { maximumScale = 2; }
  101025. if (step === void 0) { step = 0.25; }
  101026. var _this = _super.call(this, priority) || this;
  101027. _this.priority = priority;
  101028. _this.maximumScale = maximumScale;
  101029. _this.step = step;
  101030. _this._currentScale = -1;
  101031. _this._directionOffset = 1;
  101032. return _this;
  101033. }
  101034. /**
  101035. * Gets a string describing the action executed by the current optimization
  101036. * @return description string
  101037. */
  101038. HardwareScalingOptimization.prototype.getDescription = function () {
  101039. return "Setting hardware scaling level to " + this._currentScale;
  101040. };
  101041. /**
  101042. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  101043. * @param scene defines the current scene where to apply this optimization
  101044. * @param optimizer defines the current optimizer
  101045. * @returns true if everything that can be done was applied
  101046. */
  101047. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  101048. if (this._currentScale === -1) {
  101049. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  101050. if (this._currentScale > this.maximumScale) {
  101051. this._directionOffset = -1;
  101052. }
  101053. }
  101054. this._currentScale += this._directionOffset * this.step;
  101055. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  101056. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  101057. };
  101058. return HardwareScalingOptimization;
  101059. }(SceneOptimization));
  101060. /**
  101061. * Defines an optimization used to remove shadows
  101062. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101063. */
  101064. var ShadowsOptimization = /** @class */ (function (_super) {
  101065. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  101066. function ShadowsOptimization() {
  101067. return _super !== null && _super.apply(this, arguments) || this;
  101068. }
  101069. /**
  101070. * Gets a string describing the action executed by the current optimization
  101071. * @return description string
  101072. */
  101073. ShadowsOptimization.prototype.getDescription = function () {
  101074. return "Turning shadows on/off";
  101075. };
  101076. /**
  101077. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  101078. * @param scene defines the current scene where to apply this optimization
  101079. * @param optimizer defines the current optimizer
  101080. * @returns true if everything that can be done was applied
  101081. */
  101082. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  101083. scene.shadowsEnabled = optimizer.isInImprovementMode;
  101084. return true;
  101085. };
  101086. return ShadowsOptimization;
  101087. }(SceneOptimization));
  101088. /**
  101089. * Defines an optimization used to turn post-processes off
  101090. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101091. */
  101092. var PostProcessesOptimization = /** @class */ (function (_super) {
  101093. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  101094. function PostProcessesOptimization() {
  101095. return _super !== null && _super.apply(this, arguments) || this;
  101096. }
  101097. /**
  101098. * Gets a string describing the action executed by the current optimization
  101099. * @return description string
  101100. */
  101101. PostProcessesOptimization.prototype.getDescription = function () {
  101102. return "Turning post-processes on/off";
  101103. };
  101104. /**
  101105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  101106. * @param scene defines the current scene where to apply this optimization
  101107. * @param optimizer defines the current optimizer
  101108. * @returns true if everything that can be done was applied
  101109. */
  101110. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  101111. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  101112. return true;
  101113. };
  101114. return PostProcessesOptimization;
  101115. }(SceneOptimization));
  101116. /**
  101117. * Defines an optimization used to turn lens flares off
  101118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101119. */
  101120. var LensFlaresOptimization = /** @class */ (function (_super) {
  101121. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  101122. function LensFlaresOptimization() {
  101123. return _super !== null && _super.apply(this, arguments) || this;
  101124. }
  101125. /**
  101126. * Gets a string describing the action executed by the current optimization
  101127. * @return description string
  101128. */
  101129. LensFlaresOptimization.prototype.getDescription = function () {
  101130. return "Turning lens flares on/off";
  101131. };
  101132. /**
  101133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  101134. * @param scene defines the current scene where to apply this optimization
  101135. * @param optimizer defines the current optimizer
  101136. * @returns true if everything that can be done was applied
  101137. */
  101138. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  101139. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  101140. return true;
  101141. };
  101142. return LensFlaresOptimization;
  101143. }(SceneOptimization));
  101144. /**
  101145. * Defines an optimization based on user defined callback.
  101146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101147. */
  101148. var CustomOptimization = /** @class */ (function (_super) {
  101149. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  101150. function CustomOptimization() {
  101151. return _super !== null && _super.apply(this, arguments) || this;
  101152. }
  101153. /**
  101154. * Gets a string describing the action executed by the current optimization
  101155. * @returns description string
  101156. */
  101157. CustomOptimization.prototype.getDescription = function () {
  101158. if (this.onGetDescription) {
  101159. return this.onGetDescription();
  101160. }
  101161. return "Running user defined callback";
  101162. };
  101163. /**
  101164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  101165. * @param scene defines the current scene where to apply this optimization
  101166. * @param optimizer defines the current optimizer
  101167. * @returns true if everything that can be done was applied
  101168. */
  101169. CustomOptimization.prototype.apply = function (scene, optimizer) {
  101170. if (this.onApply) {
  101171. return this.onApply(scene, optimizer);
  101172. }
  101173. return true;
  101174. };
  101175. return CustomOptimization;
  101176. }(SceneOptimization));
  101177. /**
  101178. * Defines an optimization used to turn particles off
  101179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101180. */
  101181. var ParticlesOptimization = /** @class */ (function (_super) {
  101182. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  101183. function ParticlesOptimization() {
  101184. return _super !== null && _super.apply(this, arguments) || this;
  101185. }
  101186. /**
  101187. * Gets a string describing the action executed by the current optimization
  101188. * @return description string
  101189. */
  101190. ParticlesOptimization.prototype.getDescription = function () {
  101191. return "Turning particles on/off";
  101192. };
  101193. /**
  101194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  101195. * @param scene defines the current scene where to apply this optimization
  101196. * @param optimizer defines the current optimizer
  101197. * @returns true if everything that can be done was applied
  101198. */
  101199. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  101200. scene.particlesEnabled = optimizer.isInImprovementMode;
  101201. return true;
  101202. };
  101203. return ParticlesOptimization;
  101204. }(SceneOptimization));
  101205. /**
  101206. * Defines an optimization used to turn render targets off
  101207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101208. */
  101209. var RenderTargetsOptimization = /** @class */ (function (_super) {
  101210. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  101211. function RenderTargetsOptimization() {
  101212. return _super !== null && _super.apply(this, arguments) || this;
  101213. }
  101214. /**
  101215. * Gets a string describing the action executed by the current optimization
  101216. * @return description string
  101217. */
  101218. RenderTargetsOptimization.prototype.getDescription = function () {
  101219. return "Turning render targets off";
  101220. };
  101221. /**
  101222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  101223. * @param scene defines the current scene where to apply this optimization
  101224. * @param optimizer defines the current optimizer
  101225. * @returns true if everything that can be done was applied
  101226. */
  101227. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  101228. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  101229. return true;
  101230. };
  101231. return RenderTargetsOptimization;
  101232. }(SceneOptimization));
  101233. /**
  101234. * Defines an optimization used to merge meshes with compatible materials
  101235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101236. */
  101237. var MergeMeshesOptimization = /** @class */ (function (_super) {
  101238. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  101239. function MergeMeshesOptimization() {
  101240. var _this = _super !== null && _super.apply(this, arguments) || this;
  101241. _this._canBeMerged = function (abstractMesh) {
  101242. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  101243. return false;
  101244. }
  101245. var mesh = abstractMesh;
  101246. if (mesh.isDisposed()) {
  101247. return false;
  101248. }
  101249. if (!mesh.isVisible || !mesh.isEnabled()) {
  101250. return false;
  101251. }
  101252. if (mesh.instances.length > 0) {
  101253. return false;
  101254. }
  101255. if (mesh.skeleton || mesh.hasLODLevels) {
  101256. return false;
  101257. }
  101258. return true;
  101259. };
  101260. return _this;
  101261. }
  101262. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  101263. /**
  101264. * Gets or sets a boolean which defines if optimization octree has to be updated
  101265. */
  101266. get: function () {
  101267. return MergeMeshesOptimization._UpdateSelectionTree;
  101268. },
  101269. /**
  101270. * Gets or sets a boolean which defines if optimization octree has to be updated
  101271. */
  101272. set: function (value) {
  101273. MergeMeshesOptimization._UpdateSelectionTree = value;
  101274. },
  101275. enumerable: true,
  101276. configurable: true
  101277. });
  101278. /**
  101279. * Gets a string describing the action executed by the current optimization
  101280. * @return description string
  101281. */
  101282. MergeMeshesOptimization.prototype.getDescription = function () {
  101283. return "Merging similar meshes together";
  101284. };
  101285. /**
  101286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  101287. * @param scene defines the current scene where to apply this optimization
  101288. * @param optimizer defines the current optimizer
  101289. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  101290. * @returns true if everything that can be done was applied
  101291. */
  101292. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  101293. var globalPool = scene.meshes.slice(0);
  101294. var globalLength = globalPool.length;
  101295. for (var index = 0; index < globalLength; index++) {
  101296. var currentPool = new Array();
  101297. var current = globalPool[index];
  101298. // Checks
  101299. if (!this._canBeMerged(current)) {
  101300. continue;
  101301. }
  101302. currentPool.push(current);
  101303. // Find compatible meshes
  101304. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  101305. var otherMesh = globalPool[subIndex];
  101306. if (!this._canBeMerged(otherMesh)) {
  101307. continue;
  101308. }
  101309. if (otherMesh.material !== current.material) {
  101310. continue;
  101311. }
  101312. if (otherMesh.checkCollisions !== current.checkCollisions) {
  101313. continue;
  101314. }
  101315. currentPool.push(otherMesh);
  101316. globalLength--;
  101317. globalPool.splice(subIndex, 1);
  101318. subIndex--;
  101319. }
  101320. if (currentPool.length < 2) {
  101321. continue;
  101322. }
  101323. // Merge meshes
  101324. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  101325. }
  101326. // Call the octree system optimization if it is defined.
  101327. var sceneAsAny = scene;
  101328. if (sceneAsAny.createOrUpdateSelectionOctree) {
  101329. if (updateSelectionTree != undefined) {
  101330. if (updateSelectionTree) {
  101331. sceneAsAny.createOrUpdateSelectionOctree();
  101332. }
  101333. }
  101334. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  101335. sceneAsAny.createOrUpdateSelectionOctree();
  101336. }
  101337. }
  101338. return true;
  101339. };
  101340. MergeMeshesOptimization._UpdateSelectionTree = false;
  101341. return MergeMeshesOptimization;
  101342. }(SceneOptimization));
  101343. /**
  101344. * Defines a list of options used by SceneOptimizer
  101345. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101346. */
  101347. var SceneOptimizerOptions = /** @class */ (function () {
  101348. /**
  101349. * Creates a new list of options used by SceneOptimizer
  101350. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  101351. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  101352. */
  101353. function SceneOptimizerOptions(
  101354. /**
  101355. * Defines the target frame rate to reach (60 by default)
  101356. */
  101357. targetFrameRate,
  101358. /**
  101359. * Defines the interval between two checkes (2000ms by default)
  101360. */
  101361. trackerDuration) {
  101362. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  101363. if (trackerDuration === void 0) { trackerDuration = 2000; }
  101364. this.targetFrameRate = targetFrameRate;
  101365. this.trackerDuration = trackerDuration;
  101366. /**
  101367. * Gets the list of optimizations to apply
  101368. */
  101369. this.optimizations = new Array();
  101370. }
  101371. /**
  101372. * Add a new optimization
  101373. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  101374. * @returns the current SceneOptimizerOptions
  101375. */
  101376. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  101377. this.optimizations.push(optimization);
  101378. return this;
  101379. };
  101380. /**
  101381. * Add a new custom optimization
  101382. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  101383. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  101384. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  101385. * @returns the current SceneOptimizerOptions
  101386. */
  101387. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  101388. if (priority === void 0) { priority = 0; }
  101389. var optimization = new CustomOptimization(priority);
  101390. optimization.onApply = onApply;
  101391. optimization.onGetDescription = onGetDescription;
  101392. this.optimizations.push(optimization);
  101393. return this;
  101394. };
  101395. /**
  101396. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  101397. * @param targetFrameRate defines the target frame rate (60 by default)
  101398. * @returns a SceneOptimizerOptions object
  101399. */
  101400. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  101401. var result = new SceneOptimizerOptions(targetFrameRate);
  101402. var priority = 0;
  101403. result.addOptimization(new MergeMeshesOptimization(priority));
  101404. result.addOptimization(new ShadowsOptimization(priority));
  101405. result.addOptimization(new LensFlaresOptimization(priority));
  101406. // Next priority
  101407. priority++;
  101408. result.addOptimization(new PostProcessesOptimization(priority));
  101409. result.addOptimization(new ParticlesOptimization(priority));
  101410. // Next priority
  101411. priority++;
  101412. result.addOptimization(new TextureOptimization(priority, 1024));
  101413. return result;
  101414. };
  101415. /**
  101416. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  101417. * @param targetFrameRate defines the target frame rate (60 by default)
  101418. * @returns a SceneOptimizerOptions object
  101419. */
  101420. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  101421. var result = new SceneOptimizerOptions(targetFrameRate);
  101422. var priority = 0;
  101423. result.addOptimization(new MergeMeshesOptimization(priority));
  101424. result.addOptimization(new ShadowsOptimization(priority));
  101425. result.addOptimization(new LensFlaresOptimization(priority));
  101426. // Next priority
  101427. priority++;
  101428. result.addOptimization(new PostProcessesOptimization(priority));
  101429. result.addOptimization(new ParticlesOptimization(priority));
  101430. // Next priority
  101431. priority++;
  101432. result.addOptimization(new TextureOptimization(priority, 512));
  101433. // Next priority
  101434. priority++;
  101435. result.addOptimization(new RenderTargetsOptimization(priority));
  101436. // Next priority
  101437. priority++;
  101438. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  101439. return result;
  101440. };
  101441. /**
  101442. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  101443. * @param targetFrameRate defines the target frame rate (60 by default)
  101444. * @returns a SceneOptimizerOptions object
  101445. */
  101446. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  101447. var result = new SceneOptimizerOptions(targetFrameRate);
  101448. var priority = 0;
  101449. result.addOptimization(new MergeMeshesOptimization(priority));
  101450. result.addOptimization(new ShadowsOptimization(priority));
  101451. result.addOptimization(new LensFlaresOptimization(priority));
  101452. // Next priority
  101453. priority++;
  101454. result.addOptimization(new PostProcessesOptimization(priority));
  101455. result.addOptimization(new ParticlesOptimization(priority));
  101456. // Next priority
  101457. priority++;
  101458. result.addOptimization(new TextureOptimization(priority, 256));
  101459. // Next priority
  101460. priority++;
  101461. result.addOptimization(new RenderTargetsOptimization(priority));
  101462. // Next priority
  101463. priority++;
  101464. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  101465. return result;
  101466. };
  101467. return SceneOptimizerOptions;
  101468. }());
  101469. /**
  101470. * Class used to run optimizations in order to reach a target frame rate
  101471. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101472. */
  101473. var SceneOptimizer = /** @class */ (function () {
  101474. /**
  101475. * Creates a new SceneOptimizer
  101476. * @param scene defines the scene to work on
  101477. * @param options defines the options to use with the SceneOptimizer
  101478. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  101479. * @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)
  101480. */
  101481. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  101482. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  101483. if (improvementMode === void 0) { improvementMode = false; }
  101484. var _this = this;
  101485. this._isRunning = false;
  101486. this._currentPriorityLevel = 0;
  101487. this._targetFrameRate = 60;
  101488. this._trackerDuration = 2000;
  101489. this._currentFrameRate = 0;
  101490. this._improvementMode = false;
  101491. /**
  101492. * Defines an observable called when the optimizer reaches the target frame rate
  101493. */
  101494. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  101495. /**
  101496. * Defines an observable called when the optimizer enables an optimization
  101497. */
  101498. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  101499. /**
  101500. * Defines an observable called when the optimizer is not able to reach the target frame rate
  101501. */
  101502. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  101503. if (!options) {
  101504. this._options = new SceneOptimizerOptions();
  101505. }
  101506. else {
  101507. this._options = options;
  101508. }
  101509. if (this._options.targetFrameRate) {
  101510. this._targetFrameRate = this._options.targetFrameRate;
  101511. }
  101512. if (this._options.trackerDuration) {
  101513. this._trackerDuration = this._options.trackerDuration;
  101514. }
  101515. if (autoGeneratePriorities) {
  101516. var priority = 0;
  101517. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  101518. var optim = _a[_i];
  101519. optim.priority = priority++;
  101520. }
  101521. }
  101522. this._improvementMode = improvementMode;
  101523. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  101524. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  101525. _this._sceneDisposeObserver = null;
  101526. _this.dispose();
  101527. });
  101528. }
  101529. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  101530. /**
  101531. * Gets a boolean indicating if the optimizer is in improvement mode
  101532. */
  101533. get: function () {
  101534. return this._improvementMode;
  101535. },
  101536. enumerable: true,
  101537. configurable: true
  101538. });
  101539. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  101540. /**
  101541. * Gets the current priority level (0 at start)
  101542. */
  101543. get: function () {
  101544. return this._currentPriorityLevel;
  101545. },
  101546. enumerable: true,
  101547. configurable: true
  101548. });
  101549. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  101550. /**
  101551. * Gets the current frame rate checked by the SceneOptimizer
  101552. */
  101553. get: function () {
  101554. return this._currentFrameRate;
  101555. },
  101556. enumerable: true,
  101557. configurable: true
  101558. });
  101559. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  101560. /**
  101561. * Gets or sets the current target frame rate (60 by default)
  101562. */
  101563. get: function () {
  101564. return this._targetFrameRate;
  101565. },
  101566. /**
  101567. * Gets or sets the current target frame rate (60 by default)
  101568. */
  101569. set: function (value) {
  101570. this._targetFrameRate = value;
  101571. },
  101572. enumerable: true,
  101573. configurable: true
  101574. });
  101575. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  101576. /**
  101577. * Gets or sets the current interval between two checks (every 2000ms by default)
  101578. */
  101579. get: function () {
  101580. return this._trackerDuration;
  101581. },
  101582. /**
  101583. * Gets or sets the current interval between two checks (every 2000ms by default)
  101584. */
  101585. set: function (value) {
  101586. this._trackerDuration = value;
  101587. },
  101588. enumerable: true,
  101589. configurable: true
  101590. });
  101591. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  101592. /**
  101593. * Gets the list of active optimizations
  101594. */
  101595. get: function () {
  101596. return this._options.optimizations;
  101597. },
  101598. enumerable: true,
  101599. configurable: true
  101600. });
  101601. /**
  101602. * Stops the current optimizer
  101603. */
  101604. SceneOptimizer.prototype.stop = function () {
  101605. this._isRunning = false;
  101606. };
  101607. /**
  101608. * Reset the optimizer to initial step (current priority level = 0)
  101609. */
  101610. SceneOptimizer.prototype.reset = function () {
  101611. this._currentPriorityLevel = 0;
  101612. };
  101613. /**
  101614. * Start the optimizer. By default it will try to reach a specific framerate
  101615. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  101616. */
  101617. SceneOptimizer.prototype.start = function () {
  101618. var _this = this;
  101619. if (this._isRunning) {
  101620. return;
  101621. }
  101622. this._isRunning = true;
  101623. // Let's wait for the scene to be ready before running our check
  101624. this._scene.executeWhenReady(function () {
  101625. setTimeout(function () {
  101626. _this._checkCurrentState();
  101627. }, _this._trackerDuration);
  101628. });
  101629. };
  101630. SceneOptimizer.prototype._checkCurrentState = function () {
  101631. var _this = this;
  101632. if (!this._isRunning) {
  101633. return;
  101634. }
  101635. var scene = this._scene;
  101636. var options = this._options;
  101637. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  101638. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  101639. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  101640. this._isRunning = false;
  101641. this.onSuccessObservable.notifyObservers(this);
  101642. return;
  101643. }
  101644. // Apply current level of optimizations
  101645. var allDone = true;
  101646. var noOptimizationApplied = true;
  101647. for (var index = 0; index < options.optimizations.length; index++) {
  101648. var optimization = options.optimizations[index];
  101649. if (optimization.priority === this._currentPriorityLevel) {
  101650. noOptimizationApplied = false;
  101651. allDone = allDone && optimization.apply(scene, this);
  101652. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  101653. }
  101654. }
  101655. // If no optimization was applied, this is a failure :(
  101656. if (noOptimizationApplied) {
  101657. this._isRunning = false;
  101658. this.onFailureObservable.notifyObservers(this);
  101659. return;
  101660. }
  101661. // If all optimizations were done, move to next level
  101662. if (allDone) {
  101663. this._currentPriorityLevel++;
  101664. }
  101665. // Let's the system running for a specific amount of time before checking FPS
  101666. scene.executeWhenReady(function () {
  101667. setTimeout(function () {
  101668. _this._checkCurrentState();
  101669. }, _this._trackerDuration);
  101670. });
  101671. };
  101672. /**
  101673. * Release all resources
  101674. */
  101675. SceneOptimizer.prototype.dispose = function () {
  101676. this.stop();
  101677. this.onSuccessObservable.clear();
  101678. this.onFailureObservable.clear();
  101679. this.onNewOptimizationAppliedObservable.clear();
  101680. if (this._sceneDisposeObserver) {
  101681. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  101682. }
  101683. };
  101684. /**
  101685. * Helper function to create a SceneOptimizer with one single line of code
  101686. * @param scene defines the scene to work on
  101687. * @param options defines the options to use with the SceneOptimizer
  101688. * @param onSuccess defines a callback to call on success
  101689. * @param onFailure defines a callback to call on failure
  101690. * @returns the new SceneOptimizer object
  101691. */
  101692. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  101693. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  101694. if (onSuccess) {
  101695. optimizer.onSuccessObservable.add(function () {
  101696. onSuccess();
  101697. });
  101698. }
  101699. if (onFailure) {
  101700. optimizer.onFailureObservable.add(function () {
  101701. onFailure();
  101702. });
  101703. }
  101704. optimizer.start();
  101705. return optimizer;
  101706. };
  101707. return SceneOptimizer;
  101708. }());
  101709. /***/ }),
  101710. /***/ "./Misc/sceneSerializer.ts":
  101711. /*!*********************************!*\
  101712. !*** ./Misc/sceneSerializer.ts ***!
  101713. \*********************************/
  101714. /*! exports provided: SceneSerializer */
  101715. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101716. "use strict";
  101717. __webpack_require__.r(__webpack_exports__);
  101718. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  101719. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  101720. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101721. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  101722. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  101723. var serializedGeometries = [];
  101724. var serializeGeometry = function (geometry, serializationGeometries) {
  101725. if (serializedGeometries[geometry.id]) {
  101726. return;
  101727. }
  101728. if (geometry.doNotSerialize) {
  101729. return;
  101730. }
  101731. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  101732. serializedGeometries[geometry.id] = true;
  101733. };
  101734. var serializeMesh = function (mesh, serializationScene) {
  101735. var serializationObject = {};
  101736. // Geometry
  101737. var geometry = mesh._geometry;
  101738. if (geometry) {
  101739. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  101740. // 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
  101741. serializeGeometry(geometry, serializationScene.geometries);
  101742. }
  101743. }
  101744. // Custom
  101745. if (mesh.serialize) {
  101746. mesh.serialize(serializationObject);
  101747. }
  101748. return serializationObject;
  101749. };
  101750. var finalizeSingleMesh = function (mesh, serializationObject) {
  101751. //only works if the mesh is already loaded
  101752. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  101753. //serialize material
  101754. if (mesh.material) {
  101755. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  101756. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  101757. serializationObject.materials = serializationObject.materials || [];
  101758. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  101759. serializationObject.multiMaterials.push(mesh.material.serialize());
  101760. var _loop_1 = function (submaterial) {
  101761. if (submaterial) {
  101762. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  101763. serializationObject.materials.push(submaterial.serialize());
  101764. }
  101765. }
  101766. };
  101767. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  101768. var submaterial = _a[_i];
  101769. _loop_1(submaterial);
  101770. }
  101771. }
  101772. }
  101773. else {
  101774. serializationObject.materials = serializationObject.materials || [];
  101775. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  101776. serializationObject.materials.push(mesh.material.serialize());
  101777. }
  101778. }
  101779. }
  101780. //serialize geometry
  101781. var geometry = mesh._geometry;
  101782. if (geometry) {
  101783. if (!serializationObject.geometries) {
  101784. serializationObject.geometries = {};
  101785. serializationObject.geometries.boxes = [];
  101786. serializationObject.geometries.spheres = [];
  101787. serializationObject.geometries.cylinders = [];
  101788. serializationObject.geometries.toruses = [];
  101789. serializationObject.geometries.grounds = [];
  101790. serializationObject.geometries.planes = [];
  101791. serializationObject.geometries.torusKnots = [];
  101792. serializationObject.geometries.vertexData = [];
  101793. }
  101794. serializeGeometry(geometry, serializationObject.geometries);
  101795. }
  101796. // Skeletons
  101797. if (mesh.skeleton) {
  101798. serializationObject.skeletons = serializationObject.skeletons || [];
  101799. serializationObject.skeletons.push(mesh.skeleton.serialize());
  101800. }
  101801. //serialize the actual mesh
  101802. serializationObject.meshes = serializationObject.meshes || [];
  101803. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  101804. }
  101805. };
  101806. /**
  101807. * Class used to serialize a scene into a string
  101808. */
  101809. var SceneSerializer = /** @class */ (function () {
  101810. function SceneSerializer() {
  101811. }
  101812. /**
  101813. * Clear cache used by a previous serialization
  101814. */
  101815. SceneSerializer.ClearCache = function () {
  101816. serializedGeometries = [];
  101817. };
  101818. /**
  101819. * Serialize a scene into a JSON compatible object
  101820. * @param scene defines the scene to serialize
  101821. * @returns a JSON compatible object
  101822. */
  101823. SceneSerializer.Serialize = function (scene) {
  101824. var serializationObject = {};
  101825. SceneSerializer.ClearCache();
  101826. // Scene
  101827. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  101828. serializationObject.autoClear = scene.autoClear;
  101829. serializationObject.clearColor = scene.clearColor.asArray();
  101830. serializationObject.ambientColor = scene.ambientColor.asArray();
  101831. serializationObject.gravity = scene.gravity.asArray();
  101832. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  101833. // Fog
  101834. if (scene.fogMode && scene.fogMode !== 0) {
  101835. serializationObject.fogMode = scene.fogMode;
  101836. serializationObject.fogColor = scene.fogColor.asArray();
  101837. serializationObject.fogStart = scene.fogStart;
  101838. serializationObject.fogEnd = scene.fogEnd;
  101839. serializationObject.fogDensity = scene.fogDensity;
  101840. }
  101841. //Physics
  101842. if (scene.isPhysicsEnabled()) {
  101843. var physicEngine = scene.getPhysicsEngine();
  101844. if (physicEngine) {
  101845. serializationObject.physicsEnabled = true;
  101846. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  101847. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  101848. }
  101849. }
  101850. // Metadata
  101851. if (scene.metadata) {
  101852. serializationObject.metadata = scene.metadata;
  101853. }
  101854. // Morph targets
  101855. serializationObject.morphTargetManagers = [];
  101856. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  101857. var abstractMesh = _a[_i];
  101858. var manager = abstractMesh.morphTargetManager;
  101859. if (manager) {
  101860. serializationObject.morphTargetManagers.push(manager.serialize());
  101861. }
  101862. }
  101863. // Lights
  101864. serializationObject.lights = [];
  101865. var index;
  101866. var light;
  101867. for (index = 0; index < scene.lights.length; index++) {
  101868. light = scene.lights[index];
  101869. if (!light.doNotSerialize) {
  101870. serializationObject.lights.push(light.serialize());
  101871. }
  101872. }
  101873. // Cameras
  101874. serializationObject.cameras = [];
  101875. for (index = 0; index < scene.cameras.length; index++) {
  101876. var camera = scene.cameras[index];
  101877. if (!camera.doNotSerialize) {
  101878. serializationObject.cameras.push(camera.serialize());
  101879. }
  101880. }
  101881. if (scene.activeCamera) {
  101882. serializationObject.activeCameraID = scene.activeCamera.id;
  101883. }
  101884. // Animations
  101885. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  101886. // Reflection probes
  101887. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  101888. serializationObject.reflectionProbes = [];
  101889. for (index = 0; index < scene.reflectionProbes.length; index++) {
  101890. var reflectionProbe = scene.reflectionProbes[index];
  101891. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  101892. }
  101893. }
  101894. // Materials
  101895. serializationObject.materials = [];
  101896. serializationObject.multiMaterials = [];
  101897. var material;
  101898. for (index = 0; index < scene.materials.length; index++) {
  101899. material = scene.materials[index];
  101900. if (!material.doNotSerialize) {
  101901. serializationObject.materials.push(material.serialize());
  101902. }
  101903. }
  101904. // MultiMaterials
  101905. serializationObject.multiMaterials = [];
  101906. for (index = 0; index < scene.multiMaterials.length; index++) {
  101907. var multiMaterial = scene.multiMaterials[index];
  101908. serializationObject.multiMaterials.push(multiMaterial.serialize());
  101909. }
  101910. // Environment texture
  101911. if (scene.environmentTexture) {
  101912. serializationObject.environmentTexture = scene.environmentTexture.name;
  101913. }
  101914. // Skeletons
  101915. serializationObject.skeletons = [];
  101916. for (index = 0; index < scene.skeletons.length; index++) {
  101917. var skeleton = scene.skeletons[index];
  101918. if (!skeleton.doNotSerialize) {
  101919. serializationObject.skeletons.push(skeleton.serialize());
  101920. }
  101921. }
  101922. // Transform nodes
  101923. serializationObject.transformNodes = [];
  101924. for (index = 0; index < scene.transformNodes.length; index++) {
  101925. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  101926. }
  101927. // Geometries
  101928. serializationObject.geometries = {};
  101929. serializationObject.geometries.boxes = [];
  101930. serializationObject.geometries.spheres = [];
  101931. serializationObject.geometries.cylinders = [];
  101932. serializationObject.geometries.toruses = [];
  101933. serializationObject.geometries.grounds = [];
  101934. serializationObject.geometries.planes = [];
  101935. serializationObject.geometries.torusKnots = [];
  101936. serializationObject.geometries.vertexData = [];
  101937. serializedGeometries = [];
  101938. var geometries = scene.getGeometries();
  101939. for (index = 0; index < geometries.length; index++) {
  101940. var geometry = geometries[index];
  101941. if (geometry.isReady()) {
  101942. serializeGeometry(geometry, serializationObject.geometries);
  101943. }
  101944. }
  101945. // Meshes
  101946. serializationObject.meshes = [];
  101947. for (index = 0; index < scene.meshes.length; index++) {
  101948. var abstractMesh = scene.meshes[index];
  101949. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  101950. var mesh = abstractMesh;
  101951. if (!mesh.doNotSerialize) {
  101952. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  101953. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  101954. }
  101955. }
  101956. }
  101957. }
  101958. // Particles Systems
  101959. serializationObject.particleSystems = [];
  101960. for (index = 0; index < scene.particleSystems.length; index++) {
  101961. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  101962. }
  101963. // Action Manager
  101964. if (scene.actionManager) {
  101965. serializationObject.actions = scene.actionManager.serialize("scene");
  101966. }
  101967. // Components
  101968. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  101969. var component = _c[_b];
  101970. component.serialize(serializationObject);
  101971. }
  101972. return serializationObject;
  101973. };
  101974. /**
  101975. * Serialize a mesh into a JSON compatible object
  101976. * @param toSerialize defines the mesh to serialize
  101977. * @param withParents defines if parents must be serialized as well
  101978. * @param withChildren defines if children must be serialized as well
  101979. * @returns a JSON compatible object
  101980. */
  101981. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  101982. if (withParents === void 0) { withParents = false; }
  101983. if (withChildren === void 0) { withChildren = false; }
  101984. var serializationObject = {};
  101985. SceneSerializer.ClearCache();
  101986. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  101987. if (withParents || withChildren) {
  101988. //deliberate for loop! not for each, appended should be processed as well.
  101989. for (var i = 0; i < toSerialize.length; ++i) {
  101990. if (withChildren) {
  101991. toSerialize[i].getDescendants().forEach(function (node) {
  101992. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  101993. toSerialize.push(node);
  101994. }
  101995. });
  101996. }
  101997. //make sure the array doesn't contain the object already
  101998. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  101999. toSerialize.push(toSerialize[i].parent);
  102000. }
  102001. }
  102002. }
  102003. toSerialize.forEach(function (mesh) {
  102004. finalizeSingleMesh(mesh, serializationObject);
  102005. });
  102006. return serializationObject;
  102007. };
  102008. return SceneSerializer;
  102009. }());
  102010. /***/ }),
  102011. /***/ "./Misc/screenshotTools.ts":
  102012. /*!*********************************!*\
  102013. !*** ./Misc/screenshotTools.ts ***!
  102014. \*********************************/
  102015. /*! exports provided: ScreenshotTools */
  102016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102017. "use strict";
  102018. __webpack_require__.r(__webpack_exports__);
  102019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  102020. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  102021. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  102022. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  102023. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102024. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  102025. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  102026. /**
  102027. * Class containing a set of static utilities functions for screenshots
  102028. */
  102029. var ScreenshotTools = /** @class */ (function () {
  102030. function ScreenshotTools() {
  102031. }
  102032. /**
  102033. * Captures a screenshot of the current rendering
  102034. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102035. * @param engine defines the rendering engine
  102036. * @param camera defines the source camera
  102037. * @param size This parameter can be set to a single number or to an object with the
  102038. * following (optional) properties: precision, width, height. If a single number is passed,
  102039. * it will be used for both width and height. If an object is passed, the screenshot size
  102040. * will be derived from the parameters. The precision property is a multiplier allowing
  102041. * rendering at a higher or lower resolution
  102042. * @param successCallback defines the callback receives a single parameter which contains the
  102043. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102044. * src parameter of an <img> to display it
  102045. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  102046. * Check your browser for supported MIME types
  102047. */
  102048. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  102049. if (mimeType === void 0) { mimeType = "image/png"; }
  102050. var width;
  102051. var height;
  102052. // If a precision value is specified
  102053. if (size.precision) {
  102054. width = Math.round(engine.getRenderWidth() * size.precision);
  102055. height = Math.round(width / engine.getAspectRatio(camera));
  102056. }
  102057. else if (size.width && size.height) {
  102058. width = size.width;
  102059. height = size.height;
  102060. }
  102061. //If passing only width, computing height to keep display canvas ratio.
  102062. else if (size.width && !size.height) {
  102063. width = size.width;
  102064. height = Math.round(width / engine.getAspectRatio(camera));
  102065. }
  102066. //If passing only height, computing width to keep display canvas ratio.
  102067. else if (size.height && !size.width) {
  102068. height = size.height;
  102069. width = Math.round(height * engine.getAspectRatio(camera));
  102070. }
  102071. //Assuming here that "size" parameter is a number
  102072. else if (!isNaN(size)) {
  102073. height = size;
  102074. width = size;
  102075. }
  102076. else {
  102077. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  102078. return;
  102079. }
  102080. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  102081. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  102082. }
  102083. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  102084. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  102085. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  102086. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  102087. var newWidth = width;
  102088. var newHeight = newWidth / ratio;
  102089. if (newHeight > height) {
  102090. newHeight = height;
  102091. newWidth = newHeight * ratio;
  102092. }
  102093. var offsetX = Math.max(0, width - newWidth) / 2;
  102094. var offsetY = Math.max(0, height - newHeight) / 2;
  102095. var renderingCanvas = engine.getRenderingCanvas();
  102096. if (renderContext && renderingCanvas) {
  102097. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  102098. }
  102099. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  102100. };
  102101. /**
  102102. * Generates an image screenshot from the specified camera.
  102103. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  102104. * @param engine The engine to use for rendering
  102105. * @param camera The camera to use for rendering
  102106. * @param size This parameter can be set to a single number or to an object with the
  102107. * following (optional) properties: precision, width, height. If a single number is passed,
  102108. * it will be used for both width and height. If an object is passed, the screenshot size
  102109. * will be derived from the parameters. The precision property is a multiplier allowing
  102110. * rendering at a higher or lower resolution
  102111. * @param successCallback The callback receives a single parameter which contains the
  102112. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  102113. * src parameter of an <img> to display it
  102114. * @param mimeType The MIME type of the screenshot image (default: image/png).
  102115. * Check your browser for supported MIME types
  102116. * @param samples Texture samples (default: 1)
  102117. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  102118. * @param fileName A name for for the downloaded file.
  102119. */
  102120. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  102121. if (mimeType === void 0) { mimeType = "image/png"; }
  102122. if (samples === void 0) { samples = 1; }
  102123. if (antialiasing === void 0) { antialiasing = false; }
  102124. var width;
  102125. var height;
  102126. //If a precision value is specified
  102127. if (size.precision) {
  102128. width = Math.round(engine.getRenderWidth() * size.precision);
  102129. height = Math.round(width / engine.getAspectRatio(camera));
  102130. size = { width: width, height: height };
  102131. }
  102132. else if (size.width && size.height) {
  102133. width = size.width;
  102134. height = size.height;
  102135. }
  102136. //If passing only width, computing height to keep display canvas ratio.
  102137. else if (size.width && !size.height) {
  102138. width = size.width;
  102139. height = Math.round(width / engine.getAspectRatio(camera));
  102140. size = { width: width, height: height };
  102141. }
  102142. //If passing only height, computing width to keep display canvas ratio.
  102143. else if (size.height && !size.width) {
  102144. height = size.height;
  102145. width = Math.round(height * engine.getAspectRatio(camera));
  102146. size = { width: width, height: height };
  102147. }
  102148. //Assuming here that "size" parameter is a number
  102149. else if (!isNaN(size)) {
  102150. height = size;
  102151. width = size;
  102152. }
  102153. else {
  102154. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  102155. return;
  102156. }
  102157. var scene = camera.getScene();
  102158. var previousCamera = null;
  102159. if (scene.activeCamera !== camera) {
  102160. previousCamera = scene.activeCamera;
  102161. scene.activeCamera = camera;
  102162. }
  102163. var renderCanvas = engine.getRenderingCanvas();
  102164. if (!renderCanvas) {
  102165. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  102166. return;
  102167. }
  102168. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  102169. engine.setSize(width, height);
  102170. scene.render();
  102171. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  102172. 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);
  102173. texture.renderList = null;
  102174. texture.samples = samples;
  102175. if (antialiasing) {
  102176. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  102177. }
  102178. texture.onAfterRenderObservable.add(function () {
  102179. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  102180. });
  102181. scene.incrementRenderId();
  102182. scene.resetCachedMaterial();
  102183. texture.render(true);
  102184. texture.dispose();
  102185. if (previousCamera) {
  102186. scene.activeCamera = previousCamera;
  102187. }
  102188. engine.setSize(originalSize.width, originalSize.height);
  102189. camera.getProjectionMatrix(true); // Force cache refresh;
  102190. };
  102191. return ScreenshotTools;
  102192. }());
  102193. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  102194. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  102195. /***/ }),
  102196. /***/ "./Misc/smartArray.ts":
  102197. /*!****************************!*\
  102198. !*** ./Misc/smartArray.ts ***!
  102199. \****************************/
  102200. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  102201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102202. "use strict";
  102203. __webpack_require__.r(__webpack_exports__);
  102204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  102205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  102206. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102207. /**
  102208. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  102209. */
  102210. var SmartArray = /** @class */ (function () {
  102211. /**
  102212. * Instantiates a Smart Array.
  102213. * @param capacity defines the default capacity of the array.
  102214. */
  102215. function SmartArray(capacity) {
  102216. /**
  102217. * The active length of the array.
  102218. */
  102219. this.length = 0;
  102220. this.data = new Array(capacity);
  102221. this._id = SmartArray._GlobalId++;
  102222. }
  102223. /**
  102224. * Pushes a value at the end of the active data.
  102225. * @param value defines the object to push in the array.
  102226. */
  102227. SmartArray.prototype.push = function (value) {
  102228. this.data[this.length++] = value;
  102229. if (this.length > this.data.length) {
  102230. this.data.length *= 2;
  102231. }
  102232. };
  102233. /**
  102234. * Iterates over the active data and apply the lambda to them.
  102235. * @param func defines the action to apply on each value.
  102236. */
  102237. SmartArray.prototype.forEach = function (func) {
  102238. for (var index = 0; index < this.length; index++) {
  102239. func(this.data[index]);
  102240. }
  102241. };
  102242. /**
  102243. * Sorts the full sets of data.
  102244. * @param compareFn defines the comparison function to apply.
  102245. */
  102246. SmartArray.prototype.sort = function (compareFn) {
  102247. this.data.sort(compareFn);
  102248. };
  102249. /**
  102250. * Resets the active data to an empty array.
  102251. */
  102252. SmartArray.prototype.reset = function () {
  102253. this.length = 0;
  102254. };
  102255. /**
  102256. * Releases all the data from the array as well as the array.
  102257. */
  102258. SmartArray.prototype.dispose = function () {
  102259. this.reset();
  102260. if (this.data) {
  102261. this.data.length = 0;
  102262. this.data = [];
  102263. }
  102264. };
  102265. /**
  102266. * Concats the active data with a given array.
  102267. * @param array defines the data to concatenate with.
  102268. */
  102269. SmartArray.prototype.concat = function (array) {
  102270. if (array.length === 0) {
  102271. return;
  102272. }
  102273. if (this.length + array.length > this.data.length) {
  102274. this.data.length = (this.length + array.length) * 2;
  102275. }
  102276. for (var index = 0; index < array.length; index++) {
  102277. this.data[this.length++] = (array.data || array)[index];
  102278. }
  102279. };
  102280. /**
  102281. * Returns the position of a value in the active data.
  102282. * @param value defines the value to find the index for
  102283. * @returns the index if found in the active data otherwise -1
  102284. */
  102285. SmartArray.prototype.indexOf = function (value) {
  102286. var position = this.data.indexOf(value);
  102287. if (position >= this.length) {
  102288. return -1;
  102289. }
  102290. return position;
  102291. };
  102292. /**
  102293. * Returns whether an element is part of the active data.
  102294. * @param value defines the value to look for
  102295. * @returns true if found in the active data otherwise false
  102296. */
  102297. SmartArray.prototype.contains = function (value) {
  102298. return this.indexOf(value) !== -1;
  102299. };
  102300. // Statics
  102301. SmartArray._GlobalId = 0;
  102302. return SmartArray;
  102303. }());
  102304. /**
  102305. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  102306. * The data in this array can only be present once
  102307. */
  102308. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  102309. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  102310. function SmartArrayNoDuplicate() {
  102311. var _this = _super !== null && _super.apply(this, arguments) || this;
  102312. _this._duplicateId = 0;
  102313. return _this;
  102314. }
  102315. /**
  102316. * Pushes a value at the end of the active data.
  102317. * THIS DOES NOT PREVENT DUPPLICATE DATA
  102318. * @param value defines the object to push in the array.
  102319. */
  102320. SmartArrayNoDuplicate.prototype.push = function (value) {
  102321. _super.prototype.push.call(this, value);
  102322. if (!value.__smartArrayFlags) {
  102323. value.__smartArrayFlags = {};
  102324. }
  102325. value.__smartArrayFlags[this._id] = this._duplicateId;
  102326. };
  102327. /**
  102328. * Pushes a value at the end of the active data.
  102329. * If the data is already present, it won t be added again
  102330. * @param value defines the object to push in the array.
  102331. * @returns true if added false if it was already present
  102332. */
  102333. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  102334. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  102335. return false;
  102336. }
  102337. this.push(value);
  102338. return true;
  102339. };
  102340. /**
  102341. * Resets the active data to an empty array.
  102342. */
  102343. SmartArrayNoDuplicate.prototype.reset = function () {
  102344. _super.prototype.reset.call(this);
  102345. this._duplicateId++;
  102346. };
  102347. /**
  102348. * Concats the active data with a given array.
  102349. * This ensures no dupplicate will be present in the result.
  102350. * @param array defines the data to concatenate with.
  102351. */
  102352. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  102353. if (array.length === 0) {
  102354. return;
  102355. }
  102356. if (this.length + array.length > this.data.length) {
  102357. this.data.length = (this.length + array.length) * 2;
  102358. }
  102359. for (var index = 0; index < array.length; index++) {
  102360. var item = (array.data || array)[index];
  102361. this.pushNoDuplicate(item);
  102362. }
  102363. };
  102364. return SmartArrayNoDuplicate;
  102365. }(SmartArray));
  102366. /***/ }),
  102367. /***/ "./Misc/stringDictionary.ts":
  102368. /*!**********************************!*\
  102369. !*** ./Misc/stringDictionary.ts ***!
  102370. \**********************************/
  102371. /*! exports provided: StringDictionary */
  102372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102373. "use strict";
  102374. __webpack_require__.r(__webpack_exports__);
  102375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  102376. /**
  102377. * This class implement a typical dictionary using a string as key and the generic type T as value.
  102378. * The underlying implementation relies on an associative array to ensure the best performances.
  102379. * The value can be anything including 'null' but except 'undefined'
  102380. */
  102381. var StringDictionary = /** @class */ (function () {
  102382. function StringDictionary() {
  102383. this._count = 0;
  102384. this._data = {};
  102385. }
  102386. /**
  102387. * This will clear this dictionary and copy the content from the 'source' one.
  102388. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  102389. * @param source the dictionary to take the content from and copy to this dictionary
  102390. */
  102391. StringDictionary.prototype.copyFrom = function (source) {
  102392. var _this = this;
  102393. this.clear();
  102394. source.forEach(function (t, v) { return _this.add(t, v); });
  102395. };
  102396. /**
  102397. * Get a value based from its key
  102398. * @param key the given key to get the matching value from
  102399. * @return the value if found, otherwise undefined is returned
  102400. */
  102401. StringDictionary.prototype.get = function (key) {
  102402. var val = this._data[key];
  102403. if (val !== undefined) {
  102404. return val;
  102405. }
  102406. return undefined;
  102407. };
  102408. /**
  102409. * Get a value from its key or add it if it doesn't exist.
  102410. * This method will ensure you that a given key/data will be present in the dictionary.
  102411. * @param key the given key to get the matching value from
  102412. * @param factory the factory that will create the value if the key is not present in the dictionary.
  102413. * The factory will only be invoked if there's no data for the given key.
  102414. * @return the value corresponding to the key.
  102415. */
  102416. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  102417. var val = this.get(key);
  102418. if (val !== undefined) {
  102419. return val;
  102420. }
  102421. val = factory(key);
  102422. if (val) {
  102423. this.add(key, val);
  102424. }
  102425. return val;
  102426. };
  102427. /**
  102428. * Get a value from its key if present in the dictionary otherwise add it
  102429. * @param key the key to get the value from
  102430. * @param val if there's no such key/value pair in the dictionary add it with this value
  102431. * @return the value corresponding to the key
  102432. */
  102433. StringDictionary.prototype.getOrAdd = function (key, val) {
  102434. var curVal = this.get(key);
  102435. if (curVal !== undefined) {
  102436. return curVal;
  102437. }
  102438. this.add(key, val);
  102439. return val;
  102440. };
  102441. /**
  102442. * Check if there's a given key in the dictionary
  102443. * @param key the key to check for
  102444. * @return true if the key is present, false otherwise
  102445. */
  102446. StringDictionary.prototype.contains = function (key) {
  102447. return this._data[key] !== undefined;
  102448. };
  102449. /**
  102450. * Add a new key and its corresponding value
  102451. * @param key the key to add
  102452. * @param value the value corresponding to the key
  102453. * @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
  102454. */
  102455. StringDictionary.prototype.add = function (key, value) {
  102456. if (this._data[key] !== undefined) {
  102457. return false;
  102458. }
  102459. this._data[key] = value;
  102460. ++this._count;
  102461. return true;
  102462. };
  102463. /**
  102464. * Update a specific value associated to a key
  102465. * @param key defines the key to use
  102466. * @param value defines the value to store
  102467. * @returns true if the value was updated (or false if the key was not found)
  102468. */
  102469. StringDictionary.prototype.set = function (key, value) {
  102470. if (this._data[key] === undefined) {
  102471. return false;
  102472. }
  102473. this._data[key] = value;
  102474. return true;
  102475. };
  102476. /**
  102477. * Get the element of the given key and remove it from the dictionary
  102478. * @param key defines the key to search
  102479. * @returns the value associated with the key or null if not found
  102480. */
  102481. StringDictionary.prototype.getAndRemove = function (key) {
  102482. var val = this.get(key);
  102483. if (val !== undefined) {
  102484. delete this._data[key];
  102485. --this._count;
  102486. return val;
  102487. }
  102488. return null;
  102489. };
  102490. /**
  102491. * Remove a key/value from the dictionary.
  102492. * @param key the key to remove
  102493. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  102494. */
  102495. StringDictionary.prototype.remove = function (key) {
  102496. if (this.contains(key)) {
  102497. delete this._data[key];
  102498. --this._count;
  102499. return true;
  102500. }
  102501. return false;
  102502. };
  102503. /**
  102504. * Clear the whole content of the dictionary
  102505. */
  102506. StringDictionary.prototype.clear = function () {
  102507. this._data = {};
  102508. this._count = 0;
  102509. };
  102510. Object.defineProperty(StringDictionary.prototype, "count", {
  102511. /**
  102512. * Gets the current count
  102513. */
  102514. get: function () {
  102515. return this._count;
  102516. },
  102517. enumerable: true,
  102518. configurable: true
  102519. });
  102520. /**
  102521. * Execute a callback on each key/val of the dictionary.
  102522. * Note that you can remove any element in this dictionary in the callback implementation
  102523. * @param callback the callback to execute on a given key/value pair
  102524. */
  102525. StringDictionary.prototype.forEach = function (callback) {
  102526. for (var cur in this._data) {
  102527. var val = this._data[cur];
  102528. callback(cur, val);
  102529. }
  102530. };
  102531. /**
  102532. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  102533. * If the callback returns null or undefined the method will iterate to the next key/value pair
  102534. * Note that you can remove any element in this dictionary in the callback implementation
  102535. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  102536. * @returns the first item
  102537. */
  102538. StringDictionary.prototype.first = function (callback) {
  102539. for (var cur in this._data) {
  102540. var val = this._data[cur];
  102541. var res = callback(cur, val);
  102542. if (res) {
  102543. return res;
  102544. }
  102545. }
  102546. return null;
  102547. };
  102548. return StringDictionary;
  102549. }());
  102550. /***/ }),
  102551. /***/ "./Misc/tags.ts":
  102552. /*!**********************!*\
  102553. !*** ./Misc/tags.ts ***!
  102554. \**********************/
  102555. /*! exports provided: Tags */
  102556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102557. "use strict";
  102558. __webpack_require__.r(__webpack_exports__);
  102559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  102560. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  102561. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  102562. /**
  102563. * Class used to store custom tags
  102564. */
  102565. var Tags = /** @class */ (function () {
  102566. function Tags() {
  102567. }
  102568. /**
  102569. * Adds support for tags on the given object
  102570. * @param obj defines the object to use
  102571. */
  102572. Tags.EnableFor = function (obj) {
  102573. obj._tags = obj._tags || {};
  102574. obj.hasTags = function () {
  102575. return Tags.HasTags(obj);
  102576. };
  102577. obj.addTags = function (tagsString) {
  102578. return Tags.AddTagsTo(obj, tagsString);
  102579. };
  102580. obj.removeTags = function (tagsString) {
  102581. return Tags.RemoveTagsFrom(obj, tagsString);
  102582. };
  102583. obj.matchesTagsQuery = function (tagsQuery) {
  102584. return Tags.MatchesQuery(obj, tagsQuery);
  102585. };
  102586. };
  102587. /**
  102588. * Removes tags support
  102589. * @param obj defines the object to use
  102590. */
  102591. Tags.DisableFor = function (obj) {
  102592. delete obj._tags;
  102593. delete obj.hasTags;
  102594. delete obj.addTags;
  102595. delete obj.removeTags;
  102596. delete obj.matchesTagsQuery;
  102597. };
  102598. /**
  102599. * Gets a boolean indicating if the given object has tags
  102600. * @param obj defines the object to use
  102601. * @returns a boolean
  102602. */
  102603. Tags.HasTags = function (obj) {
  102604. if (!obj._tags) {
  102605. return false;
  102606. }
  102607. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  102608. };
  102609. /**
  102610. * Gets the tags available on a given object
  102611. * @param obj defines the object to use
  102612. * @param asString defines if the tags must be returned as a string instead of an array of strings
  102613. * @returns the tags
  102614. */
  102615. Tags.GetTags = function (obj, asString) {
  102616. if (asString === void 0) { asString = true; }
  102617. if (!obj._tags) {
  102618. return null;
  102619. }
  102620. if (asString) {
  102621. var tagsArray = [];
  102622. for (var tag in obj._tags) {
  102623. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  102624. tagsArray.push(tag);
  102625. }
  102626. }
  102627. return tagsArray.join(" ");
  102628. }
  102629. else {
  102630. return obj._tags;
  102631. }
  102632. };
  102633. /**
  102634. * Adds tags to an object
  102635. * @param obj defines the object to use
  102636. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  102637. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  102638. */
  102639. Tags.AddTagsTo = function (obj, tagsString) {
  102640. if (!tagsString) {
  102641. return;
  102642. }
  102643. if (typeof tagsString !== "string") {
  102644. return;
  102645. }
  102646. var tags = tagsString.split(" ");
  102647. tags.forEach(function (tag, index, array) {
  102648. Tags._AddTagTo(obj, tag);
  102649. });
  102650. };
  102651. /**
  102652. * @hidden
  102653. */
  102654. Tags._AddTagTo = function (obj, tag) {
  102655. tag = tag.trim();
  102656. if (tag === "" || tag === "true" || tag === "false") {
  102657. return;
  102658. }
  102659. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  102660. return;
  102661. }
  102662. Tags.EnableFor(obj);
  102663. obj._tags[tag] = true;
  102664. };
  102665. /**
  102666. * Removes specific tags from a specific object
  102667. * @param obj defines the object to use
  102668. * @param tagsString defines the tags to remove
  102669. */
  102670. Tags.RemoveTagsFrom = function (obj, tagsString) {
  102671. if (!Tags.HasTags(obj)) {
  102672. return;
  102673. }
  102674. var tags = tagsString.split(" ");
  102675. for (var t in tags) {
  102676. Tags._RemoveTagFrom(obj, tags[t]);
  102677. }
  102678. };
  102679. /**
  102680. * @hidden
  102681. */
  102682. Tags._RemoveTagFrom = function (obj, tag) {
  102683. delete obj._tags[tag];
  102684. };
  102685. /**
  102686. * Defines if tags hosted on an object match a given query
  102687. * @param obj defines the object to use
  102688. * @param tagsQuery defines the tag query
  102689. * @returns a boolean
  102690. */
  102691. Tags.MatchesQuery = function (obj, tagsQuery) {
  102692. if (tagsQuery === undefined) {
  102693. return true;
  102694. }
  102695. if (tagsQuery === "") {
  102696. return Tags.HasTags(obj);
  102697. }
  102698. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  102699. };
  102700. return Tags;
  102701. }());
  102702. /***/ }),
  102703. /***/ "./Misc/textureTools.ts":
  102704. /*!******************************!*\
  102705. !*** ./Misc/textureTools.ts ***!
  102706. \******************************/
  102707. /*! exports provided: TextureTools */
  102708. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102709. "use strict";
  102710. __webpack_require__.r(__webpack_exports__);
  102711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  102712. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  102713. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  102714. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  102715. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102716. /**
  102717. * Class used to host texture specific utilities
  102718. */
  102719. var TextureTools = /** @class */ (function () {
  102720. function TextureTools() {
  102721. }
  102722. /**
  102723. * Uses the GPU to create a copy texture rescaled at a given size
  102724. * @param texture Texture to copy from
  102725. * @param width defines the desired width
  102726. * @param height defines the desired height
  102727. * @param useBilinearMode defines if bilinear mode has to be used
  102728. * @return the generated texture
  102729. */
  102730. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  102731. if (useBilinearMode === void 0) { useBilinearMode = true; }
  102732. var scene = texture.getScene();
  102733. var engine = scene.getEngine();
  102734. 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);
  102735. rtt.wrapU = texture.wrapU;
  102736. rtt.wrapV = texture.wrapV;
  102737. rtt.uOffset = texture.uOffset;
  102738. rtt.vOffset = texture.vOffset;
  102739. rtt.uScale = texture.uScale;
  102740. rtt.vScale = texture.vScale;
  102741. rtt.uAng = texture.uAng;
  102742. rtt.vAng = texture.vAng;
  102743. rtt.wAng = texture.wAng;
  102744. rtt.coordinatesIndex = texture.coordinatesIndex;
  102745. rtt.level = texture.level;
  102746. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  102747. rtt._texture.isReady = false;
  102748. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  102749. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  102750. 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);
  102751. passPostProcess.getEffect().executeWhenCompiled(function () {
  102752. passPostProcess.onApply = function (effect) {
  102753. effect.setTexture("textureSampler", texture);
  102754. };
  102755. var internalTexture = rtt.getInternalTexture();
  102756. if (internalTexture) {
  102757. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  102758. engine.unBindFramebuffer(internalTexture);
  102759. rtt.disposeFramebufferObjects();
  102760. passPostProcess.dispose();
  102761. internalTexture.isReady = true;
  102762. }
  102763. });
  102764. return rtt;
  102765. };
  102766. return TextureTools;
  102767. }());
  102768. /***/ }),
  102769. /***/ "./Misc/tga.ts":
  102770. /*!*********************!*\
  102771. !*** ./Misc/tga.ts ***!
  102772. \*********************/
  102773. /*! exports provided: TGATools */
  102774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102775. "use strict";
  102776. __webpack_require__.r(__webpack_exports__);
  102777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  102778. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  102779. /**
  102780. * Based on jsTGALoader - Javascript loader for TGA file
  102781. * By Vincent Thibault
  102782. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102783. */
  102784. var TGATools = /** @class */ (function () {
  102785. function TGATools() {
  102786. }
  102787. /**
  102788. * Gets the header of a TGA file
  102789. * @param data defines the TGA data
  102790. * @returns the header
  102791. */
  102792. TGATools.GetTGAHeader = function (data) {
  102793. var offset = 0;
  102794. var header = {
  102795. id_length: data[offset++],
  102796. colormap_type: data[offset++],
  102797. image_type: data[offset++],
  102798. colormap_index: data[offset++] | data[offset++] << 8,
  102799. colormap_length: data[offset++] | data[offset++] << 8,
  102800. colormap_size: data[offset++],
  102801. origin: [
  102802. data[offset++] | data[offset++] << 8,
  102803. data[offset++] | data[offset++] << 8
  102804. ],
  102805. width: data[offset++] | data[offset++] << 8,
  102806. height: data[offset++] | data[offset++] << 8,
  102807. pixel_size: data[offset++],
  102808. flags: data[offset++]
  102809. };
  102810. return header;
  102811. };
  102812. /**
  102813. * Uploads TGA content to a Babylon Texture
  102814. * @hidden
  102815. */
  102816. TGATools.UploadContent = function (texture, data) {
  102817. // Not enough data to contain header ?
  102818. if (data.length < 19) {
  102819. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  102820. return;
  102821. }
  102822. // Read Header
  102823. var offset = 18;
  102824. var header = TGATools.GetTGAHeader(data);
  102825. // Assume it's a valid Targa file.
  102826. if (header.id_length + offset > data.length) {
  102827. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  102828. return;
  102829. }
  102830. // Skip not needed data
  102831. offset += header.id_length;
  102832. var use_rle = false;
  102833. var use_pal = false;
  102834. var use_grey = false;
  102835. // Get some informations.
  102836. switch (header.image_type) {
  102837. case TGATools._TYPE_RLE_INDEXED:
  102838. use_rle = true;
  102839. case TGATools._TYPE_INDEXED:
  102840. use_pal = true;
  102841. break;
  102842. case TGATools._TYPE_RLE_RGB:
  102843. use_rle = true;
  102844. case TGATools._TYPE_RGB:
  102845. // use_rgb = true;
  102846. break;
  102847. case TGATools._TYPE_RLE_GREY:
  102848. use_rle = true;
  102849. case TGATools._TYPE_GREY:
  102850. use_grey = true;
  102851. break;
  102852. }
  102853. var pixel_data;
  102854. // var numAlphaBits = header.flags & 0xf;
  102855. var pixel_size = header.pixel_size >> 3;
  102856. var pixel_total = header.width * header.height * pixel_size;
  102857. // Read palettes
  102858. var palettes;
  102859. if (use_pal) {
  102860. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  102861. }
  102862. // Read LRE
  102863. if (use_rle) {
  102864. pixel_data = new Uint8Array(pixel_total);
  102865. var c, count, i;
  102866. var localOffset = 0;
  102867. var pixels = new Uint8Array(pixel_size);
  102868. while (offset < pixel_total && localOffset < pixel_total) {
  102869. c = data[offset++];
  102870. count = (c & 0x7f) + 1;
  102871. // RLE pixels
  102872. if (c & 0x80) {
  102873. // Bind pixel tmp array
  102874. for (i = 0; i < pixel_size; ++i) {
  102875. pixels[i] = data[offset++];
  102876. }
  102877. // Copy pixel array
  102878. for (i = 0; i < count; ++i) {
  102879. pixel_data.set(pixels, localOffset + i * pixel_size);
  102880. }
  102881. localOffset += pixel_size * count;
  102882. }
  102883. // Raw pixels
  102884. else {
  102885. count *= pixel_size;
  102886. for (i = 0; i < count; ++i) {
  102887. pixel_data[localOffset + i] = data[offset++];
  102888. }
  102889. localOffset += count;
  102890. }
  102891. }
  102892. }
  102893. // RAW Pixels
  102894. else {
  102895. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  102896. }
  102897. // Load to texture
  102898. var x_start, y_start, x_step, y_step, y_end, x_end;
  102899. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  102900. default:
  102901. case TGATools._ORIGIN_UL:
  102902. x_start = 0;
  102903. x_step = 1;
  102904. x_end = header.width;
  102905. y_start = 0;
  102906. y_step = 1;
  102907. y_end = header.height;
  102908. break;
  102909. case TGATools._ORIGIN_BL:
  102910. x_start = 0;
  102911. x_step = 1;
  102912. x_end = header.width;
  102913. y_start = header.height - 1;
  102914. y_step = -1;
  102915. y_end = -1;
  102916. break;
  102917. case TGATools._ORIGIN_UR:
  102918. x_start = header.width - 1;
  102919. x_step = -1;
  102920. x_end = -1;
  102921. y_start = 0;
  102922. y_step = 1;
  102923. y_end = header.height;
  102924. break;
  102925. case TGATools._ORIGIN_BR:
  102926. x_start = header.width - 1;
  102927. x_step = -1;
  102928. x_end = -1;
  102929. y_start = header.height - 1;
  102930. y_step = -1;
  102931. y_end = -1;
  102932. break;
  102933. }
  102934. // Load the specify method
  102935. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  102936. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  102937. var engine = texture.getEngine();
  102938. engine._uploadDataToTextureDirectly(texture, imageData);
  102939. };
  102940. /** @hidden */
  102941. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102942. var image = pixel_data, colormap = palettes;
  102943. var width = header.width, height = header.height;
  102944. var color, i = 0, x, y;
  102945. var imageData = new Uint8Array(width * height * 4);
  102946. for (y = y_start; y !== y_end; y += y_step) {
  102947. for (x = x_start; x !== x_end; x += x_step, i++) {
  102948. color = image[i];
  102949. imageData[(x + width * y) * 4 + 3] = 255;
  102950. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  102951. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  102952. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  102953. }
  102954. }
  102955. return imageData;
  102956. };
  102957. /** @hidden */
  102958. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102959. var image = pixel_data;
  102960. var width = header.width, height = header.height;
  102961. var color, i = 0, x, y;
  102962. var imageData = new Uint8Array(width * height * 4);
  102963. for (y = y_start; y !== y_end; y += y_step) {
  102964. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  102965. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  102966. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  102967. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  102968. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  102969. imageData[(x + width * y) * 4 + 0] = r;
  102970. imageData[(x + width * y) * 4 + 1] = g;
  102971. imageData[(x + width * y) * 4 + 2] = b;
  102972. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  102973. }
  102974. }
  102975. return imageData;
  102976. };
  102977. /** @hidden */
  102978. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102979. var image = pixel_data;
  102980. var width = header.width, height = header.height;
  102981. var i = 0, x, y;
  102982. var imageData = new Uint8Array(width * height * 4);
  102983. for (y = y_start; y !== y_end; y += y_step) {
  102984. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  102985. imageData[(x + width * y) * 4 + 3] = 255;
  102986. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  102987. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  102988. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  102989. }
  102990. }
  102991. return imageData;
  102992. };
  102993. /** @hidden */
  102994. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102995. var image = pixel_data;
  102996. var width = header.width, height = header.height;
  102997. var i = 0, x, y;
  102998. var imageData = new Uint8Array(width * height * 4);
  102999. for (y = y_start; y !== y_end; y += y_step) {
  103000. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  103001. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  103002. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  103003. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  103004. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  103005. }
  103006. }
  103007. return imageData;
  103008. };
  103009. /** @hidden */
  103010. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  103011. var image = pixel_data;
  103012. var width = header.width, height = header.height;
  103013. var color, i = 0, x, y;
  103014. var imageData = new Uint8Array(width * height * 4);
  103015. for (y = y_start; y !== y_end; y += y_step) {
  103016. for (x = x_start; x !== x_end; x += x_step, i++) {
  103017. color = image[i];
  103018. imageData[(x + width * y) * 4 + 0] = color;
  103019. imageData[(x + width * y) * 4 + 1] = color;
  103020. imageData[(x + width * y) * 4 + 2] = color;
  103021. imageData[(x + width * y) * 4 + 3] = 255;
  103022. }
  103023. }
  103024. return imageData;
  103025. };
  103026. /** @hidden */
  103027. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  103028. var image = pixel_data;
  103029. var width = header.width, height = header.height;
  103030. var i = 0, x, y;
  103031. var imageData = new Uint8Array(width * height * 4);
  103032. for (y = y_start; y !== y_end; y += y_step) {
  103033. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  103034. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  103035. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  103036. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  103037. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  103038. }
  103039. }
  103040. return imageData;
  103041. };
  103042. //private static _TYPE_NO_DATA = 0;
  103043. TGATools._TYPE_INDEXED = 1;
  103044. TGATools._TYPE_RGB = 2;
  103045. TGATools._TYPE_GREY = 3;
  103046. TGATools._TYPE_RLE_INDEXED = 9;
  103047. TGATools._TYPE_RLE_RGB = 10;
  103048. TGATools._TYPE_RLE_GREY = 11;
  103049. TGATools._ORIGIN_MASK = 0x30;
  103050. TGATools._ORIGIN_SHIFT = 0x04;
  103051. TGATools._ORIGIN_BL = 0x00;
  103052. TGATools._ORIGIN_BR = 0x01;
  103053. TGATools._ORIGIN_UL = 0x02;
  103054. TGATools._ORIGIN_UR = 0x03;
  103055. return TGATools;
  103056. }());
  103057. /***/ }),
  103058. /***/ "./Misc/tools.ts":
  103059. /*!***********************!*\
  103060. !*** ./Misc/tools.ts ***!
  103061. \***********************/
  103062. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  103063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103064. "use strict";
  103065. __webpack_require__.r(__webpack_exports__);
  103066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  103067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  103068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  103069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  103070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  103071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  103072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  103073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  103074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  103075. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103076. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103077. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103078. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  103079. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  103080. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103081. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  103082. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  103083. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  103084. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  103085. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  103086. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  103087. /* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  103088. /** Class used to store color4 gradient */
  103089. var ColorGradient = /** @class */ (function () {
  103090. function ColorGradient() {
  103091. }
  103092. /**
  103093. * Will get a color picked randomly between color1 and color2.
  103094. * If color2 is undefined then color1 will be used
  103095. * @param result defines the target Color4 to store the result in
  103096. */
  103097. ColorGradient.prototype.getColorToRef = function (result) {
  103098. if (!this.color2) {
  103099. result.copyFrom(this.color1);
  103100. return;
  103101. }
  103102. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  103103. };
  103104. return ColorGradient;
  103105. }());
  103106. /** Class used to store color 3 gradient */
  103107. var Color3Gradient = /** @class */ (function () {
  103108. function Color3Gradient() {
  103109. }
  103110. return Color3Gradient;
  103111. }());
  103112. /** Class used to store factor gradient */
  103113. var FactorGradient = /** @class */ (function () {
  103114. function FactorGradient() {
  103115. }
  103116. /**
  103117. * Will get a number picked randomly between factor1 and factor2.
  103118. * If factor2 is undefined then factor1 will be used
  103119. * @returns the picked number
  103120. */
  103121. FactorGradient.prototype.getFactor = function () {
  103122. if (this.factor2 === undefined) {
  103123. return this.factor1;
  103124. }
  103125. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  103126. };
  103127. return FactorGradient;
  103128. }());
  103129. /**
  103130. * @ignore
  103131. * Application error to support additional information when loading a file
  103132. */
  103133. var LoadFileError = /** @class */ (function (_super) {
  103134. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  103135. /**
  103136. * Creates a new LoadFileError
  103137. * @param message defines the message of the error
  103138. * @param request defines the optional web request
  103139. */
  103140. function LoadFileError(message,
  103141. /** defines the optional web request */
  103142. request) {
  103143. var _this = _super.call(this, message) || this;
  103144. _this.request = request;
  103145. _this.name = "LoadFileError";
  103146. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  103147. return _this;
  103148. }
  103149. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  103150. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  103151. // Polyfill for Object.setPrototypeOf if necessary.
  103152. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  103153. return LoadFileError;
  103154. }(Error));
  103155. /**
  103156. * Class used to define a retry strategy when error happens while loading assets
  103157. */
  103158. var RetryStrategy = /** @class */ (function () {
  103159. function RetryStrategy() {
  103160. }
  103161. /**
  103162. * Function used to defines an exponential back off strategy
  103163. * @param maxRetries defines the maximum number of retries (3 by default)
  103164. * @param baseInterval defines the interval between retries
  103165. * @returns the strategy function to use
  103166. */
  103167. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  103168. if (maxRetries === void 0) { maxRetries = 3; }
  103169. if (baseInterval === void 0) { baseInterval = 500; }
  103170. return function (url, request, retryIndex) {
  103171. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  103172. return -1;
  103173. }
  103174. return Math.pow(2, retryIndex) * baseInterval;
  103175. };
  103176. };
  103177. return RetryStrategy;
  103178. }());
  103179. /**
  103180. * Class containing a set of static utilities functions
  103181. */
  103182. var Tools = /** @class */ (function () {
  103183. function Tools() {
  103184. }
  103185. /**
  103186. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  103187. * @param u defines the coordinate on X axis
  103188. * @param v defines the coordinate on Y axis
  103189. * @param width defines the width of the source data
  103190. * @param height defines the height of the source data
  103191. * @param pixels defines the source byte array
  103192. * @param color defines the output color
  103193. */
  103194. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  103195. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  103196. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  103197. var position = (wrappedU + wrappedV * width) * 4;
  103198. color.r = pixels[position] / 255;
  103199. color.g = pixels[position + 1] / 255;
  103200. color.b = pixels[position + 2] / 255;
  103201. color.a = pixels[position + 3] / 255;
  103202. };
  103203. /**
  103204. * Interpolates between a and b via alpha
  103205. * @param a The lower value (returned when alpha = 0)
  103206. * @param b The upper value (returned when alpha = 1)
  103207. * @param alpha The interpolation-factor
  103208. * @return The mixed value
  103209. */
  103210. Tools.Mix = function (a, b, alpha) {
  103211. return a * (1 - alpha) + b * alpha;
  103212. };
  103213. /**
  103214. * Tries to instantiate a new object from a given class name
  103215. * @param className defines the class name to instantiate
  103216. * @returns the new object or null if the system was not able to do the instantiation
  103217. */
  103218. Tools.Instantiate = function (className) {
  103219. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  103220. return Tools.RegisteredExternalClasses[className];
  103221. }
  103222. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  103223. if (internalClass) {
  103224. return internalClass;
  103225. }
  103226. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  103227. var arr = className.split(".");
  103228. var fn = (window || this);
  103229. for (var i = 0, len = arr.length; i < len; i++) {
  103230. fn = fn[arr[i]];
  103231. }
  103232. if (typeof fn !== "function") {
  103233. return null;
  103234. }
  103235. return fn;
  103236. };
  103237. /**
  103238. * Provides a slice function that will work even on IE
  103239. * @param data defines the array to slice
  103240. * @param start defines the start of the data (optional)
  103241. * @param end defines the end of the data (optional)
  103242. * @returns the new sliced array
  103243. */
  103244. Tools.Slice = function (data, start, end) {
  103245. if (data.slice) {
  103246. return data.slice(start, end);
  103247. }
  103248. return Array.prototype.slice.call(data, start, end);
  103249. };
  103250. /**
  103251. * Polyfill for setImmediate
  103252. * @param action defines the action to execute after the current execution block
  103253. */
  103254. Tools.SetImmediate = function (action) {
  103255. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  103256. window.setImmediate(action);
  103257. }
  103258. else {
  103259. setTimeout(action, 1);
  103260. }
  103261. };
  103262. /**
  103263. * Function indicating if a number is an exponent of 2
  103264. * @param value defines the value to test
  103265. * @returns true if the value is an exponent of 2
  103266. */
  103267. Tools.IsExponentOfTwo = function (value) {
  103268. var count = 1;
  103269. do {
  103270. count *= 2;
  103271. } while (count < value);
  103272. return count === value;
  103273. };
  103274. /**
  103275. * Returns the nearest 32-bit single precision float representation of a Number
  103276. * @param value A Number. If the parameter is of a different type, it will get converted
  103277. * to a number or to NaN if it cannot be converted
  103278. * @returns number
  103279. */
  103280. Tools.FloatRound = function (value) {
  103281. if (Math.fround) {
  103282. return Math.fround(value);
  103283. }
  103284. return (Tools._tmpFloatArray[0] = value);
  103285. };
  103286. /**
  103287. * Find the next highest power of two.
  103288. * @param x Number to start search from.
  103289. * @return Next highest power of two.
  103290. */
  103291. Tools.CeilingPOT = function (x) {
  103292. x--;
  103293. x |= x >> 1;
  103294. x |= x >> 2;
  103295. x |= x >> 4;
  103296. x |= x >> 8;
  103297. x |= x >> 16;
  103298. x++;
  103299. return x;
  103300. };
  103301. /**
  103302. * Find the next lowest power of two.
  103303. * @param x Number to start search from.
  103304. * @return Next lowest power of two.
  103305. */
  103306. Tools.FloorPOT = function (x) {
  103307. x = x | (x >> 1);
  103308. x = x | (x >> 2);
  103309. x = x | (x >> 4);
  103310. x = x | (x >> 8);
  103311. x = x | (x >> 16);
  103312. return x - (x >> 1);
  103313. };
  103314. /**
  103315. * Find the nearest power of two.
  103316. * @param x Number to start search from.
  103317. * @return Next nearest power of two.
  103318. */
  103319. Tools.NearestPOT = function (x) {
  103320. var c = Tools.CeilingPOT(x);
  103321. var f = Tools.FloorPOT(x);
  103322. return (c - x) > (x - f) ? f : c;
  103323. };
  103324. /**
  103325. * Get the closest exponent of two
  103326. * @param value defines the value to approximate
  103327. * @param max defines the maximum value to return
  103328. * @param mode defines how to define the closest value
  103329. * @returns closest exponent of two of the given value
  103330. */
  103331. Tools.GetExponentOfTwo = function (value, max, mode) {
  103332. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  103333. var pot;
  103334. switch (mode) {
  103335. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  103336. pot = Tools.FloorPOT(value);
  103337. break;
  103338. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  103339. pot = Tools.NearestPOT(value);
  103340. break;
  103341. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  103342. default:
  103343. pot = Tools.CeilingPOT(value);
  103344. break;
  103345. }
  103346. return Math.min(pot, max);
  103347. };
  103348. /**
  103349. * Extracts the filename from a path
  103350. * @param path defines the path to use
  103351. * @returns the filename
  103352. */
  103353. Tools.GetFilename = function (path) {
  103354. var index = path.lastIndexOf("/");
  103355. if (index < 0) {
  103356. return path;
  103357. }
  103358. return path.substring(index + 1);
  103359. };
  103360. /**
  103361. * Extracts the "folder" part of a path (everything before the filename).
  103362. * @param uri The URI to extract the info from
  103363. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  103364. * @returns The "folder" part of the path
  103365. */
  103366. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  103367. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  103368. var index = uri.lastIndexOf("/");
  103369. if (index < 0) {
  103370. if (returnUnchangedIfNoSlash) {
  103371. return uri;
  103372. }
  103373. return "";
  103374. }
  103375. return uri.substring(0, index + 1);
  103376. };
  103377. /**
  103378. * Convert an angle in radians to degrees
  103379. * @param angle defines the angle to convert
  103380. * @returns the angle in degrees
  103381. */
  103382. Tools.ToDegrees = function (angle) {
  103383. return angle * 180 / Math.PI;
  103384. };
  103385. /**
  103386. * Convert an angle in degrees to radians
  103387. * @param angle defines the angle to convert
  103388. * @returns the angle in radians
  103389. */
  103390. Tools.ToRadians = function (angle) {
  103391. return angle * Math.PI / 180;
  103392. };
  103393. /**
  103394. * Encode a buffer to a base64 string
  103395. * @param buffer defines the buffer to encode
  103396. * @returns the encoded string
  103397. */
  103398. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  103399. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  103400. var output = "";
  103401. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  103402. var i = 0;
  103403. var bytes = new Uint8Array(buffer);
  103404. while (i < bytes.length) {
  103405. chr1 = bytes[i++];
  103406. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  103407. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  103408. enc1 = chr1 >> 2;
  103409. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  103410. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  103411. enc4 = chr3 & 63;
  103412. if (isNaN(chr2)) {
  103413. enc3 = enc4 = 64;
  103414. }
  103415. else if (isNaN(chr3)) {
  103416. enc4 = 64;
  103417. }
  103418. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  103419. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  103420. }
  103421. return "data:image/png;base64," + output;
  103422. };
  103423. /**
  103424. * Extracts minimum and maximum values from a list of indexed positions
  103425. * @param positions defines the positions to use
  103426. * @param indices defines the indices to the positions
  103427. * @param indexStart defines the start index
  103428. * @param indexCount defines the end index
  103429. * @param bias defines bias value to add to the result
  103430. * @return minimum and maximum values
  103431. */
  103432. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  103433. if (bias === void 0) { bias = null; }
  103434. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  103435. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  103436. for (var index = indexStart; index < indexStart + indexCount; index++) {
  103437. var offset = indices[index] * 3;
  103438. var x = positions[offset];
  103439. var y = positions[offset + 1];
  103440. var z = positions[offset + 2];
  103441. minimum.minimizeInPlaceFromFloats(x, y, z);
  103442. maximum.maximizeInPlaceFromFloats(x, y, z);
  103443. }
  103444. if (bias) {
  103445. minimum.x -= minimum.x * bias.x + bias.y;
  103446. minimum.y -= minimum.y * bias.x + bias.y;
  103447. minimum.z -= minimum.z * bias.x + bias.y;
  103448. maximum.x += maximum.x * bias.x + bias.y;
  103449. maximum.y += maximum.y * bias.x + bias.y;
  103450. maximum.z += maximum.z * bias.x + bias.y;
  103451. }
  103452. return {
  103453. minimum: minimum,
  103454. maximum: maximum
  103455. };
  103456. };
  103457. /**
  103458. * Extracts minimum and maximum values from a list of positions
  103459. * @param positions defines the positions to use
  103460. * @param start defines the start index in the positions array
  103461. * @param count defines the number of positions to handle
  103462. * @param bias defines bias value to add to the result
  103463. * @param stride defines the stride size to use (distance between two positions in the positions array)
  103464. * @return minimum and maximum values
  103465. */
  103466. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  103467. if (bias === void 0) { bias = null; }
  103468. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  103469. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  103470. if (!stride) {
  103471. stride = 3;
  103472. }
  103473. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  103474. var x = positions[offset];
  103475. var y = positions[offset + 1];
  103476. var z = positions[offset + 2];
  103477. minimum.minimizeInPlaceFromFloats(x, y, z);
  103478. maximum.maximizeInPlaceFromFloats(x, y, z);
  103479. }
  103480. if (bias) {
  103481. minimum.x -= minimum.x * bias.x + bias.y;
  103482. minimum.y -= minimum.y * bias.x + bias.y;
  103483. minimum.z -= minimum.z * bias.x + bias.y;
  103484. maximum.x += maximum.x * bias.x + bias.y;
  103485. maximum.y += maximum.y * bias.x + bias.y;
  103486. maximum.z += maximum.z * bias.x + bias.y;
  103487. }
  103488. return {
  103489. minimum: minimum,
  103490. maximum: maximum
  103491. };
  103492. };
  103493. /**
  103494. * Returns an array if obj is not an array
  103495. * @param obj defines the object to evaluate as an array
  103496. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  103497. * @returns either obj directly if obj is an array or a new array containing obj
  103498. */
  103499. Tools.MakeArray = function (obj, allowsNullUndefined) {
  103500. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  103501. return null;
  103502. }
  103503. return Array.isArray(obj) ? obj : [obj];
  103504. };
  103505. /**
  103506. * Gets the pointer prefix to use
  103507. * @returns "pointer" if touch is enabled. Else returns "mouse"
  103508. */
  103509. Tools.GetPointerPrefix = function () {
  103510. var eventPrefix = "pointer";
  103511. // Check if pointer events are supported
  103512. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  103513. eventPrefix = "mouse";
  103514. }
  103515. return eventPrefix;
  103516. };
  103517. /**
  103518. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  103519. * @param func - the function to be called
  103520. * @param requester - the object that will request the next frame. Falls back to window.
  103521. * @returns frame number
  103522. */
  103523. Tools.QueueNewFrame = function (func, requester) {
  103524. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103525. return setTimeout(func, 16);
  103526. }
  103527. if (!requester) {
  103528. requester = window;
  103529. }
  103530. if (requester.requestAnimationFrame) {
  103531. return requester.requestAnimationFrame(func);
  103532. }
  103533. else if (requester.msRequestAnimationFrame) {
  103534. return requester.msRequestAnimationFrame(func);
  103535. }
  103536. else if (requester.webkitRequestAnimationFrame) {
  103537. return requester.webkitRequestAnimationFrame(func);
  103538. }
  103539. else if (requester.mozRequestAnimationFrame) {
  103540. return requester.mozRequestAnimationFrame(func);
  103541. }
  103542. else if (requester.oRequestAnimationFrame) {
  103543. return requester.oRequestAnimationFrame(func);
  103544. }
  103545. else {
  103546. return window.setTimeout(func, 16);
  103547. }
  103548. };
  103549. /**
  103550. * Ask the browser to promote the current element to fullscreen rendering mode
  103551. * @param element defines the DOM element to promote
  103552. */
  103553. Tools.RequestFullscreen = function (element) {
  103554. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  103555. if (!requestFunction) {
  103556. return;
  103557. }
  103558. requestFunction.call(element);
  103559. };
  103560. /**
  103561. * Asks the browser to exit fullscreen mode
  103562. */
  103563. Tools.ExitFullscreen = function () {
  103564. var anyDoc = document;
  103565. if (document.exitFullscreen) {
  103566. document.exitFullscreen();
  103567. }
  103568. else if (anyDoc.mozCancelFullScreen) {
  103569. anyDoc.mozCancelFullScreen();
  103570. }
  103571. else if (anyDoc.webkitCancelFullScreen) {
  103572. anyDoc.webkitCancelFullScreen();
  103573. }
  103574. else if (anyDoc.msCancelFullScreen) {
  103575. anyDoc.msCancelFullScreen();
  103576. }
  103577. };
  103578. /**
  103579. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  103580. * @param url define the url we are trying
  103581. * @param element define the dom element where to configure the cors policy
  103582. */
  103583. Tools.SetCorsBehavior = function (url, element) {
  103584. if (url && url.indexOf("data:") === 0) {
  103585. return;
  103586. }
  103587. if (Tools.CorsBehavior) {
  103588. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  103589. element.crossOrigin = Tools.CorsBehavior;
  103590. }
  103591. else {
  103592. var result = Tools.CorsBehavior(url);
  103593. if (result) {
  103594. element.crossOrigin = result;
  103595. }
  103596. }
  103597. }
  103598. };
  103599. // External files
  103600. /**
  103601. * Removes unwanted characters from an url
  103602. * @param url defines the url to clean
  103603. * @returns the cleaned url
  103604. */
  103605. Tools.CleanUrl = function (url) {
  103606. url = url.replace(/#/mg, "%23");
  103607. return url;
  103608. };
  103609. /**
  103610. * Loads an image as an HTMLImageElement.
  103611. * @param input url string, ArrayBuffer, or Blob to load
  103612. * @param onLoad callback called when the image successfully loads
  103613. * @param onError callback called when the image fails to load
  103614. * @param offlineProvider offline provider for caching
  103615. * @returns the HTMLImageElement of the loaded image
  103616. */
  103617. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  103618. var url;
  103619. var usingObjectURL = false;
  103620. if (input instanceof ArrayBuffer) {
  103621. url = URL.createObjectURL(new Blob([input]));
  103622. usingObjectURL = true;
  103623. }
  103624. else if (input instanceof Blob) {
  103625. url = URL.createObjectURL(input);
  103626. usingObjectURL = true;
  103627. }
  103628. else {
  103629. url = Tools.CleanUrl(input);
  103630. url = Tools.PreprocessUrl(input);
  103631. }
  103632. var img = new Image();
  103633. Tools.SetCorsBehavior(url, img);
  103634. var loadHandler = function () {
  103635. img.removeEventListener("load", loadHandler);
  103636. img.removeEventListener("error", errorHandler);
  103637. onLoad(img);
  103638. // Must revoke the URL after calling onLoad to avoid security exceptions in
  103639. // certain scenarios (e.g. when hosted in vscode).
  103640. if (usingObjectURL && img.src) {
  103641. URL.revokeObjectURL(img.src);
  103642. }
  103643. };
  103644. var errorHandler = function (err) {
  103645. img.removeEventListener("load", loadHandler);
  103646. img.removeEventListener("error", errorHandler);
  103647. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  103648. if (onError) {
  103649. onError("Error while trying to load image: " + input, err);
  103650. }
  103651. if (usingObjectURL && img.src) {
  103652. URL.revokeObjectURL(img.src);
  103653. }
  103654. };
  103655. img.addEventListener("load", loadHandler);
  103656. img.addEventListener("error", errorHandler);
  103657. var noOfflineSupport = function () {
  103658. img.src = url;
  103659. };
  103660. var loadFromOfflineSupport = function () {
  103661. if (offlineProvider) {
  103662. offlineProvider.loadImage(url, img);
  103663. }
  103664. };
  103665. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  103666. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  103667. }
  103668. else {
  103669. if (url.indexOf("file:") !== -1) {
  103670. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  103671. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  103672. try {
  103673. var blobURL;
  103674. try {
  103675. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  103676. }
  103677. catch (ex) {
  103678. // Chrome doesn't support oneTimeOnly parameter
  103679. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  103680. }
  103681. img.src = blobURL;
  103682. usingObjectURL = true;
  103683. }
  103684. catch (e) {
  103685. img.src = "";
  103686. }
  103687. return img;
  103688. }
  103689. }
  103690. noOfflineSupport();
  103691. }
  103692. return img;
  103693. };
  103694. /**
  103695. * Loads a file
  103696. * @param url url string, ArrayBuffer, or Blob to load
  103697. * @param onSuccess callback called when the file successfully loads
  103698. * @param onProgress callback called while file is loading (if the server supports this mode)
  103699. * @param offlineProvider defines the offline provider for caching
  103700. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  103701. * @param onError callback called when the file fails to load
  103702. * @returns a file request object
  103703. */
  103704. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  103705. url = Tools.CleanUrl(url);
  103706. url = Tools.PreprocessUrl(url);
  103707. // If file and file input are set
  103708. if (url.indexOf("file:") !== -1) {
  103709. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  103710. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  103711. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  103712. }
  103713. }
  103714. var loadUrl = Tools.BaseUrl + url;
  103715. var aborted = false;
  103716. var fileRequest = {
  103717. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  103718. abort: function () { return aborted = true; },
  103719. };
  103720. var requestFile = function () {
  103721. var request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  103722. var retryHandle = null;
  103723. fileRequest.abort = function () {
  103724. aborted = true;
  103725. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  103726. request.abort();
  103727. }
  103728. if (retryHandle !== null) {
  103729. clearTimeout(retryHandle);
  103730. retryHandle = null;
  103731. }
  103732. };
  103733. var retryLoop = function (retryIndex) {
  103734. request.open('GET', loadUrl);
  103735. if (useArrayBuffer) {
  103736. request.responseType = "arraybuffer";
  103737. }
  103738. if (onProgress) {
  103739. request.addEventListener("progress", onProgress);
  103740. }
  103741. var onLoadEnd = function () {
  103742. request.removeEventListener("loadend", onLoadEnd);
  103743. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  103744. fileRequest.onCompleteObservable.clear();
  103745. };
  103746. request.addEventListener("loadend", onLoadEnd);
  103747. var onReadyStateChange = function () {
  103748. if (aborted) {
  103749. return;
  103750. }
  103751. // In case of undefined state in some browsers.
  103752. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  103753. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  103754. request.removeEventListener("readystatechange", onReadyStateChange);
  103755. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  103756. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  103757. return;
  103758. }
  103759. var retryStrategy = Tools.DefaultRetryStrategy;
  103760. if (retryStrategy) {
  103761. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  103762. if (waitTime !== -1) {
  103763. // Prevent the request from completing for retry.
  103764. request.removeEventListener("loadend", onLoadEnd);
  103765. request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  103766. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  103767. return;
  103768. }
  103769. }
  103770. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  103771. if (onError) {
  103772. onError(request, e);
  103773. }
  103774. else {
  103775. throw e;
  103776. }
  103777. }
  103778. };
  103779. request.addEventListener("readystatechange", onReadyStateChange);
  103780. request.send();
  103781. };
  103782. retryLoop(0);
  103783. };
  103784. // Caching all files
  103785. if (offlineProvider && offlineProvider.enableSceneOffline) {
  103786. var noOfflineSupport_1 = function (request) {
  103787. if (request && request.status > 400) {
  103788. if (onError) {
  103789. onError(request);
  103790. }
  103791. }
  103792. else {
  103793. if (!aborted) {
  103794. requestFile();
  103795. }
  103796. }
  103797. };
  103798. var loadFromOfflineSupport = function () {
  103799. // TODO: database needs to support aborting and should return a IFileRequest
  103800. if (aborted) {
  103801. return;
  103802. }
  103803. if (offlineProvider) {
  103804. offlineProvider.loadFile(url, function (data) {
  103805. if (!aborted) {
  103806. onSuccess(data);
  103807. }
  103808. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  103809. }, onProgress ? function (event) {
  103810. if (!aborted) {
  103811. onProgress(event);
  103812. }
  103813. } : undefined, noOfflineSupport_1, useArrayBuffer);
  103814. }
  103815. };
  103816. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  103817. }
  103818. else {
  103819. requestFile();
  103820. }
  103821. return fileRequest;
  103822. };
  103823. /**
  103824. * Load a script (identified by an url). When the url returns, the
  103825. * content of this file is added into a new script element, attached to the DOM (body element)
  103826. * @param scriptUrl defines the url of the script to laod
  103827. * @param onSuccess defines the callback called when the script is loaded
  103828. * @param onError defines the callback to call if an error occurs
  103829. * @param scriptId defines the id of the script element
  103830. */
  103831. Tools.LoadScript = function (scriptUrl, onSuccess, onError, scriptId) {
  103832. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103833. return;
  103834. }
  103835. var head = document.getElementsByTagName('head')[0];
  103836. var script = document.createElement('script');
  103837. script.setAttribute('type', 'text/javascript');
  103838. script.setAttribute('src', scriptUrl);
  103839. if (scriptId) {
  103840. script.id = scriptId;
  103841. }
  103842. script.onload = function () {
  103843. if (onSuccess) {
  103844. onSuccess();
  103845. }
  103846. };
  103847. script.onerror = function (e) {
  103848. if (onError) {
  103849. onError("Unable to load script '" + scriptUrl + "'", e);
  103850. }
  103851. };
  103852. head.appendChild(script);
  103853. };
  103854. /**
  103855. * Load an asynchronous script (identified by an url). When the url returns, the
  103856. * content of this file is added into a new script element, attached to the DOM (body element)
  103857. * @param scriptUrl defines the url of the script to laod
  103858. * @param scriptId defines the id of the script element
  103859. * @returns a promise request object
  103860. */
  103861. Tools.LoadScriptAsync = function (scriptUrl, scriptId) {
  103862. return new Promise(function (resolve, reject) {
  103863. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103864. resolve(false);
  103865. return;
  103866. }
  103867. var head = document.getElementsByTagName('head')[0];
  103868. var script = document.createElement('script');
  103869. script.setAttribute('type', 'text/javascript');
  103870. script.setAttribute('src', scriptUrl);
  103871. if (scriptId) {
  103872. script.id = scriptId;
  103873. }
  103874. script.onload = function () {
  103875. resolve(true);
  103876. };
  103877. script.onerror = function (e) {
  103878. resolve(false);
  103879. };
  103880. head.appendChild(script);
  103881. });
  103882. };
  103883. /**
  103884. * Loads a file from a blob
  103885. * @param fileToLoad defines the blob to use
  103886. * @param callback defines the callback to call when data is loaded
  103887. * @param progressCallback defines the callback to call during loading process
  103888. * @returns a file request object
  103889. */
  103890. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  103891. var reader = new FileReader();
  103892. var request = {
  103893. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  103894. abort: function () { return reader.abort(); },
  103895. };
  103896. reader.onloadend = function (e) {
  103897. request.onCompleteObservable.notifyObservers(request);
  103898. };
  103899. reader.onload = function (e) {
  103900. //target doesn't have result from ts 1.3
  103901. callback(e.target['result']);
  103902. };
  103903. reader.onprogress = progressCallback;
  103904. reader.readAsDataURL(fileToLoad);
  103905. return request;
  103906. };
  103907. /**
  103908. * Loads a file
  103909. * @param fileToLoad defines the file to load
  103910. * @param callback defines the callback to call when data is loaded
  103911. * @param progressCallBack defines the callback to call during loading process
  103912. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  103913. * @returns a file request object
  103914. */
  103915. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  103916. var reader = new FileReader();
  103917. var request = {
  103918. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  103919. abort: function () { return reader.abort(); },
  103920. };
  103921. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  103922. reader.onerror = function (e) {
  103923. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  103924. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  103925. };
  103926. reader.onload = function (e) {
  103927. //target doesn't have result from ts 1.3
  103928. callback(e.target['result']);
  103929. };
  103930. if (progressCallBack) {
  103931. reader.onprogress = progressCallBack;
  103932. }
  103933. if (!useArrayBuffer) {
  103934. // Asynchronous read
  103935. reader.readAsText(fileToLoad);
  103936. }
  103937. else {
  103938. reader.readAsArrayBuffer(fileToLoad);
  103939. }
  103940. return request;
  103941. };
  103942. /**
  103943. * Creates a data url from a given string content
  103944. * @param content defines the content to convert
  103945. * @returns the new data url link
  103946. */
  103947. Tools.FileAsURL = function (content) {
  103948. var fileBlob = new Blob([content]);
  103949. var url = window.URL || window.webkitURL;
  103950. var link = url.createObjectURL(fileBlob);
  103951. return link;
  103952. };
  103953. /**
  103954. * Format the given number to a specific decimal format
  103955. * @param value defines the number to format
  103956. * @param decimals defines the number of decimals to use
  103957. * @returns the formatted string
  103958. */
  103959. Tools.Format = function (value, decimals) {
  103960. if (decimals === void 0) { decimals = 2; }
  103961. return value.toFixed(decimals);
  103962. };
  103963. /**
  103964. * Checks if a given vector is inside a specific range
  103965. * @param v defines the vector to test
  103966. * @param min defines the minimum range
  103967. * @param max defines the maximum range
  103968. */
  103969. Tools.CheckExtends = function (v, min, max) {
  103970. min.minimizeInPlace(v);
  103971. max.maximizeInPlace(v);
  103972. };
  103973. /**
  103974. * Tries to copy an object by duplicating every property
  103975. * @param source defines the source object
  103976. * @param destination defines the target object
  103977. * @param doNotCopyList defines a list of properties to avoid
  103978. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  103979. */
  103980. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  103981. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  103982. };
  103983. /**
  103984. * Gets a boolean indicating if the given object has no own property
  103985. * @param obj defines the object to test
  103986. * @returns true if object has no own property
  103987. */
  103988. Tools.IsEmpty = function (obj) {
  103989. for (var i in obj) {
  103990. if (obj.hasOwnProperty(i)) {
  103991. return false;
  103992. }
  103993. }
  103994. return true;
  103995. };
  103996. /**
  103997. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  103998. * @param str Source string
  103999. * @param suffix Suffix to search for in the source string
  104000. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  104001. */
  104002. Tools.EndsWith = function (str, suffix) {
  104003. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  104004. };
  104005. /**
  104006. * Function used to register events at window level
  104007. * @param events defines the events to register
  104008. */
  104009. Tools.RegisterTopRootEvents = function (events) {
  104010. for (var index = 0; index < events.length; index++) {
  104011. var event = events[index];
  104012. window.addEventListener(event.name, event.handler, false);
  104013. try {
  104014. if (window.parent) {
  104015. window.parent.addEventListener(event.name, event.handler, false);
  104016. }
  104017. }
  104018. catch (e) {
  104019. // Silently fails...
  104020. }
  104021. }
  104022. };
  104023. /**
  104024. * Function used to unregister events from window level
  104025. * @param events defines the events to unregister
  104026. */
  104027. Tools.UnregisterTopRootEvents = function (events) {
  104028. for (var index = 0; index < events.length; index++) {
  104029. var event = events[index];
  104030. window.removeEventListener(event.name, event.handler);
  104031. try {
  104032. if (window.parent) {
  104033. window.parent.removeEventListener(event.name, event.handler);
  104034. }
  104035. }
  104036. catch (e) {
  104037. // Silently fails...
  104038. }
  104039. }
  104040. };
  104041. /**
  104042. * Dumps the current bound framebuffer
  104043. * @param width defines the rendering width
  104044. * @param height defines the rendering height
  104045. * @param engine defines the hosting engine
  104046. * @param successCallback defines the callback triggered once the data are available
  104047. * @param mimeType defines the mime type of the result
  104048. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  104049. */
  104050. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  104051. if (mimeType === void 0) { mimeType = "image/png"; }
  104052. // Read the contents of the framebuffer
  104053. var numberOfChannelsByLine = width * 4;
  104054. var halfHeight = height / 2;
  104055. //Reading datas from WebGL
  104056. var data = engine.readPixels(0, 0, width, height);
  104057. //To flip image on Y axis.
  104058. for (var i = 0; i < halfHeight; i++) {
  104059. for (var j = 0; j < numberOfChannelsByLine; j++) {
  104060. var currentCell = j + i * numberOfChannelsByLine;
  104061. var targetLine = height - i - 1;
  104062. var targetCell = j + targetLine * numberOfChannelsByLine;
  104063. var temp = data[currentCell];
  104064. data[currentCell] = data[targetCell];
  104065. data[targetCell] = temp;
  104066. }
  104067. }
  104068. // Create a 2D canvas to store the result
  104069. if (!Tools._ScreenshotCanvas) {
  104070. Tools._ScreenshotCanvas = document.createElement('canvas');
  104071. }
  104072. Tools._ScreenshotCanvas.width = width;
  104073. Tools._ScreenshotCanvas.height = height;
  104074. var context = Tools._ScreenshotCanvas.getContext('2d');
  104075. if (context) {
  104076. // Copy the pixels to a 2D canvas
  104077. var imageData = context.createImageData(width, height);
  104078. var castData = (imageData.data);
  104079. castData.set(data);
  104080. context.putImageData(imageData, 0, 0);
  104081. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  104082. }
  104083. };
  104084. /**
  104085. * Converts the canvas data to blob.
  104086. * This acts as a polyfill for browsers not supporting the to blob function.
  104087. * @param canvas Defines the canvas to extract the data from
  104088. * @param successCallback Defines the callback triggered once the data are available
  104089. * @param mimeType Defines the mime type of the result
  104090. */
  104091. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  104092. if (mimeType === void 0) { mimeType = "image/png"; }
  104093. // We need HTMLCanvasElement.toBlob for HD screenshots
  104094. if (!canvas.toBlob) {
  104095. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  104096. canvas.toBlob = function (callback, type, quality) {
  104097. var _this = this;
  104098. setTimeout(function () {
  104099. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  104100. for (var i = 0; i < len; i++) {
  104101. arr[i] = binStr.charCodeAt(i);
  104102. }
  104103. callback(new Blob([arr]));
  104104. });
  104105. };
  104106. }
  104107. canvas.toBlob(function (blob) {
  104108. successCallback(blob);
  104109. }, mimeType);
  104110. };
  104111. /**
  104112. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  104113. * @param successCallback defines the callback triggered once the data are available
  104114. * @param mimeType defines the mime type of the result
  104115. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  104116. */
  104117. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  104118. if (mimeType === void 0) { mimeType = "image/png"; }
  104119. if (successCallback) {
  104120. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  104121. successCallback(base64Image);
  104122. }
  104123. else {
  104124. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  104125. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  104126. if (("download" in document.createElement("a"))) {
  104127. if (!fileName) {
  104128. var date = new Date();
  104129. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  104130. fileName = "screenshot_" + stringDate + ".png";
  104131. }
  104132. Tools.Download(blob, fileName);
  104133. }
  104134. else {
  104135. var url = URL.createObjectURL(blob);
  104136. var newWindow = window.open("");
  104137. if (!newWindow) {
  104138. return;
  104139. }
  104140. var img = newWindow.document.createElement("img");
  104141. img.onload = function () {
  104142. // no longer need to read the blob so it's revoked
  104143. URL.revokeObjectURL(url);
  104144. };
  104145. img.src = url;
  104146. newWindow.document.body.appendChild(img);
  104147. }
  104148. }, mimeType);
  104149. }
  104150. };
  104151. /**
  104152. * Downloads a blob in the browser
  104153. * @param blob defines the blob to download
  104154. * @param fileName defines the name of the downloaded file
  104155. */
  104156. Tools.Download = function (blob, fileName) {
  104157. if (navigator && navigator.msSaveBlob) {
  104158. navigator.msSaveBlob(blob, fileName);
  104159. return;
  104160. }
  104161. var url = window.URL.createObjectURL(blob);
  104162. var a = document.createElement("a");
  104163. document.body.appendChild(a);
  104164. a.style.display = "none";
  104165. a.href = url;
  104166. a.download = fileName;
  104167. a.addEventListener("click", function () {
  104168. if (a.parentElement) {
  104169. a.parentElement.removeChild(a);
  104170. }
  104171. });
  104172. a.click();
  104173. window.URL.revokeObjectURL(url);
  104174. };
  104175. /**
  104176. * Captures a screenshot of the current rendering
  104177. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104178. * @param engine defines the rendering engine
  104179. * @param camera defines the source camera
  104180. * @param size This parameter can be set to a single number or to an object with the
  104181. * following (optional) properties: precision, width, height. If a single number is passed,
  104182. * it will be used for both width and height. If an object is passed, the screenshot size
  104183. * will be derived from the parameters. The precision property is a multiplier allowing
  104184. * rendering at a higher or lower resolution
  104185. * @param successCallback defines the callback receives a single parameter which contains the
  104186. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104187. * src parameter of an <img> to display it
  104188. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104189. * Check your browser for supported MIME types
  104190. */
  104191. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  104192. if (mimeType === void 0) { mimeType = "image/png"; }
  104193. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  104194. };
  104195. /**
  104196. * Generates an image screenshot from the specified camera.
  104197. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104198. * @param engine The engine to use for rendering
  104199. * @param camera The camera to use for rendering
  104200. * @param size This parameter can be set to a single number or to an object with the
  104201. * following (optional) properties: precision, width, height. If a single number is passed,
  104202. * it will be used for both width and height. If an object is passed, the screenshot size
  104203. * will be derived from the parameters. The precision property is a multiplier allowing
  104204. * rendering at a higher or lower resolution
  104205. * @param successCallback The callback receives a single parameter which contains the
  104206. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104207. * src parameter of an <img> to display it
  104208. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104209. * Check your browser for supported MIME types
  104210. * @param samples Texture samples (default: 1)
  104211. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104212. * @param fileName A name for for the downloaded file.
  104213. */
  104214. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  104215. if (mimeType === void 0) { mimeType = "image/png"; }
  104216. if (samples === void 0) { samples = 1; }
  104217. if (antialiasing === void 0) { antialiasing = false; }
  104218. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  104219. };
  104220. /**
  104221. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104222. * Be aware Math.random() could cause collisions, but:
  104223. * "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"
  104224. * @returns a pseudo random id
  104225. */
  104226. Tools.RandomId = function () {
  104227. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  104228. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  104229. return v.toString(16);
  104230. });
  104231. };
  104232. /**
  104233. * Test if the given uri is a base64 string
  104234. * @param uri The uri to test
  104235. * @return True if the uri is a base64 string or false otherwise
  104236. */
  104237. Tools.IsBase64 = function (uri) {
  104238. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  104239. };
  104240. /**
  104241. * Decode the given base64 uri.
  104242. * @param uri The uri to decode
  104243. * @return The decoded base64 data.
  104244. */
  104245. Tools.DecodeBase64 = function (uri) {
  104246. var decodedString = atob(uri.split(",")[1]);
  104247. var bufferLength = decodedString.length;
  104248. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  104249. for (var i = 0; i < bufferLength; i++) {
  104250. bufferView[i] = decodedString.charCodeAt(i);
  104251. }
  104252. return bufferView.buffer;
  104253. };
  104254. /**
  104255. * Gets the absolute url.
  104256. * @param url the input url
  104257. * @return the absolute url
  104258. */
  104259. Tools.GetAbsoluteUrl = function (url) {
  104260. var a = document.createElement("a");
  104261. a.href = url;
  104262. return a.href;
  104263. };
  104264. Object.defineProperty(Tools, "errorsCount", {
  104265. /**
  104266. * Gets a value indicating the number of loading errors
  104267. * @ignorenaming
  104268. */
  104269. get: function () {
  104270. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  104271. },
  104272. enumerable: true,
  104273. configurable: true
  104274. });
  104275. /**
  104276. * Log a message to the console
  104277. * @param message defines the message to log
  104278. */
  104279. Tools.Log = function (message) {
  104280. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  104281. };
  104282. /**
  104283. * Write a warning message to the console
  104284. * @param message defines the message to log
  104285. */
  104286. Tools.Warn = function (message) {
  104287. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  104288. };
  104289. /**
  104290. * Write an error message to the console
  104291. * @param message defines the message to log
  104292. */
  104293. Tools.Error = function (message) {
  104294. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  104295. };
  104296. Object.defineProperty(Tools, "LogCache", {
  104297. /**
  104298. * Gets current log cache (list of logs)
  104299. */
  104300. get: function () {
  104301. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  104302. },
  104303. enumerable: true,
  104304. configurable: true
  104305. });
  104306. /**
  104307. * Clears the log cache
  104308. */
  104309. Tools.ClearLogCache = function () {
  104310. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  104311. };
  104312. Object.defineProperty(Tools, "LogLevels", {
  104313. /**
  104314. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104315. */
  104316. set: function (level) {
  104317. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  104318. },
  104319. enumerable: true,
  104320. configurable: true
  104321. });
  104322. /**
  104323. * Checks if the loaded document was accessed via `file:`-Protocol.
  104324. * @returns boolean
  104325. */
  104326. Tools.IsFileURL = function () {
  104327. return location.protocol === "file:";
  104328. };
  104329. Object.defineProperty(Tools, "PerformanceLogLevel", {
  104330. /**
  104331. * Sets the current performance log level
  104332. */
  104333. set: function (level) {
  104334. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  104335. Tools.StartPerformanceCounter = Tools._StartUserMark;
  104336. Tools.EndPerformanceCounter = Tools._EndUserMark;
  104337. return;
  104338. }
  104339. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  104340. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  104341. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  104342. return;
  104343. }
  104344. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  104345. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  104346. },
  104347. enumerable: true,
  104348. configurable: true
  104349. });
  104350. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  104351. };
  104352. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  104353. };
  104354. Tools._StartUserMark = function (counterName, condition) {
  104355. if (condition === void 0) { condition = true; }
  104356. if (!Tools._performance) {
  104357. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  104358. return;
  104359. }
  104360. Tools._performance = window.performance;
  104361. }
  104362. if (!condition || !Tools._performance.mark) {
  104363. return;
  104364. }
  104365. Tools._performance.mark(counterName + "-Begin");
  104366. };
  104367. Tools._EndUserMark = function (counterName, condition) {
  104368. if (condition === void 0) { condition = true; }
  104369. if (!condition || !Tools._performance.mark) {
  104370. return;
  104371. }
  104372. Tools._performance.mark(counterName + "-End");
  104373. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  104374. };
  104375. Tools._StartPerformanceConsole = function (counterName, condition) {
  104376. if (condition === void 0) { condition = true; }
  104377. if (!condition) {
  104378. return;
  104379. }
  104380. Tools._StartUserMark(counterName, condition);
  104381. if (console.time) {
  104382. console.time(counterName);
  104383. }
  104384. };
  104385. Tools._EndPerformanceConsole = function (counterName, condition) {
  104386. if (condition === void 0) { condition = true; }
  104387. if (!condition) {
  104388. return;
  104389. }
  104390. Tools._EndUserMark(counterName, condition);
  104391. if (console.time) {
  104392. console.timeEnd(counterName);
  104393. }
  104394. };
  104395. Object.defineProperty(Tools, "Now", {
  104396. /**
  104397. * Gets either window.performance.now() if supported or Date.now() else
  104398. */
  104399. get: function () {
  104400. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104401. },
  104402. enumerable: true,
  104403. configurable: true
  104404. });
  104405. /**
  104406. * This method will return the name of the class used to create the instance of the given object.
  104407. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104408. * @param object the object to get the class name from
  104409. * @param isType defines if the object is actually a type
  104410. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104411. */
  104412. Tools.GetClassName = function (object, isType) {
  104413. if (isType === void 0) { isType = false; }
  104414. var name = null;
  104415. if (!isType && object.getClassName) {
  104416. name = object.getClassName();
  104417. }
  104418. else {
  104419. if (object instanceof Object) {
  104420. var classObj = isType ? object : Object.getPrototypeOf(object);
  104421. name = classObj.constructor["__bjsclassName__"];
  104422. }
  104423. if (!name) {
  104424. name = typeof object;
  104425. }
  104426. }
  104427. return name;
  104428. };
  104429. /**
  104430. * Gets the first element of an array satisfying a given predicate
  104431. * @param array defines the array to browse
  104432. * @param predicate defines the predicate to use
  104433. * @returns null if not found or the element
  104434. */
  104435. Tools.First = function (array, predicate) {
  104436. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  104437. var el = array_1[_i];
  104438. if (predicate(el)) {
  104439. return el;
  104440. }
  104441. }
  104442. return null;
  104443. };
  104444. /**
  104445. * This method will return the name of the full name of the class, including its owning module (if any).
  104446. * 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).
  104447. * @param object the object to get the class name from
  104448. * @param isType defines if the object is actually a type
  104449. * @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.
  104450. * @ignorenaming
  104451. */
  104452. Tools.getFullClassName = function (object, isType) {
  104453. if (isType === void 0) { isType = false; }
  104454. var className = null;
  104455. var moduleName = null;
  104456. if (!isType && object.getClassName) {
  104457. className = object.getClassName();
  104458. }
  104459. else {
  104460. if (object instanceof Object) {
  104461. var classObj = isType ? object : Object.getPrototypeOf(object);
  104462. className = classObj.constructor["__bjsclassName__"];
  104463. moduleName = classObj.constructor["__bjsmoduleName__"];
  104464. }
  104465. if (!className) {
  104466. className = typeof object;
  104467. }
  104468. }
  104469. if (!className) {
  104470. return null;
  104471. }
  104472. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  104473. };
  104474. /**
  104475. * Returns a promise that resolves after the given amount of time.
  104476. * @param delay Number of milliseconds to delay
  104477. * @returns Promise that resolves after the given amount of time
  104478. */
  104479. Tools.DelayAsync = function (delay) {
  104480. return new Promise(function (resolve) {
  104481. setTimeout(function () {
  104482. resolve();
  104483. }, delay);
  104484. });
  104485. };
  104486. /**
  104487. * Gets the current gradient from an array of IValueGradient
  104488. * @param ratio defines the current ratio to get
  104489. * @param gradients defines the array of IValueGradient
  104490. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  104491. */
  104492. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  104493. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  104494. var currentGradient = gradients[gradientIndex];
  104495. var nextGradient = gradients[gradientIndex + 1];
  104496. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  104497. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  104498. updateFunc(currentGradient, nextGradient, scale);
  104499. return;
  104500. }
  104501. }
  104502. // Use last index if over
  104503. var lastIndex = gradients.length - 1;
  104504. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  104505. };
  104506. /**
  104507. * Gets or sets the base URL to use to load assets
  104508. */
  104509. Tools.BaseUrl = "";
  104510. /**
  104511. * Enable/Disable Custom HTTP Request Headers globally.
  104512. * default = false
  104513. * @see CustomRequestHeaders
  104514. */
  104515. Tools.UseCustomRequestHeaders = false;
  104516. /**
  104517. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104518. * i.e. when loading files, where the server/service expects an Authorization header
  104519. */
  104520. Tools.CustomRequestHeaders = _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"].CustomRequestHeaders;
  104521. /**
  104522. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104523. */
  104524. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  104525. /**
  104526. * Default behaviour for cors in the application.
  104527. * It can be a string if the expected behavior is identical in the entire app.
  104528. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104529. */
  104530. Tools.CorsBehavior = "anonymous";
  104531. /**
  104532. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104533. * @ignorenaming
  104534. */
  104535. Tools.UseFallbackTexture = true;
  104536. /**
  104537. * Use this object to register external classes like custom textures or material
  104538. * to allow the laoders to instantiate them
  104539. */
  104540. Tools.RegisteredExternalClasses = {};
  104541. /**
  104542. * Texture content used if a texture cannot loaded
  104543. * @ignorenaming
  104544. */
  104545. 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";
  104546. Tools._tmpFloatArray = new Float32Array(1);
  104547. /**
  104548. * Extracts text content from a DOM element hierarchy
  104549. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104550. */
  104551. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  104552. /**
  104553. * Gets or sets a function used to pre-process url before using them to load assets
  104554. */
  104555. Tools.PreprocessUrl = function (url) {
  104556. return url;
  104557. };
  104558. // Logs
  104559. /**
  104560. * No log
  104561. */
  104562. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  104563. /**
  104564. * Only message logs
  104565. */
  104566. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  104567. /**
  104568. * Only warning logs
  104569. */
  104570. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  104571. /**
  104572. * Only error logs
  104573. */
  104574. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  104575. /**
  104576. * All logs
  104577. */
  104578. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  104579. /**
  104580. * Checks if the window object exists
  104581. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104582. */
  104583. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  104584. // Performances
  104585. /**
  104586. * No performance log
  104587. */
  104588. Tools.PerformanceNoneLogLevel = 0;
  104589. /**
  104590. * Use user marks to log performance
  104591. */
  104592. Tools.PerformanceUserMarkLogLevel = 1;
  104593. /**
  104594. * Log performance to the console
  104595. */
  104596. Tools.PerformanceConsoleLogLevel = 2;
  104597. /**
  104598. * Starts a performance counter
  104599. */
  104600. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  104601. /**
  104602. * Ends a specific performance coutner
  104603. */
  104604. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  104605. return Tools;
  104606. }());
  104607. /**
  104608. * This class is used to track a performance counter which is number based.
  104609. * The user has access to many properties which give statistics of different nature.
  104610. *
  104611. * The implementer can track two kinds of Performance Counter: time and count.
  104612. * 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.
  104613. * 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.
  104614. */
  104615. var PerfCounter = /** @class */ (function () {
  104616. /**
  104617. * Creates a new counter
  104618. */
  104619. function PerfCounter() {
  104620. this._startMonitoringTime = 0;
  104621. this._min = 0;
  104622. this._max = 0;
  104623. this._average = 0;
  104624. this._lastSecAverage = 0;
  104625. this._current = 0;
  104626. this._totalValueCount = 0;
  104627. this._totalAccumulated = 0;
  104628. this._lastSecAccumulated = 0;
  104629. this._lastSecTime = 0;
  104630. this._lastSecValueCount = 0;
  104631. }
  104632. Object.defineProperty(PerfCounter.prototype, "min", {
  104633. /**
  104634. * Returns the smallest value ever
  104635. */
  104636. get: function () {
  104637. return this._min;
  104638. },
  104639. enumerable: true,
  104640. configurable: true
  104641. });
  104642. Object.defineProperty(PerfCounter.prototype, "max", {
  104643. /**
  104644. * Returns the biggest value ever
  104645. */
  104646. get: function () {
  104647. return this._max;
  104648. },
  104649. enumerable: true,
  104650. configurable: true
  104651. });
  104652. Object.defineProperty(PerfCounter.prototype, "average", {
  104653. /**
  104654. * Returns the average value since the performance counter is running
  104655. */
  104656. get: function () {
  104657. return this._average;
  104658. },
  104659. enumerable: true,
  104660. configurable: true
  104661. });
  104662. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  104663. /**
  104664. * Returns the average value of the last second the counter was monitored
  104665. */
  104666. get: function () {
  104667. return this._lastSecAverage;
  104668. },
  104669. enumerable: true,
  104670. configurable: true
  104671. });
  104672. Object.defineProperty(PerfCounter.prototype, "current", {
  104673. /**
  104674. * Returns the current value
  104675. */
  104676. get: function () {
  104677. return this._current;
  104678. },
  104679. enumerable: true,
  104680. configurable: true
  104681. });
  104682. Object.defineProperty(PerfCounter.prototype, "total", {
  104683. /**
  104684. * Gets the accumulated total
  104685. */
  104686. get: function () {
  104687. return this._totalAccumulated;
  104688. },
  104689. enumerable: true,
  104690. configurable: true
  104691. });
  104692. Object.defineProperty(PerfCounter.prototype, "count", {
  104693. /**
  104694. * Gets the total value count
  104695. */
  104696. get: function () {
  104697. return this._totalValueCount;
  104698. },
  104699. enumerable: true,
  104700. configurable: true
  104701. });
  104702. /**
  104703. * Call this method to start monitoring a new frame.
  104704. * 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.
  104705. */
  104706. PerfCounter.prototype.fetchNewFrame = function () {
  104707. this._totalValueCount++;
  104708. this._current = 0;
  104709. this._lastSecValueCount++;
  104710. };
  104711. /**
  104712. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  104713. * @param newCount the count value to add to the monitored count
  104714. * @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.
  104715. */
  104716. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  104717. if (!PerfCounter.Enabled) {
  104718. return;
  104719. }
  104720. this._current += newCount;
  104721. if (fetchResult) {
  104722. this._fetchResult();
  104723. }
  104724. };
  104725. /**
  104726. * Start monitoring this performance counter
  104727. */
  104728. PerfCounter.prototype.beginMonitoring = function () {
  104729. if (!PerfCounter.Enabled) {
  104730. return;
  104731. }
  104732. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104733. };
  104734. /**
  104735. * Compute the time lapsed since the previous beginMonitoring() call.
  104736. * @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
  104737. */
  104738. PerfCounter.prototype.endMonitoring = function (newFrame) {
  104739. if (newFrame === void 0) { newFrame = true; }
  104740. if (!PerfCounter.Enabled) {
  104741. return;
  104742. }
  104743. if (newFrame) {
  104744. this.fetchNewFrame();
  104745. }
  104746. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104747. this._current = currentTime - this._startMonitoringTime;
  104748. if (newFrame) {
  104749. this._fetchResult();
  104750. }
  104751. };
  104752. PerfCounter.prototype._fetchResult = function () {
  104753. this._totalAccumulated += this._current;
  104754. this._lastSecAccumulated += this._current;
  104755. // Min/Max update
  104756. this._min = Math.min(this._min, this._current);
  104757. this._max = Math.max(this._max, this._current);
  104758. this._average = this._totalAccumulated / this._totalValueCount;
  104759. // Reset last sec?
  104760. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104761. if ((now - this._lastSecTime) > 1000) {
  104762. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  104763. this._lastSecTime = now;
  104764. this._lastSecAccumulated = 0;
  104765. this._lastSecValueCount = 0;
  104766. }
  104767. };
  104768. /**
  104769. * Gets or sets a global boolean to turn on and off all the counters
  104770. */
  104771. PerfCounter.Enabled = true;
  104772. return PerfCounter;
  104773. }());
  104774. /**
  104775. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104776. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104777. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104778. * @param name The name of the class, case should be preserved
  104779. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104780. */
  104781. function className(name, module) {
  104782. return function (target) {
  104783. target["__bjsclassName__"] = name;
  104784. target["__bjsmoduleName__"] = (module != null) ? module : null;
  104785. };
  104786. }
  104787. /**
  104788. * An implementation of a loop for asynchronous functions.
  104789. */
  104790. var AsyncLoop = /** @class */ (function () {
  104791. /**
  104792. * Constructor.
  104793. * @param iterations the number of iterations.
  104794. * @param func the function to run each iteration
  104795. * @param successCallback the callback that will be called upon succesful execution
  104796. * @param offset starting offset.
  104797. */
  104798. function AsyncLoop(
  104799. /**
  104800. * Defines the number of iterations for the loop
  104801. */
  104802. iterations, func, successCallback, offset) {
  104803. if (offset === void 0) { offset = 0; }
  104804. this.iterations = iterations;
  104805. this.index = offset - 1;
  104806. this._done = false;
  104807. this._fn = func;
  104808. this._successCallback = successCallback;
  104809. }
  104810. /**
  104811. * Execute the next iteration. Must be called after the last iteration was finished.
  104812. */
  104813. AsyncLoop.prototype.executeNext = function () {
  104814. if (!this._done) {
  104815. if (this.index + 1 < this.iterations) {
  104816. ++this.index;
  104817. this._fn(this);
  104818. }
  104819. else {
  104820. this.breakLoop();
  104821. }
  104822. }
  104823. };
  104824. /**
  104825. * Break the loop and run the success callback.
  104826. */
  104827. AsyncLoop.prototype.breakLoop = function () {
  104828. this._done = true;
  104829. this._successCallback();
  104830. };
  104831. /**
  104832. * Create and run an async loop.
  104833. * @param iterations the number of iterations.
  104834. * @param fn the function to run each iteration
  104835. * @param successCallback the callback that will be called upon succesful execution
  104836. * @param offset starting offset.
  104837. * @returns the created async loop object
  104838. */
  104839. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  104840. if (offset === void 0) { offset = 0; }
  104841. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  104842. loop.executeNext();
  104843. return loop;
  104844. };
  104845. /**
  104846. * A for-loop that will run a given number of iterations synchronous and the rest async.
  104847. * @param iterations total number of iterations
  104848. * @param syncedIterations number of synchronous iterations in each async iteration.
  104849. * @param fn the function to call each iteration.
  104850. * @param callback a success call back that will be called when iterating stops.
  104851. * @param breakFunction a break condition (optional)
  104852. * @param timeout timeout settings for the setTimeout function. default - 0.
  104853. * @returns the created async loop object
  104854. */
  104855. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  104856. if (timeout === void 0) { timeout = 0; }
  104857. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  104858. if (breakFunction && breakFunction()) {
  104859. loop.breakLoop();
  104860. }
  104861. else {
  104862. setTimeout(function () {
  104863. for (var i = 0; i < syncedIterations; ++i) {
  104864. var iteration = (loop.index * syncedIterations) + i;
  104865. if (iteration >= iterations) {
  104866. break;
  104867. }
  104868. fn(iteration);
  104869. if (breakFunction && breakFunction()) {
  104870. loop.breakLoop();
  104871. break;
  104872. }
  104873. }
  104874. loop.executeNext();
  104875. }, timeout);
  104876. }
  104877. }, callback);
  104878. };
  104879. return AsyncLoop;
  104880. }());
  104881. /***/ }),
  104882. /***/ "./Misc/typeStore.ts":
  104883. /*!***************************!*\
  104884. !*** ./Misc/typeStore.ts ***!
  104885. \***************************/
  104886. /*! exports provided: _TypeStore */
  104887. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104888. "use strict";
  104889. __webpack_require__.r(__webpack_exports__);
  104890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  104891. /** @hidden */
  104892. var _TypeStore = /** @class */ (function () {
  104893. function _TypeStore() {
  104894. }
  104895. /** @hidden */
  104896. _TypeStore.GetClass = function (fqdn) {
  104897. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  104898. return this.RegisteredTypes[fqdn];
  104899. }
  104900. return null;
  104901. };
  104902. /** @hidden */
  104903. _TypeStore.RegisteredTypes = {};
  104904. return _TypeStore;
  104905. }());
  104906. /***/ }),
  104907. /***/ "./Misc/videoRecorder.ts":
  104908. /*!*******************************!*\
  104909. !*** ./Misc/videoRecorder.ts ***!
  104910. \*******************************/
  104911. /*! exports provided: VideoRecorder */
  104912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104913. "use strict";
  104914. __webpack_require__.r(__webpack_exports__);
  104915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  104916. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104917. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  104918. /**
  104919. * This can helps recording videos from BabylonJS.
  104920. * This is based on the available WebRTC functionalities of the browser.
  104921. *
  104922. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  104923. */
  104924. var VideoRecorder = /** @class */ (function () {
  104925. /**
  104926. * Create a new VideoCapture object which can help converting what you see in Babylon to
  104927. * a video file.
  104928. * @param engine Defines the BabylonJS Engine you wish to record
  104929. * @param options Defines options that can be used to customized the capture
  104930. */
  104931. function VideoRecorder(engine, options) {
  104932. if (options === void 0) { options = null; }
  104933. if (!VideoRecorder.IsSupported(engine)) {
  104934. throw "Your browser does not support recording so far.";
  104935. }
  104936. var canvas = engine.getRenderingCanvas();
  104937. if (!canvas) {
  104938. throw "The babylon engine must have a canvas to be recorded";
  104939. }
  104940. this._canvas = canvas;
  104941. this._canvas.isRecording = false;
  104942. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  104943. var stream = this._canvas.captureStream(this._options.fps);
  104944. if (this._options.audioTracks) {
  104945. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  104946. var track = _a[_i];
  104947. stream.addTrack(track);
  104948. }
  104949. }
  104950. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  104951. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  104952. this._mediaRecorder.onerror = this._handleError.bind(this);
  104953. this._mediaRecorder.onstop = this._handleStop.bind(this);
  104954. }
  104955. /**
  104956. * Returns wehther or not the VideoRecorder is available in your browser.
  104957. * @param engine Defines the Babylon Engine to check the support for
  104958. * @returns true if supported otherwise false
  104959. */
  104960. VideoRecorder.IsSupported = function (engine) {
  104961. var canvas = engine.getRenderingCanvas();
  104962. return (!!canvas && typeof canvas.captureStream === "function");
  104963. };
  104964. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  104965. /**
  104966. * True wether a recording is already in progress.
  104967. */
  104968. get: function () {
  104969. return !!this._canvas && this._canvas.isRecording;
  104970. },
  104971. enumerable: true,
  104972. configurable: true
  104973. });
  104974. /**
  104975. * Stops the current recording before the default capture timeout passed in the startRecording
  104976. * functions.
  104977. */
  104978. VideoRecorder.prototype.stopRecording = function () {
  104979. if (!this._canvas || !this._mediaRecorder) {
  104980. return;
  104981. }
  104982. if (!this.isRecording) {
  104983. return;
  104984. }
  104985. this._canvas.isRecording = false;
  104986. this._mediaRecorder.stop();
  104987. };
  104988. /**
  104989. * Starts recording the canvas for a max duration specified in parameters.
  104990. * @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.
  104991. * @param maxDuration Defines the maximum recording time in seconds.
  104992. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  104993. * @return a promise callback at the end of the recording with the video data in Blob.
  104994. */
  104995. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  104996. var _this = this;
  104997. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  104998. if (maxDuration === void 0) { maxDuration = 7; }
  104999. if (!this._canvas || !this._mediaRecorder) {
  105000. throw "Recorder has already been disposed";
  105001. }
  105002. if (this.isRecording) {
  105003. throw "Recording already in progress";
  105004. }
  105005. if (maxDuration > 0) {
  105006. setTimeout(function () {
  105007. _this.stopRecording();
  105008. }, maxDuration * 1000);
  105009. }
  105010. this._fileName = fileName;
  105011. this._recordedChunks = [];
  105012. this._resolve = null;
  105013. this._reject = null;
  105014. this._canvas.isRecording = true;
  105015. this._mediaRecorder.start(this._options.recordChunckSize);
  105016. return new Promise(function (resolve, reject) {
  105017. _this._resolve = resolve;
  105018. _this._reject = reject;
  105019. });
  105020. };
  105021. /**
  105022. * Releases internal resources used during the recording.
  105023. */
  105024. VideoRecorder.prototype.dispose = function () {
  105025. this._canvas = null;
  105026. this._mediaRecorder = null;
  105027. this._recordedChunks = [];
  105028. this._fileName = null;
  105029. this._resolve = null;
  105030. this._reject = null;
  105031. };
  105032. VideoRecorder.prototype._handleDataAvailable = function (event) {
  105033. if (event.data.size > 0) {
  105034. this._recordedChunks.push(event.data);
  105035. }
  105036. };
  105037. VideoRecorder.prototype._handleError = function (event) {
  105038. this.stopRecording();
  105039. if (this._reject) {
  105040. this._reject(event.error);
  105041. }
  105042. else {
  105043. throw new event.error();
  105044. }
  105045. };
  105046. VideoRecorder.prototype._handleStop = function () {
  105047. this.stopRecording();
  105048. var superBuffer = new Blob(this._recordedChunks);
  105049. if (this._resolve) {
  105050. this._resolve(superBuffer);
  105051. }
  105052. window.URL.createObjectURL(superBuffer);
  105053. if (this._fileName) {
  105054. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  105055. }
  105056. };
  105057. VideoRecorder._defaultOptions = {
  105058. mimeType: "video/webm",
  105059. fps: 25,
  105060. recordChunckSize: 3000
  105061. };
  105062. return VideoRecorder;
  105063. }());
  105064. /***/ }),
  105065. /***/ "./Misc/virtualJoystick.ts":
  105066. /*!*********************************!*\
  105067. !*** ./Misc/virtualJoystick.ts ***!
  105068. \*********************************/
  105069. /*! exports provided: JoystickAxis, VirtualJoystick */
  105070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105071. "use strict";
  105072. __webpack_require__.r(__webpack_exports__);
  105073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  105074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  105075. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105076. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  105077. // Mainly based on these 2 articles :
  105078. // 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
  105079. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  105080. /**
  105081. * Defines the potential axis of a Joystick
  105082. */
  105083. var JoystickAxis;
  105084. (function (JoystickAxis) {
  105085. /** X axis */
  105086. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  105087. /** Y axis */
  105088. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  105089. /** Z axis */
  105090. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  105091. })(JoystickAxis || (JoystickAxis = {}));
  105092. /**
  105093. * Class used to define virtual joystick (used in touch mode)
  105094. */
  105095. var VirtualJoystick = /** @class */ (function () {
  105096. /**
  105097. * Creates a new virtual joystick
  105098. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105099. */
  105100. function VirtualJoystick(leftJoystick) {
  105101. var _this = this;
  105102. if (leftJoystick) {
  105103. this._leftJoystick = true;
  105104. }
  105105. else {
  105106. this._leftJoystick = false;
  105107. }
  105108. VirtualJoystick._globalJoystickIndex++;
  105109. // By default left & right arrow keys are moving the X
  105110. // and up & down keys are moving the Y
  105111. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  105112. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  105113. this.reverseLeftRight = false;
  105114. this.reverseUpDown = false;
  105115. // collections of pointers
  105116. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  105117. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  105118. this._joystickSensibility = 25;
  105119. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  105120. this._onResize = function (evt) {
  105121. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  105122. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  105123. if (VirtualJoystick.Canvas) {
  105124. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  105125. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  105126. }
  105127. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  105128. };
  105129. // injecting a canvas element on top of the canvas 3D game
  105130. if (!VirtualJoystick.Canvas) {
  105131. window.addEventListener("resize", this._onResize, false);
  105132. VirtualJoystick.Canvas = document.createElement("canvas");
  105133. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  105134. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  105135. VirtualJoystick.Canvas.width = window.innerWidth;
  105136. VirtualJoystick.Canvas.height = window.innerHeight;
  105137. VirtualJoystick.Canvas.style.width = "100%";
  105138. VirtualJoystick.Canvas.style.height = "100%";
  105139. VirtualJoystick.Canvas.style.position = "absolute";
  105140. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  105141. VirtualJoystick.Canvas.style.top = "0px";
  105142. VirtualJoystick.Canvas.style.left = "0px";
  105143. VirtualJoystick.Canvas.style.zIndex = "5";
  105144. VirtualJoystick.Canvas.style.msTouchAction = "none";
  105145. // Support for jQuery PEP polyfill
  105146. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  105147. var context = VirtualJoystick.Canvas.getContext('2d');
  105148. if (!context) {
  105149. throw new Error("Unable to create canvas for virtual joystick");
  105150. }
  105151. VirtualJoystick.vjCanvasContext = context;
  105152. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  105153. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  105154. document.body.appendChild(VirtualJoystick.Canvas);
  105155. }
  105156. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  105157. this.pressed = false;
  105158. // default joystick color
  105159. this._joystickColor = "cyan";
  105160. this._joystickPointerID = -1;
  105161. // current joystick position
  105162. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  105163. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  105164. // origin joystick position
  105165. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  105166. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  105167. this._onPointerDownHandlerRef = function (evt) {
  105168. _this._onPointerDown(evt);
  105169. };
  105170. this._onPointerMoveHandlerRef = function (evt) {
  105171. _this._onPointerMove(evt);
  105172. };
  105173. this._onPointerUpHandlerRef = function (evt) {
  105174. _this._onPointerUp(evt);
  105175. };
  105176. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  105177. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  105178. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  105179. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  105180. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  105181. evt.preventDefault(); // Disables system menu
  105182. }, false);
  105183. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  105184. }
  105185. /**
  105186. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105187. * @param newJoystickSensibility defines the new sensibility
  105188. */
  105189. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  105190. this._joystickSensibility = newJoystickSensibility;
  105191. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  105192. };
  105193. VirtualJoystick.prototype._onPointerDown = function (e) {
  105194. var positionOnScreenCondition;
  105195. e.preventDefault();
  105196. if (this._leftJoystick === true) {
  105197. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  105198. }
  105199. else {
  105200. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  105201. }
  105202. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  105203. // First contact will be dedicated to the virtual joystick
  105204. this._joystickPointerID = e.pointerId;
  105205. this._joystickPointerStartPos.x = e.clientX;
  105206. this._joystickPointerStartPos.y = e.clientY;
  105207. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  105208. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  105209. this._deltaJoystickVector.x = 0;
  105210. this._deltaJoystickVector.y = 0;
  105211. this.pressed = true;
  105212. this._touches.add(e.pointerId.toString(), e);
  105213. }
  105214. else {
  105215. // You can only trigger the action buttons with a joystick declared
  105216. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  105217. this._action();
  105218. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  105219. }
  105220. }
  105221. };
  105222. VirtualJoystick.prototype._onPointerMove = function (e) {
  105223. // If the current pointer is the one associated to the joystick (first touch contact)
  105224. if (this._joystickPointerID == e.pointerId) {
  105225. this._joystickPointerPos.x = e.clientX;
  105226. this._joystickPointerPos.y = e.clientY;
  105227. this._deltaJoystickVector = this._joystickPointerPos.clone();
  105228. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  105229. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  105230. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  105231. switch (this._axisTargetedByLeftAndRight) {
  105232. case JoystickAxis.X:
  105233. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  105234. break;
  105235. case JoystickAxis.Y:
  105236. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  105237. break;
  105238. case JoystickAxis.Z:
  105239. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  105240. break;
  105241. }
  105242. var directionUpDown = this.reverseUpDown ? 1 : -1;
  105243. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  105244. switch (this._axisTargetedByUpAndDown) {
  105245. case JoystickAxis.X:
  105246. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  105247. break;
  105248. case JoystickAxis.Y:
  105249. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  105250. break;
  105251. case JoystickAxis.Z:
  105252. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  105253. break;
  105254. }
  105255. }
  105256. else {
  105257. var data = this._touches.get(e.pointerId.toString());
  105258. if (data) {
  105259. data.x = e.clientX;
  105260. data.y = e.clientY;
  105261. }
  105262. }
  105263. };
  105264. VirtualJoystick.prototype._onPointerUp = function (e) {
  105265. if (this._joystickPointerID == e.pointerId) {
  105266. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  105267. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  105268. this._joystickPointerID = -1;
  105269. this.pressed = false;
  105270. }
  105271. else {
  105272. var touch = this._touches.get(e.pointerId.toString());
  105273. if (touch) {
  105274. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  105275. }
  105276. }
  105277. this._deltaJoystickVector.x = 0;
  105278. this._deltaJoystickVector.y = 0;
  105279. this._touches.remove(e.pointerId.toString());
  105280. };
  105281. /**
  105282. * Change the color of the virtual joystick
  105283. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105284. */
  105285. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  105286. this._joystickColor = newColor;
  105287. };
  105288. /**
  105289. * Defines a callback to call when the joystick is touched
  105290. * @param action defines the callback
  105291. */
  105292. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  105293. this._action = action;
  105294. };
  105295. /**
  105296. * Defines which axis you'd like to control for left & right
  105297. * @param axis defines the axis to use
  105298. */
  105299. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  105300. switch (axis) {
  105301. case JoystickAxis.X:
  105302. case JoystickAxis.Y:
  105303. case JoystickAxis.Z:
  105304. this._axisTargetedByLeftAndRight = axis;
  105305. break;
  105306. default:
  105307. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  105308. break;
  105309. }
  105310. };
  105311. /**
  105312. * Defines which axis you'd like to control for up & down
  105313. * @param axis defines the axis to use
  105314. */
  105315. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  105316. switch (axis) {
  105317. case JoystickAxis.X:
  105318. case JoystickAxis.Y:
  105319. case JoystickAxis.Z:
  105320. this._axisTargetedByUpAndDown = axis;
  105321. break;
  105322. default:
  105323. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  105324. break;
  105325. }
  105326. };
  105327. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  105328. var _this = this;
  105329. if (this.pressed) {
  105330. this._touches.forEach(function (key, touch) {
  105331. if (touch.pointerId === _this._joystickPointerID) {
  105332. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  105333. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  105334. VirtualJoystick.vjCanvasContext.beginPath();
  105335. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  105336. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  105337. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  105338. VirtualJoystick.vjCanvasContext.stroke();
  105339. VirtualJoystick.vjCanvasContext.closePath();
  105340. VirtualJoystick.vjCanvasContext.beginPath();
  105341. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  105342. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  105343. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  105344. VirtualJoystick.vjCanvasContext.stroke();
  105345. VirtualJoystick.vjCanvasContext.closePath();
  105346. VirtualJoystick.vjCanvasContext.beginPath();
  105347. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  105348. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  105349. VirtualJoystick.vjCanvasContext.stroke();
  105350. VirtualJoystick.vjCanvasContext.closePath();
  105351. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  105352. }
  105353. else {
  105354. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  105355. VirtualJoystick.vjCanvasContext.beginPath();
  105356. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  105357. VirtualJoystick.vjCanvasContext.beginPath();
  105358. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  105359. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  105360. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  105361. VirtualJoystick.vjCanvasContext.stroke();
  105362. VirtualJoystick.vjCanvasContext.closePath();
  105363. touch.prevX = touch.x;
  105364. touch.prevY = touch.y;
  105365. }
  105366. });
  105367. }
  105368. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  105369. };
  105370. /**
  105371. * Release internal HTML canvas
  105372. */
  105373. VirtualJoystick.prototype.releaseCanvas = function () {
  105374. if (VirtualJoystick.Canvas) {
  105375. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  105376. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  105377. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  105378. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  105379. window.removeEventListener("resize", this._onResize);
  105380. document.body.removeChild(VirtualJoystick.Canvas);
  105381. VirtualJoystick.Canvas = null;
  105382. }
  105383. };
  105384. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  105385. VirtualJoystick._globalJoystickIndex = 0;
  105386. return VirtualJoystick;
  105387. }());
  105388. /***/ }),
  105389. /***/ "./Misc/webRequest.ts":
  105390. /*!****************************!*\
  105391. !*** ./Misc/webRequest.ts ***!
  105392. \****************************/
  105393. /*! exports provided: WebRequest */
  105394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105395. "use strict";
  105396. __webpack_require__.r(__webpack_exports__);
  105397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return WebRequest; });
  105398. /**
  105399. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  105400. */
  105401. var WebRequest = /** @class */ (function () {
  105402. function WebRequest() {
  105403. this._xhr = new XMLHttpRequest();
  105404. }
  105405. WebRequest.prototype._injectCustomRequestHeaders = function () {
  105406. for (var key in WebRequest.CustomRequestHeaders) {
  105407. var val = WebRequest.CustomRequestHeaders[key];
  105408. if (val) {
  105409. this._xhr.setRequestHeader(key, val);
  105410. }
  105411. }
  105412. };
  105413. Object.defineProperty(WebRequest.prototype, "onprogress", {
  105414. /**
  105415. * Gets or sets a function to be called when loading progress changes
  105416. */
  105417. get: function () {
  105418. return this._xhr.onprogress;
  105419. },
  105420. set: function (value) {
  105421. this._xhr.onprogress = value;
  105422. },
  105423. enumerable: true,
  105424. configurable: true
  105425. });
  105426. Object.defineProperty(WebRequest.prototype, "readyState", {
  105427. /**
  105428. * Returns client's state
  105429. */
  105430. get: function () {
  105431. return this._xhr.readyState;
  105432. },
  105433. enumerable: true,
  105434. configurable: true
  105435. });
  105436. Object.defineProperty(WebRequest.prototype, "status", {
  105437. /**
  105438. * Returns client's status
  105439. */
  105440. get: function () {
  105441. return this._xhr.status;
  105442. },
  105443. enumerable: true,
  105444. configurable: true
  105445. });
  105446. Object.defineProperty(WebRequest.prototype, "statusText", {
  105447. /**
  105448. * Returns client's status as a text
  105449. */
  105450. get: function () {
  105451. return this._xhr.statusText;
  105452. },
  105453. enumerable: true,
  105454. configurable: true
  105455. });
  105456. Object.defineProperty(WebRequest.prototype, "response", {
  105457. /**
  105458. * Returns client's response
  105459. */
  105460. get: function () {
  105461. return this._xhr.response;
  105462. },
  105463. enumerable: true,
  105464. configurable: true
  105465. });
  105466. Object.defineProperty(WebRequest.prototype, "responseURL", {
  105467. /**
  105468. * Returns client's response url
  105469. */
  105470. get: function () {
  105471. return this._xhr.responseURL;
  105472. },
  105473. enumerable: true,
  105474. configurable: true
  105475. });
  105476. Object.defineProperty(WebRequest.prototype, "responseText", {
  105477. /**
  105478. * Returns client's response as text
  105479. */
  105480. get: function () {
  105481. return this._xhr.responseText;
  105482. },
  105483. enumerable: true,
  105484. configurable: true
  105485. });
  105486. Object.defineProperty(WebRequest.prototype, "responseType", {
  105487. /**
  105488. * Gets or sets the expected response type
  105489. */
  105490. get: function () {
  105491. return this._xhr.responseType;
  105492. },
  105493. set: function (value) {
  105494. this._xhr.responseType = value;
  105495. },
  105496. enumerable: true,
  105497. configurable: true
  105498. });
  105499. WebRequest.prototype.addEventListener = function (type, listener, options) {
  105500. this._xhr.addEventListener(type, listener, options);
  105501. };
  105502. WebRequest.prototype.removeEventListener = function (type, listener, options) {
  105503. this._xhr.removeEventListener(type, listener, options);
  105504. };
  105505. /**
  105506. * Cancels any network activity
  105507. */
  105508. WebRequest.prototype.abort = function () {
  105509. this._xhr.abort();
  105510. };
  105511. /**
  105512. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  105513. * @param body defines an optional request body
  105514. */
  105515. WebRequest.prototype.send = function (body) {
  105516. if (WebRequest.CustomRequestHeaders) {
  105517. this._injectCustomRequestHeaders();
  105518. }
  105519. this._xhr.send(body);
  105520. };
  105521. /**
  105522. * Sets the request method, request URL
  105523. * @param method defines the method to use (GET, POST, etc..)
  105524. * @param url defines the url to connect with
  105525. */
  105526. WebRequest.prototype.open = function (method, url) {
  105527. for (var _i = 0, _a = WebRequest.CustomRequestModifiers; _i < _a.length; _i++) {
  105528. var update = _a[_i];
  105529. update(this._xhr);
  105530. }
  105531. return this._xhr.open(method, url, true);
  105532. };
  105533. /**
  105534. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  105535. * i.e. when loading files, where the server/service expects an Authorization header
  105536. */
  105537. WebRequest.CustomRequestHeaders = {};
  105538. /**
  105539. * Add callback functions in this array to update all the requests before they get sent to the network
  105540. */
  105541. WebRequest.CustomRequestModifiers = new Array();
  105542. return WebRequest;
  105543. }());
  105544. /***/ }),
  105545. /***/ "./Misc/workerPool.ts":
  105546. /*!****************************!*\
  105547. !*** ./Misc/workerPool.ts ***!
  105548. \****************************/
  105549. /*! exports provided: WorkerPool */
  105550. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105551. "use strict";
  105552. __webpack_require__.r(__webpack_exports__);
  105553. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  105554. /**
  105555. * Helper class to push actions to a pool of workers.
  105556. */
  105557. var WorkerPool = /** @class */ (function () {
  105558. /**
  105559. * Constructor
  105560. * @param workers Array of workers to use for actions
  105561. */
  105562. function WorkerPool(workers) {
  105563. this._pendingActions = new Array();
  105564. this._workerInfos = workers.map(function (worker) { return ({
  105565. worker: worker,
  105566. active: false
  105567. }); });
  105568. }
  105569. /**
  105570. * Terminates all workers and clears any pending actions.
  105571. */
  105572. WorkerPool.prototype.dispose = function () {
  105573. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  105574. var workerInfo = _a[_i];
  105575. workerInfo.worker.terminate();
  105576. }
  105577. delete this._workerInfos;
  105578. delete this._pendingActions;
  105579. };
  105580. /**
  105581. * Pushes an action to the worker pool. If all the workers are active, the action will be
  105582. * pended until a worker has completed its action.
  105583. * @param action The action to perform. Call onComplete when the action is complete.
  105584. */
  105585. WorkerPool.prototype.push = function (action) {
  105586. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  105587. var workerInfo = _a[_i];
  105588. if (!workerInfo.active) {
  105589. this._execute(workerInfo, action);
  105590. return;
  105591. }
  105592. }
  105593. this._pendingActions.push(action);
  105594. };
  105595. WorkerPool.prototype._execute = function (workerInfo, action) {
  105596. var _this = this;
  105597. workerInfo.active = true;
  105598. action(workerInfo.worker, function () {
  105599. workerInfo.active = false;
  105600. var nextAction = _this._pendingActions.shift();
  105601. if (nextAction) {
  105602. _this._execute(workerInfo, nextAction);
  105603. }
  105604. });
  105605. };
  105606. return WorkerPool;
  105607. }());
  105608. /***/ }),
  105609. /***/ "./Morph/index.ts":
  105610. /*!************************!*\
  105611. !*** ./Morph/index.ts ***!
  105612. \************************/
  105613. /*! exports provided: MorphTarget, MorphTargetManager */
  105614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105615. "use strict";
  105616. __webpack_require__.r(__webpack_exports__);
  105617. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  105618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  105619. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  105620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  105621. /***/ }),
  105622. /***/ "./Morph/morphTarget.ts":
  105623. /*!******************************!*\
  105624. !*** ./Morph/morphTarget.ts ***!
  105625. \******************************/
  105626. /*! exports provided: MorphTarget */
  105627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105628. "use strict";
  105629. __webpack_require__.r(__webpack_exports__);
  105630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  105631. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105632. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105633. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105634. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105635. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  105636. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  105637. /**
  105638. * Defines a target to use with MorphTargetManager
  105639. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105640. */
  105641. var MorphTarget = /** @class */ (function () {
  105642. /**
  105643. * Creates a new MorphTarget
  105644. * @param name defines the name of the target
  105645. * @param influence defines the influence to use
  105646. * @param scene defines the scene the morphtarget belongs to
  105647. */
  105648. function MorphTarget(
  105649. /** defines the name of the target */
  105650. name, influence, scene) {
  105651. if (influence === void 0) { influence = 0; }
  105652. if (scene === void 0) { scene = null; }
  105653. this.name = name;
  105654. /**
  105655. * Gets or sets the list of animations
  105656. */
  105657. this.animations = new Array();
  105658. this._positions = null;
  105659. this._normals = null;
  105660. this._tangents = null;
  105661. /**
  105662. * Observable raised when the influence changes
  105663. */
  105664. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  105665. /** @hidden */
  105666. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  105667. this._animationPropertiesOverride = null;
  105668. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  105669. this.influence = influence;
  105670. }
  105671. Object.defineProperty(MorphTarget.prototype, "influence", {
  105672. /**
  105673. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105674. */
  105675. get: function () {
  105676. return this._influence;
  105677. },
  105678. set: function (influence) {
  105679. if (this._influence === influence) {
  105680. return;
  105681. }
  105682. var previous = this._influence;
  105683. this._influence = influence;
  105684. if (this.onInfluenceChanged.hasObservers) {
  105685. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  105686. }
  105687. },
  105688. enumerable: true,
  105689. configurable: true
  105690. });
  105691. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  105692. /**
  105693. * Gets or sets the animation properties override
  105694. */
  105695. get: function () {
  105696. if (!this._animationPropertiesOverride && this._scene) {
  105697. return this._scene.animationPropertiesOverride;
  105698. }
  105699. return this._animationPropertiesOverride;
  105700. },
  105701. set: function (value) {
  105702. this._animationPropertiesOverride = value;
  105703. },
  105704. enumerable: true,
  105705. configurable: true
  105706. });
  105707. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  105708. /**
  105709. * Gets a boolean defining if the target contains position data
  105710. */
  105711. get: function () {
  105712. return !!this._positions;
  105713. },
  105714. enumerable: true,
  105715. configurable: true
  105716. });
  105717. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  105718. /**
  105719. * Gets a boolean defining if the target contains normal data
  105720. */
  105721. get: function () {
  105722. return !!this._normals;
  105723. },
  105724. enumerable: true,
  105725. configurable: true
  105726. });
  105727. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  105728. /**
  105729. * Gets a boolean defining if the target contains tangent data
  105730. */
  105731. get: function () {
  105732. return !!this._tangents;
  105733. },
  105734. enumerable: true,
  105735. configurable: true
  105736. });
  105737. /**
  105738. * Affects position data to this target
  105739. * @param data defines the position data to use
  105740. */
  105741. MorphTarget.prototype.setPositions = function (data) {
  105742. var hadPositions = this.hasPositions;
  105743. this._positions = data;
  105744. if (hadPositions !== this.hasPositions) {
  105745. this._onDataLayoutChanged.notifyObservers(undefined);
  105746. }
  105747. };
  105748. /**
  105749. * Gets the position data stored in this target
  105750. * @returns a FloatArray containing the position data (or null if not present)
  105751. */
  105752. MorphTarget.prototype.getPositions = function () {
  105753. return this._positions;
  105754. };
  105755. /**
  105756. * Affects normal data to this target
  105757. * @param data defines the normal data to use
  105758. */
  105759. MorphTarget.prototype.setNormals = function (data) {
  105760. var hadNormals = this.hasNormals;
  105761. this._normals = data;
  105762. if (hadNormals !== this.hasNormals) {
  105763. this._onDataLayoutChanged.notifyObservers(undefined);
  105764. }
  105765. };
  105766. /**
  105767. * Gets the normal data stored in this target
  105768. * @returns a FloatArray containing the normal data (or null if not present)
  105769. */
  105770. MorphTarget.prototype.getNormals = function () {
  105771. return this._normals;
  105772. };
  105773. /**
  105774. * Affects tangent data to this target
  105775. * @param data defines the tangent data to use
  105776. */
  105777. MorphTarget.prototype.setTangents = function (data) {
  105778. var hadTangents = this.hasTangents;
  105779. this._tangents = data;
  105780. if (hadTangents !== this.hasTangents) {
  105781. this._onDataLayoutChanged.notifyObservers(undefined);
  105782. }
  105783. };
  105784. /**
  105785. * Gets the tangent data stored in this target
  105786. * @returns a FloatArray containing the tangent data (or null if not present)
  105787. */
  105788. MorphTarget.prototype.getTangents = function () {
  105789. return this._tangents;
  105790. };
  105791. /**
  105792. * Serializes the current target into a Serialization object
  105793. * @returns the serialized object
  105794. */
  105795. MorphTarget.prototype.serialize = function () {
  105796. var serializationObject = {};
  105797. serializationObject.name = this.name;
  105798. serializationObject.influence = this.influence;
  105799. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  105800. if (this.id != null) {
  105801. serializationObject.id = this.id;
  105802. }
  105803. if (this.hasNormals) {
  105804. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  105805. }
  105806. if (this.hasTangents) {
  105807. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  105808. }
  105809. // Animations
  105810. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  105811. return serializationObject;
  105812. };
  105813. /**
  105814. * Returns the string "MorphTarget"
  105815. * @returns "MorphTarget"
  105816. */
  105817. MorphTarget.prototype.getClassName = function () {
  105818. return "MorphTarget";
  105819. };
  105820. // Statics
  105821. /**
  105822. * Creates a new target from serialized data
  105823. * @param serializationObject defines the serialized data to use
  105824. * @returns a new MorphTarget
  105825. */
  105826. MorphTarget.Parse = function (serializationObject) {
  105827. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  105828. result.setPositions(serializationObject.positions);
  105829. if (serializationObject.id != null) {
  105830. result.id = serializationObject.id;
  105831. }
  105832. if (serializationObject.normals) {
  105833. result.setNormals(serializationObject.normals);
  105834. }
  105835. if (serializationObject.tangents) {
  105836. result.setTangents(serializationObject.tangents);
  105837. }
  105838. // Animations
  105839. if (serializationObject.animations) {
  105840. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  105841. var parsedAnimation = serializationObject.animations[animationIndex];
  105842. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  105843. if (internalClass) {
  105844. result.animations.push(internalClass.Parse(parsedAnimation));
  105845. }
  105846. }
  105847. }
  105848. return result;
  105849. };
  105850. /**
  105851. * Creates a MorphTarget from mesh data
  105852. * @param mesh defines the source mesh
  105853. * @param name defines the name to use for the new target
  105854. * @param influence defines the influence to attach to the target
  105855. * @returns a new MorphTarget
  105856. */
  105857. MorphTarget.FromMesh = function (mesh, name, influence) {
  105858. if (!name) {
  105859. name = mesh.name;
  105860. }
  105861. var result = new MorphTarget(name, influence, mesh.getScene());
  105862. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  105863. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  105864. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  105865. }
  105866. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  105867. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  105868. }
  105869. return result;
  105870. };
  105871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  105872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  105873. ], MorphTarget.prototype, "id", void 0);
  105874. return MorphTarget;
  105875. }());
  105876. /***/ }),
  105877. /***/ "./Morph/morphTargetManager.ts":
  105878. /*!*************************************!*\
  105879. !*** ./Morph/morphTargetManager.ts ***!
  105880. \*************************************/
  105881. /*! exports provided: MorphTargetManager */
  105882. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105883. "use strict";
  105884. __webpack_require__.r(__webpack_exports__);
  105885. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  105886. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  105887. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  105888. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105889. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  105890. /**
  105891. * This class is used to deform meshes using morphing between different targets
  105892. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105893. */
  105894. var MorphTargetManager = /** @class */ (function () {
  105895. /**
  105896. * Creates a new MorphTargetManager
  105897. * @param scene defines the current scene
  105898. */
  105899. function MorphTargetManager(scene) {
  105900. if (scene === void 0) { scene = null; }
  105901. this._targets = new Array();
  105902. this._targetInfluenceChangedObservers = new Array();
  105903. this._targetDataLayoutChangedObservers = new Array();
  105904. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  105905. this._supportsNormals = false;
  105906. this._supportsTangents = false;
  105907. this._vertexCount = 0;
  105908. this._uniqueId = 0;
  105909. this._tempInfluences = new Array();
  105910. if (!scene) {
  105911. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  105912. }
  105913. this._scene = scene;
  105914. if (this._scene) {
  105915. this._scene.morphTargetManagers.push(this);
  105916. this._uniqueId = this._scene.getUniqueId();
  105917. }
  105918. }
  105919. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  105920. /**
  105921. * Gets the unique ID of this manager
  105922. */
  105923. get: function () {
  105924. return this._uniqueId;
  105925. },
  105926. enumerable: true,
  105927. configurable: true
  105928. });
  105929. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  105930. /**
  105931. * Gets the number of vertices handled by this manager
  105932. */
  105933. get: function () {
  105934. return this._vertexCount;
  105935. },
  105936. enumerable: true,
  105937. configurable: true
  105938. });
  105939. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  105940. /**
  105941. * Gets a boolean indicating if this manager supports morphing of normals
  105942. */
  105943. get: function () {
  105944. return this._supportsNormals;
  105945. },
  105946. enumerable: true,
  105947. configurable: true
  105948. });
  105949. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  105950. /**
  105951. * Gets a boolean indicating if this manager supports morphing of tangents
  105952. */
  105953. get: function () {
  105954. return this._supportsTangents;
  105955. },
  105956. enumerable: true,
  105957. configurable: true
  105958. });
  105959. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  105960. /**
  105961. * Gets the number of targets stored in this manager
  105962. */
  105963. get: function () {
  105964. return this._targets.length;
  105965. },
  105966. enumerable: true,
  105967. configurable: true
  105968. });
  105969. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  105970. /**
  105971. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105972. */
  105973. get: function () {
  105974. return this._activeTargets.length;
  105975. },
  105976. enumerable: true,
  105977. configurable: true
  105978. });
  105979. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  105980. /**
  105981. * Gets the list of influences (one per target)
  105982. */
  105983. get: function () {
  105984. return this._influences;
  105985. },
  105986. enumerable: true,
  105987. configurable: true
  105988. });
  105989. /**
  105990. * Gets the active target at specified index. An active target is a target with an influence > 0
  105991. * @param index defines the index to check
  105992. * @returns the requested target
  105993. */
  105994. MorphTargetManager.prototype.getActiveTarget = function (index) {
  105995. return this._activeTargets.data[index];
  105996. };
  105997. /**
  105998. * Gets the target at specified index
  105999. * @param index defines the index to check
  106000. * @returns the requested target
  106001. */
  106002. MorphTargetManager.prototype.getTarget = function (index) {
  106003. return this._targets[index];
  106004. };
  106005. /**
  106006. * Add a new target to this manager
  106007. * @param target defines the target to add
  106008. */
  106009. MorphTargetManager.prototype.addTarget = function (target) {
  106010. var _this = this;
  106011. this._targets.push(target);
  106012. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  106013. _this._syncActiveTargets(needUpdate);
  106014. }));
  106015. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  106016. _this._syncActiveTargets(true);
  106017. }));
  106018. this._syncActiveTargets(true);
  106019. };
  106020. /**
  106021. * Removes a target from the manager
  106022. * @param target defines the target to remove
  106023. */
  106024. MorphTargetManager.prototype.removeTarget = function (target) {
  106025. var index = this._targets.indexOf(target);
  106026. if (index >= 0) {
  106027. this._targets.splice(index, 1);
  106028. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  106029. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  106030. this._syncActiveTargets(true);
  106031. }
  106032. };
  106033. /**
  106034. * Serializes the current manager into a Serialization object
  106035. * @returns the serialized object
  106036. */
  106037. MorphTargetManager.prototype.serialize = function () {
  106038. var serializationObject = {};
  106039. serializationObject.id = this.uniqueId;
  106040. serializationObject.targets = [];
  106041. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  106042. var target = _a[_i];
  106043. serializationObject.targets.push(target.serialize());
  106044. }
  106045. return serializationObject;
  106046. };
  106047. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  106048. var influenceCount = 0;
  106049. this._activeTargets.reset();
  106050. this._supportsNormals = true;
  106051. this._supportsTangents = true;
  106052. this._vertexCount = 0;
  106053. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  106054. var target = _a[_i];
  106055. if (target.influence === 0) {
  106056. continue;
  106057. }
  106058. this._activeTargets.push(target);
  106059. this._tempInfluences[influenceCount++] = target.influence;
  106060. this._supportsNormals = this._supportsNormals && target.hasNormals;
  106061. this._supportsTangents = this._supportsTangents && target.hasTangents;
  106062. var positions = target.getPositions();
  106063. if (positions) {
  106064. var vertexCount = positions.length / 3;
  106065. if (this._vertexCount === 0) {
  106066. this._vertexCount = vertexCount;
  106067. }
  106068. else if (this._vertexCount !== vertexCount) {
  106069. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  106070. return;
  106071. }
  106072. }
  106073. }
  106074. if (!this._influences || this._influences.length !== influenceCount) {
  106075. this._influences = new Float32Array(influenceCount);
  106076. }
  106077. for (var index = 0; index < influenceCount; index++) {
  106078. this._influences[index] = this._tempInfluences[index];
  106079. }
  106080. if (needUpdate) {
  106081. this.synchronize();
  106082. }
  106083. };
  106084. /**
  106085. * Syncrhonize the targets with all the meshes using this morph target manager
  106086. */
  106087. MorphTargetManager.prototype.synchronize = function () {
  106088. if (!this._scene) {
  106089. return;
  106090. }
  106091. // Flag meshes as dirty to resync with the active targets
  106092. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  106093. var mesh = _a[_i];
  106094. if (mesh.morphTargetManager === this) {
  106095. mesh._syncGeometryWithMorphTargetManager();
  106096. }
  106097. }
  106098. };
  106099. // Statics
  106100. /**
  106101. * Creates a new MorphTargetManager from serialized data
  106102. * @param serializationObject defines the serialized data
  106103. * @param scene defines the hosting scene
  106104. * @returns the new MorphTargetManager
  106105. */
  106106. MorphTargetManager.Parse = function (serializationObject, scene) {
  106107. var result = new MorphTargetManager(scene);
  106108. result._uniqueId = serializationObject.id;
  106109. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  106110. var targetData = _a[_i];
  106111. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  106112. }
  106113. return result;
  106114. };
  106115. return MorphTargetManager;
  106116. }());
  106117. /***/ }),
  106118. /***/ "./Offline/database.ts":
  106119. /*!*****************************!*\
  106120. !*** ./Offline/database.ts ***!
  106121. \*****************************/
  106122. /*! exports provided: Database */
  106123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106124. "use strict";
  106125. __webpack_require__.r(__webpack_exports__);
  106126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  106127. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  106128. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  106129. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  106130. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  106131. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/webRequest */ "./Misc/webRequest.ts");
  106132. // Sets the default offline provider to Babylon.js
  106133. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  106134. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  106135. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  106136. };
  106137. /**
  106138. * Class used to enable access to IndexedDB
  106139. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106140. */
  106141. var Database = /** @class */ (function () {
  106142. /**
  106143. * Creates a new Database
  106144. * @param urlToScene defines the url to load the scene
  106145. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106146. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106147. */
  106148. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  106149. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  106150. var _this = this;
  106151. // Handling various flavors of prefixed version of IndexedDB
  106152. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  106153. this._callbackManifestChecked = callbackManifestChecked;
  106154. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  106155. this._db = null;
  106156. this._enableSceneOffline = false;
  106157. this._enableTexturesOffline = false;
  106158. this._manifestVersionFound = 0;
  106159. this._mustUpdateRessources = false;
  106160. this._hasReachedQuota = false;
  106161. if (!Database.IDBStorageEnabled) {
  106162. this._callbackManifestChecked(true);
  106163. }
  106164. else {
  106165. if (disableManifestCheck) {
  106166. this._enableSceneOffline = true;
  106167. this._enableTexturesOffline = true;
  106168. this._manifestVersionFound = 1;
  106169. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  106170. _this._callbackManifestChecked(true);
  106171. });
  106172. }
  106173. else {
  106174. this._checkManifestFile();
  106175. }
  106176. }
  106177. }
  106178. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  106179. /**
  106180. * Gets a boolean indicating if scene must be saved in the database
  106181. */
  106182. get: function () {
  106183. return this._enableSceneOffline;
  106184. },
  106185. enumerable: true,
  106186. configurable: true
  106187. });
  106188. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  106189. /**
  106190. * Gets a boolean indicating if textures must be saved in the database
  106191. */
  106192. get: function () {
  106193. return this._enableTexturesOffline;
  106194. },
  106195. enumerable: true,
  106196. configurable: true
  106197. });
  106198. Database.prototype._checkManifestFile = function () {
  106199. var _this = this;
  106200. var noManifestFile = function () {
  106201. _this._enableSceneOffline = false;
  106202. _this._enableTexturesOffline = false;
  106203. _this._callbackManifestChecked(false);
  106204. };
  106205. var timeStampUsed = false;
  106206. var manifestURL = this._currentSceneUrl + ".manifest";
  106207. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  106208. if (navigator.onLine) {
  106209. // Adding a timestamp to by-pass browsers' cache
  106210. timeStampUsed = true;
  106211. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  106212. }
  106213. xhr.open("GET", manifestURL);
  106214. xhr.addEventListener("load", function () {
  106215. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  106216. try {
  106217. var manifestFile = JSON.parse(xhr.response);
  106218. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  106219. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  106220. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  106221. _this._manifestVersionFound = manifestFile.version;
  106222. }
  106223. if (_this._callbackManifestChecked) {
  106224. _this._callbackManifestChecked(true);
  106225. }
  106226. }
  106227. catch (ex) {
  106228. noManifestFile();
  106229. }
  106230. }
  106231. else {
  106232. noManifestFile();
  106233. }
  106234. }, false);
  106235. xhr.addEventListener("error", function () {
  106236. if (timeStampUsed) {
  106237. timeStampUsed = false;
  106238. // Let's retry without the timeStamp
  106239. // It could fail when coupled with HTML5 Offline API
  106240. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  106241. xhr.open("GET", retryManifestURL);
  106242. xhr.send();
  106243. }
  106244. else {
  106245. noManifestFile();
  106246. }
  106247. }, false);
  106248. try {
  106249. xhr.send();
  106250. }
  106251. catch (ex) {
  106252. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  106253. this._callbackManifestChecked(false);
  106254. }
  106255. };
  106256. /**
  106257. * Open the database and make it available
  106258. * @param successCallback defines the callback to call on success
  106259. * @param errorCallback defines the callback to call on error
  106260. */
  106261. Database.prototype.open = function (successCallback, errorCallback) {
  106262. var _this = this;
  106263. var handleError = function () {
  106264. _this._isSupported = false;
  106265. if (errorCallback) {
  106266. errorCallback();
  106267. }
  106268. };
  106269. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  106270. // Your browser doesn't support IndexedDB
  106271. this._isSupported = false;
  106272. if (errorCallback) {
  106273. errorCallback();
  106274. }
  106275. }
  106276. else {
  106277. // If the DB hasn't been opened or created yet
  106278. if (!this._db) {
  106279. this._hasReachedQuota = false;
  106280. this._isSupported = true;
  106281. var request = this._idbFactory.open("babylonjs", 1);
  106282. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  106283. request.onerror = function () {
  106284. handleError();
  106285. };
  106286. // executes when a version change transaction cannot complete due to other active transactions
  106287. request.onblocked = function () {
  106288. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  106289. handleError();
  106290. };
  106291. // DB has been opened successfully
  106292. request.onsuccess = function () {
  106293. _this._db = request.result;
  106294. successCallback();
  106295. };
  106296. // Initialization of the DB. Creating Scenes & Textures stores
  106297. request.onupgradeneeded = function (event) {
  106298. _this._db = (event.target).result;
  106299. if (_this._db) {
  106300. try {
  106301. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  106302. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  106303. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  106304. }
  106305. catch (ex) {
  106306. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  106307. handleError();
  106308. }
  106309. }
  106310. };
  106311. }
  106312. // DB has already been created and opened
  106313. else {
  106314. if (successCallback) {
  106315. successCallback();
  106316. }
  106317. }
  106318. }
  106319. };
  106320. /**
  106321. * Loads an image from the database
  106322. * @param url defines the url to load from
  106323. * @param image defines the target DOM image
  106324. */
  106325. Database.prototype.loadImage = function (url, image) {
  106326. var _this = this;
  106327. var completeURL = Database._ReturnFullUrlLocation(url);
  106328. var saveAndLoadImage = function () {
  106329. if (!_this._hasReachedQuota && _this._db !== null) {
  106330. // the texture is not yet in the DB, let's try to save it
  106331. _this._saveImageIntoDBAsync(completeURL, image);
  106332. }
  106333. // If the texture is not in the DB and we've reached the DB quota limit
  106334. // let's load it directly from the web
  106335. else {
  106336. image.src = url;
  106337. }
  106338. };
  106339. if (!this._mustUpdateRessources) {
  106340. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  106341. }
  106342. // First time we're download the images or update requested in the manifest file by a version change
  106343. else {
  106344. saveAndLoadImage();
  106345. }
  106346. };
  106347. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  106348. if (this._isSupported && this._db !== null) {
  106349. var texture;
  106350. var transaction = this._db.transaction(["textures"]);
  106351. transaction.onabort = function () {
  106352. image.src = url;
  106353. };
  106354. transaction.oncomplete = function () {
  106355. var blobTextureURL;
  106356. if (texture) {
  106357. var URL = window.URL || window.webkitURL;
  106358. blobTextureURL = URL.createObjectURL(texture.data);
  106359. image.onerror = function () {
  106360. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  106361. image.src = url;
  106362. };
  106363. image.src = blobTextureURL;
  106364. }
  106365. else {
  106366. notInDBCallback();
  106367. }
  106368. };
  106369. var getRequest = transaction.objectStore("textures").get(url);
  106370. getRequest.onsuccess = function (event) {
  106371. texture = (event.target).result;
  106372. };
  106373. getRequest.onerror = function () {
  106374. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  106375. image.src = url;
  106376. };
  106377. }
  106378. else {
  106379. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106380. image.src = url;
  106381. }
  106382. };
  106383. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  106384. var _this = this;
  106385. if (this._isSupported) {
  106386. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  106387. var generateBlobUrl = function () {
  106388. var blobTextureURL;
  106389. if (blob) {
  106390. var URL = window.URL || window.webkitURL;
  106391. try {
  106392. blobTextureURL = URL.createObjectURL(blob);
  106393. }
  106394. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  106395. catch (ex) {
  106396. blobTextureURL = URL.createObjectURL(blob);
  106397. }
  106398. }
  106399. if (blobTextureURL) {
  106400. image.src = blobTextureURL;
  106401. }
  106402. };
  106403. if (Database.IsUASupportingBlobStorage) { // Create XHR
  106404. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"](), blob;
  106405. xhr.open("GET", url);
  106406. xhr.responseType = "blob";
  106407. xhr.addEventListener("load", function () {
  106408. if (xhr.status === 200 && _this._db) {
  106409. // Blob as response (XHR2)
  106410. blob = xhr.response;
  106411. var transaction = _this._db.transaction(["textures"], "readwrite");
  106412. // the transaction could abort because of a QuotaExceededError error
  106413. transaction.onabort = function (event) {
  106414. try {
  106415. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  106416. var srcElement = (event.srcElement || event.target);
  106417. var error = srcElement.error;
  106418. if (error && error.name === "QuotaExceededError") {
  106419. _this._hasReachedQuota = true;
  106420. }
  106421. }
  106422. catch (ex) { }
  106423. generateBlobUrl();
  106424. };
  106425. transaction.oncomplete = function () {
  106426. generateBlobUrl();
  106427. };
  106428. var newTexture = { textureUrl: url, data: blob };
  106429. try {
  106430. // Put the blob into the dabase
  106431. var addRequest = transaction.objectStore("textures").put(newTexture);
  106432. addRequest.onsuccess = function () {
  106433. };
  106434. addRequest.onerror = function () {
  106435. generateBlobUrl();
  106436. };
  106437. }
  106438. catch (ex) {
  106439. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  106440. if (ex.code === 25) {
  106441. Database.IsUASupportingBlobStorage = false;
  106442. _this._enableTexturesOffline = false;
  106443. }
  106444. image.src = url;
  106445. }
  106446. }
  106447. else {
  106448. image.src = url;
  106449. }
  106450. }, false);
  106451. xhr.addEventListener("error", function () {
  106452. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  106453. image.src = url;
  106454. }, false);
  106455. xhr.send();
  106456. }
  106457. else {
  106458. image.src = url;
  106459. }
  106460. }
  106461. else {
  106462. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106463. image.src = url;
  106464. }
  106465. };
  106466. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  106467. var _this = this;
  106468. var updateVersion = function () {
  106469. // the version is not yet in the DB or we need to update it
  106470. _this._saveVersionIntoDBAsync(url, versionLoaded);
  106471. };
  106472. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  106473. };
  106474. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  106475. var _this = this;
  106476. if (this._isSupported && this._db) {
  106477. var version;
  106478. try {
  106479. var transaction = this._db.transaction(["versions"]);
  106480. transaction.oncomplete = function () {
  106481. if (version) {
  106482. // If the version in the JSON file is different from the version in DB
  106483. if (_this._manifestVersionFound !== version.data) {
  106484. _this._mustUpdateRessources = true;
  106485. updateInDBCallback();
  106486. }
  106487. else {
  106488. callback(version.data);
  106489. }
  106490. }
  106491. // version was not found in DB
  106492. else {
  106493. _this._mustUpdateRessources = true;
  106494. updateInDBCallback();
  106495. }
  106496. };
  106497. transaction.onabort = function () {
  106498. callback(-1);
  106499. };
  106500. var getRequest = transaction.objectStore("versions").get(url);
  106501. getRequest.onsuccess = function (event) {
  106502. version = (event.target).result;
  106503. };
  106504. getRequest.onerror = function () {
  106505. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  106506. callback(-1);
  106507. };
  106508. }
  106509. catch (ex) {
  106510. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  106511. callback(-1);
  106512. }
  106513. }
  106514. else {
  106515. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106516. callback(-1);
  106517. }
  106518. };
  106519. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  106520. var _this = this;
  106521. if (this._isSupported && !this._hasReachedQuota && this._db) {
  106522. try {
  106523. // Open a transaction to the database
  106524. var transaction = this._db.transaction(["versions"], "readwrite");
  106525. // the transaction could abort because of a QuotaExceededError error
  106526. transaction.onabort = function (event) {
  106527. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  106528. var error = event.srcElement['error'];
  106529. if (error && error.name === "QuotaExceededError") {
  106530. _this._hasReachedQuota = true;
  106531. }
  106532. }
  106533. catch (ex) { }
  106534. callback(-1);
  106535. };
  106536. transaction.oncomplete = function () {
  106537. callback(_this._manifestVersionFound);
  106538. };
  106539. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  106540. // Put the scene into the database
  106541. var addRequest = transaction.objectStore("versions").put(newVersion);
  106542. addRequest.onsuccess = function () {
  106543. };
  106544. addRequest.onerror = function () {
  106545. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  106546. };
  106547. }
  106548. catch (ex) {
  106549. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  106550. callback(-1);
  106551. }
  106552. }
  106553. else {
  106554. callback(-1);
  106555. }
  106556. };
  106557. /**
  106558. * Loads a file from database
  106559. * @param url defines the URL to load from
  106560. * @param sceneLoaded defines a callback to call on success
  106561. * @param progressCallBack defines a callback to call when progress changed
  106562. * @param errorCallback defines a callback to call on error
  106563. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106564. */
  106565. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  106566. var _this = this;
  106567. var completeUrl = Database._ReturnFullUrlLocation(url);
  106568. var saveAndLoadFile = function () {
  106569. // the scene is not yet in the DB, let's try to save it
  106570. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  106571. };
  106572. this._checkVersionFromDB(completeUrl, function (version) {
  106573. if (version !== -1) {
  106574. if (!_this._mustUpdateRessources) {
  106575. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  106576. }
  106577. else {
  106578. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  106579. }
  106580. }
  106581. else {
  106582. if (errorCallback) {
  106583. errorCallback();
  106584. }
  106585. }
  106586. });
  106587. };
  106588. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  106589. if (this._isSupported && this._db) {
  106590. var targetStore;
  106591. if (url.indexOf(".babylon") !== -1) {
  106592. targetStore = "scenes";
  106593. }
  106594. else {
  106595. targetStore = "textures";
  106596. }
  106597. var file;
  106598. var transaction = this._db.transaction([targetStore]);
  106599. transaction.oncomplete = function () {
  106600. if (file) {
  106601. callback(file.data);
  106602. }
  106603. // file was not found in DB
  106604. else {
  106605. notInDBCallback();
  106606. }
  106607. };
  106608. transaction.onabort = function () {
  106609. notInDBCallback();
  106610. };
  106611. var getRequest = transaction.objectStore(targetStore).get(url);
  106612. getRequest.onsuccess = function (event) {
  106613. file = (event.target).result;
  106614. };
  106615. getRequest.onerror = function () {
  106616. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  106617. notInDBCallback();
  106618. };
  106619. }
  106620. else {
  106621. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106622. callback();
  106623. }
  106624. };
  106625. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  106626. var _this = this;
  106627. if (this._isSupported) {
  106628. var targetStore;
  106629. if (url.indexOf(".babylon") !== -1) {
  106630. targetStore = "scenes";
  106631. }
  106632. else {
  106633. targetStore = "textures";
  106634. }
  106635. // Create XHR
  106636. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  106637. var fileData;
  106638. xhr.open("GET", url + "?" + Date.now());
  106639. if (useArrayBuffer) {
  106640. xhr.responseType = "arraybuffer";
  106641. }
  106642. if (progressCallback) {
  106643. xhr.onprogress = progressCallback;
  106644. }
  106645. xhr.addEventListener("load", function () {
  106646. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  106647. // Blob as response (XHR2)
  106648. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  106649. if (!_this._hasReachedQuota && _this._db) {
  106650. // Open a transaction to the database
  106651. var transaction = _this._db.transaction([targetStore], "readwrite");
  106652. // the transaction could abort because of a QuotaExceededError error
  106653. transaction.onabort = function (event) {
  106654. try {
  106655. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  106656. var error = event.srcElement['error'];
  106657. if (error && error.name === "QuotaExceededError") {
  106658. _this._hasReachedQuota = true;
  106659. }
  106660. }
  106661. catch (ex) { }
  106662. callback(fileData);
  106663. };
  106664. transaction.oncomplete = function () {
  106665. callback(fileData);
  106666. };
  106667. var newFile;
  106668. if (targetStore === "scenes") {
  106669. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  106670. }
  106671. else {
  106672. newFile = { textureUrl: url, data: fileData };
  106673. }
  106674. try {
  106675. // Put the scene into the database
  106676. var addRequest = transaction.objectStore(targetStore).put(newFile);
  106677. addRequest.onsuccess = function () {
  106678. };
  106679. addRequest.onerror = function () {
  106680. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  106681. };
  106682. }
  106683. catch (ex) {
  106684. callback(fileData);
  106685. }
  106686. }
  106687. else {
  106688. callback(fileData);
  106689. }
  106690. }
  106691. else {
  106692. if (xhr.status >= 400 && errorCallback) {
  106693. errorCallback(xhr);
  106694. }
  106695. else {
  106696. callback();
  106697. }
  106698. }
  106699. }, false);
  106700. xhr.addEventListener("error", function () {
  106701. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  106702. callback();
  106703. }, false);
  106704. xhr.send();
  106705. }
  106706. else {
  106707. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  106708. callback();
  106709. }
  106710. };
  106711. /**
  106712. * Validates if xhr data is correct
  106713. * @param xhr defines the request to validate
  106714. * @param dataType defines the expected data type
  106715. * @returns true if data is correct
  106716. */
  106717. Database._ValidateXHRData = function (xhr, dataType) {
  106718. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  106719. if (dataType === void 0) { dataType = 7; }
  106720. try {
  106721. if (dataType & 1) {
  106722. if (xhr.responseText && xhr.responseText.length > 0) {
  106723. return true;
  106724. }
  106725. else if (dataType === 1) {
  106726. return false;
  106727. }
  106728. }
  106729. if (dataType & 2) {
  106730. // Check header width and height since there is no "TGA" magic number
  106731. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  106732. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  106733. return true;
  106734. }
  106735. else if (dataType === 2) {
  106736. return false;
  106737. }
  106738. }
  106739. if (dataType & 4) {
  106740. // Check for the "DDS" magic number
  106741. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  106742. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  106743. return true;
  106744. }
  106745. else {
  106746. return false;
  106747. }
  106748. }
  106749. }
  106750. catch (e) {
  106751. // Global protection
  106752. }
  106753. return false;
  106754. };
  106755. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106756. Database.IsUASupportingBlobStorage = true;
  106757. /**
  106758. * Gets a boolean indicating if Database storate is enabled (off by default)
  106759. */
  106760. Database.IDBStorageEnabled = false;
  106761. Database._ParseURL = function (url) {
  106762. var a = document.createElement('a');
  106763. a.href = url;
  106764. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  106765. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  106766. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  106767. return absLocation;
  106768. };
  106769. Database._ReturnFullUrlLocation = function (url) {
  106770. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  106771. return (Database._ParseURL(window.location.href) + url);
  106772. }
  106773. else {
  106774. return url;
  106775. }
  106776. };
  106777. return Database;
  106778. }());
  106779. /***/ }),
  106780. /***/ "./Offline/index.ts":
  106781. /*!**************************!*\
  106782. !*** ./Offline/index.ts ***!
  106783. \**************************/
  106784. /*! exports provided: Database */
  106785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106786. "use strict";
  106787. __webpack_require__.r(__webpack_exports__);
  106788. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  106789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  106790. /***/ }),
  106791. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  106792. /*!******************************************************!*\
  106793. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  106794. \******************************************************/
  106795. /*! exports provided: BoxParticleEmitter */
  106796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106797. "use strict";
  106798. __webpack_require__.r(__webpack_exports__);
  106799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  106800. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106801. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106802. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106803. /**
  106804. * Particle emitter emitting particles from the inside of a box.
  106805. * It emits the particles randomly between 2 given directions.
  106806. */
  106807. var BoxParticleEmitter = /** @class */ (function () {
  106808. /**
  106809. * Creates a new instance BoxParticleEmitter
  106810. */
  106811. function BoxParticleEmitter() {
  106812. /**
  106813. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106814. */
  106815. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  106816. /**
  106817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106818. */
  106819. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  106820. /**
  106821. * 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.
  106822. */
  106823. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  106824. /**
  106825. * 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.
  106826. */
  106827. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  106828. }
  106829. /**
  106830. * Called by the particle System when the direction is computed for the created particle.
  106831. * @param worldMatrix is the world matrix of the particle system
  106832. * @param directionToUpdate is the direction vector to update with the result
  106833. * @param particle is the particle we are computed the direction for
  106834. */
  106835. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106836. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  106837. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  106838. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  106839. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  106840. };
  106841. /**
  106842. * Called by the particle System when the position is computed for the created particle.
  106843. * @param worldMatrix is the world matrix of the particle system
  106844. * @param positionToUpdate is the position vector to update with the result
  106845. * @param particle is the particle we are computed the position for
  106846. */
  106847. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106848. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  106849. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  106850. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  106851. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  106852. };
  106853. /**
  106854. * Clones the current emitter and returns a copy of it
  106855. * @returns the new emitter
  106856. */
  106857. BoxParticleEmitter.prototype.clone = function () {
  106858. var newOne = new BoxParticleEmitter();
  106859. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  106860. return newOne;
  106861. };
  106862. /**
  106863. * Called by the GPUParticleSystem to setup the update shader
  106864. * @param effect defines the update shader
  106865. */
  106866. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  106867. effect.setVector3("direction1", this.direction1);
  106868. effect.setVector3("direction2", this.direction2);
  106869. effect.setVector3("minEmitBox", this.minEmitBox);
  106870. effect.setVector3("maxEmitBox", this.maxEmitBox);
  106871. };
  106872. /**
  106873. * Returns a string to use to update the GPU particles update shader
  106874. * @returns a string containng the defines string
  106875. */
  106876. BoxParticleEmitter.prototype.getEffectDefines = function () {
  106877. return "#define BOXEMITTER";
  106878. };
  106879. /**
  106880. * Returns the string "BoxParticleEmitter"
  106881. * @returns a string containing the class name
  106882. */
  106883. BoxParticleEmitter.prototype.getClassName = function () {
  106884. return "BoxParticleEmitter";
  106885. };
  106886. /**
  106887. * Serializes the particle system to a JSON object.
  106888. * @returns the JSON object
  106889. */
  106890. BoxParticleEmitter.prototype.serialize = function () {
  106891. var serializationObject = {};
  106892. serializationObject.type = this.getClassName();
  106893. serializationObject.direction1 = this.direction1.asArray();
  106894. serializationObject.direction2 = this.direction2.asArray();
  106895. serializationObject.minEmitBox = this.minEmitBox.asArray();
  106896. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  106897. return serializationObject;
  106898. };
  106899. /**
  106900. * Parse properties from a JSON object
  106901. * @param serializationObject defines the JSON object
  106902. */
  106903. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  106904. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  106905. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  106906. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  106907. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  106908. };
  106909. return BoxParticleEmitter;
  106910. }());
  106911. /***/ }),
  106912. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  106913. /*!*******************************************************!*\
  106914. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  106915. \*******************************************************/
  106916. /*! exports provided: ConeParticleEmitter */
  106917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106918. "use strict";
  106919. __webpack_require__.r(__webpack_exports__);
  106920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  106921. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106922. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106923. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106924. /**
  106925. * Particle emitter emitting particles from the inside of a cone.
  106926. * It emits the particles alongside the cone volume from the base to the particle.
  106927. * The emission direction might be randomized.
  106928. */
  106929. var ConeParticleEmitter = /** @class */ (function () {
  106930. /**
  106931. * Creates a new instance ConeParticleEmitter
  106932. * @param radius the radius of the emission cone (1 by default)
  106933. * @param angle the cone base angle (PI by default)
  106934. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  106935. */
  106936. function ConeParticleEmitter(radius, angle,
  106937. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  106938. directionRandomizer) {
  106939. if (radius === void 0) { radius = 1; }
  106940. if (angle === void 0) { angle = Math.PI; }
  106941. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  106942. this.directionRandomizer = directionRandomizer;
  106943. /**
  106944. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  106945. */
  106946. this.radiusRange = 1;
  106947. /**
  106948. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  106949. */
  106950. this.heightRange = 1;
  106951. /**
  106952. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  106953. */
  106954. this.emitFromSpawnPointOnly = false;
  106955. this.angle = angle;
  106956. this.radius = radius;
  106957. }
  106958. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  106959. /**
  106960. * Gets or sets the radius of the emission cone
  106961. */
  106962. get: function () {
  106963. return this._radius;
  106964. },
  106965. set: function (value) {
  106966. this._radius = value;
  106967. this._buildHeight();
  106968. },
  106969. enumerable: true,
  106970. configurable: true
  106971. });
  106972. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  106973. /**
  106974. * Gets or sets the angle of the emission cone
  106975. */
  106976. get: function () {
  106977. return this._angle;
  106978. },
  106979. set: function (value) {
  106980. this._angle = value;
  106981. this._buildHeight();
  106982. },
  106983. enumerable: true,
  106984. configurable: true
  106985. });
  106986. ConeParticleEmitter.prototype._buildHeight = function () {
  106987. if (this._angle !== 0) {
  106988. this._height = this._radius / Math.tan(this._angle / 2);
  106989. }
  106990. else {
  106991. this._height = 1;
  106992. }
  106993. };
  106994. /**
  106995. * Called by the particle System when the direction is computed for the created particle.
  106996. * @param worldMatrix is the world matrix of the particle system
  106997. * @param directionToUpdate is the direction vector to update with the result
  106998. * @param particle is the particle we are computed the direction for
  106999. */
  107000. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107001. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  107002. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  107003. }
  107004. else {
  107005. // measure the direction Vector from the emitter to the particle.
  107006. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  107007. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107008. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107009. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107010. direction.x += randX;
  107011. direction.y += randY;
  107012. direction.z += randZ;
  107013. direction.normalize();
  107014. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  107015. }
  107016. };
  107017. /**
  107018. * Called by the particle System when the position is computed for the created particle.
  107019. * @param worldMatrix is the world matrix of the particle system
  107020. * @param positionToUpdate is the position vector to update with the result
  107021. * @param particle is the particle we are computed the position for
  107022. */
  107023. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107024. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  107025. var h;
  107026. if (!this.emitFromSpawnPointOnly) {
  107027. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  107028. // Better distribution in a cone at normal angles.
  107029. h = 1 - h * h;
  107030. }
  107031. else {
  107032. h = 0.0001;
  107033. }
  107034. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  107035. radius = radius * h;
  107036. var randX = radius * Math.sin(s);
  107037. var randZ = radius * Math.cos(s);
  107038. var randY = h * this._height;
  107039. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  107040. };
  107041. /**
  107042. * Clones the current emitter and returns a copy of it
  107043. * @returns the new emitter
  107044. */
  107045. ConeParticleEmitter.prototype.clone = function () {
  107046. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  107047. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  107048. return newOne;
  107049. };
  107050. /**
  107051. * Called by the GPUParticleSystem to setup the update shader
  107052. * @param effect defines the update shader
  107053. */
  107054. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  107055. effect.setFloat2("radius", this._radius, this.radiusRange);
  107056. effect.setFloat("coneAngle", this._angle);
  107057. effect.setFloat2("height", this._height, this.heightRange);
  107058. effect.setFloat("directionRandomizer", this.directionRandomizer);
  107059. };
  107060. /**
  107061. * Returns a string to use to update the GPU particles update shader
  107062. * @returns a string containng the defines string
  107063. */
  107064. ConeParticleEmitter.prototype.getEffectDefines = function () {
  107065. var defines = "#define CONEEMITTER";
  107066. if (this.emitFromSpawnPointOnly) {
  107067. defines += "\n#define CONEEMITTERSPAWNPOINT";
  107068. }
  107069. return defines;
  107070. };
  107071. /**
  107072. * Returns the string "ConeParticleEmitter"
  107073. * @returns a string containing the class name
  107074. */
  107075. ConeParticleEmitter.prototype.getClassName = function () {
  107076. return "ConeParticleEmitter";
  107077. };
  107078. /**
  107079. * Serializes the particle system to a JSON object.
  107080. * @returns the JSON object
  107081. */
  107082. ConeParticleEmitter.prototype.serialize = function () {
  107083. var serializationObject = {};
  107084. serializationObject.type = this.getClassName();
  107085. serializationObject.radius = this._radius;
  107086. serializationObject.angle = this._angle;
  107087. serializationObject.directionRandomizer = this.directionRandomizer;
  107088. return serializationObject;
  107089. };
  107090. /**
  107091. * Parse properties from a JSON object
  107092. * @param serializationObject defines the JSON object
  107093. */
  107094. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  107095. this.radius = serializationObject.radius;
  107096. this.angle = serializationObject.angle;
  107097. this.directionRandomizer = serializationObject.directionRandomizer;
  107098. };
  107099. return ConeParticleEmitter;
  107100. }());
  107101. /***/ }),
  107102. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  107103. /*!***********************************************************!*\
  107104. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  107105. \***********************************************************/
  107106. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  107107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107108. "use strict";
  107109. __webpack_require__.r(__webpack_exports__);
  107110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  107111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  107112. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  107113. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107114. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107115. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107116. /**
  107117. * Particle emitter emitting particles from the inside of a cylinder.
  107118. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  107119. */
  107120. var CylinderParticleEmitter = /** @class */ (function () {
  107121. /**
  107122. * Creates a new instance CylinderParticleEmitter
  107123. * @param radius the radius of the emission cylinder (1 by default)
  107124. * @param height the height of the emission cylinder (1 by default)
  107125. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  107126. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  107127. */
  107128. function CylinderParticleEmitter(
  107129. /**
  107130. * The radius of the emission cylinder.
  107131. */
  107132. radius,
  107133. /**
  107134. * The height of the emission cylinder.
  107135. */
  107136. height,
  107137. /**
  107138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  107139. */
  107140. radiusRange,
  107141. /**
  107142. * How much to randomize the particle direction [0-1].
  107143. */
  107144. directionRandomizer) {
  107145. if (radius === void 0) { radius = 1; }
  107146. if (height === void 0) { height = 1; }
  107147. if (radiusRange === void 0) { radiusRange = 1; }
  107148. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  107149. this.radius = radius;
  107150. this.height = height;
  107151. this.radiusRange = radiusRange;
  107152. this.directionRandomizer = directionRandomizer;
  107153. }
  107154. /**
  107155. * Called by the particle System when the direction is computed for the created particle.
  107156. * @param worldMatrix is the world matrix of the particle system
  107157. * @param directionToUpdate is the direction vector to update with the result
  107158. * @param particle is the particle we are computed the direction for
  107159. */
  107160. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107161. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  107162. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  107163. var angle = Math.atan2(direction.x, direction.z);
  107164. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  107165. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  107166. direction.x = Math.sin(angle);
  107167. direction.z = Math.cos(angle);
  107168. direction.normalize();
  107169. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  107170. };
  107171. /**
  107172. * Called by the particle System when the position is computed for the created particle.
  107173. * @param worldMatrix is the world matrix of the particle system
  107174. * @param positionToUpdate is the position vector to update with the result
  107175. * @param particle is the particle we are computed the position for
  107176. */
  107177. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107178. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  107179. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  107180. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  107181. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  107182. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  107183. var xPos = positionRadius * Math.cos(angle);
  107184. var zPos = positionRadius * Math.sin(angle);
  107185. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  107186. };
  107187. /**
  107188. * Clones the current emitter and returns a copy of it
  107189. * @returns the new emitter
  107190. */
  107191. CylinderParticleEmitter.prototype.clone = function () {
  107192. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  107193. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  107194. return newOne;
  107195. };
  107196. /**
  107197. * Called by the GPUParticleSystem to setup the update shader
  107198. * @param effect defines the update shader
  107199. */
  107200. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  107201. effect.setFloat("radius", this.radius);
  107202. effect.setFloat("height", this.height);
  107203. effect.setFloat("radiusRange", this.radiusRange);
  107204. effect.setFloat("directionRandomizer", this.directionRandomizer);
  107205. };
  107206. /**
  107207. * Returns a string to use to update the GPU particles update shader
  107208. * @returns a string containng the defines string
  107209. */
  107210. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  107211. return "#define CYLINDEREMITTER";
  107212. };
  107213. /**
  107214. * Returns the string "CylinderParticleEmitter"
  107215. * @returns a string containing the class name
  107216. */
  107217. CylinderParticleEmitter.prototype.getClassName = function () {
  107218. return "CylinderParticleEmitter";
  107219. };
  107220. /**
  107221. * Serializes the particle system to a JSON object.
  107222. * @returns the JSON object
  107223. */
  107224. CylinderParticleEmitter.prototype.serialize = function () {
  107225. var serializationObject = {};
  107226. serializationObject.type = this.getClassName();
  107227. serializationObject.radius = this.radius;
  107228. serializationObject.height = this.height;
  107229. serializationObject.radiusRange = this.radiusRange;
  107230. serializationObject.directionRandomizer = this.directionRandomizer;
  107231. return serializationObject;
  107232. };
  107233. /**
  107234. * Parse properties from a JSON object
  107235. * @param serializationObject defines the JSON object
  107236. */
  107237. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  107238. this.radius = serializationObject.radius;
  107239. this.height = serializationObject.height;
  107240. this.radiusRange = serializationObject.radiusRange;
  107241. this.directionRandomizer = serializationObject.directionRandomizer;
  107242. };
  107243. return CylinderParticleEmitter;
  107244. }());
  107245. /**
  107246. * Particle emitter emitting particles from the inside of a cylinder.
  107247. * It emits the particles randomly between two vectors.
  107248. */
  107249. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  107250. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  107251. /**
  107252. * Creates a new instance CylinderDirectedParticleEmitter
  107253. * @param radius the radius of the emission cylinder (1 by default)
  107254. * @param height the height of the emission cylinder (1 by default)
  107255. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  107256. * @param direction1 the min limit of the emission direction (up vector by default)
  107257. * @param direction2 the max limit of the emission direction (up vector by default)
  107258. */
  107259. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  107260. /**
  107261. * The min limit of the emission direction.
  107262. */
  107263. direction1,
  107264. /**
  107265. * The max limit of the emission direction.
  107266. */
  107267. direction2) {
  107268. if (radius === void 0) { radius = 1; }
  107269. if (height === void 0) { height = 1; }
  107270. if (radiusRange === void 0) { radiusRange = 1; }
  107271. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  107272. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  107273. var _this = _super.call(this, radius, height, radiusRange) || this;
  107274. _this.direction1 = direction1;
  107275. _this.direction2 = direction2;
  107276. return _this;
  107277. }
  107278. /**
  107279. * Called by the particle System when the direction is computed for the created particle.
  107280. * @param worldMatrix is the world matrix of the particle system
  107281. * @param directionToUpdate is the direction vector to update with the result
  107282. * @param particle is the particle we are computed the direction for
  107283. */
  107284. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107285. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  107286. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  107287. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  107288. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  107289. };
  107290. /**
  107291. * Clones the current emitter and returns a copy of it
  107292. * @returns the new emitter
  107293. */
  107294. CylinderDirectedParticleEmitter.prototype.clone = function () {
  107295. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  107296. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  107297. return newOne;
  107298. };
  107299. /**
  107300. * Called by the GPUParticleSystem to setup the update shader
  107301. * @param effect defines the update shader
  107302. */
  107303. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  107304. effect.setFloat("radius", this.radius);
  107305. effect.setFloat("height", this.height);
  107306. effect.setFloat("radiusRange", this.radiusRange);
  107307. effect.setVector3("direction1", this.direction1);
  107308. effect.setVector3("direction2", this.direction2);
  107309. };
  107310. /**
  107311. * Returns a string to use to update the GPU particles update shader
  107312. * @returns a string containng the defines string
  107313. */
  107314. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  107315. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  107316. };
  107317. /**
  107318. * Returns the string "CylinderDirectedParticleEmitter"
  107319. * @returns a string containing the class name
  107320. */
  107321. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  107322. return "CylinderDirectedParticleEmitter";
  107323. };
  107324. /**
  107325. * Serializes the particle system to a JSON object.
  107326. * @returns the JSON object
  107327. */
  107328. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  107329. var serializationObject = _super.prototype.serialize.call(this);
  107330. serializationObject.direction1 = this.direction1.asArray();
  107331. serializationObject.direction2 = this.direction2.asArray();
  107332. return serializationObject;
  107333. };
  107334. /**
  107335. * Parse properties from a JSON object
  107336. * @param serializationObject defines the JSON object
  107337. */
  107338. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  107339. _super.prototype.parse.call(this, serializationObject);
  107340. this.direction1.copyFrom(serializationObject.direction1);
  107341. this.direction2.copyFrom(serializationObject.direction2);
  107342. };
  107343. return CylinderDirectedParticleEmitter;
  107344. }(CylinderParticleEmitter));
  107345. /***/ }),
  107346. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  107347. /*!**************************************************************!*\
  107348. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  107349. \**************************************************************/
  107350. /*! exports provided: HemisphericParticleEmitter */
  107351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107352. "use strict";
  107353. __webpack_require__.r(__webpack_exports__);
  107354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  107355. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107356. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107357. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107358. /**
  107359. * Particle emitter emitting particles from the inside of a hemisphere.
  107360. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  107361. */
  107362. var HemisphericParticleEmitter = /** @class */ (function () {
  107363. /**
  107364. * Creates a new instance HemisphericParticleEmitter
  107365. * @param radius the radius of the emission hemisphere (1 by default)
  107366. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  107367. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  107368. */
  107369. function HemisphericParticleEmitter(
  107370. /**
  107371. * The radius of the emission hemisphere.
  107372. */
  107373. radius,
  107374. /**
  107375. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  107376. */
  107377. radiusRange,
  107378. /**
  107379. * How much to randomize the particle direction [0-1].
  107380. */
  107381. directionRandomizer) {
  107382. if (radius === void 0) { radius = 1; }
  107383. if (radiusRange === void 0) { radiusRange = 1; }
  107384. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  107385. this.radius = radius;
  107386. this.radiusRange = radiusRange;
  107387. this.directionRandomizer = directionRandomizer;
  107388. }
  107389. /**
  107390. * Called by the particle System when the direction is computed for the created particle.
  107391. * @param worldMatrix is the world matrix of the particle system
  107392. * @param directionToUpdate is the direction vector to update with the result
  107393. * @param particle is the particle we are computed the direction for
  107394. */
  107395. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107396. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  107397. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107398. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107399. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107400. direction.x += randX;
  107401. direction.y += randY;
  107402. direction.z += randZ;
  107403. direction.normalize();
  107404. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  107405. };
  107406. /**
  107407. * Called by the particle System when the position is computed for the created particle.
  107408. * @param worldMatrix is the world matrix of the particle system
  107409. * @param positionToUpdate is the position vector to update with the result
  107410. * @param particle is the particle we are computed the position for
  107411. */
  107412. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107413. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  107414. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  107415. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  107416. var theta = Math.acos(2 * v - 1);
  107417. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  107418. var randY = randRadius * Math.cos(theta);
  107419. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  107420. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  107421. };
  107422. /**
  107423. * Clones the current emitter and returns a copy of it
  107424. * @returns the new emitter
  107425. */
  107426. HemisphericParticleEmitter.prototype.clone = function () {
  107427. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  107428. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  107429. return newOne;
  107430. };
  107431. /**
  107432. * Called by the GPUParticleSystem to setup the update shader
  107433. * @param effect defines the update shader
  107434. */
  107435. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  107436. effect.setFloat("radius", this.radius);
  107437. effect.setFloat("radiusRange", this.radiusRange);
  107438. effect.setFloat("directionRandomizer", this.directionRandomizer);
  107439. };
  107440. /**
  107441. * Returns a string to use to update the GPU particles update shader
  107442. * @returns a string containng the defines string
  107443. */
  107444. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  107445. return "#define HEMISPHERICEMITTER";
  107446. };
  107447. /**
  107448. * Returns the string "HemisphericParticleEmitter"
  107449. * @returns a string containing the class name
  107450. */
  107451. HemisphericParticleEmitter.prototype.getClassName = function () {
  107452. return "HemisphericParticleEmitter";
  107453. };
  107454. /**
  107455. * Serializes the particle system to a JSON object.
  107456. * @returns the JSON object
  107457. */
  107458. HemisphericParticleEmitter.prototype.serialize = function () {
  107459. var serializationObject = {};
  107460. serializationObject.type = this.getClassName();
  107461. serializationObject.radius = this.radius;
  107462. serializationObject.radiusRange = this.radiusRange;
  107463. serializationObject.directionRandomizer = this.directionRandomizer;
  107464. return serializationObject;
  107465. };
  107466. /**
  107467. * Parse properties from a JSON object
  107468. * @param serializationObject defines the JSON object
  107469. */
  107470. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  107471. this.radius = serializationObject.radius;
  107472. this.radiusRange = serializationObject.radiusRange;
  107473. this.directionRandomizer = serializationObject.directionRandomizer;
  107474. };
  107475. return HemisphericParticleEmitter;
  107476. }());
  107477. /***/ }),
  107478. /***/ "./Particles/EmitterTypes/index.ts":
  107479. /*!*****************************************!*\
  107480. !*** ./Particles/EmitterTypes/index.ts ***!
  107481. \*****************************************/
  107482. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  107483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107484. "use strict";
  107485. __webpack_require__.r(__webpack_exports__);
  107486. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  107487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  107488. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  107489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  107490. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  107491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  107492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  107493. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  107494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  107495. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  107496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  107497. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  107498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  107499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  107500. /***/ }),
  107501. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  107502. /*!********************************************************!*\
  107503. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  107504. \********************************************************/
  107505. /*! exports provided: PointParticleEmitter */
  107506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107507. "use strict";
  107508. __webpack_require__.r(__webpack_exports__);
  107509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  107510. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107511. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107512. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107513. /**
  107514. * Particle emitter emitting particles from a point.
  107515. * It emits the particles randomly between 2 given directions.
  107516. */
  107517. var PointParticleEmitter = /** @class */ (function () {
  107518. /**
  107519. * Creates a new instance PointParticleEmitter
  107520. */
  107521. function PointParticleEmitter() {
  107522. /**
  107523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107524. */
  107525. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  107526. /**
  107527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107528. */
  107529. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  107530. }
  107531. /**
  107532. * Called by the particle System when the direction is computed for the created particle.
  107533. * @param worldMatrix is the world matrix of the particle system
  107534. * @param directionToUpdate is the direction vector to update with the result
  107535. * @param particle is the particle we are computed the direction for
  107536. */
  107537. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107538. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  107539. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  107540. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  107541. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  107542. };
  107543. /**
  107544. * Called by the particle System when the position is computed for the created particle.
  107545. * @param worldMatrix is the world matrix of the particle system
  107546. * @param positionToUpdate is the position vector to update with the result
  107547. * @param particle is the particle we are computed the position for
  107548. */
  107549. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107550. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  107551. };
  107552. /**
  107553. * Clones the current emitter and returns a copy of it
  107554. * @returns the new emitter
  107555. */
  107556. PointParticleEmitter.prototype.clone = function () {
  107557. var newOne = new PointParticleEmitter();
  107558. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  107559. return newOne;
  107560. };
  107561. /**
  107562. * Called by the GPUParticleSystem to setup the update shader
  107563. * @param effect defines the update shader
  107564. */
  107565. PointParticleEmitter.prototype.applyToShader = function (effect) {
  107566. effect.setVector3("direction1", this.direction1);
  107567. effect.setVector3("direction2", this.direction2);
  107568. };
  107569. /**
  107570. * Returns a string to use to update the GPU particles update shader
  107571. * @returns a string containng the defines string
  107572. */
  107573. PointParticleEmitter.prototype.getEffectDefines = function () {
  107574. return "#define POINTEMITTER";
  107575. };
  107576. /**
  107577. * Returns the string "PointParticleEmitter"
  107578. * @returns a string containing the class name
  107579. */
  107580. PointParticleEmitter.prototype.getClassName = function () {
  107581. return "PointParticleEmitter";
  107582. };
  107583. /**
  107584. * Serializes the particle system to a JSON object.
  107585. * @returns the JSON object
  107586. */
  107587. PointParticleEmitter.prototype.serialize = function () {
  107588. var serializationObject = {};
  107589. serializationObject.type = this.getClassName();
  107590. serializationObject.direction1 = this.direction1.asArray();
  107591. serializationObject.direction2 = this.direction2.asArray();
  107592. return serializationObject;
  107593. };
  107594. /**
  107595. * Parse properties from a JSON object
  107596. * @param serializationObject defines the JSON object
  107597. */
  107598. PointParticleEmitter.prototype.parse = function (serializationObject) {
  107599. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  107600. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  107601. };
  107602. return PointParticleEmitter;
  107603. }());
  107604. /***/ }),
  107605. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  107606. /*!*********************************************************!*\
  107607. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  107608. \*********************************************************/
  107609. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  107610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107611. "use strict";
  107612. __webpack_require__.r(__webpack_exports__);
  107613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  107614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  107615. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  107616. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107617. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107618. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107619. /**
  107620. * Particle emitter emitting particles from the inside of a sphere.
  107621. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  107622. */
  107623. var SphereParticleEmitter = /** @class */ (function () {
  107624. /**
  107625. * Creates a new instance SphereParticleEmitter
  107626. * @param radius the radius of the emission sphere (1 by default)
  107627. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  107628. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  107629. */
  107630. function SphereParticleEmitter(
  107631. /**
  107632. * The radius of the emission sphere.
  107633. */
  107634. radius,
  107635. /**
  107636. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  107637. */
  107638. radiusRange,
  107639. /**
  107640. * How much to randomize the particle direction [0-1].
  107641. */
  107642. directionRandomizer) {
  107643. if (radius === void 0) { radius = 1; }
  107644. if (radiusRange === void 0) { radiusRange = 1; }
  107645. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  107646. this.radius = radius;
  107647. this.radiusRange = radiusRange;
  107648. this.directionRandomizer = directionRandomizer;
  107649. }
  107650. /**
  107651. * Called by the particle System when the direction is computed for the created particle.
  107652. * @param worldMatrix is the world matrix of the particle system
  107653. * @param directionToUpdate is the direction vector to update with the result
  107654. * @param particle is the particle we are computed the direction for
  107655. */
  107656. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107657. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  107658. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107659. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107660. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107661. direction.x += randX;
  107662. direction.y += randY;
  107663. direction.z += randZ;
  107664. direction.normalize();
  107665. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  107666. };
  107667. /**
  107668. * Called by the particle System when the position is computed for the created particle.
  107669. * @param worldMatrix is the world matrix of the particle system
  107670. * @param positionToUpdate is the position vector to update with the result
  107671. * @param particle is the particle we are computed the position for
  107672. */
  107673. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107674. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  107675. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  107676. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  107677. var theta = Math.acos(2 * v - 1);
  107678. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  107679. var randY = randRadius * Math.cos(theta);
  107680. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  107681. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  107682. };
  107683. /**
  107684. * Clones the current emitter and returns a copy of it
  107685. * @returns the new emitter
  107686. */
  107687. SphereParticleEmitter.prototype.clone = function () {
  107688. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  107689. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  107690. return newOne;
  107691. };
  107692. /**
  107693. * Called by the GPUParticleSystem to setup the update shader
  107694. * @param effect defines the update shader
  107695. */
  107696. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  107697. effect.setFloat("radius", this.radius);
  107698. effect.setFloat("radiusRange", this.radiusRange);
  107699. effect.setFloat("directionRandomizer", this.directionRandomizer);
  107700. };
  107701. /**
  107702. * Returns a string to use to update the GPU particles update shader
  107703. * @returns a string containng the defines string
  107704. */
  107705. SphereParticleEmitter.prototype.getEffectDefines = function () {
  107706. return "#define SPHEREEMITTER";
  107707. };
  107708. /**
  107709. * Returns the string "SphereParticleEmitter"
  107710. * @returns a string containing the class name
  107711. */
  107712. SphereParticleEmitter.prototype.getClassName = function () {
  107713. return "SphereParticleEmitter";
  107714. };
  107715. /**
  107716. * Serializes the particle system to a JSON object.
  107717. * @returns the JSON object
  107718. */
  107719. SphereParticleEmitter.prototype.serialize = function () {
  107720. var serializationObject = {};
  107721. serializationObject.type = this.getClassName();
  107722. serializationObject.radius = this.radius;
  107723. serializationObject.radiusRange = this.radiusRange;
  107724. serializationObject.directionRandomizer = this.directionRandomizer;
  107725. return serializationObject;
  107726. };
  107727. /**
  107728. * Parse properties from a JSON object
  107729. * @param serializationObject defines the JSON object
  107730. */
  107731. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  107732. this.radius = serializationObject.radius;
  107733. this.radiusRange = serializationObject.radiusRange;
  107734. this.directionRandomizer = serializationObject.directionRandomizer;
  107735. };
  107736. return SphereParticleEmitter;
  107737. }());
  107738. /**
  107739. * Particle emitter emitting particles from the inside of a sphere.
  107740. * It emits the particles randomly between two vectors.
  107741. */
  107742. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  107743. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  107744. /**
  107745. * Creates a new instance SphereDirectedParticleEmitter
  107746. * @param radius the radius of the emission sphere (1 by default)
  107747. * @param direction1 the min limit of the emission direction (up vector by default)
  107748. * @param direction2 the max limit of the emission direction (up vector by default)
  107749. */
  107750. function SphereDirectedParticleEmitter(radius,
  107751. /**
  107752. * The min limit of the emission direction.
  107753. */
  107754. direction1,
  107755. /**
  107756. * The max limit of the emission direction.
  107757. */
  107758. direction2) {
  107759. if (radius === void 0) { radius = 1; }
  107760. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  107761. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  107762. var _this = _super.call(this, radius) || this;
  107763. _this.direction1 = direction1;
  107764. _this.direction2 = direction2;
  107765. return _this;
  107766. }
  107767. /**
  107768. * Called by the particle System when the direction is computed for the created particle.
  107769. * @param worldMatrix is the world matrix of the particle system
  107770. * @param directionToUpdate is the direction vector to update with the result
  107771. * @param particle is the particle we are computed the direction for
  107772. */
  107773. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107774. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  107775. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  107776. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  107777. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  107778. };
  107779. /**
  107780. * Clones the current emitter and returns a copy of it
  107781. * @returns the new emitter
  107782. */
  107783. SphereDirectedParticleEmitter.prototype.clone = function () {
  107784. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  107785. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  107786. return newOne;
  107787. };
  107788. /**
  107789. * Called by the GPUParticleSystem to setup the update shader
  107790. * @param effect defines the update shader
  107791. */
  107792. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  107793. effect.setFloat("radius", this.radius);
  107794. effect.setFloat("radiusRange", this.radiusRange);
  107795. effect.setVector3("direction1", this.direction1);
  107796. effect.setVector3("direction2", this.direction2);
  107797. };
  107798. /**
  107799. * Returns a string to use to update the GPU particles update shader
  107800. * @returns a string containng the defines string
  107801. */
  107802. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  107803. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  107804. };
  107805. /**
  107806. * Returns the string "SphereDirectedParticleEmitter"
  107807. * @returns a string containing the class name
  107808. */
  107809. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  107810. return "SphereDirectedParticleEmitter";
  107811. };
  107812. /**
  107813. * Serializes the particle system to a JSON object.
  107814. * @returns the JSON object
  107815. */
  107816. SphereDirectedParticleEmitter.prototype.serialize = function () {
  107817. var serializationObject = _super.prototype.serialize.call(this);
  107818. serializationObject.direction1 = this.direction1.asArray();
  107819. serializationObject.direction2 = this.direction2.asArray();
  107820. return serializationObject;
  107821. };
  107822. /**
  107823. * Parse properties from a JSON object
  107824. * @param serializationObject defines the JSON object
  107825. */
  107826. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  107827. _super.prototype.parse.call(this, serializationObject);
  107828. this.direction1.copyFrom(serializationObject.direction1);
  107829. this.direction2.copyFrom(serializationObject.direction2);
  107830. };
  107831. return SphereDirectedParticleEmitter;
  107832. }(SphereParticleEmitter));
  107833. /***/ }),
  107834. /***/ "./Particles/baseParticleSystem.ts":
  107835. /*!*****************************************!*\
  107836. !*** ./Particles/baseParticleSystem.ts ***!
  107837. \*****************************************/
  107838. /*! exports provided: BaseParticleSystem */
  107839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107840. "use strict";
  107841. __webpack_require__.r(__webpack_exports__);
  107842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  107843. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107844. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  107845. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  107846. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107847. /**
  107848. * This represents the base class for particle system in Babylon.
  107849. * 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.
  107850. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  107851. * @example https://doc.babylonjs.com/babylon101/particles
  107852. */
  107853. var BaseParticleSystem = /** @class */ (function () {
  107854. /**
  107855. * Instantiates a particle system.
  107856. * 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.
  107857. * @param name The name of the particle system
  107858. */
  107859. function BaseParticleSystem(name) {
  107860. /**
  107861. * List of animations used by the particle system.
  107862. */
  107863. this.animations = [];
  107864. /**
  107865. * The rendering group used by the Particle system to chose when to render.
  107866. */
  107867. this.renderingGroupId = 0;
  107868. /**
  107869. * The emitter represents the Mesh or position we are attaching the particle system to.
  107870. */
  107871. this.emitter = null;
  107872. /**
  107873. * The maximum number of particles to emit per frame
  107874. */
  107875. this.emitRate = 10;
  107876. /**
  107877. * If you want to launch only a few particles at once, that can be done, as well.
  107878. */
  107879. this.manualEmitCount = -1;
  107880. /**
  107881. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  107882. */
  107883. this.updateSpeed = 0.01;
  107884. /**
  107885. * The amount of time the particle system is running (depends of the overall update speed).
  107886. */
  107887. this.targetStopDuration = 0;
  107888. /**
  107889. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  107890. */
  107891. this.disposeOnStop = false;
  107892. /**
  107893. * Minimum power of emitting particles.
  107894. */
  107895. this.minEmitPower = 1;
  107896. /**
  107897. * Maximum power of emitting particles.
  107898. */
  107899. this.maxEmitPower = 1;
  107900. /**
  107901. * Minimum life time of emitting particles.
  107902. */
  107903. this.minLifeTime = 1;
  107904. /**
  107905. * Maximum life time of emitting particles.
  107906. */
  107907. this.maxLifeTime = 1;
  107908. /**
  107909. * Minimum Size of emitting particles.
  107910. */
  107911. this.minSize = 1;
  107912. /**
  107913. * Maximum Size of emitting particles.
  107914. */
  107915. this.maxSize = 1;
  107916. /**
  107917. * Minimum scale of emitting particles on X axis.
  107918. */
  107919. this.minScaleX = 1;
  107920. /**
  107921. * Maximum scale of emitting particles on X axis.
  107922. */
  107923. this.maxScaleX = 1;
  107924. /**
  107925. * Minimum scale of emitting particles on Y axis.
  107926. */
  107927. this.minScaleY = 1;
  107928. /**
  107929. * Maximum scale of emitting particles on Y axis.
  107930. */
  107931. this.maxScaleY = 1;
  107932. /**
  107933. * Gets or sets the minimal initial rotation in radians.
  107934. */
  107935. this.minInitialRotation = 0;
  107936. /**
  107937. * Gets or sets the maximal initial rotation in radians.
  107938. */
  107939. this.maxInitialRotation = 0;
  107940. /**
  107941. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  107942. */
  107943. this.minAngularSpeed = 0;
  107944. /**
  107945. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  107946. */
  107947. this.maxAngularSpeed = 0;
  107948. /**
  107949. * The layer mask we are rendering the particles through.
  107950. */
  107951. this.layerMask = 0x0FFFFFFF;
  107952. /**
  107953. * This can help using your own shader to render the particle system.
  107954. * The according effect will be created
  107955. */
  107956. this.customShader = null;
  107957. /**
  107958. * By default particle system starts as soon as they are created. This prevents the
  107959. * automatic start to happen and let you decide when to start emitting particles.
  107960. */
  107961. this.preventAutoStart = false;
  107962. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  107963. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  107964. /**
  107965. * Callback triggered when the particle animation is ending.
  107966. */
  107967. this.onAnimationEnd = null;
  107968. /**
  107969. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  107970. */
  107971. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  107972. /**
  107973. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  107974. * to override the particles.
  107975. */
  107976. this.forceDepthWrite = false;
  107977. /** 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 */
  107978. this.preWarmCycles = 0;
  107979. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  107980. this.preWarmStepOffset = 1;
  107981. /**
  107982. * 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)
  107983. */
  107984. this.spriteCellChangeSpeed = 1;
  107985. /**
  107986. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  107987. */
  107988. this.startSpriteCellID = 0;
  107989. /**
  107990. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  107991. */
  107992. this.endSpriteCellID = 0;
  107993. /**
  107994. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  107995. */
  107996. this.spriteCellWidth = 0;
  107997. /**
  107998. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  107999. */
  108000. this.spriteCellHeight = 0;
  108001. /**
  108002. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  108003. */
  108004. this.spriteRandomStartCell = false;
  108005. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  108006. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  108007. /**
  108008. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  108009. */
  108010. this.beginAnimationOnStart = false;
  108011. /**
  108012. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  108013. */
  108014. this.beginAnimationFrom = 0;
  108015. /**
  108016. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  108017. */
  108018. this.beginAnimationTo = 60;
  108019. /**
  108020. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  108021. */
  108022. this.beginAnimationLoop = false;
  108023. /**
  108024. * Gets or sets a world offset applied to all particles
  108025. */
  108026. this.worldOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  108027. /**
  108028. * You can use gravity if you want to give an orientation to your particles.
  108029. */
  108030. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108031. this._colorGradients = null;
  108032. this._sizeGradients = null;
  108033. this._lifeTimeGradients = null;
  108034. this._angularSpeedGradients = null;
  108035. this._velocityGradients = null;
  108036. this._limitVelocityGradients = null;
  108037. this._dragGradients = null;
  108038. this._emitRateGradients = null;
  108039. this._startSizeGradients = null;
  108040. this._rampGradients = null;
  108041. this._colorRemapGradients = null;
  108042. this._alphaRemapGradients = null;
  108043. /**
  108044. * Defines the delay in milliseconds before starting the system (0 by default)
  108045. */
  108046. this.startDelay = 0;
  108047. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  108048. this.limitVelocityDamping = 0.4;
  108049. /**
  108050. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  108051. */
  108052. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  108053. /**
  108054. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  108055. */
  108056. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  108057. /**
  108058. * Color the particle will have at the end of its lifetime
  108059. */
  108060. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  108061. /**
  108062. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  108063. */
  108064. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  108065. /** @hidden */
  108066. this._isSubEmitter = false;
  108067. /**
  108068. * Gets or sets the billboard mode to use when isBillboardBased = true.
  108069. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  108070. */
  108071. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  108072. this._isBillboardBased = true;
  108073. /**
  108074. * Local cache of defines for image processing.
  108075. */
  108076. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  108077. this.id = name;
  108078. this.name = name;
  108079. }
  108080. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  108081. /**
  108082. * Gets or sets a texture used to add random noise to particle positions
  108083. */
  108084. get: function () {
  108085. return this._noiseTexture;
  108086. },
  108087. set: function (value) {
  108088. if (this._noiseTexture === value) {
  108089. return;
  108090. }
  108091. this._noiseTexture = value;
  108092. this._reset();
  108093. },
  108094. enumerable: true,
  108095. configurable: true
  108096. });
  108097. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  108098. /**
  108099. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  108100. */
  108101. get: function () {
  108102. return this._isAnimationSheetEnabled;
  108103. },
  108104. set: function (value) {
  108105. if (this._isAnimationSheetEnabled == value) {
  108106. return;
  108107. }
  108108. this._isAnimationSheetEnabled = value;
  108109. this._reset();
  108110. },
  108111. enumerable: true,
  108112. configurable: true
  108113. });
  108114. /**
  108115. * Get hosting scene
  108116. * @returns the scene
  108117. */
  108118. BaseParticleSystem.prototype.getScene = function () {
  108119. return this._scene;
  108120. };
  108121. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  108122. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  108123. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  108124. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  108125. };
  108126. /**
  108127. * Gets the current list of drag gradients.
  108128. * You must use addDragGradient and removeDragGradient to udpate this list
  108129. * @returns the list of drag gradients
  108130. */
  108131. BaseParticleSystem.prototype.getDragGradients = function () {
  108132. return this._dragGradients;
  108133. };
  108134. /**
  108135. * Gets the current list of limit velocity gradients.
  108136. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  108137. * @returns the list of limit velocity gradients
  108138. */
  108139. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  108140. return this._limitVelocityGradients;
  108141. };
  108142. /**
  108143. * Gets the current list of color gradients.
  108144. * You must use addColorGradient and removeColorGradient to udpate this list
  108145. * @returns the list of color gradients
  108146. */
  108147. BaseParticleSystem.prototype.getColorGradients = function () {
  108148. return this._colorGradients;
  108149. };
  108150. /**
  108151. * Gets the current list of size gradients.
  108152. * You must use addSizeGradient and removeSizeGradient to udpate this list
  108153. * @returns the list of size gradients
  108154. */
  108155. BaseParticleSystem.prototype.getSizeGradients = function () {
  108156. return this._sizeGradients;
  108157. };
  108158. /**
  108159. * Gets the current list of color remap gradients.
  108160. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  108161. * @returns the list of color remap gradients
  108162. */
  108163. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  108164. return this._colorRemapGradients;
  108165. };
  108166. /**
  108167. * Gets the current list of alpha remap gradients.
  108168. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  108169. * @returns the list of alpha remap gradients
  108170. */
  108171. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  108172. return this._alphaRemapGradients;
  108173. };
  108174. /**
  108175. * Gets the current list of life time gradients.
  108176. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  108177. * @returns the list of life time gradients
  108178. */
  108179. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  108180. return this._lifeTimeGradients;
  108181. };
  108182. /**
  108183. * Gets the current list of angular speed gradients.
  108184. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  108185. * @returns the list of angular speed gradients
  108186. */
  108187. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  108188. return this._angularSpeedGradients;
  108189. };
  108190. /**
  108191. * Gets the current list of velocity gradients.
  108192. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  108193. * @returns the list of velocity gradients
  108194. */
  108195. BaseParticleSystem.prototype.getVelocityGradients = function () {
  108196. return this._velocityGradients;
  108197. };
  108198. /**
  108199. * Gets the current list of start size gradients.
  108200. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  108201. * @returns the list of start size gradients
  108202. */
  108203. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  108204. return this._startSizeGradients;
  108205. };
  108206. /**
  108207. * Gets the current list of emit rate gradients.
  108208. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  108209. * @returns the list of emit rate gradients
  108210. */
  108211. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  108212. return this._emitRateGradients;
  108213. };
  108214. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  108215. /**
  108216. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  108217. * This only works when particleEmitterTyps is a BoxParticleEmitter
  108218. */
  108219. get: function () {
  108220. if (this.particleEmitterType.direction1) {
  108221. return this.particleEmitterType.direction1;
  108222. }
  108223. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108224. },
  108225. set: function (value) {
  108226. if (this.particleEmitterType.direction1) {
  108227. this.particleEmitterType.direction1 = value;
  108228. }
  108229. },
  108230. enumerable: true,
  108231. configurable: true
  108232. });
  108233. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  108234. /**
  108235. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  108236. * This only works when particleEmitterTyps is a BoxParticleEmitter
  108237. */
  108238. get: function () {
  108239. if (this.particleEmitterType.direction2) {
  108240. return this.particleEmitterType.direction2;
  108241. }
  108242. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108243. },
  108244. set: function (value) {
  108245. if (this.particleEmitterType.direction2) {
  108246. this.particleEmitterType.direction2 = value;
  108247. }
  108248. },
  108249. enumerable: true,
  108250. configurable: true
  108251. });
  108252. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  108253. /**
  108254. * 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.
  108255. * This only works when particleEmitterTyps is a BoxParticleEmitter
  108256. */
  108257. get: function () {
  108258. if (this.particleEmitterType.minEmitBox) {
  108259. return this.particleEmitterType.minEmitBox;
  108260. }
  108261. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108262. },
  108263. set: function (value) {
  108264. if (this.particleEmitterType.minEmitBox) {
  108265. this.particleEmitterType.minEmitBox = value;
  108266. }
  108267. },
  108268. enumerable: true,
  108269. configurable: true
  108270. });
  108271. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  108272. /**
  108273. * 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.
  108274. * This only works when particleEmitterTyps is a BoxParticleEmitter
  108275. */
  108276. get: function () {
  108277. if (this.particleEmitterType.maxEmitBox) {
  108278. return this.particleEmitterType.maxEmitBox;
  108279. }
  108280. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108281. },
  108282. set: function (value) {
  108283. if (this.particleEmitterType.maxEmitBox) {
  108284. this.particleEmitterType.maxEmitBox = value;
  108285. }
  108286. },
  108287. enumerable: true,
  108288. configurable: true
  108289. });
  108290. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  108291. /**
  108292. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  108293. */
  108294. get: function () {
  108295. return this._isBillboardBased;
  108296. },
  108297. set: function (value) {
  108298. if (this._isBillboardBased === value) {
  108299. return;
  108300. }
  108301. this._isBillboardBased = value;
  108302. this._reset();
  108303. },
  108304. enumerable: true,
  108305. configurable: true
  108306. });
  108307. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  108308. /**
  108309. * Gets the image processing configuration used either in this material.
  108310. */
  108311. get: function () {
  108312. return this._imageProcessingConfiguration;
  108313. },
  108314. /**
  108315. * Sets the Default image processing configuration used either in the this material.
  108316. *
  108317. * If sets to null, the scene one is in use.
  108318. */
  108319. set: function (value) {
  108320. this._attachImageProcessingConfiguration(value);
  108321. },
  108322. enumerable: true,
  108323. configurable: true
  108324. });
  108325. /**
  108326. * Attaches a new image processing configuration to the Standard Material.
  108327. * @param configuration
  108328. */
  108329. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  108330. if (configuration === this._imageProcessingConfiguration) {
  108331. return;
  108332. }
  108333. // Pick the scene configuration if needed.
  108334. if (!configuration) {
  108335. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  108336. }
  108337. else {
  108338. this._imageProcessingConfiguration = configuration;
  108339. }
  108340. };
  108341. /** @hidden */
  108342. BaseParticleSystem.prototype._reset = function () {
  108343. };
  108344. /** @hidden */
  108345. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  108346. if (!gradients) {
  108347. return this;
  108348. }
  108349. var index = 0;
  108350. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  108351. var valueGradient = gradients_1[_i];
  108352. if (valueGradient.gradient === gradient) {
  108353. gradients.splice(index, 1);
  108354. break;
  108355. }
  108356. index++;
  108357. }
  108358. if (texture) {
  108359. texture.dispose();
  108360. }
  108361. return this;
  108362. };
  108363. /**
  108364. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  108365. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  108366. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  108367. * @returns the emitter
  108368. */
  108369. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  108370. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  108371. particleEmitter.direction1 = direction1;
  108372. particleEmitter.direction2 = direction2;
  108373. this.particleEmitterType = particleEmitter;
  108374. return particleEmitter;
  108375. };
  108376. /**
  108377. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  108378. * @param radius The radius of the hemisphere to emit from
  108379. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  108380. * @returns the emitter
  108381. */
  108382. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  108383. if (radius === void 0) { radius = 1; }
  108384. if (radiusRange === void 0) { radiusRange = 1; }
  108385. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  108386. this.particleEmitterType = particleEmitter;
  108387. return particleEmitter;
  108388. };
  108389. /**
  108390. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  108391. * @param radius The radius of the sphere to emit from
  108392. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  108393. * @returns the emitter
  108394. */
  108395. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  108396. if (radius === void 0) { radius = 1; }
  108397. if (radiusRange === void 0) { radiusRange = 1; }
  108398. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  108399. this.particleEmitterType = particleEmitter;
  108400. return particleEmitter;
  108401. };
  108402. /**
  108403. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  108404. * @param radius The radius of the sphere to emit from
  108405. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  108406. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  108407. * @returns the emitter
  108408. */
  108409. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  108410. if (radius === void 0) { radius = 1; }
  108411. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108412. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108413. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  108414. this.particleEmitterType = particleEmitter;
  108415. return particleEmitter;
  108416. };
  108417. /**
  108418. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  108419. * @param radius The radius of the emission cylinder
  108420. * @param height The height of the emission cylinder
  108421. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  108422. * @param directionRandomizer How much to randomize the particle direction [0-1]
  108423. * @returns the emitter
  108424. */
  108425. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  108426. if (radius === void 0) { radius = 1; }
  108427. if (height === void 0) { height = 1; }
  108428. if (radiusRange === void 0) { radiusRange = 1; }
  108429. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  108430. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  108431. this.particleEmitterType = particleEmitter;
  108432. return particleEmitter;
  108433. };
  108434. /**
  108435. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  108436. * @param radius The radius of the cylinder to emit from
  108437. * @param height The height of the emission cylinder
  108438. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  108439. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  108440. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  108441. * @returns the emitter
  108442. */
  108443. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  108444. if (radius === void 0) { radius = 1; }
  108445. if (height === void 0) { height = 1; }
  108446. if (radiusRange === void 0) { radiusRange = 1; }
  108447. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108448. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108449. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  108450. this.particleEmitterType = particleEmitter;
  108451. return particleEmitter;
  108452. };
  108453. /**
  108454. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  108455. * @param radius The radius of the cone to emit from
  108456. * @param angle The base angle of the cone
  108457. * @returns the emitter
  108458. */
  108459. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  108460. if (radius === void 0) { radius = 1; }
  108461. if (angle === void 0) { angle = Math.PI / 4; }
  108462. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  108463. this.particleEmitterType = particleEmitter;
  108464. return particleEmitter;
  108465. };
  108466. /**
  108467. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  108468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  108469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  108470. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  108471. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  108472. * @returns the emitter
  108473. */
  108474. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  108475. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  108476. this.particleEmitterType = particleEmitter;
  108477. this.direction1 = direction1;
  108478. this.direction2 = direction2;
  108479. this.minEmitBox = minEmitBox;
  108480. this.maxEmitBox = maxEmitBox;
  108481. return particleEmitter;
  108482. };
  108483. /**
  108484. * Source color is added to the destination color without alpha affecting the result
  108485. */
  108486. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  108487. /**
  108488. * Blend current color and particle color using particle’s alpha
  108489. */
  108490. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  108491. /**
  108492. * Add current color and particle color multiplied by particle’s alpha
  108493. */
  108494. BaseParticleSystem.BLENDMODE_ADD = 2;
  108495. /**
  108496. * Multiply current color with particle color
  108497. */
  108498. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  108499. /**
  108500. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  108501. */
  108502. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  108503. return BaseParticleSystem;
  108504. }());
  108505. /***/ }),
  108506. /***/ "./Particles/gpuParticleSystem.ts":
  108507. /*!****************************************!*\
  108508. !*** ./Particles/gpuParticleSystem.ts ***!
  108509. \****************************************/
  108510. /*! exports provided: GPUParticleSystem */
  108511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108512. "use strict";
  108513. __webpack_require__.r(__webpack_exports__);
  108514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  108515. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  108516. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  108517. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  108518. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108519. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108520. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  108521. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  108522. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  108523. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  108524. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  108525. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  108526. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  108527. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  108528. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  108529. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  108530. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108531. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  108532. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  108533. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  108534. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  108535. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  108536. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  108537. /**
  108538. * This represents a GPU particle system in Babylon
  108539. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108540. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108541. */
  108542. var GPUParticleSystem = /** @class */ (function (_super) {
  108543. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  108544. /**
  108545. * Instantiates a GPU particle system.
  108546. * 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.
  108547. * @param name The name of the particle system
  108548. * @param options The options used to create the system
  108549. * @param scene The scene the particle system belongs to
  108550. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108551. */
  108552. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  108553. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  108554. var _this = _super.call(this, name) || this;
  108555. /**
  108556. * The layer mask we are rendering the particles through.
  108557. */
  108558. _this.layerMask = 0x0FFFFFFF;
  108559. _this._accumulatedCount = 0;
  108560. _this._targetIndex = 0;
  108561. _this._currentRenderId = -1;
  108562. _this._started = false;
  108563. _this._stopped = false;
  108564. _this._timeDelta = 0;
  108565. _this._actualFrame = 0;
  108566. _this._rawTextureWidth = 256;
  108567. /**
  108568. * An event triggered when the system is disposed.
  108569. */
  108570. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  108571. /**
  108572. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108573. * to override the particles.
  108574. */
  108575. _this.forceDepthWrite = false;
  108576. _this._preWarmDone = false;
  108577. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  108578. // Setup the default processing configuration to the scene.
  108579. _this._attachImageProcessingConfiguration(null);
  108580. _this._engine = _this._scene.getEngine();
  108581. if (!options.randomTextureSize) {
  108582. delete options.randomTextureSize;
  108583. }
  108584. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  108585. var optionsAsNumber = options;
  108586. if (isFinite(optionsAsNumber)) {
  108587. fullOptions.capacity = optionsAsNumber;
  108588. }
  108589. _this._capacity = fullOptions.capacity;
  108590. _this._activeCount = fullOptions.capacity;
  108591. _this._currentActiveCount = 0;
  108592. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  108593. _this._scene.particleSystems.push(_this);
  108594. _this._updateEffectOptions = {
  108595. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  108596. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  108597. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  108598. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  108599. uniformBuffersNames: [],
  108600. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  108601. defines: "",
  108602. fallbacks: null,
  108603. onCompiled: null,
  108604. onError: null,
  108605. indexParameters: null,
  108606. maxSimultaneousLights: 0,
  108607. transformFeedbackVaryings: []
  108608. };
  108609. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  108610. // Random data
  108611. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  108612. var d = [];
  108613. for (var i = 0; i < maxTextureSize; ++i) {
  108614. d.push(Math.random());
  108615. d.push(Math.random());
  108616. d.push(Math.random());
  108617. d.push(Math.random());
  108618. }
  108619. _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);
  108620. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108621. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108622. d = [];
  108623. for (var i = 0; i < maxTextureSize; ++i) {
  108624. d.push(Math.random());
  108625. d.push(Math.random());
  108626. d.push(Math.random());
  108627. d.push(Math.random());
  108628. }
  108629. _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);
  108630. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108631. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108632. _this._randomTextureSize = maxTextureSize;
  108633. return _this;
  108634. }
  108635. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  108636. /**
  108637. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108638. */
  108639. get: function () {
  108640. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  108641. return false;
  108642. }
  108643. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  108644. },
  108645. enumerable: true,
  108646. configurable: true
  108647. });
  108648. /**
  108649. * Gets the maximum number of particles active at the same time.
  108650. * @returns The max number of active particles.
  108651. */
  108652. GPUParticleSystem.prototype.getCapacity = function () {
  108653. return this._capacity;
  108654. };
  108655. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  108656. /**
  108657. * Gets or set the number of active particles
  108658. */
  108659. get: function () {
  108660. return this._activeCount;
  108661. },
  108662. set: function (value) {
  108663. this._activeCount = Math.min(value, this._capacity);
  108664. },
  108665. enumerable: true,
  108666. configurable: true
  108667. });
  108668. /**
  108669. * Is this system ready to be used/rendered
  108670. * @return true if the system is ready
  108671. */
  108672. GPUParticleSystem.prototype.isReady = function () {
  108673. if (!this._updateEffect) {
  108674. this._recreateUpdateEffect();
  108675. this._recreateRenderEffect();
  108676. return false;
  108677. }
  108678. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  108679. return false;
  108680. }
  108681. return true;
  108682. };
  108683. /**
  108684. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108685. * @returns True if it has been started, otherwise false.
  108686. */
  108687. GPUParticleSystem.prototype.isStarted = function () {
  108688. return this._started;
  108689. };
  108690. /**
  108691. * Starts the particle system and begins to emit
  108692. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108693. */
  108694. GPUParticleSystem.prototype.start = function (delay) {
  108695. var _this = this;
  108696. if (delay === void 0) { delay = this.startDelay; }
  108697. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  108698. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  108699. }
  108700. if (delay) {
  108701. setTimeout(function () {
  108702. _this.start(0);
  108703. }, delay);
  108704. return;
  108705. }
  108706. this._started = true;
  108707. this._stopped = false;
  108708. this._preWarmDone = false;
  108709. // Animations
  108710. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  108711. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  108712. }
  108713. };
  108714. /**
  108715. * Stops the particle system.
  108716. */
  108717. GPUParticleSystem.prototype.stop = function () {
  108718. this._stopped = true;
  108719. };
  108720. /**
  108721. * Remove all active particles
  108722. */
  108723. GPUParticleSystem.prototype.reset = function () {
  108724. this._releaseBuffers();
  108725. this._releaseVAOs();
  108726. this._currentActiveCount = 0;
  108727. this._targetIndex = 0;
  108728. };
  108729. /**
  108730. * Returns the string "GPUParticleSystem"
  108731. * @returns a string containing the class name
  108732. */
  108733. GPUParticleSystem.prototype.getClassName = function () {
  108734. return "GPUParticleSystem";
  108735. };
  108736. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  108737. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  108738. this._releaseBuffers();
  108739. return this;
  108740. };
  108741. /**
  108742. * Adds a new color gradient
  108743. * @param gradient defines the gradient to use (between 0 and 1)
  108744. * @param color1 defines the color to affect to the specified gradient
  108745. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108746. * @returns the current particle system
  108747. */
  108748. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  108749. if (!this._colorGradients) {
  108750. this._colorGradients = [];
  108751. }
  108752. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  108753. colorGradient.gradient = gradient;
  108754. colorGradient.color1 = color1;
  108755. this._colorGradients.push(colorGradient);
  108756. this._colorGradients.sort(function (a, b) {
  108757. if (a.gradient < b.gradient) {
  108758. return -1;
  108759. }
  108760. else if (a.gradient > b.gradient) {
  108761. return 1;
  108762. }
  108763. return 0;
  108764. });
  108765. if (this._colorGradientsTexture) {
  108766. this._colorGradientsTexture.dispose();
  108767. this._colorGradientsTexture = null;
  108768. }
  108769. this._releaseBuffers();
  108770. return this;
  108771. };
  108772. /**
  108773. * Remove a specific color gradient
  108774. * @param gradient defines the gradient to remove
  108775. * @returns the current particle system
  108776. */
  108777. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  108778. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  108779. this._colorGradientsTexture = null;
  108780. return this;
  108781. };
  108782. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  108783. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  108784. valueGradient.gradient = gradient;
  108785. valueGradient.factor1 = factor;
  108786. factorGradients.push(valueGradient);
  108787. factorGradients.sort(function (a, b) {
  108788. if (a.gradient < b.gradient) {
  108789. return -1;
  108790. }
  108791. else if (a.gradient > b.gradient) {
  108792. return 1;
  108793. }
  108794. return 0;
  108795. });
  108796. this._releaseBuffers();
  108797. };
  108798. /**
  108799. * Adds a new size gradient
  108800. * @param gradient defines the gradient to use (between 0 and 1)
  108801. * @param factor defines the size factor to affect to the specified gradient
  108802. * @returns the current particle system
  108803. */
  108804. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  108805. if (!this._sizeGradients) {
  108806. this._sizeGradients = [];
  108807. }
  108808. this._addFactorGradient(this._sizeGradients, gradient, factor);
  108809. if (this._sizeGradientsTexture) {
  108810. this._sizeGradientsTexture.dispose();
  108811. this._sizeGradientsTexture = null;
  108812. }
  108813. this._releaseBuffers();
  108814. return this;
  108815. };
  108816. /**
  108817. * Remove a specific size gradient
  108818. * @param gradient defines the gradient to remove
  108819. * @returns the current particle system
  108820. */
  108821. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  108822. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  108823. this._sizeGradientsTexture = null;
  108824. return this;
  108825. };
  108826. /**
  108827. * Adds a new angular speed gradient
  108828. * @param gradient defines the gradient to use (between 0 and 1)
  108829. * @param factor defines the angular speed to affect to the specified gradient
  108830. * @returns the current particle system
  108831. */
  108832. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  108833. if (!this._angularSpeedGradients) {
  108834. this._angularSpeedGradients = [];
  108835. }
  108836. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  108837. if (this._angularSpeedGradientsTexture) {
  108838. this._angularSpeedGradientsTexture.dispose();
  108839. this._angularSpeedGradientsTexture = null;
  108840. }
  108841. this._releaseBuffers();
  108842. return this;
  108843. };
  108844. /**
  108845. * Remove a specific angular speed gradient
  108846. * @param gradient defines the gradient to remove
  108847. * @returns the current particle system
  108848. */
  108849. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  108850. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  108851. this._angularSpeedGradientsTexture = null;
  108852. return this;
  108853. };
  108854. /**
  108855. * Adds a new velocity gradient
  108856. * @param gradient defines the gradient to use (between 0 and 1)
  108857. * @param factor defines the velocity to affect to the specified gradient
  108858. * @returns the current particle system
  108859. */
  108860. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  108861. if (!this._velocityGradients) {
  108862. this._velocityGradients = [];
  108863. }
  108864. this._addFactorGradient(this._velocityGradients, gradient, factor);
  108865. if (this._velocityGradientsTexture) {
  108866. this._velocityGradientsTexture.dispose();
  108867. this._velocityGradientsTexture = null;
  108868. }
  108869. this._releaseBuffers();
  108870. return this;
  108871. };
  108872. /**
  108873. * Remove a specific velocity gradient
  108874. * @param gradient defines the gradient to remove
  108875. * @returns the current particle system
  108876. */
  108877. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  108878. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  108879. this._velocityGradientsTexture = null;
  108880. return this;
  108881. };
  108882. /**
  108883. * Adds a new limit velocity gradient
  108884. * @param gradient defines the gradient to use (between 0 and 1)
  108885. * @param factor defines the limit velocity value to affect to the specified gradient
  108886. * @returns the current particle system
  108887. */
  108888. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  108889. if (!this._limitVelocityGradients) {
  108890. this._limitVelocityGradients = [];
  108891. }
  108892. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  108893. if (this._limitVelocityGradientsTexture) {
  108894. this._limitVelocityGradientsTexture.dispose();
  108895. this._limitVelocityGradientsTexture = null;
  108896. }
  108897. this._releaseBuffers();
  108898. return this;
  108899. };
  108900. /**
  108901. * Remove a specific limit velocity gradient
  108902. * @param gradient defines the gradient to remove
  108903. * @returns the current particle system
  108904. */
  108905. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  108906. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  108907. this._limitVelocityGradientsTexture = null;
  108908. return this;
  108909. };
  108910. /**
  108911. * Adds a new drag gradient
  108912. * @param gradient defines the gradient to use (between 0 and 1)
  108913. * @param factor defines the drag value to affect to the specified gradient
  108914. * @returns the current particle system
  108915. */
  108916. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  108917. if (!this._dragGradients) {
  108918. this._dragGradients = [];
  108919. }
  108920. this._addFactorGradient(this._dragGradients, gradient, factor);
  108921. if (this._dragGradientsTexture) {
  108922. this._dragGradientsTexture.dispose();
  108923. this._dragGradientsTexture = null;
  108924. }
  108925. this._releaseBuffers();
  108926. return this;
  108927. };
  108928. /**
  108929. * Remove a specific drag gradient
  108930. * @param gradient defines the gradient to remove
  108931. * @returns the current particle system
  108932. */
  108933. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  108934. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  108935. this._dragGradientsTexture = null;
  108936. return this;
  108937. };
  108938. /**
  108939. * Not supported by GPUParticleSystem
  108940. * @param gradient defines the gradient to use (between 0 and 1)
  108941. * @param factor defines the emit rate value to affect to the specified gradient
  108942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108943. * @returns the current particle system
  108944. */
  108945. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  108946. // Do nothing as emit rate is not supported by GPUParticleSystem
  108947. return this;
  108948. };
  108949. /**
  108950. * Not supported by GPUParticleSystem
  108951. * @param gradient defines the gradient to remove
  108952. * @returns the current particle system
  108953. */
  108954. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  108955. // Do nothing as emit rate is not supported by GPUParticleSystem
  108956. return this;
  108957. };
  108958. /**
  108959. * Not supported by GPUParticleSystem
  108960. * @param gradient defines the gradient to use (between 0 and 1)
  108961. * @param factor defines the start size value to affect to the specified gradient
  108962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108963. * @returns the current particle system
  108964. */
  108965. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  108966. // Do nothing as start size is not supported by GPUParticleSystem
  108967. return this;
  108968. };
  108969. /**
  108970. * Not supported by GPUParticleSystem
  108971. * @param gradient defines the gradient to remove
  108972. * @returns the current particle system
  108973. */
  108974. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  108975. // Do nothing as start size is not supported by GPUParticleSystem
  108976. return this;
  108977. };
  108978. /**
  108979. * Not supported by GPUParticleSystem
  108980. * @param gradient defines the gradient to use (between 0 and 1)
  108981. * @param min defines the color remap minimal range
  108982. * @param max defines the color remap maximal range
  108983. * @returns the current particle system
  108984. */
  108985. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  108986. // Do nothing as start size is not supported by GPUParticleSystem
  108987. return this;
  108988. };
  108989. /**
  108990. * Not supported by GPUParticleSystem
  108991. * @param gradient defines the gradient to remove
  108992. * @returns the current particle system
  108993. */
  108994. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  108995. // Do nothing as start size is not supported by GPUParticleSystem
  108996. return this;
  108997. };
  108998. /**
  108999. * Not supported by GPUParticleSystem
  109000. * @param gradient defines the gradient to use (between 0 and 1)
  109001. * @param min defines the alpha remap minimal range
  109002. * @param max defines the alpha remap maximal range
  109003. * @returns the current particle system
  109004. */
  109005. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  109006. // Do nothing as start size is not supported by GPUParticleSystem
  109007. return this;
  109008. };
  109009. /**
  109010. * Not supported by GPUParticleSystem
  109011. * @param gradient defines the gradient to remove
  109012. * @returns the current particle system
  109013. */
  109014. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  109015. // Do nothing as start size is not supported by GPUParticleSystem
  109016. return this;
  109017. };
  109018. /**
  109019. * Not supported by GPUParticleSystem
  109020. * @param gradient defines the gradient to use (between 0 and 1)
  109021. * @param color defines the color to affect to the specified gradient
  109022. * @returns the current particle system
  109023. */
  109024. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  109025. //Not supported by GPUParticleSystem
  109026. return this;
  109027. };
  109028. /**
  109029. * Not supported by GPUParticleSystem
  109030. * @param gradient defines the gradient to remove
  109031. * @returns the current particle system
  109032. */
  109033. GPUParticleSystem.prototype.removeRampGradient = function () {
  109034. //Not supported by GPUParticleSystem
  109035. return this;
  109036. };
  109037. /**
  109038. * Not supported by GPUParticleSystem
  109039. * @returns the list of ramp gradients
  109040. */
  109041. GPUParticleSystem.prototype.getRampGradients = function () {
  109042. return null;
  109043. };
  109044. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  109045. /**
  109046. * Not supported by GPUParticleSystem
  109047. * Gets or sets a boolean indicating that ramp gradients must be used
  109048. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  109049. */
  109050. get: function () {
  109051. //Not supported by GPUParticleSystem
  109052. return false;
  109053. },
  109054. set: function (value) {
  109055. //Not supported by GPUParticleSystem
  109056. },
  109057. enumerable: true,
  109058. configurable: true
  109059. });
  109060. /**
  109061. * Not supported by GPUParticleSystem
  109062. * @param gradient defines the gradient to use (between 0 and 1)
  109063. * @param factor defines the life time factor to affect to the specified gradient
  109064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  109065. * @returns the current particle system
  109066. */
  109067. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  109068. //Not supported by GPUParticleSystem
  109069. return this;
  109070. };
  109071. /**
  109072. * Not supported by GPUParticleSystem
  109073. * @param gradient defines the gradient to remove
  109074. * @returns the current particle system
  109075. */
  109076. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  109077. //Not supported by GPUParticleSystem
  109078. return this;
  109079. };
  109080. GPUParticleSystem.prototype._reset = function () {
  109081. this._releaseBuffers();
  109082. };
  109083. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  109084. var updateVertexBuffers = {};
  109085. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  109086. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  109087. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  109088. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  109089. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  109090. var offset = 12;
  109091. if (!this._colorGradientsTexture) {
  109092. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  109093. offset += 4;
  109094. }
  109095. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  109096. offset += 3;
  109097. if (!this._isBillboardBased) {
  109098. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  109099. offset += 3;
  109100. }
  109101. if (this._angularSpeedGradientsTexture) {
  109102. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  109103. offset += 1;
  109104. }
  109105. else {
  109106. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  109107. offset += 2;
  109108. }
  109109. if (this._isAnimationSheetEnabled) {
  109110. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  109111. offset += 1;
  109112. if (this.spriteRandomStartCell) {
  109113. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  109114. offset += 1;
  109115. }
  109116. }
  109117. if (this.noiseTexture) {
  109118. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  109119. offset += 3;
  109120. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  109121. offset += 3;
  109122. }
  109123. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  109124. this._engine.bindArrayBuffer(null);
  109125. return vao;
  109126. };
  109127. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  109128. var renderVertexBuffers = {};
  109129. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  109130. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  109131. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  109132. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  109133. var offset = 12;
  109134. if (!this._colorGradientsTexture) {
  109135. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  109136. offset += 4;
  109137. }
  109138. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  109139. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  109140. }
  109141. offset += 3; // Direction
  109142. if (!this._isBillboardBased) {
  109143. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  109144. offset += 3;
  109145. }
  109146. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  109147. if (this._angularSpeedGradientsTexture) {
  109148. offset++;
  109149. }
  109150. else {
  109151. offset += 2;
  109152. }
  109153. if (this._isAnimationSheetEnabled) {
  109154. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  109155. offset += 1;
  109156. if (this.spriteRandomStartCell) {
  109157. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  109158. offset += 1;
  109159. }
  109160. }
  109161. if (this.noiseTexture) {
  109162. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  109163. offset += 3;
  109164. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  109165. offset += 3;
  109166. }
  109167. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  109168. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  109169. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  109170. this._engine.bindArrayBuffer(null);
  109171. return vao;
  109172. };
  109173. GPUParticleSystem.prototype._initialize = function (force) {
  109174. if (force === void 0) { force = false; }
  109175. if (this._buffer0 && !force) {
  109176. return;
  109177. }
  109178. var engine = this._scene.getEngine();
  109179. var data = new Array();
  109180. this._attributesStrideSize = 21;
  109181. this._targetIndex = 0;
  109182. if (!this.isBillboardBased) {
  109183. this._attributesStrideSize += 3;
  109184. }
  109185. if (this._colorGradientsTexture) {
  109186. this._attributesStrideSize -= 4;
  109187. }
  109188. if (this._angularSpeedGradientsTexture) {
  109189. this._attributesStrideSize -= 1;
  109190. }
  109191. if (this._isAnimationSheetEnabled) {
  109192. this._attributesStrideSize += 1;
  109193. if (this.spriteRandomStartCell) {
  109194. this._attributesStrideSize += 1;
  109195. }
  109196. }
  109197. if (this.noiseTexture) {
  109198. this._attributesStrideSize += 6;
  109199. }
  109200. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  109201. // position
  109202. data.push(0.0);
  109203. data.push(0.0);
  109204. data.push(0.0);
  109205. // Age and life
  109206. data.push(0.0); // create the particle as a dead one to create a new one at start
  109207. data.push(0.0);
  109208. // Seed
  109209. data.push(Math.random());
  109210. data.push(Math.random());
  109211. data.push(Math.random());
  109212. data.push(Math.random());
  109213. // Size
  109214. data.push(0.0);
  109215. data.push(0.0);
  109216. data.push(0.0);
  109217. if (!this._colorGradientsTexture) {
  109218. // color
  109219. data.push(0.0);
  109220. data.push(0.0);
  109221. data.push(0.0);
  109222. data.push(0.0);
  109223. }
  109224. // direction
  109225. data.push(0.0);
  109226. data.push(0.0);
  109227. data.push(0.0);
  109228. if (!this.isBillboardBased) {
  109229. // initialDirection
  109230. data.push(0.0);
  109231. data.push(0.0);
  109232. data.push(0.0);
  109233. }
  109234. // angle
  109235. data.push(0.0);
  109236. if (!this._angularSpeedGradientsTexture) {
  109237. data.push(0.0);
  109238. }
  109239. if (this._isAnimationSheetEnabled) {
  109240. data.push(0.0);
  109241. if (this.spriteRandomStartCell) {
  109242. data.push(0.0);
  109243. }
  109244. }
  109245. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  109246. data.push(Math.random());
  109247. data.push(Math.random());
  109248. data.push(Math.random());
  109249. data.push(Math.random());
  109250. data.push(Math.random());
  109251. data.push(Math.random());
  109252. }
  109253. }
  109254. // Sprite data
  109255. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  109256. -0.5, 0.5, 0, 1,
  109257. -0.5, -0.5, 0, 0,
  109258. 0.5, -0.5, 1, 0]);
  109259. // Buffers
  109260. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  109261. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  109262. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  109263. // Update VAO
  109264. this._updateVAO = [];
  109265. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  109266. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  109267. // Render VAO
  109268. this._renderVAO = [];
  109269. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  109270. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  109271. // Links
  109272. this._sourceBuffer = this._buffer0;
  109273. this._targetBuffer = this._buffer1;
  109274. };
  109275. /** @hidden */
  109276. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  109277. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  109278. if (this._isBillboardBased) {
  109279. defines += "\n#define BILLBOARD";
  109280. }
  109281. if (this._colorGradientsTexture) {
  109282. defines += "\n#define COLORGRADIENTS";
  109283. }
  109284. if (this._sizeGradientsTexture) {
  109285. defines += "\n#define SIZEGRADIENTS";
  109286. }
  109287. if (this._angularSpeedGradientsTexture) {
  109288. defines += "\n#define ANGULARSPEEDGRADIENTS";
  109289. }
  109290. if (this._velocityGradientsTexture) {
  109291. defines += "\n#define VELOCITYGRADIENTS";
  109292. }
  109293. if (this._limitVelocityGradientsTexture) {
  109294. defines += "\n#define LIMITVELOCITYGRADIENTS";
  109295. }
  109296. if (this._dragGradientsTexture) {
  109297. defines += "\n#define DRAGGRADIENTS";
  109298. }
  109299. if (this.isAnimationSheetEnabled) {
  109300. defines += "\n#define ANIMATESHEET";
  109301. if (this.spriteRandomStartCell) {
  109302. defines += "\n#define ANIMATESHEETRANDOMSTART";
  109303. }
  109304. }
  109305. if (this.noiseTexture) {
  109306. defines += "\n#define NOISE";
  109307. }
  109308. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  109309. return;
  109310. }
  109311. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  109312. if (!this._colorGradientsTexture) {
  109313. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  109314. }
  109315. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  109316. if (!this._isBillboardBased) {
  109317. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  109318. }
  109319. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  109320. if (this.isAnimationSheetEnabled) {
  109321. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  109322. if (this.spriteRandomStartCell) {
  109323. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  109324. }
  109325. }
  109326. if (this.noiseTexture) {
  109327. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  109328. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  109329. }
  109330. this._updateEffectOptions.defines = defines;
  109331. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  109332. };
  109333. /** @hidden */
  109334. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  109335. var defines = "";
  109336. if (this._scene.clipPlane) {
  109337. defines = "\n#define CLIPPLANE";
  109338. }
  109339. if (this._scene.clipPlane2) {
  109340. defines = "\n#define CLIPPLANE2";
  109341. }
  109342. if (this._scene.clipPlane3) {
  109343. defines = "\n#define CLIPPLANE3";
  109344. }
  109345. if (this._scene.clipPlane4) {
  109346. defines = "\n#define CLIPPLANE4";
  109347. }
  109348. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  109349. defines = "\n#define BLENDMULTIPLYMODE";
  109350. }
  109351. if (this._isBillboardBased) {
  109352. defines += "\n#define BILLBOARD";
  109353. switch (this.billboardMode) {
  109354. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  109355. defines += "\n#define BILLBOARDY";
  109356. break;
  109357. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  109358. defines += "\n#define BILLBOARDSTRETCHED";
  109359. break;
  109360. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  109361. default:
  109362. break;
  109363. }
  109364. }
  109365. if (this._colorGradientsTexture) {
  109366. defines += "\n#define COLORGRADIENTS";
  109367. }
  109368. if (this.isAnimationSheetEnabled) {
  109369. defines += "\n#define ANIMATESHEET";
  109370. }
  109371. if (this._imageProcessingConfiguration) {
  109372. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  109373. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  109374. }
  109375. if (this._renderEffect && this._renderEffect.defines === defines) {
  109376. return;
  109377. }
  109378. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  109379. var samplers = ["textureSampler", "colorGradientSampler"];
  109380. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  109381. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  109382. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  109383. }
  109384. 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);
  109385. };
  109386. /**
  109387. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  109388. * @param preWarm defines if we are in the pre-warmimg phase
  109389. */
  109390. GPUParticleSystem.prototype.animate = function (preWarm) {
  109391. if (preWarm === void 0) { preWarm = false; }
  109392. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  109393. this._actualFrame += this._timeDelta;
  109394. if (!this._stopped) {
  109395. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  109396. this.stop();
  109397. }
  109398. }
  109399. };
  109400. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  109401. var texture = this[textureName];
  109402. if (!factorGradients || !factorGradients.length || texture) {
  109403. return;
  109404. }
  109405. var data = new Float32Array(this._rawTextureWidth);
  109406. for (var x = 0; x < this._rawTextureWidth; x++) {
  109407. var ratio = x / this._rawTextureWidth;
  109408. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  109409. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  109410. });
  109411. }
  109412. 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);
  109413. };
  109414. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  109415. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  109416. };
  109417. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  109418. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  109419. };
  109420. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  109421. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  109422. };
  109423. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  109424. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  109425. };
  109426. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  109427. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  109428. };
  109429. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  109430. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  109431. return;
  109432. }
  109433. var data = new Uint8Array(this._rawTextureWidth * 4);
  109434. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  109435. for (var x = 0; x < this._rawTextureWidth; x++) {
  109436. var ratio = x / this._rawTextureWidth;
  109437. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  109438. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  109439. data[x * 4] = tmpColor.r * 255;
  109440. data[x * 4 + 1] = tmpColor.g * 255;
  109441. data[x * 4 + 2] = tmpColor.b * 255;
  109442. data[x * 4 + 3] = tmpColor.a * 255;
  109443. });
  109444. }
  109445. 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);
  109446. };
  109447. /**
  109448. * Renders the particle system in its current state
  109449. * @param preWarm defines if the system should only update the particles but not render them
  109450. * @returns the current number of particles
  109451. */
  109452. GPUParticleSystem.prototype.render = function (preWarm) {
  109453. if (preWarm === void 0) { preWarm = false; }
  109454. if (!this._started) {
  109455. return 0;
  109456. }
  109457. this._createColorGradientTexture();
  109458. this._createSizeGradientTexture();
  109459. this._createAngularSpeedGradientTexture();
  109460. this._createVelocityGradientTexture();
  109461. this._createLimitVelocityGradientTexture();
  109462. this._createDragGradientTexture();
  109463. this._recreateUpdateEffect();
  109464. this._recreateRenderEffect();
  109465. if (!this.isReady()) {
  109466. return 0;
  109467. }
  109468. if (!preWarm) {
  109469. if (!this._preWarmDone && this.preWarmCycles) {
  109470. for (var index = 0; index < this.preWarmCycles; index++) {
  109471. this.animate(true);
  109472. this.render(true);
  109473. }
  109474. this._preWarmDone = true;
  109475. }
  109476. if (this._currentRenderId === this._scene.getFrameId()) {
  109477. return 0;
  109478. }
  109479. this._currentRenderId = this._scene.getFrameId();
  109480. }
  109481. // Get everything ready to render
  109482. this._initialize();
  109483. this._accumulatedCount += this.emitRate * this._timeDelta;
  109484. if (this._accumulatedCount > 1) {
  109485. var intPart = this._accumulatedCount | 0;
  109486. this._accumulatedCount -= intPart;
  109487. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  109488. }
  109489. if (!this._currentActiveCount) {
  109490. return 0;
  109491. }
  109492. // Enable update effect
  109493. this._engine.enableEffect(this._updateEffect);
  109494. this._engine.setState(false);
  109495. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  109496. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  109497. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  109498. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  109499. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  109500. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  109501. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  109502. if (!this._colorGradientsTexture) {
  109503. this._updateEffect.setDirectColor4("color1", this.color1);
  109504. this._updateEffect.setDirectColor4("color2", this.color2);
  109505. }
  109506. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  109507. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  109508. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  109509. this._updateEffect.setVector3("gravity", this.gravity);
  109510. if (this._sizeGradientsTexture) {
  109511. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  109512. }
  109513. if (this._angularSpeedGradientsTexture) {
  109514. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  109515. }
  109516. if (this._velocityGradientsTexture) {
  109517. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  109518. }
  109519. if (this._limitVelocityGradientsTexture) {
  109520. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  109521. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  109522. }
  109523. if (this._dragGradientsTexture) {
  109524. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  109525. }
  109526. if (this.particleEmitterType) {
  109527. this.particleEmitterType.applyToShader(this._updateEffect);
  109528. }
  109529. if (this._isAnimationSheetEnabled) {
  109530. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  109531. }
  109532. if (this.noiseTexture) {
  109533. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  109534. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  109535. }
  109536. var emitterWM;
  109537. if (this.emitter.position) {
  109538. var emitterMesh = this.emitter;
  109539. emitterWM = emitterMesh.getWorldMatrix();
  109540. }
  109541. else {
  109542. var emitterPosition = this.emitter;
  109543. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  109544. }
  109545. this._updateEffect.setMatrix("emitterWM", emitterWM);
  109546. // Bind source VAO
  109547. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  109548. // Update
  109549. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  109550. this._engine.setRasterizerState(false);
  109551. this._engine.beginTransformFeedback(true);
  109552. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  109553. this._engine.endTransformFeedback();
  109554. this._engine.setRasterizerState(true);
  109555. this._engine.bindTransformFeedbackBuffer(null);
  109556. if (!preWarm) {
  109557. // Enable render effect
  109558. this._engine.enableEffect(this._renderEffect);
  109559. var viewMatrix = this._scene.getViewMatrix();
  109560. this._renderEffect.setMatrix("view", viewMatrix);
  109561. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  109562. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  109563. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  109564. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  109565. if (this._colorGradientsTexture) {
  109566. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  109567. }
  109568. else {
  109569. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  109570. }
  109571. if (this._isAnimationSheetEnabled && this.particleTexture) {
  109572. var baseSize = this.particleTexture.getBaseSize();
  109573. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  109574. }
  109575. if (this._isBillboardBased) {
  109576. var camera = this._scene.activeCamera;
  109577. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  109578. }
  109579. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  109580. var invView = viewMatrix.clone();
  109581. invView.invert();
  109582. this._renderEffect.setMatrix("invView", invView);
  109583. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  109584. }
  109585. // image processing
  109586. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  109587. this._imageProcessingConfiguration.bind(this._renderEffect);
  109588. }
  109589. // Draw order
  109590. switch (this.blendMode) {
  109591. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  109592. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  109593. break;
  109594. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  109595. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  109596. break;
  109597. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  109598. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  109599. break;
  109600. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  109601. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  109602. break;
  109603. }
  109604. if (this.forceDepthWrite) {
  109605. this._engine.setDepthWrite(true);
  109606. }
  109607. // Bind source VAO
  109608. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  109609. // Render
  109610. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  109611. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  109612. }
  109613. // Switch VAOs
  109614. this._targetIndex++;
  109615. if (this._targetIndex === 2) {
  109616. this._targetIndex = 0;
  109617. }
  109618. // Switch buffers
  109619. var tmpBuffer = this._sourceBuffer;
  109620. this._sourceBuffer = this._targetBuffer;
  109621. this._targetBuffer = tmpBuffer;
  109622. return this._currentActiveCount;
  109623. };
  109624. /**
  109625. * Rebuilds the particle system
  109626. */
  109627. GPUParticleSystem.prototype.rebuild = function () {
  109628. this._initialize(true);
  109629. };
  109630. GPUParticleSystem.prototype._releaseBuffers = function () {
  109631. if (this._buffer0) {
  109632. this._buffer0.dispose();
  109633. this._buffer0 = null;
  109634. }
  109635. if (this._buffer1) {
  109636. this._buffer1.dispose();
  109637. this._buffer1 = null;
  109638. }
  109639. if (this._spriteBuffer) {
  109640. this._spriteBuffer.dispose();
  109641. this._spriteBuffer = null;
  109642. }
  109643. };
  109644. GPUParticleSystem.prototype._releaseVAOs = function () {
  109645. if (!this._updateVAO) {
  109646. return;
  109647. }
  109648. for (var index = 0; index < this._updateVAO.length; index++) {
  109649. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  109650. }
  109651. this._updateVAO = [];
  109652. for (var index = 0; index < this._renderVAO.length; index++) {
  109653. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  109654. }
  109655. this._renderVAO = [];
  109656. };
  109657. /**
  109658. * Disposes the particle system and free the associated resources
  109659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  109660. */
  109661. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  109662. if (disposeTexture === void 0) { disposeTexture = true; }
  109663. var index = this._scene.particleSystems.indexOf(this);
  109664. if (index > -1) {
  109665. this._scene.particleSystems.splice(index, 1);
  109666. }
  109667. this._releaseBuffers();
  109668. this._releaseVAOs();
  109669. if (this._colorGradientsTexture) {
  109670. this._colorGradientsTexture.dispose();
  109671. this._colorGradientsTexture = null;
  109672. }
  109673. if (this._sizeGradientsTexture) {
  109674. this._sizeGradientsTexture.dispose();
  109675. this._sizeGradientsTexture = null;
  109676. }
  109677. if (this._angularSpeedGradientsTexture) {
  109678. this._angularSpeedGradientsTexture.dispose();
  109679. this._angularSpeedGradientsTexture = null;
  109680. }
  109681. if (this._velocityGradientsTexture) {
  109682. this._velocityGradientsTexture.dispose();
  109683. this._velocityGradientsTexture = null;
  109684. }
  109685. if (this._limitVelocityGradientsTexture) {
  109686. this._limitVelocityGradientsTexture.dispose();
  109687. this._limitVelocityGradientsTexture = null;
  109688. }
  109689. if (this._dragGradientsTexture) {
  109690. this._dragGradientsTexture.dispose();
  109691. this._dragGradientsTexture = null;
  109692. }
  109693. if (this._randomTexture) {
  109694. this._randomTexture.dispose();
  109695. this._randomTexture = null;
  109696. }
  109697. if (this._randomTexture2) {
  109698. this._randomTexture2.dispose();
  109699. this._randomTexture2 = null;
  109700. }
  109701. if (disposeTexture && this.particleTexture) {
  109702. this.particleTexture.dispose();
  109703. this.particleTexture = null;
  109704. }
  109705. if (disposeTexture && this.noiseTexture) {
  109706. this.noiseTexture.dispose();
  109707. this.noiseTexture = null;
  109708. }
  109709. // Callback
  109710. this.onDisposeObservable.notifyObservers(this);
  109711. this.onDisposeObservable.clear();
  109712. };
  109713. /**
  109714. * Clones the particle system.
  109715. * @param name The name of the cloned object
  109716. * @param newEmitter The new emitter to use
  109717. * @returns the cloned particle system
  109718. */
  109719. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  109720. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  109721. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  109722. if (newEmitter === undefined) {
  109723. newEmitter = this.emitter;
  109724. }
  109725. result.emitter = newEmitter;
  109726. if (this.particleTexture) {
  109727. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  109728. }
  109729. return result;
  109730. };
  109731. /**
  109732. * Serializes the particle system to a JSON object.
  109733. * @returns the JSON object
  109734. */
  109735. GPUParticleSystem.prototype.serialize = function () {
  109736. var serializationObject = {};
  109737. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  109738. serializationObject.activeParticleCount = this.activeParticleCount;
  109739. return serializationObject;
  109740. };
  109741. /**
  109742. * Parses a JSON object to create a GPU particle system.
  109743. * @param parsedParticleSystem The JSON object to parse
  109744. * @param scene The scene to create the particle system in
  109745. * @param rootUrl The root url to use to load external dependencies like texture
  109746. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  109747. * @returns the parsed GPU particle system
  109748. */
  109749. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  109750. if (doNotStart === void 0) { doNotStart = false; }
  109751. var name = parsedParticleSystem.name;
  109752. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  109753. if (parsedParticleSystem.activeParticleCount) {
  109754. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  109755. }
  109756. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  109757. // Auto start
  109758. if (parsedParticleSystem.preventAutoStart) {
  109759. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  109760. }
  109761. if (!doNotStart && !particleSystem.preventAutoStart) {
  109762. particleSystem.start();
  109763. }
  109764. return particleSystem;
  109765. };
  109766. return GPUParticleSystem;
  109767. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  109768. /***/ }),
  109769. /***/ "./Particles/index.ts":
  109770. /*!****************************!*\
  109771. !*** ./Particles/index.ts ***!
  109772. \****************************/
  109773. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  109774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109775. "use strict";
  109776. __webpack_require__.r(__webpack_exports__);
  109777. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  109778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  109779. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  109780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  109781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  109782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  109783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  109784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  109785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  109786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  109787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  109788. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  109789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  109790. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  109791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  109792. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  109793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  109794. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  109795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  109796. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  109797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  109798. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  109799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  109800. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  109801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  109802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  109803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  109804. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  109805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  109806. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  109807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  109808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  109809. /***/ }),
  109810. /***/ "./Particles/particle.ts":
  109811. /*!*******************************!*\
  109812. !*** ./Particles/particle.ts ***!
  109813. \*******************************/
  109814. /*! exports provided: Particle */
  109815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109816. "use strict";
  109817. __webpack_require__.r(__webpack_exports__);
  109818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  109819. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109820. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109821. /**
  109822. * A particle represents one of the element emitted by a particle system.
  109823. * This is mainly define by its coordinates, direction, velocity and age.
  109824. */
  109825. var Particle = /** @class */ (function () {
  109826. /**
  109827. * Creates a new instance Particle
  109828. * @param particleSystem the particle system the particle belongs to
  109829. */
  109830. function Particle(
  109831. /**
  109832. * The particle system the particle belongs to.
  109833. */
  109834. particleSystem) {
  109835. this.particleSystem = particleSystem;
  109836. /**
  109837. * The world position of the particle in the scene.
  109838. */
  109839. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109840. /**
  109841. * The world direction of the particle in the scene.
  109842. */
  109843. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109844. /**
  109845. * The color of the particle.
  109846. */
  109847. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109848. /**
  109849. * The color change of the particle per step.
  109850. */
  109851. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109852. /**
  109853. * Defines how long will the life of the particle be.
  109854. */
  109855. this.lifeTime = 1.0;
  109856. /**
  109857. * The current age of the particle.
  109858. */
  109859. this.age = 0;
  109860. /**
  109861. * The current size of the particle.
  109862. */
  109863. this.size = 0;
  109864. /**
  109865. * The current scale of the particle.
  109866. */
  109867. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  109868. /**
  109869. * The current angle of the particle.
  109870. */
  109871. this.angle = 0;
  109872. /**
  109873. * Defines how fast is the angle changing.
  109874. */
  109875. this.angularSpeed = 0;
  109876. /**
  109877. * Defines the cell index used by the particle to be rendered from a sprite.
  109878. */
  109879. this.cellIndex = 0;
  109880. /** @hidden */
  109881. this._attachedSubEmitters = null;
  109882. /** @hidden */
  109883. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109884. /** @hidden */
  109885. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109886. /** @hidden */
  109887. this._currentSize1 = 0;
  109888. /** @hidden */
  109889. this._currentSize2 = 0;
  109890. /** @hidden */
  109891. this._currentAngularSpeed1 = 0;
  109892. /** @hidden */
  109893. this._currentAngularSpeed2 = 0;
  109894. /** @hidden */
  109895. this._currentVelocity1 = 0;
  109896. /** @hidden */
  109897. this._currentVelocity2 = 0;
  109898. /** @hidden */
  109899. this._currentLimitVelocity1 = 0;
  109900. /** @hidden */
  109901. this._currentLimitVelocity2 = 0;
  109902. /** @hidden */
  109903. this._currentDrag1 = 0;
  109904. /** @hidden */
  109905. this._currentDrag2 = 0;
  109906. this.id = Particle._Count++;
  109907. if (!this.particleSystem.isAnimationSheetEnabled) {
  109908. return;
  109909. }
  109910. this.updateCellInfoFromSystem();
  109911. }
  109912. Particle.prototype.updateCellInfoFromSystem = function () {
  109913. this.cellIndex = this.particleSystem.startSpriteCellID;
  109914. };
  109915. /**
  109916. * Defines how the sprite cell index is updated for the particle
  109917. */
  109918. Particle.prototype.updateCellIndex = function () {
  109919. var offsetAge = this.age;
  109920. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  109921. if (this.particleSystem.spriteRandomStartCell) {
  109922. if (this._randomCellOffset === undefined) {
  109923. this._randomCellOffset = Math.random() * this.lifeTime;
  109924. }
  109925. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  109926. changeSpeed = 1;
  109927. offsetAge = this._randomCellOffset;
  109928. }
  109929. else {
  109930. offsetAge += this._randomCellOffset;
  109931. }
  109932. }
  109933. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  109934. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  109935. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  109936. };
  109937. /** @hidden */
  109938. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  109939. if (subEmitter.particleSystem.emitter.position) {
  109940. var emitterMesh = subEmitter.particleSystem.emitter;
  109941. emitterMesh.position.copyFrom(this.position);
  109942. if (subEmitter.inheritDirection) {
  109943. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  109944. // Look at using Y as forward
  109945. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  109946. }
  109947. }
  109948. else {
  109949. var emitterPosition = subEmitter.particleSystem.emitter;
  109950. emitterPosition.copyFrom(this.position);
  109951. }
  109952. // Set inheritedVelocityOffset to be used when new particles are created
  109953. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  109954. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  109955. };
  109956. /** @hidden */
  109957. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  109958. var _this = this;
  109959. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  109960. this._attachedSubEmitters.forEach(function (subEmitter) {
  109961. _this._inheritParticleInfoToSubEmitter(subEmitter);
  109962. });
  109963. }
  109964. };
  109965. /** @hidden */
  109966. Particle.prototype._reset = function () {
  109967. this.age = 0;
  109968. this._currentColorGradient = null;
  109969. this._currentSizeGradient = null;
  109970. this._currentAngularSpeedGradient = null;
  109971. this._currentVelocityGradient = null;
  109972. this._currentLimitVelocityGradient = null;
  109973. this._currentDragGradient = null;
  109974. this.cellIndex = this.particleSystem.startSpriteCellID;
  109975. this._randomCellOffset = undefined;
  109976. };
  109977. /**
  109978. * Copy the properties of particle to another one.
  109979. * @param other the particle to copy the information to.
  109980. */
  109981. Particle.prototype.copyTo = function (other) {
  109982. other.position.copyFrom(this.position);
  109983. if (this._initialDirection) {
  109984. if (other._initialDirection) {
  109985. other._initialDirection.copyFrom(this._initialDirection);
  109986. }
  109987. else {
  109988. other._initialDirection = this._initialDirection.clone();
  109989. }
  109990. }
  109991. else {
  109992. other._initialDirection = null;
  109993. }
  109994. other.direction.copyFrom(this.direction);
  109995. other.color.copyFrom(this.color);
  109996. other.colorStep.copyFrom(this.colorStep);
  109997. other.lifeTime = this.lifeTime;
  109998. other.age = this.age;
  109999. other._randomCellOffset = this._randomCellOffset;
  110000. other.size = this.size;
  110001. other.scale.copyFrom(this.scale);
  110002. other.angle = this.angle;
  110003. other.angularSpeed = this.angularSpeed;
  110004. other.particleSystem = this.particleSystem;
  110005. other.cellIndex = this.cellIndex;
  110006. other.id = this.id;
  110007. other._attachedSubEmitters = this._attachedSubEmitters;
  110008. if (this._currentColorGradient) {
  110009. other._currentColorGradient = this._currentColorGradient;
  110010. other._currentColor1.copyFrom(this._currentColor1);
  110011. other._currentColor2.copyFrom(this._currentColor2);
  110012. }
  110013. if (this._currentSizeGradient) {
  110014. other._currentSizeGradient = this._currentSizeGradient;
  110015. other._currentSize1 = this._currentSize1;
  110016. other._currentSize2 = this._currentSize2;
  110017. }
  110018. if (this._currentAngularSpeedGradient) {
  110019. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  110020. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  110021. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  110022. }
  110023. if (this._currentVelocityGradient) {
  110024. other._currentVelocityGradient = this._currentVelocityGradient;
  110025. other._currentVelocity1 = this._currentVelocity1;
  110026. other._currentVelocity2 = this._currentVelocity2;
  110027. }
  110028. if (this._currentLimitVelocityGradient) {
  110029. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  110030. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  110031. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  110032. }
  110033. if (this._currentDragGradient) {
  110034. other._currentDragGradient = this._currentDragGradient;
  110035. other._currentDrag1 = this._currentDrag1;
  110036. other._currentDrag2 = this._currentDrag2;
  110037. }
  110038. if (this.particleSystem.isAnimationSheetEnabled) {
  110039. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  110040. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  110041. }
  110042. if (this.particleSystem.useRampGradients) {
  110043. other.remapData.copyFrom(this.remapData);
  110044. }
  110045. if (this._randomNoiseCoordinates1) {
  110046. if (other._randomNoiseCoordinates1) {
  110047. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  110048. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  110049. }
  110050. else {
  110051. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  110052. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  110053. }
  110054. }
  110055. };
  110056. Particle._Count = 0;
  110057. return Particle;
  110058. }());
  110059. /***/ }),
  110060. /***/ "./Particles/particleHelper.ts":
  110061. /*!*************************************!*\
  110062. !*** ./Particles/particleHelper.ts ***!
  110063. \*************************************/
  110064. /*! exports provided: ParticleHelper */
  110065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110066. "use strict";
  110067. __webpack_require__.r(__webpack_exports__);
  110068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  110069. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  110070. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110071. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  110072. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  110073. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  110074. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  110075. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  110076. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  110077. /**
  110078. * This class is made for on one-liner static method to help creating particle system set.
  110079. */
  110080. var ParticleHelper = /** @class */ (function () {
  110081. function ParticleHelper() {
  110082. }
  110083. /**
  110084. * Create a default particle system that you can tweak
  110085. * @param emitter defines the emitter to use
  110086. * @param capacity defines the system capacity (default is 500 particles)
  110087. * @param scene defines the hosting scene
  110088. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110089. * @returns the new Particle system
  110090. */
  110091. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  110092. if (capacity === void 0) { capacity = 500; }
  110093. if (useGPU === void 0) { useGPU = false; }
  110094. var system;
  110095. if (useGPU) {
  110096. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  110097. }
  110098. else {
  110099. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  110100. }
  110101. system.emitter = emitter;
  110102. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  110103. system.createConeEmitter(0.1, Math.PI / 4);
  110104. // Particle color
  110105. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  110106. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  110107. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  110108. // Particle Size
  110109. system.minSize = 0.1;
  110110. system.maxSize = 0.1;
  110111. // Emission speed
  110112. system.minEmitPower = 2;
  110113. system.maxEmitPower = 2;
  110114. // Update speed
  110115. system.updateSpeed = 1 / 60;
  110116. system.emitRate = 30;
  110117. return system;
  110118. };
  110119. /**
  110120. * This is the main static method (one-liner) of this helper to create different particle systems
  110121. * @param type This string represents the type to the particle system to create
  110122. * @param scene The scene where the particle system should live
  110123. * @param gpu If the system will use gpu
  110124. * @returns the ParticleSystemSet created
  110125. */
  110126. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  110127. if (gpu === void 0) { gpu = false; }
  110128. if (!scene) {
  110129. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  110130. }
  110131. var token = {};
  110132. scene._addPendingData(token);
  110133. return new Promise(function (resolve, reject) {
  110134. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  110135. scene._removePendingData(token);
  110136. return reject("Particle system with GPU is not supported.");
  110137. }
  110138. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  110139. scene._removePendingData(token);
  110140. var newData = JSON.parse(data.toString());
  110141. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  110142. }, undefined, undefined, undefined, function () {
  110143. scene._removePendingData(token);
  110144. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  110145. });
  110146. });
  110147. };
  110148. /**
  110149. * Static function used to export a particle system to a ParticleSystemSet variable.
  110150. * Please note that the emitter shape is not exported
  110151. * @param systems defines the particle systems to export
  110152. * @returns the created particle system set
  110153. */
  110154. ParticleHelper.ExportSet = function (systems) {
  110155. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  110156. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  110157. var system = systems_1[_i];
  110158. set.systems.push(system);
  110159. }
  110160. return set;
  110161. };
  110162. /**
  110163. * Gets or sets base Assets URL
  110164. */
  110165. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  110166. return ParticleHelper;
  110167. }());
  110168. /***/ }),
  110169. /***/ "./Particles/particleSystem.ts":
  110170. /*!*************************************!*\
  110171. !*** ./Particles/particleSystem.ts ***!
  110172. \*************************************/
  110173. /*! exports provided: ParticleSystem */
  110174. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110175. "use strict";
  110176. __webpack_require__.r(__webpack_exports__);
  110177. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  110178. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  110179. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  110180. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  110181. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  110182. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  110183. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  110184. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  110185. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  110186. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  110187. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  110188. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  110189. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  110190. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  110191. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  110192. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  110193. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  110194. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  110195. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  110196. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  110197. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  110198. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  110199. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  110200. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  110201. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  110202. /**
  110203. * This represents a particle system in Babylon.
  110204. * 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.
  110205. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  110206. * @example https://doc.babylonjs.com/babylon101/particles
  110207. */
  110208. var ParticleSystem = /** @class */ (function (_super) {
  110209. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  110210. /**
  110211. * Instantiates a particle system.
  110212. * 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.
  110213. * @param name The name of the particle system
  110214. * @param capacity The max number of particles alive at the same time
  110215. * @param scene The scene the particle system belongs to
  110216. * @param customEffect a custom effect used to change the way particles are rendered by default
  110217. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110218. * @param epsilon Offset used to render the particles
  110219. */
  110220. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  110221. if (customEffect === void 0) { customEffect = null; }
  110222. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  110223. if (epsilon === void 0) { epsilon = 0.01; }
  110224. var _this = _super.call(this, name) || this;
  110225. /**
  110226. * @hidden
  110227. */
  110228. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  110229. /**
  110230. * An event triggered when the system is disposed
  110231. */
  110232. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  110233. _this._particles = new Array();
  110234. _this._stockParticles = new Array();
  110235. _this._newPartsExcess = 0;
  110236. _this._vertexBuffers = {};
  110237. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  110238. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  110239. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110240. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  110241. _this._currentRenderId = -1;
  110242. _this._useInstancing = false;
  110243. _this._started = false;
  110244. _this._stopped = false;
  110245. _this._actualFrame = 0;
  110246. /** @hidden */
  110247. _this._currentEmitRate1 = 0;
  110248. /** @hidden */
  110249. _this._currentEmitRate2 = 0;
  110250. /** @hidden */
  110251. _this._currentStartSize1 = 0;
  110252. /** @hidden */
  110253. _this._currentStartSize2 = 0;
  110254. _this._rawTextureWidth = 256;
  110255. _this._useRampGradients = false;
  110256. /**
  110257. * @hidden
  110258. * If the particle systems emitter should be disposed when the particle system is disposed
  110259. */
  110260. _this._disposeEmitterOnDispose = false;
  110261. // start of sub system methods
  110262. /**
  110263. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  110264. * Its lifetime will start back at 0.
  110265. */
  110266. _this.recycleParticle = function (particle) {
  110267. // move particle from activeParticle list to stock particles
  110268. var lastParticle = _this._particles.pop();
  110269. if (lastParticle !== particle) {
  110270. lastParticle.copyTo(particle);
  110271. }
  110272. _this._stockParticles.push(lastParticle);
  110273. };
  110274. _this._createParticle = function () {
  110275. var particle;
  110276. if (_this._stockParticles.length !== 0) {
  110277. particle = _this._stockParticles.pop();
  110278. particle._reset();
  110279. }
  110280. else {
  110281. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  110282. }
  110283. // Attach emitters
  110284. if (_this._subEmitters && _this._subEmitters.length > 0) {
  110285. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  110286. particle._attachedSubEmitters = [];
  110287. subEmitters.forEach(function (subEmitter) {
  110288. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  110289. var newEmitter = subEmitter.clone();
  110290. particle._attachedSubEmitters.push(newEmitter);
  110291. newEmitter.particleSystem.start();
  110292. }
  110293. });
  110294. }
  110295. return particle;
  110296. };
  110297. _this._emitFromParticle = function (particle) {
  110298. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  110299. return;
  110300. }
  110301. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  110302. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  110303. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  110304. var subSystem = subEmitter.clone();
  110305. particle._inheritParticleInfoToSubEmitter(subSystem);
  110306. subSystem.particleSystem._rootParticleSystem = _this;
  110307. _this.activeSubSystems.push(subSystem.particleSystem);
  110308. subSystem.particleSystem.start();
  110309. }
  110310. });
  110311. };
  110312. _this._capacity = capacity;
  110313. _this._epsilon = epsilon;
  110314. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  110315. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  110316. // Setup the default processing configuration to the scene.
  110317. _this._attachImageProcessingConfiguration(null);
  110318. _this._customEffect = customEffect;
  110319. _this._scene.particleSystems.push(_this);
  110320. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  110321. _this._createIndexBuffer();
  110322. _this._createVertexBuffers();
  110323. // Default emitter type
  110324. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  110325. // Update
  110326. _this.updateFunction = function (particles) {
  110327. var noiseTextureSize = null;
  110328. var noiseTextureData = null;
  110329. if (_this.noiseTexture) { // We need to get texture data back to CPU
  110330. noiseTextureSize = _this.noiseTexture.getSize();
  110331. noiseTextureData = (_this.noiseTexture.getContent());
  110332. }
  110333. var _loop_1 = function () {
  110334. particle = particles[index];
  110335. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  110336. var previousAge = particle.age;
  110337. particle.age += scaledUpdateSpeed;
  110338. // Evaluate step to death
  110339. if (particle.age > particle.lifeTime) {
  110340. var diff = particle.age - previousAge;
  110341. var oldDiff = particle.lifeTime - previousAge;
  110342. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  110343. particle.age = particle.lifeTime;
  110344. }
  110345. var ratio = particle.age / particle.lifeTime;
  110346. // Color
  110347. if (_this._colorGradients && _this._colorGradients.length > 0) {
  110348. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  110349. if (currentGradient !== particle._currentColorGradient) {
  110350. particle._currentColor1.copyFrom(particle._currentColor2);
  110351. nextGradient.getColorToRef(particle._currentColor2);
  110352. particle._currentColorGradient = currentGradient;
  110353. }
  110354. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  110355. });
  110356. }
  110357. else {
  110358. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  110359. particle.color.addInPlace(_this._scaledColorStep);
  110360. if (particle.color.a < 0) {
  110361. particle.color.a = 0;
  110362. }
  110363. }
  110364. // Angular speed
  110365. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  110366. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  110367. if (currentGradient !== particle._currentAngularSpeedGradient) {
  110368. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  110369. particle._currentAngularSpeed2 = nextGradient.getFactor();
  110370. particle._currentAngularSpeedGradient = currentGradient;
  110371. }
  110372. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  110373. });
  110374. }
  110375. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  110376. // Direction
  110377. var directionScale = scaledUpdateSpeed;
  110378. /// Velocity
  110379. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  110380. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  110381. if (currentGradient !== particle._currentVelocityGradient) {
  110382. particle._currentVelocity1 = particle._currentVelocity2;
  110383. particle._currentVelocity2 = nextGradient.getFactor();
  110384. particle._currentVelocityGradient = currentGradient;
  110385. }
  110386. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  110387. });
  110388. }
  110389. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  110390. /// Limit velocity
  110391. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  110392. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  110393. if (currentGradient !== particle._currentLimitVelocityGradient) {
  110394. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  110395. particle._currentLimitVelocity2 = nextGradient.getFactor();
  110396. particle._currentLimitVelocityGradient = currentGradient;
  110397. }
  110398. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  110399. var currentVelocity = particle.direction.length();
  110400. if (currentVelocity > limitVelocity) {
  110401. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  110402. }
  110403. });
  110404. }
  110405. /// Drag
  110406. if (_this._dragGradients && _this._dragGradients.length > 0) {
  110407. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  110408. if (currentGradient !== particle._currentDragGradient) {
  110409. particle._currentDrag1 = particle._currentDrag2;
  110410. particle._currentDrag2 = nextGradient.getFactor();
  110411. particle._currentDragGradient = currentGradient;
  110412. }
  110413. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  110414. _this._scaledDirection.scaleInPlace(1.0 - drag);
  110415. });
  110416. }
  110417. particle.position.addInPlace(_this._scaledDirection);
  110418. // Noise
  110419. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  110420. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  110421. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  110422. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  110423. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  110424. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  110425. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  110426. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  110427. particle.direction.addInPlace(scaledForce);
  110428. }
  110429. // Gravity
  110430. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  110431. particle.direction.addInPlace(_this._scaledGravity);
  110432. // Size
  110433. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  110434. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  110435. if (currentGradient !== particle._currentSizeGradient) {
  110436. particle._currentSize1 = particle._currentSize2;
  110437. particle._currentSize2 = nextGradient.getFactor();
  110438. particle._currentSizeGradient = currentGradient;
  110439. }
  110440. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  110441. });
  110442. }
  110443. // Remap data
  110444. if (_this._useRampGradients) {
  110445. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  110446. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  110447. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  110448. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  110449. particle.remapData.x = min;
  110450. particle.remapData.y = max - min;
  110451. });
  110452. }
  110453. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  110454. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  110455. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  110456. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  110457. particle.remapData.z = min;
  110458. particle.remapData.w = max - min;
  110459. });
  110460. }
  110461. }
  110462. if (_this._isAnimationSheetEnabled) {
  110463. particle.updateCellIndex();
  110464. }
  110465. // Update the position of the attached sub-emitters to match their attached particle
  110466. particle._inheritParticleInfoToSubEmitters();
  110467. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  110468. _this._emitFromParticle(particle);
  110469. if (particle._attachedSubEmitters) {
  110470. particle._attachedSubEmitters.forEach(function (subEmitter) {
  110471. subEmitter.particleSystem.disposeOnStop = true;
  110472. subEmitter.particleSystem.stop();
  110473. });
  110474. particle._attachedSubEmitters = null;
  110475. }
  110476. _this.recycleParticle(particle);
  110477. index--;
  110478. return "continue";
  110479. }
  110480. };
  110481. var particle;
  110482. for (var index = 0; index < particles.length; index++) {
  110483. _loop_1();
  110484. }
  110485. };
  110486. return _this;
  110487. }
  110488. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  110489. /**
  110490. * Sets a callback that will be triggered when the system is disposed
  110491. */
  110492. set: function (callback) {
  110493. if (this._onDisposeObserver) {
  110494. this.onDisposeObservable.remove(this._onDisposeObserver);
  110495. }
  110496. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  110497. },
  110498. enumerable: true,
  110499. configurable: true
  110500. });
  110501. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  110502. /** Gets or sets a boolean indicating that ramp gradients must be used
  110503. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110504. */
  110505. get: function () {
  110506. return this._useRampGradients;
  110507. },
  110508. set: function (value) {
  110509. if (this._useRampGradients === value) {
  110510. return;
  110511. }
  110512. this._useRampGradients = value;
  110513. this._resetEffect();
  110514. },
  110515. enumerable: true,
  110516. configurable: true
  110517. });
  110518. Object.defineProperty(ParticleSystem.prototype, "particles", {
  110519. //end of Sub-emitter
  110520. /**
  110521. * Gets the current list of active particles
  110522. */
  110523. get: function () {
  110524. return this._particles;
  110525. },
  110526. enumerable: true,
  110527. configurable: true
  110528. });
  110529. /**
  110530. * Returns the string "ParticleSystem"
  110531. * @returns a string containing the class name
  110532. */
  110533. ParticleSystem.prototype.getClassName = function () {
  110534. return "ParticleSystem";
  110535. };
  110536. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  110537. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  110538. newGradient.gradient = gradient;
  110539. newGradient.factor1 = factor;
  110540. newGradient.factor2 = factor2;
  110541. factorGradients.push(newGradient);
  110542. factorGradients.sort(function (a, b) {
  110543. if (a.gradient < b.gradient) {
  110544. return -1;
  110545. }
  110546. else if (a.gradient > b.gradient) {
  110547. return 1;
  110548. }
  110549. return 0;
  110550. });
  110551. };
  110552. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  110553. if (!factorGradients) {
  110554. return;
  110555. }
  110556. var index = 0;
  110557. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  110558. var factorGradient = factorGradients_1[_i];
  110559. if (factorGradient.gradient === gradient) {
  110560. factorGradients.splice(index, 1);
  110561. break;
  110562. }
  110563. index++;
  110564. }
  110565. };
  110566. /**
  110567. * Adds a new life time gradient
  110568. * @param gradient defines the gradient to use (between 0 and 1)
  110569. * @param factor defines the life time factor to affect to the specified gradient
  110570. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110571. * @returns the current particle system
  110572. */
  110573. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  110574. if (!this._lifeTimeGradients) {
  110575. this._lifeTimeGradients = [];
  110576. }
  110577. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  110578. return this;
  110579. };
  110580. /**
  110581. * Remove a specific life time gradient
  110582. * @param gradient defines the gradient to remove
  110583. * @returns the current particle system
  110584. */
  110585. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  110586. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  110587. return this;
  110588. };
  110589. /**
  110590. * Adds a new size gradient
  110591. * @param gradient defines the gradient to use (between 0 and 1)
  110592. * @param factor defines the size factor to affect to the specified gradient
  110593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110594. * @returns the current particle system
  110595. */
  110596. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  110597. if (!this._sizeGradients) {
  110598. this._sizeGradients = [];
  110599. }
  110600. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  110601. return this;
  110602. };
  110603. /**
  110604. * Remove a specific size gradient
  110605. * @param gradient defines the gradient to remove
  110606. * @returns the current particle system
  110607. */
  110608. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  110609. this._removeFactorGradient(this._sizeGradients, gradient);
  110610. return this;
  110611. };
  110612. /**
  110613. * Adds a new color remap gradient
  110614. * @param gradient defines the gradient to use (between 0 and 1)
  110615. * @param min defines the color remap minimal range
  110616. * @param max defines the color remap maximal range
  110617. * @returns the current particle system
  110618. */
  110619. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  110620. if (!this._colorRemapGradients) {
  110621. this._colorRemapGradients = [];
  110622. }
  110623. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  110624. return this;
  110625. };
  110626. /**
  110627. * Remove a specific color remap gradient
  110628. * @param gradient defines the gradient to remove
  110629. * @returns the current particle system
  110630. */
  110631. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  110632. this._removeFactorGradient(this._colorRemapGradients, gradient);
  110633. return this;
  110634. };
  110635. /**
  110636. * Adds a new alpha remap gradient
  110637. * @param gradient defines the gradient to use (between 0 and 1)
  110638. * @param min defines the alpha remap minimal range
  110639. * @param max defines the alpha remap maximal range
  110640. * @returns the current particle system
  110641. */
  110642. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  110643. if (!this._alphaRemapGradients) {
  110644. this._alphaRemapGradients = [];
  110645. }
  110646. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  110647. return this;
  110648. };
  110649. /**
  110650. * Remove a specific alpha remap gradient
  110651. * @param gradient defines the gradient to remove
  110652. * @returns the current particle system
  110653. */
  110654. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  110655. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  110656. return this;
  110657. };
  110658. /**
  110659. * Adds a new angular speed gradient
  110660. * @param gradient defines the gradient to use (between 0 and 1)
  110661. * @param factor defines the angular speed to affect to the specified gradient
  110662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110663. * @returns the current particle system
  110664. */
  110665. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  110666. if (!this._angularSpeedGradients) {
  110667. this._angularSpeedGradients = [];
  110668. }
  110669. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  110670. return this;
  110671. };
  110672. /**
  110673. * Remove a specific angular speed gradient
  110674. * @param gradient defines the gradient to remove
  110675. * @returns the current particle system
  110676. */
  110677. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  110678. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  110679. return this;
  110680. };
  110681. /**
  110682. * Adds a new velocity gradient
  110683. * @param gradient defines the gradient to use (between 0 and 1)
  110684. * @param factor defines the velocity to affect to the specified gradient
  110685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110686. * @returns the current particle system
  110687. */
  110688. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  110689. if (!this._velocityGradients) {
  110690. this._velocityGradients = [];
  110691. }
  110692. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  110693. return this;
  110694. };
  110695. /**
  110696. * Remove a specific velocity gradient
  110697. * @param gradient defines the gradient to remove
  110698. * @returns the current particle system
  110699. */
  110700. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  110701. this._removeFactorGradient(this._velocityGradients, gradient);
  110702. return this;
  110703. };
  110704. /**
  110705. * Adds a new limit velocity gradient
  110706. * @param gradient defines the gradient to use (between 0 and 1)
  110707. * @param factor defines the limit velocity value to affect to the specified gradient
  110708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110709. * @returns the current particle system
  110710. */
  110711. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  110712. if (!this._limitVelocityGradients) {
  110713. this._limitVelocityGradients = [];
  110714. }
  110715. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  110716. return this;
  110717. };
  110718. /**
  110719. * Remove a specific limit velocity gradient
  110720. * @param gradient defines the gradient to remove
  110721. * @returns the current particle system
  110722. */
  110723. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  110724. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  110725. return this;
  110726. };
  110727. /**
  110728. * Adds a new drag gradient
  110729. * @param gradient defines the gradient to use (between 0 and 1)
  110730. * @param factor defines the drag value to affect to the specified gradient
  110731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110732. * @returns the current particle system
  110733. */
  110734. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  110735. if (!this._dragGradients) {
  110736. this._dragGradients = [];
  110737. }
  110738. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  110739. return this;
  110740. };
  110741. /**
  110742. * Remove a specific drag gradient
  110743. * @param gradient defines the gradient to remove
  110744. * @returns the current particle system
  110745. */
  110746. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  110747. this._removeFactorGradient(this._dragGradients, gradient);
  110748. return this;
  110749. };
  110750. /**
  110751. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  110752. * @param gradient defines the gradient to use (between 0 and 1)
  110753. * @param factor defines the emit rate value to affect to the specified gradient
  110754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110755. * @returns the current particle system
  110756. */
  110757. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  110758. if (!this._emitRateGradients) {
  110759. this._emitRateGradients = [];
  110760. }
  110761. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  110762. return this;
  110763. };
  110764. /**
  110765. * Remove a specific emit rate gradient
  110766. * @param gradient defines the gradient to remove
  110767. * @returns the current particle system
  110768. */
  110769. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  110770. this._removeFactorGradient(this._emitRateGradients, gradient);
  110771. return this;
  110772. };
  110773. /**
  110774. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  110775. * @param gradient defines the gradient to use (between 0 and 1)
  110776. * @param factor defines the start size value to affect to the specified gradient
  110777. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110778. * @returns the current particle system
  110779. */
  110780. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  110781. if (!this._startSizeGradients) {
  110782. this._startSizeGradients = [];
  110783. }
  110784. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  110785. return this;
  110786. };
  110787. /**
  110788. * Remove a specific start size gradient
  110789. * @param gradient defines the gradient to remove
  110790. * @returns the current particle system
  110791. */
  110792. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  110793. this._removeFactorGradient(this._emitRateGradients, gradient);
  110794. return this;
  110795. };
  110796. ParticleSystem.prototype._createRampGradientTexture = function () {
  110797. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  110798. return;
  110799. }
  110800. var data = new Uint8Array(this._rawTextureWidth * 4);
  110801. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  110802. for (var x = 0; x < this._rawTextureWidth; x++) {
  110803. var ratio = x / this._rawTextureWidth;
  110804. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  110805. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  110806. data[x * 4] = tmpColor.r * 255;
  110807. data[x * 4 + 1] = tmpColor.g * 255;
  110808. data[x * 4 + 2] = tmpColor.b * 255;
  110809. data[x * 4 + 3] = 255;
  110810. });
  110811. }
  110812. 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);
  110813. };
  110814. /**
  110815. * Gets the current list of ramp gradients.
  110816. * You must use addRampGradient and removeRampGradient to udpate this list
  110817. * @returns the list of ramp gradients
  110818. */
  110819. ParticleSystem.prototype.getRampGradients = function () {
  110820. return this._rampGradients;
  110821. };
  110822. /**
  110823. * Adds a new ramp gradient used to remap particle colors
  110824. * @param gradient defines the gradient to use (between 0 and 1)
  110825. * @param color defines the color to affect to the specified gradient
  110826. * @returns the current particle system
  110827. */
  110828. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  110829. if (!this._rampGradients) {
  110830. this._rampGradients = [];
  110831. }
  110832. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  110833. rampGradient.gradient = gradient;
  110834. rampGradient.color = color;
  110835. this._rampGradients.push(rampGradient);
  110836. this._rampGradients.sort(function (a, b) {
  110837. if (a.gradient < b.gradient) {
  110838. return -1;
  110839. }
  110840. else if (a.gradient > b.gradient) {
  110841. return 1;
  110842. }
  110843. return 0;
  110844. });
  110845. if (this._rampGradientsTexture) {
  110846. this._rampGradientsTexture.dispose();
  110847. this._rampGradientsTexture = null;
  110848. }
  110849. this._createRampGradientTexture();
  110850. return this;
  110851. };
  110852. /**
  110853. * Remove a specific ramp gradient
  110854. * @param gradient defines the gradient to remove
  110855. * @returns the current particle system
  110856. */
  110857. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  110858. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  110859. this._rampGradientsTexture = null;
  110860. if (this._rampGradients && this._rampGradients.length > 0) {
  110861. this._createRampGradientTexture();
  110862. }
  110863. return this;
  110864. };
  110865. /**
  110866. * Adds a new color gradient
  110867. * @param gradient defines the gradient to use (between 0 and 1)
  110868. * @param color1 defines the color to affect to the specified gradient
  110869. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110870. * @returns this particle system
  110871. */
  110872. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  110873. if (!this._colorGradients) {
  110874. this._colorGradients = [];
  110875. }
  110876. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  110877. colorGradient.gradient = gradient;
  110878. colorGradient.color1 = color1;
  110879. colorGradient.color2 = color2;
  110880. this._colorGradients.push(colorGradient);
  110881. this._colorGradients.sort(function (a, b) {
  110882. if (a.gradient < b.gradient) {
  110883. return -1;
  110884. }
  110885. else if (a.gradient > b.gradient) {
  110886. return 1;
  110887. }
  110888. return 0;
  110889. });
  110890. return this;
  110891. };
  110892. /**
  110893. * Remove a specific color gradient
  110894. * @param gradient defines the gradient to remove
  110895. * @returns this particle system
  110896. */
  110897. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  110898. if (!this._colorGradients) {
  110899. return this;
  110900. }
  110901. var index = 0;
  110902. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  110903. var colorGradient = _a[_i];
  110904. if (colorGradient.gradient === gradient) {
  110905. this._colorGradients.splice(index, 1);
  110906. break;
  110907. }
  110908. index++;
  110909. }
  110910. return this;
  110911. };
  110912. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  110913. u = Math.abs(u) * 0.5 + 0.5;
  110914. v = Math.abs(v) * 0.5 + 0.5;
  110915. var wrappedU = ((u * width) % width) | 0;
  110916. var wrappedV = ((v * height) % height) | 0;
  110917. var position = (wrappedU + wrappedV * width) * 4;
  110918. return pixels[position] / 255;
  110919. };
  110920. ParticleSystem.prototype._reset = function () {
  110921. this._resetEffect();
  110922. };
  110923. ParticleSystem.prototype._resetEffect = function () {
  110924. if (this._vertexBuffer) {
  110925. this._vertexBuffer.dispose();
  110926. this._vertexBuffer = null;
  110927. }
  110928. if (this._spriteBuffer) {
  110929. this._spriteBuffer.dispose();
  110930. this._spriteBuffer = null;
  110931. }
  110932. this._createVertexBuffers();
  110933. };
  110934. ParticleSystem.prototype._createVertexBuffers = function () {
  110935. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  110936. if (this._isAnimationSheetEnabled) {
  110937. this._vertexBufferSize += 1;
  110938. }
  110939. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  110940. this._vertexBufferSize += 3;
  110941. }
  110942. if (this._useRampGradients) {
  110943. this._vertexBufferSize += 4;
  110944. }
  110945. var engine = this._scene.getEngine();
  110946. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  110947. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  110948. var dataOffset = 0;
  110949. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  110950. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  110951. dataOffset += 3;
  110952. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  110953. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  110954. dataOffset += 4;
  110955. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  110956. this._vertexBuffers["angle"] = options;
  110957. dataOffset += 1;
  110958. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  110959. this._vertexBuffers["size"] = size;
  110960. dataOffset += 2;
  110961. if (this._isAnimationSheetEnabled) {
  110962. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  110963. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  110964. dataOffset += 1;
  110965. }
  110966. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  110967. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  110968. this._vertexBuffers["direction"] = directionBuffer;
  110969. dataOffset += 3;
  110970. }
  110971. if (this._useRampGradients) {
  110972. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  110973. this._vertexBuffers["remapData"] = rampDataBuffer;
  110974. dataOffset += 4;
  110975. }
  110976. var offsets;
  110977. if (this._useInstancing) {
  110978. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  110979. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  110980. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  110981. }
  110982. else {
  110983. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  110984. dataOffset += 2;
  110985. }
  110986. this._vertexBuffers["offset"] = offsets;
  110987. };
  110988. ParticleSystem.prototype._createIndexBuffer = function () {
  110989. if (this._useInstancing) {
  110990. return;
  110991. }
  110992. var indices = [];
  110993. var index = 0;
  110994. for (var count = 0; count < this._capacity; count++) {
  110995. indices.push(index);
  110996. indices.push(index + 1);
  110997. indices.push(index + 2);
  110998. indices.push(index);
  110999. indices.push(index + 2);
  111000. indices.push(index + 3);
  111001. index += 4;
  111002. }
  111003. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  111004. };
  111005. /**
  111006. * Gets the maximum number of particles active at the same time.
  111007. * @returns The max number of active particles.
  111008. */
  111009. ParticleSystem.prototype.getCapacity = function () {
  111010. return this._capacity;
  111011. };
  111012. /**
  111013. * Gets whether there are still active particles in the system.
  111014. * @returns True if it is alive, otherwise false.
  111015. */
  111016. ParticleSystem.prototype.isAlive = function () {
  111017. return this._alive;
  111018. };
  111019. /**
  111020. * Gets if the system has been started. (Note: this will still be true after stop is called)
  111021. * @returns True if it has been started, otherwise false.
  111022. */
  111023. ParticleSystem.prototype.isStarted = function () {
  111024. return this._started;
  111025. };
  111026. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  111027. var _this = this;
  111028. this._subEmitters = new Array();
  111029. if (this.subEmitters) {
  111030. this.subEmitters.forEach(function (subEmitter) {
  111031. if (subEmitter instanceof ParticleSystem) {
  111032. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  111033. }
  111034. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  111035. _this._subEmitters.push([subEmitter]);
  111036. }
  111037. else if (subEmitter instanceof Array) {
  111038. _this._subEmitters.push(subEmitter);
  111039. }
  111040. });
  111041. }
  111042. };
  111043. /**
  111044. * Starts the particle system and begins to emit
  111045. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  111046. */
  111047. ParticleSystem.prototype.start = function (delay) {
  111048. var _this = this;
  111049. if (delay === void 0) { delay = this.startDelay; }
  111050. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  111051. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  111052. }
  111053. if (delay) {
  111054. setTimeout(function () {
  111055. _this.start(0);
  111056. }, delay);
  111057. return;
  111058. }
  111059. // Convert the subEmitters field to the constant type field _subEmitters
  111060. this._prepareSubEmitterInternalArray();
  111061. this._started = true;
  111062. this._stopped = false;
  111063. this._actualFrame = 0;
  111064. if (this._subEmitters && this._subEmitters.length != 0) {
  111065. this.activeSubSystems = new Array();
  111066. }
  111067. // Reset emit gradient so it acts the same on every start
  111068. if (this._emitRateGradients) {
  111069. if (this._emitRateGradients.length > 0) {
  111070. this._currentEmitRateGradient = this._emitRateGradients[0];
  111071. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  111072. this._currentEmitRate2 = this._currentEmitRate1;
  111073. }
  111074. if (this._emitRateGradients.length > 1) {
  111075. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  111076. }
  111077. }
  111078. // Reset start size gradient so it acts the same on every start
  111079. if (this._startSizeGradients) {
  111080. if (this._startSizeGradients.length > 0) {
  111081. this._currentStartSizeGradient = this._startSizeGradients[0];
  111082. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  111083. this._currentStartSize2 = this._currentStartSize1;
  111084. }
  111085. if (this._startSizeGradients.length > 1) {
  111086. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  111087. }
  111088. }
  111089. if (this.preWarmCycles) {
  111090. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  111091. this.emitter.computeWorldMatrix(true);
  111092. }
  111093. var noiseTextureAsProcedural_1 = this.noiseTexture;
  111094. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  111095. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  111096. setTimeout(function () {
  111097. for (var index = 0; index < _this.preWarmCycles; index++) {
  111098. _this.animate(true);
  111099. noiseTextureAsProcedural_1.render();
  111100. }
  111101. });
  111102. });
  111103. }
  111104. else {
  111105. for (var index = 0; index < this.preWarmCycles; index++) {
  111106. this.animate(true);
  111107. }
  111108. }
  111109. }
  111110. // Animations
  111111. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  111112. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  111113. }
  111114. };
  111115. /**
  111116. * Stops the particle system.
  111117. * @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.
  111118. */
  111119. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  111120. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  111121. this._stopped = true;
  111122. if (stopSubEmitters) {
  111123. this._stopSubEmitters();
  111124. }
  111125. };
  111126. // animation sheet
  111127. /**
  111128. * Remove all active particles
  111129. */
  111130. ParticleSystem.prototype.reset = function () {
  111131. this._stockParticles = [];
  111132. this._particles = [];
  111133. };
  111134. /**
  111135. * @hidden (for internal use only)
  111136. */
  111137. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  111138. var offset = index * this._vertexBufferSize;
  111139. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  111140. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  111141. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  111142. this._vertexData[offset++] = particle.color.r;
  111143. this._vertexData[offset++] = particle.color.g;
  111144. this._vertexData[offset++] = particle.color.b;
  111145. this._vertexData[offset++] = particle.color.a;
  111146. this._vertexData[offset++] = particle.angle;
  111147. this._vertexData[offset++] = particle.scale.x * particle.size;
  111148. this._vertexData[offset++] = particle.scale.y * particle.size;
  111149. if (this._isAnimationSheetEnabled) {
  111150. this._vertexData[offset++] = particle.cellIndex;
  111151. }
  111152. if (!this._isBillboardBased) {
  111153. if (particle._initialDirection) {
  111154. this._vertexData[offset++] = particle._initialDirection.x;
  111155. this._vertexData[offset++] = particle._initialDirection.y;
  111156. this._vertexData[offset++] = particle._initialDirection.z;
  111157. }
  111158. else {
  111159. this._vertexData[offset++] = particle.direction.x;
  111160. this._vertexData[offset++] = particle.direction.y;
  111161. this._vertexData[offset++] = particle.direction.z;
  111162. }
  111163. }
  111164. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  111165. this._vertexData[offset++] = particle.direction.x;
  111166. this._vertexData[offset++] = particle.direction.y;
  111167. this._vertexData[offset++] = particle.direction.z;
  111168. }
  111169. if (this._useRampGradients) {
  111170. this._vertexData[offset++] = particle.remapData.x;
  111171. this._vertexData[offset++] = particle.remapData.y;
  111172. this._vertexData[offset++] = particle.remapData.z;
  111173. this._vertexData[offset++] = particle.remapData.w;
  111174. }
  111175. if (!this._useInstancing) {
  111176. if (this._isAnimationSheetEnabled) {
  111177. if (offsetX === 0) {
  111178. offsetX = this._epsilon;
  111179. }
  111180. else if (offsetX === 1) {
  111181. offsetX = 1 - this._epsilon;
  111182. }
  111183. if (offsetY === 0) {
  111184. offsetY = this._epsilon;
  111185. }
  111186. else if (offsetY === 1) {
  111187. offsetY = 1 - this._epsilon;
  111188. }
  111189. }
  111190. this._vertexData[offset++] = offsetX;
  111191. this._vertexData[offset++] = offsetY;
  111192. }
  111193. };
  111194. ParticleSystem.prototype._stopSubEmitters = function () {
  111195. if (!this.activeSubSystems) {
  111196. return;
  111197. }
  111198. this.activeSubSystems.forEach(function (subSystem) {
  111199. subSystem.stop(true);
  111200. });
  111201. this.activeSubSystems = new Array();
  111202. };
  111203. ParticleSystem.prototype._removeFromRoot = function () {
  111204. if (!this._rootParticleSystem) {
  111205. return;
  111206. }
  111207. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  111208. if (index !== -1) {
  111209. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  111210. }
  111211. this._rootParticleSystem = null;
  111212. };
  111213. // End of sub system methods
  111214. ParticleSystem.prototype._update = function (newParticles) {
  111215. var _this = this;
  111216. // Update current
  111217. this._alive = this._particles.length > 0;
  111218. if (this.emitter.position) {
  111219. var emitterMesh = this.emitter;
  111220. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  111221. }
  111222. else {
  111223. var emitterPosition = this.emitter;
  111224. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  111225. }
  111226. this.updateFunction(this._particles);
  111227. // Add new ones
  111228. var particle;
  111229. var _loop_2 = function () {
  111230. if (this_1._particles.length === this_1._capacity) {
  111231. return "break";
  111232. }
  111233. particle = this_1._createParticle();
  111234. this_1._particles.push(particle);
  111235. // Emitter
  111236. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  111237. if (this_1.startPositionFunction) {
  111238. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  111239. }
  111240. else {
  111241. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  111242. }
  111243. if (this_1.startDirectionFunction) {
  111244. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  111245. }
  111246. else {
  111247. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  111248. }
  111249. if (emitPower === 0) {
  111250. if (!particle._initialDirection) {
  111251. particle._initialDirection = particle.direction.clone();
  111252. }
  111253. else {
  111254. particle._initialDirection.copyFrom(particle.direction);
  111255. }
  111256. }
  111257. else {
  111258. particle._initialDirection = null;
  111259. }
  111260. particle.direction.scaleInPlace(emitPower);
  111261. // Life time
  111262. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  111263. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  111264. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  111265. var factorGradient1 = currentGradient;
  111266. var factorGradient2 = nextGradient;
  111267. var lifeTime1 = factorGradient1.getFactor();
  111268. var lifeTime2 = factorGradient2.getFactor();
  111269. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  111270. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  111271. });
  111272. }
  111273. else {
  111274. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  111275. }
  111276. // Size
  111277. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  111278. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  111279. }
  111280. else {
  111281. particle._currentSizeGradient = this_1._sizeGradients[0];
  111282. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  111283. particle.size = particle._currentSize1;
  111284. if (this_1._sizeGradients.length > 1) {
  111285. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  111286. }
  111287. else {
  111288. particle._currentSize2 = particle._currentSize1;
  111289. }
  111290. }
  111291. // Size and scale
  111292. 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));
  111293. // Adjust scale by start size
  111294. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  111295. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  111296. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  111297. if (currentGradient !== _this._currentStartSizeGradient) {
  111298. _this._currentStartSize1 = _this._currentStartSize2;
  111299. _this._currentStartSize2 = nextGradient.getFactor();
  111300. _this._currentStartSizeGradient = currentGradient;
  111301. }
  111302. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  111303. particle.scale.scaleInPlace(value);
  111304. });
  111305. }
  111306. // Angle
  111307. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  111308. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  111309. }
  111310. else {
  111311. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  111312. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  111313. particle._currentAngularSpeed1 = particle.angularSpeed;
  111314. if (this_1._angularSpeedGradients.length > 1) {
  111315. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  111316. }
  111317. else {
  111318. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  111319. }
  111320. }
  111321. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  111322. // Velocity
  111323. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  111324. particle._currentVelocityGradient = this_1._velocityGradients[0];
  111325. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  111326. if (this_1._velocityGradients.length > 1) {
  111327. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  111328. }
  111329. else {
  111330. particle._currentVelocity2 = particle._currentVelocity1;
  111331. }
  111332. }
  111333. // Limit velocity
  111334. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  111335. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  111336. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  111337. if (this_1._limitVelocityGradients.length > 1) {
  111338. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  111339. }
  111340. else {
  111341. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  111342. }
  111343. }
  111344. // Drag
  111345. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  111346. particle._currentDragGradient = this_1._dragGradients[0];
  111347. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  111348. if (this_1._dragGradients.length > 1) {
  111349. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  111350. }
  111351. else {
  111352. particle._currentDrag2 = particle._currentDrag1;
  111353. }
  111354. }
  111355. // Color
  111356. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  111357. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  111358. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  111359. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  111360. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  111361. }
  111362. else {
  111363. particle._currentColorGradient = this_1._colorGradients[0];
  111364. particle._currentColorGradient.getColorToRef(particle.color);
  111365. particle._currentColor1.copyFrom(particle.color);
  111366. if (this_1._colorGradients.length > 1) {
  111367. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  111368. }
  111369. else {
  111370. particle._currentColor2.copyFrom(particle.color);
  111371. }
  111372. }
  111373. // Sheet
  111374. if (this_1._isAnimationSheetEnabled) {
  111375. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  111376. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  111377. }
  111378. // Inherited Velocity
  111379. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  111380. // Ramp
  111381. if (this_1._useRampGradients) {
  111382. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  111383. }
  111384. // Noise texture coordinates
  111385. if (this_1.noiseTexture) {
  111386. if (particle._randomNoiseCoordinates1) {
  111387. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  111388. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  111389. }
  111390. else {
  111391. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  111392. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  111393. }
  111394. }
  111395. // Update the position of the attached sub-emitters to match their attached particle
  111396. particle._inheritParticleInfoToSubEmitters();
  111397. };
  111398. var this_1 = this, step;
  111399. for (var index = 0; index < newParticles; index++) {
  111400. var state_1 = _loop_2();
  111401. if (state_1 === "break")
  111402. break;
  111403. }
  111404. };
  111405. /** @hidden */
  111406. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  111407. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  111408. if (isBillboardBased === void 0) { isBillboardBased = false; }
  111409. if (useRampGradients === void 0) { useRampGradients = false; }
  111410. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  111411. if (isAnimationSheetEnabled) {
  111412. attributeNamesOrOptions.push("cellIndex");
  111413. }
  111414. if (!isBillboardBased) {
  111415. attributeNamesOrOptions.push("direction");
  111416. }
  111417. if (useRampGradients) {
  111418. attributeNamesOrOptions.push("remapData");
  111419. }
  111420. return attributeNamesOrOptions;
  111421. };
  111422. /** @hidden */
  111423. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  111424. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  111425. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  111426. if (isAnimationSheetEnabled) {
  111427. effectCreationOption.push("particlesInfos");
  111428. }
  111429. return effectCreationOption;
  111430. };
  111431. /** @hidden */
  111432. ParticleSystem.prototype._getEffect = function (blendMode) {
  111433. if (this._customEffect) {
  111434. return this._customEffect;
  111435. }
  111436. var defines = [];
  111437. if (this._scene.clipPlane) {
  111438. defines.push("#define CLIPPLANE");
  111439. }
  111440. if (this._scene.clipPlane2) {
  111441. defines.push("#define CLIPPLANE2");
  111442. }
  111443. if (this._scene.clipPlane3) {
  111444. defines.push("#define CLIPPLANE3");
  111445. }
  111446. if (this._scene.clipPlane4) {
  111447. defines.push("#define CLIPPLANE4");
  111448. }
  111449. if (this._isAnimationSheetEnabled) {
  111450. defines.push("#define ANIMATESHEET");
  111451. }
  111452. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  111453. defines.push("#define BLENDMULTIPLYMODE");
  111454. }
  111455. if (this._useRampGradients) {
  111456. defines.push("#define RAMPGRADIENT");
  111457. }
  111458. if (this._isBillboardBased) {
  111459. defines.push("#define BILLBOARD");
  111460. switch (this.billboardMode) {
  111461. case ParticleSystem.BILLBOARDMODE_Y:
  111462. defines.push("#define BILLBOARDY");
  111463. break;
  111464. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  111465. defines.push("#define BILLBOARDSTRETCHED");
  111466. break;
  111467. case ParticleSystem.BILLBOARDMODE_ALL:
  111468. default:
  111469. break;
  111470. }
  111471. }
  111472. if (this._imageProcessingConfiguration) {
  111473. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  111474. defines.push(this._imageProcessingConfigurationDefines.toString());
  111475. }
  111476. // Effect
  111477. var join = defines.join("\n");
  111478. if (this._cachedDefines !== join) {
  111479. this._cachedDefines = join;
  111480. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  111481. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  111482. var samplers = ["diffuseSampler", "rampSampler"];
  111483. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  111484. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  111485. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  111486. }
  111487. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  111488. }
  111489. return this._effect;
  111490. };
  111491. /**
  111492. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111493. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  111494. */
  111495. ParticleSystem.prototype.animate = function (preWarmOnly) {
  111496. var _this = this;
  111497. if (preWarmOnly === void 0) { preWarmOnly = false; }
  111498. if (!this._started) {
  111499. return;
  111500. }
  111501. if (!preWarmOnly) {
  111502. // Check
  111503. if (!this.isReady()) {
  111504. return;
  111505. }
  111506. if (this._currentRenderId === this._scene.getFrameId()) {
  111507. return;
  111508. }
  111509. this._currentRenderId = this._scene.getFrameId();
  111510. }
  111511. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  111512. // Determine the number of particles we need to create
  111513. var newParticles;
  111514. if (this.manualEmitCount > -1) {
  111515. newParticles = this.manualEmitCount;
  111516. this._newPartsExcess = 0;
  111517. this.manualEmitCount = 0;
  111518. }
  111519. else {
  111520. var rate_1 = this.emitRate;
  111521. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  111522. var ratio = this._actualFrame / this.targetStopDuration;
  111523. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  111524. if (currentGradient !== _this._currentEmitRateGradient) {
  111525. _this._currentEmitRate1 = _this._currentEmitRate2;
  111526. _this._currentEmitRate2 = nextGradient.getFactor();
  111527. _this._currentEmitRateGradient = currentGradient;
  111528. }
  111529. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  111530. });
  111531. }
  111532. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  111533. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  111534. }
  111535. if (this._newPartsExcess > 1.0) {
  111536. newParticles += this._newPartsExcess >> 0;
  111537. this._newPartsExcess -= this._newPartsExcess >> 0;
  111538. }
  111539. this._alive = false;
  111540. if (!this._stopped) {
  111541. this._actualFrame += this._scaledUpdateSpeed;
  111542. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  111543. this.stop();
  111544. }
  111545. }
  111546. else {
  111547. newParticles = 0;
  111548. }
  111549. this._update(newParticles);
  111550. // Stopped?
  111551. if (this._stopped) {
  111552. if (!this._alive) {
  111553. this._started = false;
  111554. if (this.onAnimationEnd) {
  111555. this.onAnimationEnd();
  111556. }
  111557. if (this.disposeOnStop) {
  111558. this._scene._toBeDisposed.push(this);
  111559. }
  111560. }
  111561. }
  111562. if (!preWarmOnly) {
  111563. // Update VBO
  111564. var offset = 0;
  111565. for (var index = 0; index < this._particles.length; index++) {
  111566. var particle = this._particles[index];
  111567. this._appendParticleVertices(offset, particle);
  111568. offset += this._useInstancing ? 1 : 4;
  111569. }
  111570. if (this._vertexBuffer) {
  111571. this._vertexBuffer.update(this._vertexData);
  111572. }
  111573. }
  111574. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  111575. this.stop();
  111576. }
  111577. };
  111578. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  111579. this._appendParticleVertex(offset++, particle, 0, 0);
  111580. if (!this._useInstancing) {
  111581. this._appendParticleVertex(offset++, particle, 1, 0);
  111582. this._appendParticleVertex(offset++, particle, 1, 1);
  111583. this._appendParticleVertex(offset++, particle, 0, 1);
  111584. }
  111585. };
  111586. /**
  111587. * Rebuilds the particle system.
  111588. */
  111589. ParticleSystem.prototype.rebuild = function () {
  111590. this._createIndexBuffer();
  111591. if (this._vertexBuffer) {
  111592. this._vertexBuffer._rebuild();
  111593. }
  111594. };
  111595. /**
  111596. * Is this system ready to be used/rendered
  111597. * @return true if the system is ready
  111598. */
  111599. ParticleSystem.prototype.isReady = function () {
  111600. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  111601. return false;
  111602. }
  111603. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  111604. if (!this._getEffect(this.blendMode).isReady()) {
  111605. return false;
  111606. }
  111607. }
  111608. else {
  111609. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  111610. return false;
  111611. }
  111612. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  111613. return false;
  111614. }
  111615. }
  111616. return true;
  111617. };
  111618. ParticleSystem.prototype._render = function (blendMode) {
  111619. var effect = this._getEffect(blendMode);
  111620. var engine = this._scene.getEngine();
  111621. // Render
  111622. engine.enableEffect(effect);
  111623. var viewMatrix = this._scene.getViewMatrix();
  111624. effect.setTexture("diffuseSampler", this.particleTexture);
  111625. effect.setMatrix("view", viewMatrix);
  111626. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  111627. if (this._isAnimationSheetEnabled && this.particleTexture) {
  111628. var baseSize = this.particleTexture.getBaseSize();
  111629. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  111630. }
  111631. effect.setVector2("translationPivot", this.translationPivot);
  111632. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  111633. if (this._isBillboardBased) {
  111634. var camera = this._scene.activeCamera;
  111635. effect.setVector3("eyePosition", camera.globalPosition);
  111636. }
  111637. if (this._rampGradientsTexture) {
  111638. effect.setTexture("rampSampler", this._rampGradientsTexture);
  111639. }
  111640. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  111641. var invView = viewMatrix.clone();
  111642. invView.invert();
  111643. effect.setMatrix("invView", invView);
  111644. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  111645. }
  111646. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  111647. // image processing
  111648. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  111649. this._imageProcessingConfiguration.bind(effect);
  111650. }
  111651. // Draw order
  111652. switch (blendMode) {
  111653. case ParticleSystem.BLENDMODE_ADD:
  111654. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  111655. break;
  111656. case ParticleSystem.BLENDMODE_ONEONE:
  111657. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  111658. break;
  111659. case ParticleSystem.BLENDMODE_STANDARD:
  111660. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  111661. break;
  111662. case ParticleSystem.BLENDMODE_MULTIPLY:
  111663. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  111664. break;
  111665. }
  111666. if (this._useInstancing) {
  111667. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  111668. }
  111669. else {
  111670. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  111671. }
  111672. return this._particles.length;
  111673. };
  111674. /**
  111675. * Renders the particle system in its current state.
  111676. * @returns the current number of particles
  111677. */
  111678. ParticleSystem.prototype.render = function () {
  111679. // Check
  111680. if (!this.isReady() || !this._particles.length) {
  111681. return 0;
  111682. }
  111683. var engine = this._scene.getEngine();
  111684. engine.setState(false);
  111685. if (this.forceDepthWrite) {
  111686. engine.setDepthWrite(true);
  111687. }
  111688. var outparticles = 0;
  111689. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  111690. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  111691. }
  111692. outparticles = this._render(this.blendMode);
  111693. engine.unbindInstanceAttributes();
  111694. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  111695. return outparticles;
  111696. };
  111697. /**
  111698. * Disposes the particle system and free the associated resources
  111699. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111700. */
  111701. ParticleSystem.prototype.dispose = function (disposeTexture) {
  111702. if (disposeTexture === void 0) { disposeTexture = true; }
  111703. if (this._vertexBuffer) {
  111704. this._vertexBuffer.dispose();
  111705. this._vertexBuffer = null;
  111706. }
  111707. if (this._spriteBuffer) {
  111708. this._spriteBuffer.dispose();
  111709. this._spriteBuffer = null;
  111710. }
  111711. if (this._indexBuffer) {
  111712. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  111713. this._indexBuffer = null;
  111714. }
  111715. if (disposeTexture && this.particleTexture) {
  111716. this.particleTexture.dispose();
  111717. this.particleTexture = null;
  111718. }
  111719. if (disposeTexture && this.noiseTexture) {
  111720. this.noiseTexture.dispose();
  111721. this.noiseTexture = null;
  111722. }
  111723. if (this._rampGradientsTexture) {
  111724. this._rampGradientsTexture.dispose();
  111725. this._rampGradientsTexture = null;
  111726. }
  111727. this._removeFromRoot();
  111728. if (this._subEmitters && this._subEmitters.length) {
  111729. for (var index = 0; index < this._subEmitters.length; index++) {
  111730. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  111731. var subEmitter = _a[_i];
  111732. subEmitter.dispose();
  111733. }
  111734. }
  111735. this._subEmitters = [];
  111736. this.subEmitters = [];
  111737. }
  111738. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  111739. this.emitter.dispose(true);
  111740. }
  111741. // Remove from scene
  111742. var index = this._scene.particleSystems.indexOf(this);
  111743. if (index > -1) {
  111744. this._scene.particleSystems.splice(index, 1);
  111745. }
  111746. this._scene._activeParticleSystems.dispose();
  111747. // Callback
  111748. this.onDisposeObservable.notifyObservers(this);
  111749. this.onDisposeObservable.clear();
  111750. this.reset();
  111751. };
  111752. // Clone
  111753. /**
  111754. * Clones the particle system.
  111755. * @param name The name of the cloned object
  111756. * @param newEmitter The new emitter to use
  111757. * @returns the cloned particle system
  111758. */
  111759. ParticleSystem.prototype.clone = function (name, newEmitter) {
  111760. var custom = null;
  111761. var program = null;
  111762. if (this.customShader != null) {
  111763. program = this.customShader;
  111764. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  111765. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  111766. }
  111767. else if (this._customEffect) {
  111768. custom = this._customEffect;
  111769. }
  111770. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  111771. result.customShader = program;
  111772. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  111773. if (newEmitter === undefined) {
  111774. newEmitter = this.emitter;
  111775. }
  111776. result.noiseTexture = this.noiseTexture;
  111777. result.emitter = newEmitter;
  111778. if (this.particleTexture) {
  111779. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  111780. }
  111781. // Clone gradients
  111782. if (this._colorGradients) {
  111783. this._colorGradients.forEach(function (v) {
  111784. result.addColorGradient(v.gradient, v.color1, v.color2);
  111785. });
  111786. }
  111787. if (this._dragGradients) {
  111788. this._dragGradients.forEach(function (v) {
  111789. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  111790. });
  111791. }
  111792. if (this._angularSpeedGradients) {
  111793. this._angularSpeedGradients.forEach(function (v) {
  111794. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  111795. });
  111796. }
  111797. if (this._emitRateGradients) {
  111798. this._emitRateGradients.forEach(function (v) {
  111799. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  111800. });
  111801. }
  111802. if (this._lifeTimeGradients) {
  111803. this._lifeTimeGradients.forEach(function (v) {
  111804. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  111805. });
  111806. }
  111807. if (this._limitVelocityGradients) {
  111808. this._limitVelocityGradients.forEach(function (v) {
  111809. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  111810. });
  111811. }
  111812. if (this._sizeGradients) {
  111813. this._sizeGradients.forEach(function (v) {
  111814. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  111815. });
  111816. }
  111817. if (this._startSizeGradients) {
  111818. this._startSizeGradients.forEach(function (v) {
  111819. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  111820. });
  111821. }
  111822. if (this._velocityGradients) {
  111823. this._velocityGradients.forEach(function (v) {
  111824. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  111825. });
  111826. }
  111827. if (this._rampGradients) {
  111828. this._rampGradients.forEach(function (v) {
  111829. result.addRampGradient(v.gradient, v.color);
  111830. });
  111831. }
  111832. if (this._colorRemapGradients) {
  111833. this._colorRemapGradients.forEach(function (v) {
  111834. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  111835. });
  111836. }
  111837. if (this._alphaRemapGradients) {
  111838. this._alphaRemapGradients.forEach(function (v) {
  111839. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  111840. });
  111841. }
  111842. if (!this.preventAutoStart) {
  111843. result.start();
  111844. }
  111845. return result;
  111846. };
  111847. /**
  111848. * Serializes the particle system to a JSON object.
  111849. * @returns the JSON object
  111850. */
  111851. ParticleSystem.prototype.serialize = function () {
  111852. var serializationObject = {};
  111853. ParticleSystem._Serialize(serializationObject, this);
  111854. serializationObject.textureMask = this.textureMask.asArray();
  111855. serializationObject.customShader = this.customShader;
  111856. serializationObject.preventAutoStart = this.preventAutoStart;
  111857. // SubEmitters
  111858. if (this.subEmitters) {
  111859. serializationObject.subEmitters = [];
  111860. if (!this._subEmitters) {
  111861. this._prepareSubEmitterInternalArray();
  111862. }
  111863. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  111864. var subs = _a[_i];
  111865. var cell = [];
  111866. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  111867. var sub = subs_1[_b];
  111868. cell.push(sub.serialize());
  111869. }
  111870. serializationObject.subEmitters.push(cell);
  111871. }
  111872. }
  111873. return serializationObject;
  111874. };
  111875. /** @hidden */
  111876. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  111877. serializationObject.name = particleSystem.name;
  111878. serializationObject.id = particleSystem.id;
  111879. serializationObject.capacity = particleSystem.getCapacity();
  111880. // Emitter
  111881. if (particleSystem.emitter.position) {
  111882. var emitterMesh = particleSystem.emitter;
  111883. serializationObject.emitterId = emitterMesh.id;
  111884. }
  111885. else {
  111886. var emitterPosition = particleSystem.emitter;
  111887. serializationObject.emitter = emitterPosition.asArray();
  111888. }
  111889. // Emitter
  111890. if (particleSystem.particleEmitterType) {
  111891. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  111892. }
  111893. if (particleSystem.particleTexture) {
  111894. serializationObject.textureName = particleSystem.particleTexture.name;
  111895. serializationObject.invertY = particleSystem.particleTexture._invertY;
  111896. }
  111897. // Animations
  111898. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  111899. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  111900. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  111901. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  111902. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  111903. // Particle system
  111904. serializationObject.startDelay = particleSystem.startDelay;
  111905. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  111906. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  111907. serializationObject.billboardMode = particleSystem.billboardMode;
  111908. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  111909. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  111910. serializationObject.minSize = particleSystem.minSize;
  111911. serializationObject.maxSize = particleSystem.maxSize;
  111912. serializationObject.minScaleX = particleSystem.minScaleX;
  111913. serializationObject.maxScaleX = particleSystem.maxScaleX;
  111914. serializationObject.minScaleY = particleSystem.minScaleY;
  111915. serializationObject.maxScaleY = particleSystem.maxScaleY;
  111916. serializationObject.minEmitPower = particleSystem.minEmitPower;
  111917. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  111918. serializationObject.minLifeTime = particleSystem.minLifeTime;
  111919. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  111920. serializationObject.emitRate = particleSystem.emitRate;
  111921. serializationObject.gravity = particleSystem.gravity.asArray();
  111922. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  111923. serializationObject.color1 = particleSystem.color1.asArray();
  111924. serializationObject.color2 = particleSystem.color2.asArray();
  111925. serializationObject.colorDead = particleSystem.colorDead.asArray();
  111926. serializationObject.updateSpeed = particleSystem.updateSpeed;
  111927. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  111928. serializationObject.blendMode = particleSystem.blendMode;
  111929. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  111930. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  111931. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  111932. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  111933. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  111934. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  111935. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  111936. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  111937. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  111938. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  111939. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  111940. var colorGradients = particleSystem.getColorGradients();
  111941. if (colorGradients) {
  111942. serializationObject.colorGradients = [];
  111943. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  111944. var colorGradient = colorGradients_1[_i];
  111945. var serializedGradient = {
  111946. gradient: colorGradient.gradient,
  111947. color1: colorGradient.color1.asArray()
  111948. };
  111949. if (colorGradient.color2) {
  111950. serializedGradient.color2 = colorGradient.color2.asArray();
  111951. }
  111952. serializationObject.colorGradients.push(serializedGradient);
  111953. }
  111954. }
  111955. var rampGradients = particleSystem.getRampGradients();
  111956. if (rampGradients) {
  111957. serializationObject.rampGradients = [];
  111958. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  111959. var rampGradient = rampGradients_1[_a];
  111960. var serializedGradient = {
  111961. gradient: rampGradient.gradient,
  111962. color: rampGradient.color.asArray()
  111963. };
  111964. serializationObject.rampGradients.push(serializedGradient);
  111965. }
  111966. serializationObject.useRampGradients = particleSystem.useRampGradients;
  111967. }
  111968. var colorRemapGradients = particleSystem.getColorRemapGradients();
  111969. if (colorRemapGradients) {
  111970. serializationObject.colorRemapGradients = [];
  111971. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  111972. var colorRemapGradient = colorRemapGradients_1[_b];
  111973. var serializedGradient = {
  111974. gradient: colorRemapGradient.gradient,
  111975. factor1: colorRemapGradient.factor1
  111976. };
  111977. if (colorRemapGradient.factor2 !== undefined) {
  111978. serializedGradient.factor2 = colorRemapGradient.factor2;
  111979. }
  111980. serializationObject.colorRemapGradients.push(serializedGradient);
  111981. }
  111982. }
  111983. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  111984. if (alphaRemapGradients) {
  111985. serializationObject.alphaRemapGradients = [];
  111986. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  111987. var alphaRemapGradient = alphaRemapGradients_1[_c];
  111988. var serializedGradient = {
  111989. gradient: alphaRemapGradient.gradient,
  111990. factor1: alphaRemapGradient.factor1
  111991. };
  111992. if (alphaRemapGradient.factor2 !== undefined) {
  111993. serializedGradient.factor2 = alphaRemapGradient.factor2;
  111994. }
  111995. serializationObject.alphaRemapGradients.push(serializedGradient);
  111996. }
  111997. }
  111998. var sizeGradients = particleSystem.getSizeGradients();
  111999. if (sizeGradients) {
  112000. serializationObject.sizeGradients = [];
  112001. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  112002. var sizeGradient = sizeGradients_1[_d];
  112003. var serializedGradient = {
  112004. gradient: sizeGradient.gradient,
  112005. factor1: sizeGradient.factor1
  112006. };
  112007. if (sizeGradient.factor2 !== undefined) {
  112008. serializedGradient.factor2 = sizeGradient.factor2;
  112009. }
  112010. serializationObject.sizeGradients.push(serializedGradient);
  112011. }
  112012. }
  112013. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  112014. if (angularSpeedGradients) {
  112015. serializationObject.angularSpeedGradients = [];
  112016. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  112017. var angularSpeedGradient = angularSpeedGradients_1[_e];
  112018. var serializedGradient = {
  112019. gradient: angularSpeedGradient.gradient,
  112020. factor1: angularSpeedGradient.factor1
  112021. };
  112022. if (angularSpeedGradient.factor2 !== undefined) {
  112023. serializedGradient.factor2 = angularSpeedGradient.factor2;
  112024. }
  112025. serializationObject.angularSpeedGradients.push(serializedGradient);
  112026. }
  112027. }
  112028. var velocityGradients = particleSystem.getVelocityGradients();
  112029. if (velocityGradients) {
  112030. serializationObject.velocityGradients = [];
  112031. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  112032. var velocityGradient = velocityGradients_1[_f];
  112033. var serializedGradient = {
  112034. gradient: velocityGradient.gradient,
  112035. factor1: velocityGradient.factor1
  112036. };
  112037. if (velocityGradient.factor2 !== undefined) {
  112038. serializedGradient.factor2 = velocityGradient.factor2;
  112039. }
  112040. serializationObject.velocityGradients.push(serializedGradient);
  112041. }
  112042. }
  112043. var dragGradients = particleSystem.getDragGradients();
  112044. if (dragGradients) {
  112045. serializationObject.dragyGradients = [];
  112046. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  112047. var dragGradient = dragGradients_1[_g];
  112048. var serializedGradient = {
  112049. gradient: dragGradient.gradient,
  112050. factor1: dragGradient.factor1
  112051. };
  112052. if (dragGradient.factor2 !== undefined) {
  112053. serializedGradient.factor2 = dragGradient.factor2;
  112054. }
  112055. serializationObject.dragGradients.push(serializedGradient);
  112056. }
  112057. }
  112058. var emitRateGradients = particleSystem.getEmitRateGradients();
  112059. if (emitRateGradients) {
  112060. serializationObject.emitRateGradients = [];
  112061. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  112062. var emitRateGradient = emitRateGradients_1[_h];
  112063. var serializedGradient = {
  112064. gradient: emitRateGradient.gradient,
  112065. factor1: emitRateGradient.factor1
  112066. };
  112067. if (emitRateGradient.factor2 !== undefined) {
  112068. serializedGradient.factor2 = emitRateGradient.factor2;
  112069. }
  112070. serializationObject.emitRateGradients.push(serializedGradient);
  112071. }
  112072. }
  112073. var startSizeGradients = particleSystem.getStartSizeGradients();
  112074. if (startSizeGradients) {
  112075. serializationObject.startSizeGradients = [];
  112076. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  112077. var startSizeGradient = startSizeGradients_1[_j];
  112078. var serializedGradient = {
  112079. gradient: startSizeGradient.gradient,
  112080. factor1: startSizeGradient.factor1
  112081. };
  112082. if (startSizeGradient.factor2 !== undefined) {
  112083. serializedGradient.factor2 = startSizeGradient.factor2;
  112084. }
  112085. serializationObject.startSizeGradients.push(serializedGradient);
  112086. }
  112087. }
  112088. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  112089. if (lifeTimeGradients) {
  112090. serializationObject.lifeTimeGradients = [];
  112091. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  112092. var lifeTimeGradient = lifeTimeGradients_1[_k];
  112093. var serializedGradient = {
  112094. gradient: lifeTimeGradient.gradient,
  112095. factor1: lifeTimeGradient.factor1
  112096. };
  112097. if (lifeTimeGradient.factor2 !== undefined) {
  112098. serializedGradient.factor2 = lifeTimeGradient.factor2;
  112099. }
  112100. serializationObject.lifeTimeGradients.push(serializedGradient);
  112101. }
  112102. }
  112103. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  112104. if (limitVelocityGradients) {
  112105. serializationObject.limitVelocityGradients = [];
  112106. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  112107. var limitVelocityGradient = limitVelocityGradients_1[_l];
  112108. var serializedGradient = {
  112109. gradient: limitVelocityGradient.gradient,
  112110. factor1: limitVelocityGradient.factor1
  112111. };
  112112. if (limitVelocityGradient.factor2 !== undefined) {
  112113. serializedGradient.factor2 = limitVelocityGradient.factor2;
  112114. }
  112115. serializationObject.limitVelocityGradients.push(serializedGradient);
  112116. }
  112117. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  112118. }
  112119. if (particleSystem.noiseTexture) {
  112120. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  112121. }
  112122. };
  112123. /** @hidden */
  112124. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  112125. // Texture
  112126. if (parsedParticleSystem.textureName) {
  112127. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  112128. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  112129. }
  112130. // Emitter
  112131. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  112132. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  112133. }
  112134. else if (parsedParticleSystem.emitterId) {
  112135. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  112136. }
  112137. else {
  112138. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  112139. }
  112140. // Misc.
  112141. if (parsedParticleSystem.renderingGroupId !== undefined) {
  112142. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  112143. }
  112144. if (parsedParticleSystem.isBillboardBased !== undefined) {
  112145. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  112146. }
  112147. if (parsedParticleSystem.billboardMode !== undefined) {
  112148. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  112149. }
  112150. // Animations
  112151. if (parsedParticleSystem.animations) {
  112152. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  112153. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  112154. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  112155. if (internalClass) {
  112156. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  112157. }
  112158. }
  112159. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  112160. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  112161. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  112162. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  112163. }
  112164. if (parsedParticleSystem.autoAnimate) {
  112165. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  112166. }
  112167. // Particle system
  112168. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  112169. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  112170. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  112171. particleSystem.minSize = parsedParticleSystem.minSize;
  112172. particleSystem.maxSize = parsedParticleSystem.maxSize;
  112173. if (parsedParticleSystem.minScaleX) {
  112174. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  112175. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  112176. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  112177. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  112178. }
  112179. if (parsedParticleSystem.preWarmCycles !== undefined) {
  112180. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  112181. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  112182. }
  112183. if (parsedParticleSystem.minInitialRotation !== undefined) {
  112184. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  112185. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  112186. }
  112187. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  112188. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  112189. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  112190. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  112191. particleSystem.emitRate = parsedParticleSystem.emitRate;
  112192. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  112193. if (parsedParticleSystem.noiseStrength) {
  112194. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  112195. }
  112196. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  112197. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  112198. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  112199. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  112200. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  112201. particleSystem.blendMode = parsedParticleSystem.blendMode;
  112202. if (parsedParticleSystem.colorGradients) {
  112203. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  112204. var colorGradient = _a[_i];
  112205. 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);
  112206. }
  112207. }
  112208. if (parsedParticleSystem.rampGradients) {
  112209. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  112210. var rampGradient = _c[_b];
  112211. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  112212. }
  112213. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  112214. }
  112215. if (parsedParticleSystem.colorRemapGradients) {
  112216. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  112217. var colorRemapGradient = _e[_d];
  112218. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  112219. }
  112220. }
  112221. if (parsedParticleSystem.alphaRemapGradients) {
  112222. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  112223. var alphaRemapGradient = _g[_f];
  112224. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  112225. }
  112226. }
  112227. if (parsedParticleSystem.sizeGradients) {
  112228. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  112229. var sizeGradient = _j[_h];
  112230. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  112231. }
  112232. }
  112233. if (parsedParticleSystem.sizeGradients) {
  112234. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  112235. var sizeGradient = _l[_k];
  112236. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  112237. }
  112238. }
  112239. if (parsedParticleSystem.angularSpeedGradients) {
  112240. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  112241. var angularSpeedGradient = _o[_m];
  112242. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  112243. }
  112244. }
  112245. if (parsedParticleSystem.velocityGradients) {
  112246. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  112247. var velocityGradient = _q[_p];
  112248. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  112249. }
  112250. }
  112251. if (parsedParticleSystem.dragGradients) {
  112252. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  112253. var dragGradient = _s[_r];
  112254. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  112255. }
  112256. }
  112257. if (parsedParticleSystem.emitRateGradients) {
  112258. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  112259. var emitRateGradient = _u[_t];
  112260. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  112261. }
  112262. }
  112263. if (parsedParticleSystem.startSizeGradients) {
  112264. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  112265. var startSizeGradient = _w[_v];
  112266. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  112267. }
  112268. }
  112269. if (parsedParticleSystem.lifeTimeGradients) {
  112270. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  112271. var lifeTimeGradient = _y[_x];
  112272. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  112273. }
  112274. }
  112275. if (parsedParticleSystem.limitVelocityGradients) {
  112276. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  112277. var limitVelocityGradient = _0[_z];
  112278. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  112279. }
  112280. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  112281. }
  112282. if (parsedParticleSystem.noiseTexture) {
  112283. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  112284. }
  112285. // Emitter
  112286. var emitterType;
  112287. if (parsedParticleSystem.particleEmitterType) {
  112288. switch (parsedParticleSystem.particleEmitterType.type) {
  112289. case "SphereParticleEmitter":
  112290. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  112291. break;
  112292. case "SphereDirectedParticleEmitter":
  112293. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  112294. break;
  112295. case "ConeEmitter":
  112296. case "ConeParticleEmitter":
  112297. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  112298. break;
  112299. case "CylinderParticleEmitter":
  112300. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  112301. break;
  112302. case "HemisphericParticleEmitter":
  112303. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  112304. break;
  112305. case "BoxEmitter":
  112306. case "BoxParticleEmitter":
  112307. default:
  112308. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  112309. break;
  112310. }
  112311. emitterType.parse(parsedParticleSystem.particleEmitterType);
  112312. }
  112313. else {
  112314. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  112315. emitterType.parse(parsedParticleSystem);
  112316. }
  112317. particleSystem.particleEmitterType = emitterType;
  112318. // Animation sheet
  112319. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  112320. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  112321. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  112322. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  112323. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  112324. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  112325. };
  112326. /**
  112327. * Parses a JSON object to create a particle system.
  112328. * @param parsedParticleSystem The JSON object to parse
  112329. * @param scene The scene to create the particle system in
  112330. * @param rootUrl The root url to use to load external dependencies like texture
  112331. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  112332. * @returns the Parsed particle system
  112333. */
  112334. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  112335. if (doNotStart === void 0) { doNotStart = false; }
  112336. var name = parsedParticleSystem.name;
  112337. var custom = null;
  112338. var program = null;
  112339. if (parsedParticleSystem.customShader) {
  112340. program = parsedParticleSystem.customShader;
  112341. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  112342. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  112343. }
  112344. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  112345. particleSystem.customShader = program;
  112346. if (parsedParticleSystem.id) {
  112347. particleSystem.id = parsedParticleSystem.id;
  112348. }
  112349. // SubEmitters
  112350. if (parsedParticleSystem.subEmitters) {
  112351. particleSystem.subEmitters = [];
  112352. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  112353. var cell = _a[_i];
  112354. var cellArray = [];
  112355. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  112356. var sub = cell_1[_b];
  112357. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  112358. }
  112359. particleSystem.subEmitters.push(cellArray);
  112360. }
  112361. }
  112362. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  112363. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  112364. // Auto start
  112365. if (parsedParticleSystem.preventAutoStart) {
  112366. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  112367. }
  112368. if (!doNotStart && !particleSystem.preventAutoStart) {
  112369. particleSystem.start();
  112370. }
  112371. return particleSystem;
  112372. };
  112373. /**
  112374. * Billboard mode will only apply to Y axis
  112375. */
  112376. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  112377. /**
  112378. * Billboard mode will apply to all axes
  112379. */
  112380. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  112381. /**
  112382. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  112383. */
  112384. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  112385. return ParticleSystem;
  112386. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  112387. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  112388. /***/ }),
  112389. /***/ "./Particles/particleSystemComponent.ts":
  112390. /*!**********************************************!*\
  112391. !*** ./Particles/particleSystemComponent.ts ***!
  112392. \**********************************************/
  112393. /*! exports provided: _IDoNeedToBeInTheBuild */
  112394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112395. "use strict";
  112396. __webpack_require__.r(__webpack_exports__);
  112397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  112398. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112399. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  112400. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  112401. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  112402. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  112403. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  112404. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  112405. // Adds the parsers to the scene parsers.
  112406. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  112407. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  112408. if (!individualParser) {
  112409. return;
  112410. }
  112411. // Particles Systems
  112412. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  112413. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  112414. var parsedParticleSystem = parsedData.particleSystems[index];
  112415. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  112416. }
  112417. }
  112418. });
  112419. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  112420. if (parsedParticleSystem.activeParticleCount) {
  112421. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  112422. return ps;
  112423. }
  112424. else {
  112425. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  112426. return ps;
  112427. }
  112428. });
  112429. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  112430. if (uniformsNames === void 0) { uniformsNames = []; }
  112431. if (samplers === void 0) { samplers = []; }
  112432. if (defines === void 0) { defines = ""; }
  112433. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  112434. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  112435. if (defines.indexOf(" BILLBOARD") === -1) {
  112436. defines += "\n#define BILLBOARD\n";
  112437. }
  112438. if (samplers.indexOf("diffuseSampler") === -1) {
  112439. samplers.push("diffuseSampler");
  112440. }
  112441. return this.createEffect({
  112442. vertex: "particles",
  112443. fragmentElement: fragmentName
  112444. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  112445. };
  112446. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  112447. var results = new Array();
  112448. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  112449. var particleSystem = this.getScene().particleSystems[index];
  112450. if (particleSystem.emitter === this) {
  112451. results.push(particleSystem);
  112452. }
  112453. }
  112454. return results;
  112455. };
  112456. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  112457. var results = new Array();
  112458. var descendants = this.getDescendants();
  112459. descendants.push(this);
  112460. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  112461. var particleSystem = this.getScene().particleSystems[index];
  112462. var emitter = particleSystem.emitter;
  112463. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  112464. results.push(particleSystem);
  112465. }
  112466. }
  112467. return results;
  112468. };
  112469. /**
  112470. * @hidden
  112471. */
  112472. var _IDoNeedToBeInTheBuild = 42;
  112473. /***/ }),
  112474. /***/ "./Particles/particleSystemSet.ts":
  112475. /*!****************************************!*\
  112476. !*** ./Particles/particleSystemSet.ts ***!
  112477. \****************************************/
  112478. /*! exports provided: ParticleSystemSet */
  112479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112480. "use strict";
  112481. __webpack_require__.r(__webpack_exports__);
  112482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  112483. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112484. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  112485. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  112486. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  112487. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  112488. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  112489. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  112490. /** Internal class used to store shapes for emitters */
  112491. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  112492. function ParticleSystemSetEmitterCreationOptions() {
  112493. }
  112494. return ParticleSystemSetEmitterCreationOptions;
  112495. }());
  112496. /**
  112497. * Represents a set of particle systems working together to create a specific effect
  112498. */
  112499. var ParticleSystemSet = /** @class */ (function () {
  112500. function ParticleSystemSet() {
  112501. /**
  112502. * Gets the particle system list
  112503. */
  112504. this.systems = new Array();
  112505. }
  112506. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  112507. /**
  112508. * Gets the emitter node used with this set
  112509. */
  112510. get: function () {
  112511. return this._emitterNode;
  112512. },
  112513. enumerable: true,
  112514. configurable: true
  112515. });
  112516. /**
  112517. * Creates a new emitter mesh as a sphere
  112518. * @param options defines the options used to create the sphere
  112519. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  112520. * @param scene defines the hosting scene
  112521. */
  112522. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  112523. if (this._emitterNode) {
  112524. this._emitterNode.dispose();
  112525. }
  112526. this._emitterCreationOptions = {
  112527. kind: "Sphere",
  112528. options: options,
  112529. renderingGroupId: renderingGroupId
  112530. };
  112531. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  112532. emitterMesh.renderingGroupId = renderingGroupId;
  112533. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  112534. material.emissiveColor = options.color;
  112535. emitterMesh.material = material;
  112536. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112537. var system = _a[_i];
  112538. system.emitter = emitterMesh;
  112539. }
  112540. this._emitterNode = emitterMesh;
  112541. };
  112542. /**
  112543. * Starts all particle systems of the set
  112544. * @param emitter defines an optional mesh to use as emitter for the particle systems
  112545. */
  112546. ParticleSystemSet.prototype.start = function (emitter) {
  112547. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112548. var system = _a[_i];
  112549. if (emitter) {
  112550. system.emitter = emitter;
  112551. }
  112552. system.start();
  112553. }
  112554. };
  112555. /**
  112556. * Release all associated resources
  112557. */
  112558. ParticleSystemSet.prototype.dispose = function () {
  112559. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112560. var system = _a[_i];
  112561. system.dispose();
  112562. }
  112563. this.systems = [];
  112564. if (this._emitterNode) {
  112565. this._emitterNode.dispose();
  112566. this._emitterNode = null;
  112567. }
  112568. };
  112569. /**
  112570. * Serialize the set into a JSON compatible object
  112571. * @returns a JSON compatible representation of the set
  112572. */
  112573. ParticleSystemSet.prototype.serialize = function () {
  112574. var result = {};
  112575. result.systems = [];
  112576. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112577. var system = _a[_i];
  112578. result.systems.push(system.serialize());
  112579. }
  112580. if (this._emitterNode) {
  112581. result.emitter = this._emitterCreationOptions;
  112582. }
  112583. return result;
  112584. };
  112585. /**
  112586. * Parse a new ParticleSystemSet from a serialized source
  112587. * @param data defines a JSON compatible representation of the set
  112588. * @param scene defines the hosting scene
  112589. * @param gpu defines if we want GPU particles or CPU particles
  112590. * @returns a new ParticleSystemSet
  112591. */
  112592. ParticleSystemSet.Parse = function (data, scene, gpu) {
  112593. if (gpu === void 0) { gpu = false; }
  112594. var result = new ParticleSystemSet();
  112595. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  112596. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  112597. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  112598. var system = _a[_i];
  112599. 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));
  112600. }
  112601. if (data.emitter) {
  112602. var options = data.emitter.options;
  112603. switch (data.emitter.kind) {
  112604. case "Sphere":
  112605. result.setEmitterAsSphere({
  112606. diameter: options.diameter,
  112607. segments: options.segments,
  112608. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  112609. }, data.emitter.renderingGroupId, scene);
  112610. break;
  112611. }
  112612. }
  112613. return result;
  112614. };
  112615. return ParticleSystemSet;
  112616. }());
  112617. /***/ }),
  112618. /***/ "./Particles/solidParticle.ts":
  112619. /*!************************************!*\
  112620. !*** ./Particles/solidParticle.ts ***!
  112621. \************************************/
  112622. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  112623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112624. "use strict";
  112625. __webpack_require__.r(__webpack_exports__);
  112626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  112627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  112628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  112629. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112630. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  112631. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  112632. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  112633. /**
  112634. * Represents one particle of a solid particle system.
  112635. */
  112636. var SolidParticle = /** @class */ (function () {
  112637. /**
  112638. * Creates a Solid Particle object.
  112639. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112640. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  112641. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112642. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112643. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112644. * @param shapeId (integer) is the model shape identifier in the SPS.
  112645. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112646. * @param sps defines the sps it is associated to
  112647. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112648. */
  112649. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  112650. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  112651. /**
  112652. * particle global index
  112653. */
  112654. this.idx = 0;
  112655. /**
  112656. * The color of the particle
  112657. */
  112658. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  112659. /**
  112660. * The world space position of the particle.
  112661. */
  112662. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112663. /**
  112664. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  112665. */
  112666. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112667. /**
  112668. * The scaling of the particle.
  112669. */
  112670. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  112671. /**
  112672. * The uvs of the particle.
  112673. */
  112674. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  112675. /**
  112676. * The current speed of the particle.
  112677. */
  112678. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112679. /**
  112680. * The pivot point in the particle local space.
  112681. */
  112682. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112683. /**
  112684. * Must the particle be translated from its pivot point in its local space ?
  112685. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112686. * Default : false
  112687. */
  112688. this.translateFromPivot = false;
  112689. /**
  112690. * Is the particle active or not ?
  112691. */
  112692. this.alive = true;
  112693. /**
  112694. * Is the particle visible or not ?
  112695. */
  112696. this.isVisible = true;
  112697. /**
  112698. * Index of this particle in the global "positions" array (Internal use)
  112699. * @hidden
  112700. */
  112701. this._pos = 0;
  112702. /**
  112703. * @hidden Index of this particle in the global "indices" array (Internal use)
  112704. */
  112705. this._ind = 0;
  112706. /**
  112707. * ModelShape id of this particle
  112708. */
  112709. this.shapeId = 0;
  112710. /**
  112711. * Index of the particle in its shape id (Internal use)
  112712. */
  112713. this.idxInShape = 0;
  112714. /**
  112715. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112716. */
  112717. this._stillInvisible = false;
  112718. /**
  112719. * @hidden Last computed particle rotation matrix
  112720. */
  112721. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  112722. /**
  112723. * Parent particle Id, if any.
  112724. * Default null.
  112725. */
  112726. this.parentId = null;
  112727. /**
  112728. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112729. * The possible values are :
  112730. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112731. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112732. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112733. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112734. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112735. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112736. * */
  112737. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  112738. /**
  112739. * @hidden Internal global position in the SPS.
  112740. */
  112741. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112742. this.idx = particleIndex;
  112743. this._pos = positionIndex;
  112744. this._ind = indiceIndex;
  112745. this._model = model;
  112746. this.shapeId = shapeId;
  112747. this.idxInShape = idxInShape;
  112748. this._sps = sps;
  112749. if (modelBoundingInfo) {
  112750. this._modelBoundingInfo = modelBoundingInfo;
  112751. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  112752. }
  112753. }
  112754. Object.defineProperty(SolidParticle.prototype, "scale", {
  112755. /**
  112756. * Legacy support, changed scale to scaling
  112757. */
  112758. get: function () {
  112759. return this.scaling;
  112760. },
  112761. /**
  112762. * Legacy support, changed scale to scaling
  112763. */
  112764. set: function (scale) {
  112765. this.scaling = scale;
  112766. },
  112767. enumerable: true,
  112768. configurable: true
  112769. });
  112770. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  112771. /**
  112772. * Legacy support, changed quaternion to rotationQuaternion
  112773. */
  112774. get: function () {
  112775. return this.rotationQuaternion;
  112776. },
  112777. /**
  112778. * Legacy support, changed quaternion to rotationQuaternion
  112779. */
  112780. set: function (q) {
  112781. this.rotationQuaternion = q;
  112782. },
  112783. enumerable: true,
  112784. configurable: true
  112785. });
  112786. /**
  112787. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112788. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112789. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112790. * @returns true if it intersects
  112791. */
  112792. SolidParticle.prototype.intersectsMesh = function (target) {
  112793. if (!this._boundingInfo || !target._boundingInfo) {
  112794. return false;
  112795. }
  112796. if (this._sps._bSphereOnly) {
  112797. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  112798. }
  112799. return this._boundingInfo.intersects(target._boundingInfo, false);
  112800. };
  112801. /**
  112802. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112803. * A particle is in the frustum if its bounding box intersects the frustum
  112804. * @param frustumPlanes defines the frustum to test
  112805. * @returns true if the particle is in the frustum planes
  112806. */
  112807. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  112808. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  112809. };
  112810. /**
  112811. * get the rotation matrix of the particle
  112812. * @hidden
  112813. */
  112814. SolidParticle.prototype.getRotationMatrix = function (m) {
  112815. var quaternion;
  112816. if (this.rotationQuaternion) {
  112817. quaternion = this.rotationQuaternion;
  112818. }
  112819. else {
  112820. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  112821. var rotation = this.rotation;
  112822. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  112823. }
  112824. quaternion.toRotationMatrix(m);
  112825. };
  112826. return SolidParticle;
  112827. }());
  112828. /**
  112829. * Represents the shape of the model used by one particle of a solid particle system.
  112830. * SPS internal tool, don't use it manually.
  112831. */
  112832. var ModelShape = /** @class */ (function () {
  112833. /**
  112834. * 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.
  112835. * SPS internal tool, don't use it manually.
  112836. * @hidden
  112837. */
  112838. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  112839. /**
  112840. * length of the shape in the model indices array (internal use)
  112841. * @hidden
  112842. */
  112843. this._indicesLength = 0;
  112844. this.shapeID = id;
  112845. this._shape = shape;
  112846. this._indicesLength = indicesLength;
  112847. this._shapeUV = shapeUV;
  112848. this._positionFunction = posFunction;
  112849. this._vertexFunction = vtxFunction;
  112850. }
  112851. return ModelShape;
  112852. }());
  112853. /**
  112854. * Represents a Depth Sorted Particle in the solid particle system.
  112855. */
  112856. var DepthSortedParticle = /** @class */ (function () {
  112857. function DepthSortedParticle() {
  112858. /**
  112859. * Index of the particle in the "indices" array
  112860. */
  112861. this.ind = 0;
  112862. /**
  112863. * Length of the particle shape in the "indices" array
  112864. */
  112865. this.indicesLength = 0;
  112866. /**
  112867. * Squared distance from the particle to the camera
  112868. */
  112869. this.sqDistance = 0.0;
  112870. }
  112871. return DepthSortedParticle;
  112872. }());
  112873. /***/ }),
  112874. /***/ "./Particles/solidParticleSystem.ts":
  112875. /*!******************************************!*\
  112876. !*** ./Particles/solidParticleSystem.ts ***!
  112877. \******************************************/
  112878. /*! exports provided: SolidParticleSystem */
  112879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112880. "use strict";
  112881. __webpack_require__.r(__webpack_exports__);
  112882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  112883. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112884. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  112885. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  112886. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112887. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  112888. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  112889. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  112890. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  112891. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  112892. /**
  112893. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  112894. *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.
  112895. * The SPS is also a particle system. It provides some methods to manage the particles.
  112896. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  112897. *
  112898. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  112899. */
  112900. var SolidParticleSystem = /** @class */ (function () {
  112901. /**
  112902. * Creates a SPS (Solid Particle System) object.
  112903. * @param name (String) is the SPS name, this will be the underlying mesh name.
  112904. * @param scene (Scene) is the scene in which the SPS is added.
  112905. * @param options defines the options of the sps e.g.
  112906. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  112907. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  112908. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  112909. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  112910. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  112911. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  112912. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  112913. */
  112914. function SolidParticleSystem(name, scene, options) {
  112915. /**
  112916. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  112917. * Example : var p = SPS.particles[i];
  112918. */
  112919. this.particles = new Array();
  112920. /**
  112921. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  112922. */
  112923. this.nbParticles = 0;
  112924. /**
  112925. * If the particles must ever face the camera (default false). Useful for planar particles.
  112926. */
  112927. this.billboard = false;
  112928. /**
  112929. * Recompute normals when adding a shape
  112930. */
  112931. this.recomputeNormals = true;
  112932. /**
  112933. * This a counter ofr your own usage. It's not set by any SPS functions.
  112934. */
  112935. this.counter = 0;
  112936. /**
  112937. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  112938. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  112939. */
  112940. this.vars = {};
  112941. /**
  112942. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  112943. * @hidden
  112944. */
  112945. this._bSphereOnly = false;
  112946. /**
  112947. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  112948. * @hidden
  112949. */
  112950. this._bSphereRadiusFactor = 1.0;
  112951. this._positions = new Array();
  112952. this._indices = new Array();
  112953. this._normals = new Array();
  112954. this._colors = new Array();
  112955. this._uvs = new Array();
  112956. this._index = 0; // indices index
  112957. this._updatable = true;
  112958. this._pickable = false;
  112959. this._isVisibilityBoxLocked = false;
  112960. this._alwaysVisible = false;
  112961. this._depthSort = false;
  112962. this._shapeCounter = 0;
  112963. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  112964. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  112965. this._computeParticleColor = true;
  112966. this._computeParticleTexture = true;
  112967. this._computeParticleRotation = true;
  112968. this._computeParticleVertex = false;
  112969. this._computeBoundingBox = false;
  112970. this._depthSortParticles = true;
  112971. this._mustUnrotateFixedNormals = false;
  112972. this._particlesIntersect = false;
  112973. this._needs32Bits = false;
  112974. this.name = name;
  112975. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  112976. this._camera = scene.activeCamera;
  112977. this._pickable = options ? options.isPickable : false;
  112978. this._depthSort = options ? options.enableDepthSort : false;
  112979. this._particlesIntersect = options ? options.particleIntersection : false;
  112980. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  112981. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  112982. if (options && options.updatable !== undefined) {
  112983. this._updatable = options.updatable;
  112984. }
  112985. else {
  112986. this._updatable = true;
  112987. }
  112988. if (this._pickable) {
  112989. this.pickedParticles = [];
  112990. }
  112991. if (this._depthSort) {
  112992. this.depthSortedParticles = [];
  112993. }
  112994. }
  112995. /**
  112996. * Builds the SPS underlying mesh. Returns a standard Mesh.
  112997. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  112998. * @returns the created mesh
  112999. */
  113000. SolidParticleSystem.prototype.buildMesh = function () {
  113001. if (this.nbParticles === 0) {
  113002. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  113003. this.addShape(triangle, 1);
  113004. triangle.dispose();
  113005. }
  113006. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  113007. this._positions32 = new Float32Array(this._positions);
  113008. this._uvs32 = new Float32Array(this._uvs);
  113009. this._colors32 = new Float32Array(this._colors);
  113010. if (this.recomputeNormals) {
  113011. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  113012. }
  113013. this._normals32 = new Float32Array(this._normals);
  113014. this._fixedNormal32 = new Float32Array(this._normals);
  113015. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  113016. this._unrotateFixedNormals();
  113017. }
  113018. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  113019. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  113020. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  113021. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  113022. if (this._uvs32.length > 0) {
  113023. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  113024. }
  113025. if (this._colors32.length > 0) {
  113026. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  113027. }
  113028. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  113029. vertexData.applyToMesh(mesh, this._updatable);
  113030. this.mesh = mesh;
  113031. this.mesh.isPickable = this._pickable;
  113032. // free memory
  113033. if (!this._depthSort) {
  113034. this._indices = null;
  113035. }
  113036. this._positions = null;
  113037. this._normals = null;
  113038. this._uvs = null;
  113039. this._colors = null;
  113040. if (!this._updatable) {
  113041. this.particles.length = 0;
  113042. }
  113043. return mesh;
  113044. };
  113045. /**
  113046. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  113047. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  113048. * Thus the particles generated from `digest()` have their property `position` set yet.
  113049. * @param mesh ( Mesh ) is the mesh to be digested
  113050. * @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
  113051. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  113052. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  113053. * @returns the current SPS
  113054. */
  113055. SolidParticleSystem.prototype.digest = function (mesh, options) {
  113056. var size = (options && options.facetNb) || 1;
  113057. var number = (options && options.number) || 0;
  113058. var delta = (options && options.delta) || 0;
  113059. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  113060. var meshInd = mesh.getIndices();
  113061. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  113062. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  113063. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  113064. var f = 0; // facet counter
  113065. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  113066. // compute size from number
  113067. if (number) {
  113068. number = (number > totalFacets) ? totalFacets : number;
  113069. size = Math.round(totalFacets / number);
  113070. delta = 0;
  113071. }
  113072. else {
  113073. size = (size > totalFacets) ? totalFacets : size;
  113074. }
  113075. var facetPos = []; // submesh positions
  113076. var facetInd = []; // submesh indices
  113077. var facetUV = []; // submesh UV
  113078. var facetCol = []; // submesh colors
  113079. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  113080. var sizeO = size;
  113081. while (f < totalFacets) {
  113082. size = sizeO + Math.floor((1 + delta) * Math.random());
  113083. if (f > totalFacets - size) {
  113084. size = totalFacets - f;
  113085. }
  113086. // reset temp arrays
  113087. facetPos.length = 0;
  113088. facetInd.length = 0;
  113089. facetUV.length = 0;
  113090. facetCol.length = 0;
  113091. // iterate over "size" facets
  113092. var fi = 0;
  113093. for (var j = f * 3; j < (f + size) * 3; j++) {
  113094. facetInd.push(fi);
  113095. var i = meshInd[j];
  113096. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  113097. if (meshUV) {
  113098. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  113099. }
  113100. if (meshCol) {
  113101. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  113102. }
  113103. fi++;
  113104. }
  113105. // create a model shape for each single particle
  113106. var idx = this.nbParticles;
  113107. var shape = this._posToShape(facetPos);
  113108. var shapeUV = this._uvsToShapeUV(facetUV);
  113109. // compute the barycenter of the shape
  113110. var v;
  113111. for (v = 0; v < shape.length; v++) {
  113112. barycenter.addInPlace(shape[v]);
  113113. }
  113114. barycenter.scaleInPlace(1 / shape.length);
  113115. // shift the shape from its barycenter to the origin
  113116. for (v = 0; v < shape.length; v++) {
  113117. shape[v].subtractInPlace(barycenter);
  113118. }
  113119. var bInfo;
  113120. if (this._particlesIntersect) {
  113121. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  113122. }
  113123. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  113124. // add the particle in the SPS
  113125. var currentPos = this._positions.length;
  113126. var currentInd = this._indices.length;
  113127. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  113128. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  113129. // initialize the particle position
  113130. this.particles[this.nbParticles].position.addInPlace(barycenter);
  113131. this._index += shape.length;
  113132. idx++;
  113133. this.nbParticles++;
  113134. this._shapeCounter++;
  113135. f += size;
  113136. }
  113137. return this;
  113138. };
  113139. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  113140. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  113141. var index = 0;
  113142. var idx = 0;
  113143. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  113144. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  113145. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  113146. for (var p = 0; p < this.particles.length; p++) {
  113147. var particle = this.particles[p];
  113148. var shape = particle._model._shape;
  113149. // computing the inverse of the rotation matrix from the quaternion
  113150. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  113151. if (particle.rotationQuaternion) {
  113152. particle.rotationQuaternion.conjugateToRef(quaternion);
  113153. }
  113154. else {
  113155. var rotation = particle.rotation;
  113156. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  113157. quaternion.conjugateInPlace();
  113158. }
  113159. quaternion.toRotationMatrix(invertedRotMatrix);
  113160. for (var pt = 0; pt < shape.length; pt++) {
  113161. idx = index + pt * 3;
  113162. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  113163. tmpNormal.toArray(this._fixedNormal32, idx);
  113164. }
  113165. index = idx + 3;
  113166. }
  113167. };
  113168. //reset copy
  113169. SolidParticleSystem.prototype._resetCopy = function () {
  113170. var copy = this._copy;
  113171. copy.position.setAll(0);
  113172. copy.rotation.setAll(0);
  113173. copy.rotationQuaternion = null;
  113174. copy.scaling.setAll(1);
  113175. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  113176. copy.color = null;
  113177. copy.translateFromPivot = false;
  113178. };
  113179. // _meshBuilder : inserts the shape model in the global SPS mesh
  113180. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  113181. var i;
  113182. var u = 0;
  113183. var c = 0;
  113184. var n = 0;
  113185. this._resetCopy();
  113186. var copy = this._copy;
  113187. if (options && options.positionFunction) { // call to custom positionFunction
  113188. options.positionFunction(copy, idx, idxInShape);
  113189. this._mustUnrotateFixedNormals = true;
  113190. }
  113191. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  113192. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  113193. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  113194. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  113195. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  113196. copy.getRotationMatrix(rotMatrix);
  113197. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  113198. if (copy.translateFromPivot) {
  113199. pivotBackTranslation.setAll(0.0);
  113200. }
  113201. else {
  113202. pivotBackTranslation.copyFrom(scaledPivot);
  113203. }
  113204. for (i = 0; i < shape.length; i++) {
  113205. tmpVertex.copyFrom(shape[i]);
  113206. if (options && options.vertexFunction) {
  113207. options.vertexFunction(copy, tmpVertex, i);
  113208. }
  113209. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  113210. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  113211. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  113212. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  113213. if (meshUV) {
  113214. var copyUvs = copy.uvs;
  113215. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  113216. u += 2;
  113217. }
  113218. if (copy.color) {
  113219. this._color = copy.color;
  113220. }
  113221. else {
  113222. var color = this._color;
  113223. if (meshCol && meshCol[c] !== undefined) {
  113224. color.r = meshCol[c];
  113225. color.g = meshCol[c + 1];
  113226. color.b = meshCol[c + 2];
  113227. color.a = meshCol[c + 3];
  113228. }
  113229. else {
  113230. color.r = 1.0;
  113231. color.g = 1.0;
  113232. color.b = 1.0;
  113233. color.a = 1.0;
  113234. }
  113235. }
  113236. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  113237. c += 4;
  113238. if (!this.recomputeNormals && meshNor) {
  113239. tmpVertex.x = meshNor[n];
  113240. tmpVertex.y = meshNor[n + 1];
  113241. tmpVertex.z = meshNor[n + 2];
  113242. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  113243. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  113244. n += 3;
  113245. }
  113246. }
  113247. for (i = 0; i < meshInd.length; i++) {
  113248. var current_ind = p + meshInd[i];
  113249. indices.push(current_ind);
  113250. if (current_ind > 65535) {
  113251. this._needs32Bits = true;
  113252. }
  113253. }
  113254. if (this._pickable) {
  113255. var nbfaces = meshInd.length / 3;
  113256. for (i = 0; i < nbfaces; i++) {
  113257. this.pickedParticles.push({ idx: idx, faceId: i });
  113258. }
  113259. }
  113260. if (this._depthSort) {
  113261. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  113262. }
  113263. return copy;
  113264. };
  113265. // returns a shape array from positions array
  113266. SolidParticleSystem.prototype._posToShape = function (positions) {
  113267. var shape = [];
  113268. for (var i = 0; i < positions.length; i += 3) {
  113269. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  113270. }
  113271. return shape;
  113272. };
  113273. // returns a shapeUV array from a Vector4 uvs
  113274. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  113275. var shapeUV = [];
  113276. if (uvs) {
  113277. for (var i = 0; i < uvs.length; i++) {
  113278. shapeUV.push(uvs[i]);
  113279. }
  113280. }
  113281. return shapeUV;
  113282. };
  113283. // adds a new particle object in the particles array
  113284. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  113285. if (bInfo === void 0) { bInfo = null; }
  113286. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  113287. this.particles.push(sp);
  113288. return sp;
  113289. };
  113290. /**
  113291. * Adds some particles to the SPS from the model shape. Returns the shape id.
  113292. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  113293. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  113294. * @param nb (positive integer) the number of particles to be created from this model
  113295. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  113296. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  113297. * @returns the number of shapes in the system
  113298. */
  113299. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  113300. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  113301. var meshInd = mesh.getIndices();
  113302. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  113303. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  113304. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  113305. var bbInfo;
  113306. if (this._particlesIntersect) {
  113307. bbInfo = mesh.getBoundingInfo();
  113308. }
  113309. var shape = this._posToShape(meshPos);
  113310. var shapeUV = this._uvsToShapeUV(meshUV);
  113311. var posfunc = options ? options.positionFunction : null;
  113312. var vtxfunc = options ? options.vertexFunction : null;
  113313. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  113314. // particles
  113315. var sp;
  113316. var currentCopy;
  113317. var idx = this.nbParticles;
  113318. for (var i = 0; i < nb; i++) {
  113319. var currentPos = this._positions.length;
  113320. var currentInd = this._indices.length;
  113321. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  113322. if (this._updatable) {
  113323. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  113324. sp.position.copyFrom(currentCopy.position);
  113325. sp.rotation.copyFrom(currentCopy.rotation);
  113326. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  113327. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  113328. }
  113329. if (currentCopy.color && sp.color) {
  113330. sp.color.copyFrom(currentCopy.color);
  113331. }
  113332. sp.scaling.copyFrom(currentCopy.scaling);
  113333. sp.uvs.copyFrom(currentCopy.uvs);
  113334. }
  113335. this._index += shape.length;
  113336. idx++;
  113337. }
  113338. this.nbParticles += nb;
  113339. this._shapeCounter++;
  113340. return this._shapeCounter - 1;
  113341. };
  113342. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  113343. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  113344. this._resetCopy();
  113345. var copy = this._copy;
  113346. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  113347. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  113348. }
  113349. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  113350. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  113351. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  113352. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  113353. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  113354. copy.getRotationMatrix(rotMatrix);
  113355. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  113356. if (copy.translateFromPivot) {
  113357. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  113358. }
  113359. else {
  113360. pivotBackTranslation.copyFrom(scaledPivot);
  113361. }
  113362. var shape = particle._model._shape;
  113363. for (var pt = 0; pt < shape.length; pt++) {
  113364. tmpVertex.copyFrom(shape[pt]);
  113365. if (particle._model._vertexFunction) {
  113366. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  113367. }
  113368. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  113369. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  113370. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  113371. }
  113372. particle.position.setAll(0.0);
  113373. particle.rotation.setAll(0.0);
  113374. particle.rotationQuaternion = null;
  113375. particle.scaling.setAll(1.0);
  113376. particle.uvs.setAll(0.0);
  113377. particle.pivot.setAll(0.0);
  113378. particle.translateFromPivot = false;
  113379. particle.parentId = null;
  113380. };
  113381. /**
  113382. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  113383. * @returns the SPS.
  113384. */
  113385. SolidParticleSystem.prototype.rebuildMesh = function () {
  113386. for (var p = 0; p < this.particles.length; p++) {
  113387. this._rebuildParticle(this.particles[p]);
  113388. }
  113389. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  113390. return this;
  113391. };
  113392. /**
  113393. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  113394. * This method calls `updateParticle()` for each particle of the SPS.
  113395. * For an animated SPS, it is usually called within the render loop.
  113396. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  113397. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  113398. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  113399. * @returns the SPS.
  113400. */
  113401. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  113402. if (start === void 0) { start = 0; }
  113403. if (end === void 0) { end = this.nbParticles - 1; }
  113404. if (update === void 0) { update = true; }
  113405. if (!this._updatable) {
  113406. return this;
  113407. }
  113408. // custom beforeUpdate
  113409. this.beforeUpdateParticles(start, end, update);
  113410. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  113411. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  113412. var mesh = this.mesh;
  113413. var colors32 = this._colors32;
  113414. var positions32 = this._positions32;
  113415. var normals32 = this._normals32;
  113416. var uvs32 = this._uvs32;
  113417. var indices32 = this._indices32;
  113418. var indices = this._indices;
  113419. var fixedNormal32 = this._fixedNormal32;
  113420. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  113421. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  113422. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  113423. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  113424. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  113425. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  113426. var camInvertedPosition = tempVectors[10].setAll(0);
  113427. // cases when the World Matrix is to be computed first
  113428. if (this.billboard || this._depthSort) {
  113429. this.mesh.computeWorldMatrix(true);
  113430. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  113431. }
  113432. // if the particles will always face the camera
  113433. if (this.billboard) {
  113434. // compute the camera position and un-rotate it by the current mesh rotation
  113435. var tmpVertex = tempVectors[0];
  113436. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  113437. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  113438. camAxisZ.normalize();
  113439. // same for camera up vector extracted from the cam view matrix
  113440. var view = this._camera.getViewMatrix(true);
  113441. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  113442. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  113443. camAxisY.normalize();
  113444. camAxisX.normalize();
  113445. }
  113446. // if depthSort, compute the camera global position in the mesh local system
  113447. if (this._depthSort) {
  113448. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  113449. }
  113450. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  113451. var idx = 0; // current position index in the global array positions32
  113452. var index = 0; // position start index in the global array positions32 of the current particle
  113453. var colidx = 0; // current color index in the global array colors32
  113454. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  113455. var uvidx = 0; // current uv index in the global array uvs32
  113456. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  113457. var pt = 0; // current index in the particle model shape
  113458. if (this.mesh.isFacetDataEnabled) {
  113459. this._computeBoundingBox = true;
  113460. }
  113461. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  113462. if (this._computeBoundingBox) {
  113463. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  113464. var boundingInfo = this.mesh._boundingInfo;
  113465. if (boundingInfo) {
  113466. minimum.copyFrom(boundingInfo.minimum);
  113467. maximum.copyFrom(boundingInfo.maximum);
  113468. }
  113469. }
  113470. }
  113471. // particle loop
  113472. index = this.particles[start]._pos;
  113473. var vpos = (index / 3) | 0;
  113474. colorIndex = vpos * 4;
  113475. uvIndex = vpos * 2;
  113476. for (var p = start; p <= end; p++) {
  113477. var particle = this.particles[p];
  113478. // call to custom user function to update the particle properties
  113479. this.updateParticle(particle);
  113480. var shape = particle._model._shape;
  113481. var shapeUV = particle._model._shapeUV;
  113482. var particleRotationMatrix = particle._rotationMatrix;
  113483. var particlePosition = particle.position;
  113484. var particleRotation = particle.rotation;
  113485. var particleScaling = particle.scaling;
  113486. var particleGlobalPosition = particle._globalPosition;
  113487. // camera-particle distance for depth sorting
  113488. if (this._depthSort && this._depthSortParticles) {
  113489. var dsp = this.depthSortedParticles[p];
  113490. dsp.ind = particle._ind;
  113491. dsp.indicesLength = particle._model._indicesLength;
  113492. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  113493. }
  113494. // skip the computations for inactive or already invisible particles
  113495. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  113496. // increment indexes for the next particle
  113497. pt = shape.length;
  113498. index += pt * 3;
  113499. colorIndex += pt * 4;
  113500. uvIndex += pt * 2;
  113501. continue;
  113502. }
  113503. if (particle.isVisible) {
  113504. particle._stillInvisible = false; // un-mark permanent invisibility
  113505. var scaledPivot = tempVectors[12];
  113506. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  113507. // particle rotation matrix
  113508. if (this.billboard) {
  113509. particleRotation.x = 0.0;
  113510. particleRotation.y = 0.0;
  113511. }
  113512. if (this._computeParticleRotation || this.billboard) {
  113513. particle.getRotationMatrix(rotMatrix);
  113514. }
  113515. var particleHasParent = (particle.parentId !== null);
  113516. if (particleHasParent) {
  113517. var parent_1 = this.particles[particle.parentId];
  113518. var parentRotationMatrix = parent_1._rotationMatrix;
  113519. var parentGlobalPosition = parent_1._globalPosition;
  113520. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  113521. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  113522. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  113523. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  113524. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  113525. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  113526. if (this._computeParticleRotation || this.billboard) {
  113527. var rotMatrixValues = rotMatrix.m;
  113528. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  113529. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  113530. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  113531. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  113532. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  113533. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  113534. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  113535. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  113536. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  113537. }
  113538. }
  113539. else {
  113540. particleGlobalPosition.x = particlePosition.x;
  113541. particleGlobalPosition.y = particlePosition.y;
  113542. particleGlobalPosition.z = particlePosition.z;
  113543. if (this._computeParticleRotation || this.billboard) {
  113544. var rotMatrixValues = rotMatrix.m;
  113545. particleRotationMatrix[0] = rotMatrixValues[0];
  113546. particleRotationMatrix[1] = rotMatrixValues[1];
  113547. particleRotationMatrix[2] = rotMatrixValues[2];
  113548. particleRotationMatrix[3] = rotMatrixValues[4];
  113549. particleRotationMatrix[4] = rotMatrixValues[5];
  113550. particleRotationMatrix[5] = rotMatrixValues[6];
  113551. particleRotationMatrix[6] = rotMatrixValues[8];
  113552. particleRotationMatrix[7] = rotMatrixValues[9];
  113553. particleRotationMatrix[8] = rotMatrixValues[10];
  113554. }
  113555. }
  113556. var pivotBackTranslation = tempVectors[11];
  113557. if (particle.translateFromPivot) {
  113558. pivotBackTranslation.setAll(0.0);
  113559. }
  113560. else {
  113561. pivotBackTranslation.copyFrom(scaledPivot);
  113562. }
  113563. // particle vertex loop
  113564. for (pt = 0; pt < shape.length; pt++) {
  113565. idx = index + pt * 3;
  113566. colidx = colorIndex + pt * 4;
  113567. uvidx = uvIndex + pt * 2;
  113568. var tmpVertex = tempVectors[0];
  113569. tmpVertex.copyFrom(shape[pt]);
  113570. if (this._computeParticleVertex) {
  113571. this.updateParticleVertex(particle, tmpVertex, pt);
  113572. }
  113573. // positions
  113574. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  113575. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  113576. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  113577. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  113578. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  113579. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  113580. rotatedX += pivotBackTranslation.x;
  113581. rotatedY += pivotBackTranslation.y;
  113582. rotatedZ += pivotBackTranslation.z;
  113583. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  113584. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  113585. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  113586. if (this._computeBoundingBox) {
  113587. minimum.minimizeInPlaceFromFloats(px, py, pz);
  113588. maximum.maximizeInPlaceFromFloats(px, py, pz);
  113589. }
  113590. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  113591. if (!this._computeParticleVertex) {
  113592. var normalx = fixedNormal32[idx];
  113593. var normaly = fixedNormal32[idx + 1];
  113594. var normalz = fixedNormal32[idx + 2];
  113595. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  113596. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  113597. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  113598. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  113599. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  113600. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  113601. }
  113602. if (this._computeParticleColor && particle.color) {
  113603. var color = particle.color;
  113604. var colors32_1 = this._colors32;
  113605. colors32_1[colidx] = color.r;
  113606. colors32_1[colidx + 1] = color.g;
  113607. colors32_1[colidx + 2] = color.b;
  113608. colors32_1[colidx + 3] = color.a;
  113609. }
  113610. if (this._computeParticleTexture) {
  113611. var uvs = particle.uvs;
  113612. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  113613. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  113614. }
  113615. }
  113616. }
  113617. // particle just set invisible : scaled to zero and positioned at the origin
  113618. else {
  113619. particle._stillInvisible = true; // mark the particle as invisible
  113620. for (pt = 0; pt < shape.length; pt++) {
  113621. idx = index + pt * 3;
  113622. colidx = colorIndex + pt * 4;
  113623. uvidx = uvIndex + pt * 2;
  113624. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  113625. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  113626. if (this._computeParticleColor && particle.color) {
  113627. var color = particle.color;
  113628. colors32[colidx] = color.r;
  113629. colors32[colidx + 1] = color.g;
  113630. colors32[colidx + 2] = color.b;
  113631. colors32[colidx + 3] = color.a;
  113632. }
  113633. if (this._computeParticleTexture) {
  113634. var uvs = particle.uvs;
  113635. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  113636. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  113637. }
  113638. }
  113639. }
  113640. // if the particle intersections must be computed : update the bbInfo
  113641. if (this._particlesIntersect) {
  113642. var bInfo = particle._boundingInfo;
  113643. var bBox = bInfo.boundingBox;
  113644. var bSphere = bInfo.boundingSphere;
  113645. var modelBoundingInfo = particle._modelBoundingInfo;
  113646. if (!this._bSphereOnly) {
  113647. // place, scale and rotate the particle bbox within the SPS local system, then update it
  113648. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  113649. var tempMin = tempVectors[1];
  113650. var tempMax = tempVectors[2];
  113651. tempMin.setAll(Number.MAX_VALUE);
  113652. tempMax.setAll(-Number.MAX_VALUE);
  113653. for (var b = 0; b < 8; b++) {
  113654. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  113655. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  113656. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  113657. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  113658. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  113659. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  113660. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  113661. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  113662. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  113663. tempMin.minimizeInPlaceFromFloats(x, y, z);
  113664. tempMax.maximizeInPlaceFromFloats(x, y, z);
  113665. }
  113666. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  113667. }
  113668. // place and scale the particle bouding sphere in the SPS local system, then update it
  113669. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  113670. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  113671. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  113672. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  113673. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  113674. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  113675. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  113676. }
  113677. // increment indexes for the next particle
  113678. index = idx + 3;
  113679. colorIndex = colidx + 4;
  113680. uvIndex = uvidx + 2;
  113681. }
  113682. // if the VBO must be updated
  113683. if (update) {
  113684. if (this._computeParticleColor) {
  113685. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  113686. }
  113687. if (this._computeParticleTexture) {
  113688. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  113689. }
  113690. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  113691. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  113692. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  113693. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  113694. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  113695. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  113696. for (var i = 0; i < normals32.length; i++) {
  113697. fixedNormal32[i] = normals32[i];
  113698. }
  113699. }
  113700. if (!mesh.areNormalsFrozen) {
  113701. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  113702. }
  113703. }
  113704. if (this._depthSort && this._depthSortParticles) {
  113705. var depthSortedParticles = this.depthSortedParticles;
  113706. depthSortedParticles.sort(depthSortFunction);
  113707. var dspl = depthSortedParticles.length;
  113708. var sid = 0;
  113709. for (var sorted = 0; sorted < dspl; sorted++) {
  113710. var lind = depthSortedParticles[sorted].indicesLength;
  113711. var sind = depthSortedParticles[sorted].ind;
  113712. for (var i = 0; i < lind; i++) {
  113713. indices32[sid] = indices[sind + i];
  113714. sid++;
  113715. }
  113716. }
  113717. mesh.updateIndices(indices32);
  113718. }
  113719. }
  113720. if (this._computeBoundingBox) {
  113721. if (mesh._boundingInfo) {
  113722. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  113723. }
  113724. else {
  113725. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  113726. }
  113727. }
  113728. this.afterUpdateParticles(start, end, update);
  113729. return this;
  113730. };
  113731. /**
  113732. * Disposes the SPS.
  113733. */
  113734. SolidParticleSystem.prototype.dispose = function () {
  113735. this.mesh.dispose();
  113736. this.vars = null;
  113737. // drop references to internal big arrays for the GC
  113738. this._positions = null;
  113739. this._indices = null;
  113740. this._normals = null;
  113741. this._uvs = null;
  113742. this._colors = null;
  113743. this._indices32 = null;
  113744. this._positions32 = null;
  113745. this._normals32 = null;
  113746. this._fixedNormal32 = null;
  113747. this._uvs32 = null;
  113748. this._colors32 = null;
  113749. this.pickedParticles = null;
  113750. };
  113751. /**
  113752. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  113753. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113754. * @returns the SPS.
  113755. */
  113756. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  113757. if (!this._isVisibilityBoxLocked) {
  113758. this.mesh.refreshBoundingInfo();
  113759. }
  113760. return this;
  113761. };
  113762. /**
  113763. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  113764. * @param size the size (float) of the visibility box
  113765. * note : this doesn't lock the SPS mesh bounding box.
  113766. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113767. */
  113768. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  113769. var vis = size / 2;
  113770. 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));
  113771. };
  113772. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  113773. /**
  113774. * Gets whether the SPS as always visible or not
  113775. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113776. */
  113777. get: function () {
  113778. return this._alwaysVisible;
  113779. },
  113780. /**
  113781. * Sets the SPS as always visible or not
  113782. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113783. */
  113784. set: function (val) {
  113785. this._alwaysVisible = val;
  113786. this.mesh.alwaysSelectAsActiveMesh = val;
  113787. },
  113788. enumerable: true,
  113789. configurable: true
  113790. });
  113791. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  113792. /**
  113793. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  113794. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113795. */
  113796. get: function () {
  113797. return this._isVisibilityBoxLocked;
  113798. },
  113799. /**
  113800. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  113801. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113802. */
  113803. set: function (val) {
  113804. this._isVisibilityBoxLocked = val;
  113805. var boundingInfo = this.mesh.getBoundingInfo();
  113806. boundingInfo.isLocked = val;
  113807. },
  113808. enumerable: true,
  113809. configurable: true
  113810. });
  113811. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  113812. /**
  113813. * Gets if `setParticles()` computes the particle rotations or not.
  113814. * Default value : true. The SPS is faster when it's set to false.
  113815. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  113816. */
  113817. get: function () {
  113818. return this._computeParticleRotation;
  113819. },
  113820. /**
  113821. * Tells to `setParticles()` to compute the particle rotations or not.
  113822. * Default value : true. The SPS is faster when it's set to false.
  113823. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  113824. */
  113825. set: function (val) {
  113826. this._computeParticleRotation = val;
  113827. },
  113828. enumerable: true,
  113829. configurable: true
  113830. });
  113831. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  113832. /**
  113833. * Gets if `setParticles()` computes the particle colors or not.
  113834. * Default value : true. The SPS is faster when it's set to false.
  113835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  113836. */
  113837. get: function () {
  113838. return this._computeParticleColor;
  113839. },
  113840. /**
  113841. * Tells to `setParticles()` to compute the particle colors or not.
  113842. * Default value : true. The SPS is faster when it's set to false.
  113843. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  113844. */
  113845. set: function (val) {
  113846. this._computeParticleColor = val;
  113847. },
  113848. enumerable: true,
  113849. configurable: true
  113850. });
  113851. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  113852. /**
  113853. * Gets if `setParticles()` computes the particle textures or not.
  113854. * Default value : true. The SPS is faster when it's set to false.
  113855. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  113856. */
  113857. get: function () {
  113858. return this._computeParticleTexture;
  113859. },
  113860. set: function (val) {
  113861. this._computeParticleTexture = val;
  113862. },
  113863. enumerable: true,
  113864. configurable: true
  113865. });
  113866. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  113867. /**
  113868. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  113869. * Default value : false. The SPS is faster when it's set to false.
  113870. * Note : the particle custom vertex positions aren't stored values.
  113871. */
  113872. get: function () {
  113873. return this._computeParticleVertex;
  113874. },
  113875. /**
  113876. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  113877. * Default value : false. The SPS is faster when it's set to false.
  113878. * Note : the particle custom vertex positions aren't stored values.
  113879. */
  113880. set: function (val) {
  113881. this._computeParticleVertex = val;
  113882. },
  113883. enumerable: true,
  113884. configurable: true
  113885. });
  113886. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  113887. /**
  113888. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  113889. */
  113890. get: function () {
  113891. return this._computeBoundingBox;
  113892. },
  113893. /**
  113894. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  113895. */
  113896. set: function (val) {
  113897. this._computeBoundingBox = val;
  113898. },
  113899. enumerable: true,
  113900. configurable: true
  113901. });
  113902. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  113903. /**
  113904. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  113905. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  113906. * Default : `true`
  113907. */
  113908. get: function () {
  113909. return this._depthSortParticles;
  113910. },
  113911. /**
  113912. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  113913. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  113914. * Default : `true`
  113915. */
  113916. set: function (val) {
  113917. this._depthSortParticles = val;
  113918. },
  113919. enumerable: true,
  113920. configurable: true
  113921. });
  113922. // =======================================================================
  113923. // Particle behavior logic
  113924. // these following methods may be overwritten by the user to fit his needs
  113925. /**
  113926. * This function does nothing. It may be overwritten to set all the particle first values.
  113927. * The SPS doesn't call this function, you may have to call it by your own.
  113928. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  113929. */
  113930. SolidParticleSystem.prototype.initParticles = function () {
  113931. };
  113932. /**
  113933. * This function does nothing. It may be overwritten to recycle a particle.
  113934. * The SPS doesn't call this function, you may have to call it by your own.
  113935. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  113936. * @param particle The particle to recycle
  113937. * @returns the recycled particle
  113938. */
  113939. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  113940. return particle;
  113941. };
  113942. /**
  113943. * Updates a particle : this function should be overwritten by the user.
  113944. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  113945. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  113946. * @example : just set a particle position or velocity and recycle conditions
  113947. * @param particle The particle to update
  113948. * @returns the updated particle
  113949. */
  113950. SolidParticleSystem.prototype.updateParticle = function (particle) {
  113951. return particle;
  113952. };
  113953. /**
  113954. * Updates a vertex of a particle : it can be overwritten by the user.
  113955. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  113956. * @param particle the current particle
  113957. * @param vertex the current index of the current particle
  113958. * @param pt the index of the current vertex in the particle shape
  113959. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  113960. * @example : just set a vertex particle position
  113961. * @returns the updated vertex
  113962. */
  113963. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  113964. return vertex;
  113965. };
  113966. /**
  113967. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  113968. * This does nothing and may be overwritten by the user.
  113969. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113970. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113971. * @param update the boolean update value actually passed to setParticles()
  113972. */
  113973. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  113974. };
  113975. /**
  113976. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  113977. * This will be passed three parameters.
  113978. * This does nothing and may be overwritten by the user.
  113979. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113980. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113981. * @param update the boolean update value actually passed to setParticles()
  113982. */
  113983. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  113984. };
  113985. return SolidParticleSystem;
  113986. }());
  113987. /***/ }),
  113988. /***/ "./Particles/subEmitter.ts":
  113989. /*!*********************************!*\
  113990. !*** ./Particles/subEmitter.ts ***!
  113991. \*********************************/
  113992. /*! exports provided: SubEmitterType, SubEmitter */
  113993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113994. "use strict";
  113995. __webpack_require__.r(__webpack_exports__);
  113996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  113997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  113998. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  113999. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  114000. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  114001. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  114002. /**
  114003. * Type of sub emitter
  114004. */
  114005. var SubEmitterType;
  114006. (function (SubEmitterType) {
  114007. /**
  114008. * Attached to the particle over it's lifetime
  114009. */
  114010. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  114011. /**
  114012. * Created when the particle dies
  114013. */
  114014. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  114015. })(SubEmitterType || (SubEmitterType = {}));
  114016. /**
  114017. * Sub emitter class used to emit particles from an existing particle
  114018. */
  114019. var SubEmitter = /** @class */ (function () {
  114020. /**
  114021. * Creates a sub emitter
  114022. * @param particleSystem the particle system to be used by the sub emitter
  114023. */
  114024. function SubEmitter(
  114025. /**
  114026. * the particle system to be used by the sub emitter
  114027. */
  114028. particleSystem) {
  114029. this.particleSystem = particleSystem;
  114030. /**
  114031. * Type of the submitter (Default: END)
  114032. */
  114033. this.type = SubEmitterType.END;
  114034. /**
  114035. * 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)
  114036. * Note: This only is supported when using an emitter of type Mesh
  114037. */
  114038. this.inheritDirection = false;
  114039. /**
  114040. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  114041. */
  114042. this.inheritedVelocityAmount = 0;
  114043. // Create mesh as emitter to support rotation
  114044. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  114045. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  114046. }
  114047. // Automatically dispose of subemitter when system is disposed
  114048. particleSystem.onDisposeObservable.add(function () {
  114049. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  114050. particleSystem.emitter.dispose();
  114051. }
  114052. });
  114053. }
  114054. /**
  114055. * Clones the sub emitter
  114056. * @returns the cloned sub emitter
  114057. */
  114058. SubEmitter.prototype.clone = function () {
  114059. // Clone particle system
  114060. var emitter = this.particleSystem.emitter;
  114061. if (!emitter) {
  114062. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  114063. }
  114064. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  114065. emitter = emitter.clone();
  114066. }
  114067. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  114068. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  114069. emitter.isVisible = false;
  114070. }
  114071. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  114072. // Clone properties
  114073. clone.type = this.type;
  114074. clone.inheritDirection = this.inheritDirection;
  114075. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  114076. clone.particleSystem._disposeEmitterOnDispose = true;
  114077. clone.particleSystem.disposeOnStop = true;
  114078. return clone;
  114079. };
  114080. /**
  114081. * Serialize current object to a JSON object
  114082. * @returns the serialized object
  114083. */
  114084. SubEmitter.prototype.serialize = function () {
  114085. var serializationObject = {};
  114086. serializationObject.type = this.type;
  114087. serializationObject.inheritDirection = this.inheritDirection;
  114088. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  114089. serializationObject.particleSystem = this.particleSystem.serialize();
  114090. return serializationObject;
  114091. };
  114092. /** @hidden */
  114093. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  114094. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  114095. };
  114096. /**
  114097. * Creates a new SubEmitter from a serialized JSON version
  114098. * @param serializationObject defines the JSON object to read from
  114099. * @param scene defines the hosting scene
  114100. * @param rootUrl defines the rootUrl for data loading
  114101. * @returns a new SubEmitter
  114102. */
  114103. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  114104. var system = serializationObject.particleSystem;
  114105. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  114106. subEmitter.type = serializationObject.type;
  114107. subEmitter.inheritDirection = serializationObject.inheritDirection;
  114108. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  114109. subEmitter.particleSystem._isSubEmitter = true;
  114110. return subEmitter;
  114111. };
  114112. /** Release associated resources */
  114113. SubEmitter.prototype.dispose = function () {
  114114. this.particleSystem.dispose();
  114115. };
  114116. return SubEmitter;
  114117. }());
  114118. /***/ }),
  114119. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  114120. /*!*****************************************!*\
  114121. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  114122. \*****************************************/
  114123. /*! exports provided: AmmoJSPlugin */
  114124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114125. "use strict";
  114126. __webpack_require__.r(__webpack_exports__);
  114127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  114128. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  114129. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  114130. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  114131. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  114132. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  114133. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  114134. /* harmony import */ var _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Meshes/Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  114135. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  114136. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  114137. /**
  114138. * AmmoJS Physics plugin
  114139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114140. * @see https://github.com/kripken/ammo.js/
  114141. */
  114142. var AmmoJSPlugin = /** @class */ (function () {
  114143. /**
  114144. * Initializes the ammoJS plugin
  114145. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  114146. * @param ammoInjection can be used to inject your own ammo reference
  114147. */
  114148. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  114149. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  114150. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  114151. var _this = this;
  114152. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  114153. /**
  114154. * Reference to the Ammo library
  114155. */
  114156. this.bjsAMMO = {};
  114157. /**
  114158. * Name of the plugin
  114159. */
  114160. this.name = "AmmoJSPlugin";
  114161. this._timeStep = 1 / 60;
  114162. this._fixedTimeStep = 1 / 60;
  114163. this._maxSteps = 5;
  114164. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  114165. this._tmpContactCallbackResult = false;
  114166. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  114167. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  114168. if (typeof ammoInjection === "function") {
  114169. ammoInjection(this.bjsAMMO);
  114170. }
  114171. else {
  114172. this.bjsAMMO = ammoInjection;
  114173. }
  114174. if (!this.isSupported()) {
  114175. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  114176. return;
  114177. }
  114178. // Initialize the physics world
  114179. this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration();
  114180. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  114181. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  114182. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  114183. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver();
  114184. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver);
  114185. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  114186. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  114187. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__["PhysicsRaycastResult"]();
  114188. // Create temp ammo variables
  114189. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  114190. this._tmpAmmoTransform.setIdentity();
  114191. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  114192. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  114193. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  114194. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  114195. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0);
  114196. }
  114197. /**
  114198. * Sets the gravity of the physics world (m/(s^2))
  114199. * @param gravity Gravity to set
  114200. */
  114201. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  114202. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  114203. this.world.setGravity(this._tmpAmmoVectorA);
  114204. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
  114205. };
  114206. /**
  114207. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  114208. * @param timeStep timestep to use in seconds
  114209. */
  114210. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  114211. this._timeStep = timeStep;
  114212. };
  114213. /**
  114214. * 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)
  114215. * @param fixedTimeStep fixedTimeStep to use in seconds
  114216. */
  114217. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  114218. this._fixedTimeStep = fixedTimeStep;
  114219. };
  114220. /**
  114221. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  114222. * @param maxSteps the maximum number of steps by the physics engine per frame
  114223. */
  114224. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  114225. this._maxSteps = maxSteps;
  114226. };
  114227. /**
  114228. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  114229. * @returns the current timestep in seconds
  114230. */
  114231. AmmoJSPlugin.prototype.getTimeStep = function () {
  114232. return this._timeStep;
  114233. };
  114234. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  114235. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  114236. this._tmpContactCallbackResult = false;
  114237. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  114238. return this._tmpContactCallbackResult;
  114239. };
  114240. // Ammo's collision events have some weird quirks
  114241. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  114242. // so only fire event if both contactTest and contactPairTest have a hit
  114243. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  114244. this._tmpContactCallbackResult = false;
  114245. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  114246. return this._tmpContactCallbackResult;
  114247. };
  114248. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  114249. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  114250. //
  114251. // When maxSteps is 0 do the entire simulation in one step
  114252. // 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)
  114253. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  114254. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  114255. if (timeStep === void 0) { timeStep = 1 / 60; }
  114256. if (maxSteps === void 0) { maxSteps = 10; }
  114257. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  114258. if (maxSteps == 0) {
  114259. this.world.stepSimulation(timeStep, 0);
  114260. }
  114261. else {
  114262. while (maxSteps > 0 && timeStep > 0) {
  114263. if (timeStep - fixedTimeStep < fixedTimeStep) {
  114264. this.world.stepSimulation(timeStep, 0);
  114265. timeStep = 0;
  114266. }
  114267. else {
  114268. timeStep -= fixedTimeStep;
  114269. this.world.stepSimulation(fixedTimeStep, 0);
  114270. }
  114271. maxSteps--;
  114272. }
  114273. }
  114274. };
  114275. /**
  114276. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  114277. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  114278. * After the step the babylon meshes are set to the position of the physics imposters
  114279. * @param delta amount of time to step forward
  114280. * @param impostors array of imposters to update before/after the step
  114281. */
  114282. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  114283. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  114284. var impostor = impostors_1[_i];
  114285. // Update physics world objects to match babylon world
  114286. if (!impostor.soft) {
  114287. impostor.beforeStep();
  114288. }
  114289. }
  114290. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  114291. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  114292. var mainImpostor = impostors_2[_a];
  114293. // After physics update make babylon world objects match physics world objects
  114294. if (mainImpostor.soft) {
  114295. this._afterSoftStep(mainImpostor);
  114296. }
  114297. else {
  114298. mainImpostor.afterStep();
  114299. }
  114300. // Handle collision event
  114301. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  114302. if (this._isImpostorInContact(mainImpostor)) {
  114303. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  114304. var collideCallback = _c[_b];
  114305. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  114306. var otherImpostor = _e[_d];
  114307. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  114308. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  114309. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  114310. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  114311. }
  114312. }
  114313. }
  114314. }
  114315. }
  114316. }
  114317. }
  114318. };
  114319. /**
  114320. * Update babylon mesh to match physics world object
  114321. * @param impostor imposter to match
  114322. */
  114323. AmmoJSPlugin.prototype._afterSoftStep = function (impostor) {
  114324. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor) {
  114325. this._ropeStep(impostor);
  114326. }
  114327. else {
  114328. this._softbodyOrClothStep(impostor);
  114329. }
  114330. };
  114331. /**
  114332. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114333. * @param impostor imposter to match
  114334. */
  114335. AmmoJSPlugin.prototype._ropeStep = function (impostor) {
  114336. var bodyVertices = impostor.physicsBody.get_m_nodes();
  114337. var nbVertices = bodyVertices.size();
  114338. var node;
  114339. var nodePositions;
  114340. var x, y, z;
  114341. var path = new Array();
  114342. for (var n = 0; n < nbVertices; n++) {
  114343. node = bodyVertices.at(n);
  114344. nodePositions = node.get_m_x();
  114345. x = nodePositions.x();
  114346. y = nodePositions.y();
  114347. z = nodePositions.z();
  114348. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](x, y, z));
  114349. }
  114350. var object = impostor.object;
  114351. var shape = impostor.getParam("shape");
  114352. if (impostor._isFromLine) {
  114353. impostor.object = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines("lines", { points: path, instance: object });
  114354. }
  114355. else {
  114356. impostor.object = _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__["ShapeBuilder"].ExtrudeShape("ext", { shape: shape, path: path, instance: object });
  114357. }
  114358. };
  114359. /**
  114360. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114361. * @param impostor imposter to match
  114362. */
  114363. AmmoJSPlugin.prototype._softbodyOrClothStep = function (impostor) {
  114364. var normalDirection = (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor) ? 1 : -1;
  114365. var object = impostor.object;
  114366. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114367. if (!vertexPositions) {
  114368. vertexPositions = [];
  114369. }
  114370. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  114371. if (!vertexNormals) {
  114372. vertexNormals = [];
  114373. }
  114374. var nbVertices = vertexPositions.length / 3;
  114375. var bodyVertices = impostor.physicsBody.get_m_nodes();
  114376. var node;
  114377. var nodePositions;
  114378. var nodeNormals;
  114379. var x, y, z;
  114380. var nx, ny, nz;
  114381. for (var n = 0; n < nbVertices; n++) {
  114382. node = bodyVertices.at(n);
  114383. nodePositions = node.get_m_x();
  114384. x = nodePositions.x();
  114385. y = nodePositions.y();
  114386. z = nodePositions.z() * normalDirection;
  114387. var nodeNormals = node.get_m_n();
  114388. nx = nodeNormals.x();
  114389. ny = nodeNormals.y();
  114390. nz = nodeNormals.z() * normalDirection;
  114391. vertexPositions[3 * n] = x;
  114392. vertexPositions[3 * n + 1] = y;
  114393. vertexPositions[3 * n + 2] = z;
  114394. vertexNormals[3 * n] = nx;
  114395. vertexNormals[3 * n + 1] = ny;
  114396. vertexNormals[3 * n + 2] = nz;
  114397. }
  114398. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  114399. vertex_data.positions = vertexPositions;
  114400. vertex_data.normals = vertexNormals;
  114401. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  114402. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  114403. if (object && object.getIndices) {
  114404. vertex_data.indices = object.getIndices();
  114405. }
  114406. vertex_data.applyToMesh(object);
  114407. };
  114408. /**
  114409. * Applies an impulse on the imposter
  114410. * @param impostor imposter to apply impulse to
  114411. * @param force amount of force to be applied to the imposter
  114412. * @param contactPoint the location to apply the impulse on the imposter
  114413. */
  114414. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  114415. if (!impostor.soft) {
  114416. impostor.physicsBody.activate();
  114417. var worldPoint = this._tmpAmmoVectorA;
  114418. var impulse = this._tmpAmmoVectorB;
  114419. // Convert contactPoint into world space
  114420. if (impostor.object && impostor.object.getWorldMatrix) {
  114421. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  114422. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  114423. contactPoint = this._tmpVector;
  114424. }
  114425. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  114426. impulse.setValue(force.x, force.y, force.z);
  114427. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  114428. }
  114429. else {
  114430. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  114431. }
  114432. };
  114433. /**
  114434. * Applies a force on the imposter
  114435. * @param impostor imposter to apply force
  114436. * @param force amount of force to be applied to the imposter
  114437. * @param contactPoint the location to apply the force on the imposter
  114438. */
  114439. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  114440. if (!impostor.soft) {
  114441. impostor.physicsBody.activate();
  114442. var worldPoint = this._tmpAmmoVectorA;
  114443. var impulse = this._tmpAmmoVectorB;
  114444. // Convert contactPoint into world space
  114445. if (impostor.object && impostor.object.getWorldMatrix) {
  114446. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  114447. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  114448. contactPoint = this._tmpVector;
  114449. }
  114450. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  114451. impulse.setValue(force.x, force.y, force.z);
  114452. impostor.physicsBody.applyForce(impulse, worldPoint);
  114453. }
  114454. else {
  114455. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  114456. }
  114457. };
  114458. /**
  114459. * Creates a physics body using the plugin
  114460. * @param impostor the imposter to create the physics body on
  114461. */
  114462. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  114463. // Note: this method will not be called on child imposotrs for compound impostors
  114464. impostor._pluginData.toDispose = [];
  114465. //parent-child relationship
  114466. if (impostor.parent) {
  114467. if (impostor.physicsBody) {
  114468. this.removePhysicsBody(impostor);
  114469. impostor.forceUpdate();
  114470. }
  114471. return;
  114472. }
  114473. if (impostor.isBodyInitRequired()) {
  114474. var colShape = this._createShape(impostor);
  114475. var mass = impostor.getParam("mass");
  114476. impostor._pluginData.mass = mass;
  114477. if (impostor.soft) {
  114478. colShape.get_m_cfg().set_collisions(0x11);
  114479. colShape.get_m_cfg().set_kDP(impostor.getParam("damping"));
  114480. Ammo.castObject(colShape, Ammo.btCollisionObject).getCollisionShape().setMargin(impostor.getParam("margin"));
  114481. colShape.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  114482. this.world.addSoftBody(colShape, 1, -1);
  114483. impostor.physicsBody = colShape;
  114484. impostor._pluginData.toDispose.concat([colShape]);
  114485. this.setBodyPressure(impostor, 0);
  114486. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  114487. this.setBodyPressure(impostor, impostor.getParam("pressure"));
  114488. }
  114489. this.setBodyStiffness(impostor, impostor.getParam("stiffness"));
  114490. this.setBodyVelocityIterations(impostor, impostor.getParam("velocityIterations"));
  114491. this.setBodyPositionIterations(impostor, impostor.getParam("positionIterations"));
  114492. }
  114493. else {
  114494. var localInertia = new Ammo.btVector3(0, 0, 0);
  114495. var startTransform = new Ammo.btTransform();
  114496. startTransform.setIdentity();
  114497. if (mass !== 0) {
  114498. colShape.calculateLocalInertia(mass, localInertia);
  114499. }
  114500. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  114501. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  114502. startTransform.setOrigin(this._tmpAmmoVectorA);
  114503. startTransform.setRotation(this._tmpAmmoQuaternion);
  114504. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  114505. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  114506. var body = new Ammo.btRigidBody(rbInfo);
  114507. // Make objects kinematic if it's mass is 0
  114508. if (mass === 0) {
  114509. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  114510. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  114511. }
  114512. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  114513. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  114514. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  114515. }
  114516. this.world.addRigidBody(body);
  114517. impostor.physicsBody = body;
  114518. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  114519. }
  114520. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  114521. this.setBodyFriction(impostor, impostor.getParam("friction"));
  114522. }
  114523. };
  114524. /**
  114525. * Removes the physics body from the imposter and disposes of the body's memory
  114526. * @param impostor imposter to remove the physics body from
  114527. */
  114528. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  114529. var _this = this;
  114530. if (this.world) {
  114531. this.world.removeRigidBody(impostor.physicsBody);
  114532. if (impostor._pluginData) {
  114533. impostor._pluginData.toDispose.forEach(function (d) {
  114534. _this.bjsAMMO.destroy(d);
  114535. });
  114536. }
  114537. }
  114538. };
  114539. /**
  114540. * Generates a joint
  114541. * @param impostorJoint the imposter joint to create the joint with
  114542. */
  114543. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  114544. var mainBody = impostorJoint.mainImpostor.physicsBody;
  114545. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  114546. if (!mainBody || !connectedBody) {
  114547. return;
  114548. }
  114549. var jointData = impostorJoint.joint.jointData;
  114550. if (!jointData.mainPivot) {
  114551. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114552. }
  114553. if (!jointData.connectedPivot) {
  114554. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114555. }
  114556. var joint;
  114557. switch (impostorJoint.joint.type) {
  114558. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  114559. var distance = jointData.maxDistance;
  114560. if (distance) {
  114561. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  114562. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  114563. }
  114564. 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));
  114565. break;
  114566. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  114567. if (!jointData.mainAxis) {
  114568. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114569. }
  114570. if (!jointData.connectedAxis) {
  114571. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114572. }
  114573. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  114574. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  114575. 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);
  114576. break;
  114577. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  114578. 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));
  114579. break;
  114580. default:
  114581. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  114582. 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));
  114583. break;
  114584. }
  114585. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  114586. impostorJoint.joint.physicsJoint = joint;
  114587. };
  114588. /**
  114589. * Removes a joint
  114590. * @param impostorJoint the imposter joint to remove the joint from
  114591. */
  114592. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  114593. if (this.world) {
  114594. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  114595. }
  114596. };
  114597. // adds all verticies (including child verticies) to the triangle mesh
  114598. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  114599. var _this = this;
  114600. var triangleCount = 0;
  114601. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  114602. var indices = object.getIndices();
  114603. if (!indices) {
  114604. indices = [];
  114605. }
  114606. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114607. if (!vertexPositions) {
  114608. vertexPositions = [];
  114609. }
  114610. object.computeWorldMatrix(false);
  114611. var faceCount = indices.length / 3;
  114612. for (var i = 0; i < faceCount; i++) {
  114613. var triPoints = [];
  114614. for (var point = 0; point < 3; point++) {
  114615. 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]);
  114616. // Adjust for initial scaling
  114617. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  114618. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  114619. var vec;
  114620. if (point == 0) {
  114621. vec = this._tmpAmmoVectorA;
  114622. }
  114623. else if (point == 1) {
  114624. vec = this._tmpAmmoVectorB;
  114625. }
  114626. else {
  114627. vec = this._tmpAmmoVectorC;
  114628. }
  114629. vec.setValue(v.x, v.y, v.z);
  114630. triPoints.push(vec);
  114631. }
  114632. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  114633. triangleCount++;
  114634. }
  114635. object.getChildMeshes().forEach(function (m) {
  114636. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  114637. });
  114638. }
  114639. return triangleCount;
  114640. };
  114641. /**
  114642. * Initialise the soft body vertices to match its object's (mesh) vertices
  114643. * Softbody vertices (nodes) are in world space and to match this
  114644. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  114645. * @param impostor to create the softbody for
  114646. */
  114647. AmmoJSPlugin.prototype._softVertexData = function (impostor) {
  114648. var object = impostor.object;
  114649. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  114650. var indices = object.getIndices();
  114651. if (!indices) {
  114652. indices = [];
  114653. }
  114654. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114655. if (!vertexPositions) {
  114656. vertexPositions = [];
  114657. }
  114658. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  114659. if (!vertexNormals) {
  114660. vertexNormals = [];
  114661. }
  114662. object.computeWorldMatrix(false);
  114663. var newPoints = [];
  114664. var newNorms = [];
  114665. for (var i = 0; i < vertexPositions.length; i += 3) {
  114666. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  114667. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  114668. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  114669. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(n, object.getWorldMatrix());
  114670. newPoints.push(v.x, v.y, v.z);
  114671. newNorms.push(n.x, n.y, n.z);
  114672. }
  114673. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  114674. vertex_data.positions = newPoints;
  114675. vertex_data.normals = newNorms;
  114676. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  114677. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  114678. if (object && object.getIndices) {
  114679. vertex_data.indices = object.getIndices();
  114680. }
  114681. vertex_data.applyToMesh(object);
  114682. object.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114683. object.rotationQuaternion = null;
  114684. object.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114685. object.computeWorldMatrix(true);
  114686. return vertex_data;
  114687. }
  114688. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"].ExtractFromMesh(object);
  114689. };
  114690. /**
  114691. * Create an impostor's soft body
  114692. * @param impostor to create the softbody for
  114693. */
  114694. AmmoJSPlugin.prototype._createSoftbody = function (impostor) {
  114695. var object = impostor.object;
  114696. if (object && object.getIndices) {
  114697. var indices = object.getIndices();
  114698. if (!indices) {
  114699. indices = [];
  114700. }
  114701. var vertex_data = this._softVertexData(impostor);
  114702. var vertexPositions = vertex_data.positions;
  114703. var vertexNormals = vertex_data.normals;
  114704. if (vertexPositions === null || vertexNormals === null) {
  114705. return new Ammo.btCompoundShape();
  114706. }
  114707. else {
  114708. var triPoints = [];
  114709. var triNorms = [];
  114710. for (var i = 0; i < vertexPositions.length; i += 3) {
  114711. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  114712. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  114713. triPoints.push(v.x, v.y, -v.z);
  114714. triNorms.push(n.x, n.y, -n.z);
  114715. }
  114716. var softBody = new Ammo.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), triPoints, object.getIndices(), indices.length / 3, true);
  114717. var nbVertices = vertexPositions.length / 3;
  114718. var bodyVertices = softBody.get_m_nodes();
  114719. var node;
  114720. var nodeNormals;
  114721. for (var i = 0; i < nbVertices; i++) {
  114722. node = bodyVertices.at(i);
  114723. var nodeNormals = node.get_m_n();
  114724. nodeNormals.setX(triNorms[3 * i]);
  114725. nodeNormals.setY(triNorms[3 * i + 1]);
  114726. nodeNormals.setZ(triNorms[3 * i + 2]);
  114727. }
  114728. return softBody;
  114729. }
  114730. }
  114731. };
  114732. /**
  114733. * Create cloth for an impostor
  114734. * @param impostor to create the softbody for
  114735. */
  114736. AmmoJSPlugin.prototype._createCloth = function (impostor) {
  114737. var object = impostor.object;
  114738. if (object && object.getIndices) {
  114739. var indices = object.getIndices();
  114740. if (!indices) {
  114741. indices = [];
  114742. }
  114743. var vertex_data = this._softVertexData(impostor);
  114744. var vertexPositions = vertex_data.positions;
  114745. var vertexNormals = vertex_data.normals;
  114746. if (vertexPositions === null || vertexNormals === null) {
  114747. return new Ammo.btCompoundShape();
  114748. }
  114749. else {
  114750. var len = vertexPositions.length;
  114751. var segments = Math.sqrt(len / 3);
  114752. impostor.segments = segments;
  114753. var segs = segments - 1;
  114754. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  114755. this._tmpAmmoVectorB.setValue(vertexPositions[3 * segs], vertexPositions[3 * segs + 1], vertexPositions[3 * segs + 2]);
  114756. this._tmpAmmoVectorD.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  114757. this._tmpAmmoVectorC.setValue(vertexPositions[len - 3 - 3 * segs], vertexPositions[len - 2 - 3 * segs], vertexPositions[len - 1 - 3 * segs]);
  114758. var clothBody = new Ammo.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, segments, segments, impostor.getParam("fixedPoints"), true);
  114759. return clothBody;
  114760. }
  114761. }
  114762. };
  114763. /**
  114764. * Create rope for an impostor
  114765. * @param impostor to create the softbody for
  114766. */
  114767. AmmoJSPlugin.prototype._createRope = function (impostor) {
  114768. var len;
  114769. var segments;
  114770. var vertex_data = this._softVertexData(impostor);
  114771. var vertexPositions = vertex_data.positions;
  114772. var vertexNormals = vertex_data.normals;
  114773. if (vertexPositions === null || vertexNormals === null) {
  114774. return new Ammo.btCompoundShape();
  114775. }
  114776. //force the mesh to be updatable
  114777. vertex_data.applyToMesh(impostor.object, true);
  114778. impostor._isFromLine = true;
  114779. // If in lines mesh all normals will be zero
  114780. var vertexSquared = vertexNormals.map(function (x) { return x * x; });
  114781. var reducer = function (accumulator, currentValue) { return accumulator + currentValue; };
  114782. var reduced = vertexSquared.reduce(reducer);
  114783. if (reduced === 0) { // line mesh
  114784. len = vertexPositions.length;
  114785. segments = len / 3 - 1;
  114786. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  114787. this._tmpAmmoVectorB.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  114788. }
  114789. else { //extruded mesh
  114790. impostor._isFromLine = false;
  114791. var pathVectors = impostor.getParam("path");
  114792. var shape = impostor.getParam("shape");
  114793. if (shape === null) {
  114794. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("No shape available for extruded mesh");
  114795. return new Ammo.btCompoundShape();
  114796. }
  114797. if ((vertexPositions.length % (3 * pathVectors.length)) !== 0) {
  114798. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Path does not match extrusion");
  114799. return new Ammo.btCompoundShape();
  114800. }
  114801. len = pathVectors.length;
  114802. segments = len - 1;
  114803. this._tmpAmmoVectorA.setValue(pathVectors[0].x, pathVectors[0].y, pathVectors[0].z);
  114804. this._tmpAmmoVectorB.setValue(pathVectors[len - 1].x, pathVectors[len - 1].y, pathVectors[len - 1].z);
  114805. }
  114806. impostor.segments = segments;
  114807. var fixedPoints = impostor.getParam("fixedPoints");
  114808. fixedPoints = (fixedPoints > 3) ? 3 : fixedPoints;
  114809. var ropeBody = new Ammo.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, segments - 1, fixedPoints);
  114810. ropeBody.get_m_cfg().set_collisions(0x11);
  114811. return ropeBody;
  114812. };
  114813. // adds all verticies (including child verticies) to the convex hull shape
  114814. AmmoJSPlugin.prototype._addHullVerts = function (btConvexHullShape, topLevelObject, object) {
  114815. var _this = this;
  114816. var triangleCount = 0;
  114817. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  114818. var indices = object.getIndices();
  114819. if (!indices) {
  114820. indices = [];
  114821. }
  114822. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114823. if (!vertexPositions) {
  114824. vertexPositions = [];
  114825. }
  114826. object.computeWorldMatrix(false);
  114827. var faceCount = indices.length / 3;
  114828. for (var i = 0; i < faceCount; i++) {
  114829. var triPoints = [];
  114830. for (var point = 0; point < 3; point++) {
  114831. 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]);
  114832. // Adjust for initial scaling
  114833. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  114834. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  114835. var vec;
  114836. if (point == 0) {
  114837. vec = this._tmpAmmoVectorA;
  114838. }
  114839. else if (point == 1) {
  114840. vec = this._tmpAmmoVectorB;
  114841. }
  114842. else {
  114843. vec = this._tmpAmmoVectorC;
  114844. }
  114845. vec.setValue(v.x, v.y, v.z);
  114846. triPoints.push(vec);
  114847. }
  114848. btConvexHullShape.addPoint(triPoints[0], true);
  114849. btConvexHullShape.addPoint(triPoints[1], true);
  114850. btConvexHullShape.addPoint(triPoints[2], true);
  114851. triangleCount++;
  114852. }
  114853. object.getChildMeshes().forEach(function (m) {
  114854. triangleCount += _this._addHullVerts(btConvexHullShape, topLevelObject, m);
  114855. });
  114856. }
  114857. return triangleCount;
  114858. };
  114859. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  114860. var _this = this;
  114861. if (ignoreChildren === void 0) { ignoreChildren = false; }
  114862. var object = impostor.object;
  114863. var returnValue;
  114864. var extendSize = impostor.getObjectExtendSize();
  114865. if (!ignoreChildren) {
  114866. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  114867. returnValue = new Ammo.btCompoundShape();
  114868. // Add shape of all children to the compound shape
  114869. var childrenAdded = 0;
  114870. meshChildren.forEach(function (childMesh) {
  114871. var childImpostor = childMesh.getPhysicsImpostor();
  114872. if (childImpostor) {
  114873. if (childImpostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor) {
  114874. throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
  114875. }
  114876. var shape = _this._createShape(childImpostor);
  114877. // Position needs to be scaled based on parent's scaling
  114878. var parentMat = childMesh.parent.getWorldMatrix().clone();
  114879. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  114880. parentMat.decompose(s);
  114881. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  114882. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  114883. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  114884. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  114885. childImpostor.dispose();
  114886. childrenAdded++;
  114887. }
  114888. });
  114889. if (childrenAdded > 0) {
  114890. // Add parents shape as a child if present
  114891. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  114892. var shape = this._createShape(impostor, true);
  114893. if (shape) {
  114894. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  114895. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  114896. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  114897. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  114898. }
  114899. }
  114900. return returnValue;
  114901. }
  114902. else {
  114903. // If no children with impostors create the actual shape below instead
  114904. Ammo.destroy(returnValue);
  114905. returnValue = null;
  114906. }
  114907. }
  114908. switch (impostor.type) {
  114909. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  114910. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  114911. break;
  114912. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  114913. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  114914. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  114915. break;
  114916. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  114917. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  114918. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  114919. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  114920. break;
  114921. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  114922. if (impostor.getParam("mass") == 0) {
  114923. // Only create btBvhTriangleMeshShape impostor is static
  114924. // See https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=7283
  114925. var tetraMesh = new Ammo.btTriangleMesh();
  114926. impostor._pluginData.toDispose.concat([tetraMesh]);
  114927. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  114928. if (triangeCount == 0) {
  114929. returnValue = new Ammo.btCompoundShape();
  114930. }
  114931. else {
  114932. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  114933. }
  114934. break;
  114935. }
  114936. // Otherwise create convexHullImpostor
  114937. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ConvexHullImpostor:
  114938. var convexMesh = new Ammo.btConvexHullShape();
  114939. var triangeCount = this._addHullVerts(convexMesh, object, object);
  114940. if (triangeCount == 0) {
  114941. // Cleanup Unused Convex Hull Shape
  114942. impostor._pluginData.toDispose.concat([convexMesh]);
  114943. returnValue = new Ammo.btCompoundShape();
  114944. }
  114945. else {
  114946. returnValue = convexMesh;
  114947. }
  114948. break;
  114949. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  114950. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  114951. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  114952. break;
  114953. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor:
  114954. // Only usable with a mesh that has sufficient and shared vertices
  114955. returnValue = this._createSoftbody(impostor);
  114956. break;
  114957. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor:
  114958. // Only usable with a ground mesh that has sufficient and shared vertices
  114959. returnValue = this._createCloth(impostor);
  114960. break;
  114961. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor:
  114962. // Only usable with a line mesh or an extruded mesh that is updatable
  114963. returnValue = this._createRope(impostor);
  114964. break;
  114965. default:
  114966. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  114967. break;
  114968. }
  114969. return returnValue;
  114970. };
  114971. /**
  114972. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  114973. * @param impostor imposter containing the physics body and babylon object
  114974. */
  114975. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  114976. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  114977. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  114978. if (!impostor.object.rotationQuaternion) {
  114979. if (impostor.object.rotation) {
  114980. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  114981. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  114982. }
  114983. }
  114984. else {
  114985. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  114986. }
  114987. };
  114988. /**
  114989. * Sets the babylon object's position/rotation from the physics body's position/rotation
  114990. * @param impostor imposter containing the physics body and babylon object
  114991. * @param newPosition new position
  114992. * @param newRotation new rotation
  114993. */
  114994. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  114995. var trans = impostor.physicsBody.getWorldTransform();
  114996. // If rotation/position has changed update and activate riged body
  114997. if (trans.getOrigin().x() != newPosition.x ||
  114998. trans.getOrigin().y() != newPosition.y ||
  114999. trans.getOrigin().z() != newPosition.z ||
  115000. trans.getRotation().x() != newRotation.x ||
  115001. trans.getRotation().y() != newRotation.y ||
  115002. trans.getRotation().z() != newRotation.z ||
  115003. trans.getRotation().w() != newRotation.w) {
  115004. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  115005. trans.setOrigin(this._tmpAmmoVectorA);
  115006. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  115007. trans.setRotation(this._tmpAmmoQuaternion);
  115008. impostor.physicsBody.setWorldTransform(trans);
  115009. if (impostor.mass == 0) {
  115010. // Kinematic objects must be updated using motion state
  115011. var motionState = impostor.physicsBody.getMotionState();
  115012. if (motionState) {
  115013. motionState.setWorldTransform(trans);
  115014. }
  115015. }
  115016. else {
  115017. impostor.physicsBody.activate();
  115018. }
  115019. }
  115020. };
  115021. /**
  115022. * If this plugin is supported
  115023. * @returns true if its supported
  115024. */
  115025. AmmoJSPlugin.prototype.isSupported = function () {
  115026. return this.bjsAMMO !== undefined;
  115027. };
  115028. /**
  115029. * Sets the linear velocity of the physics body
  115030. * @param impostor imposter to set the velocity on
  115031. * @param velocity velocity to set
  115032. */
  115033. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  115034. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  115035. if (impostor.soft) {
  115036. impostor.physicsBody.linearVelocity(this._tmpAmmoVectorA);
  115037. }
  115038. else {
  115039. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  115040. }
  115041. };
  115042. /**
  115043. * Sets the angular velocity of the physics body
  115044. * @param impostor imposter to set the velocity on
  115045. * @param velocity velocity to set
  115046. */
  115047. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  115048. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  115049. if (impostor.soft) {
  115050. impostor.physicsBody.angularVelocity(this._tmpAmmoVectorA);
  115051. }
  115052. else {
  115053. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  115054. }
  115055. };
  115056. /**
  115057. * gets the linear velocity
  115058. * @param impostor imposter to get linear velocity from
  115059. * @returns linear velocity
  115060. */
  115061. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  115062. if (impostor.soft) {
  115063. var v = impostor.physicsBody.linearVelocity();
  115064. }
  115065. else {
  115066. var v = impostor.physicsBody.getLinearVelocity();
  115067. }
  115068. if (!v) {
  115069. return null;
  115070. }
  115071. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  115072. };
  115073. /**
  115074. * gets the angular velocity
  115075. * @param impostor imposter to get angular velocity from
  115076. * @returns angular velocity
  115077. */
  115078. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  115079. if (impostor.soft) {
  115080. var v = impostor.physicsBody.angularVelocity();
  115081. }
  115082. else {
  115083. var v = impostor.physicsBody.getAngularVelocity();
  115084. }
  115085. if (!v) {
  115086. return null;
  115087. }
  115088. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  115089. };
  115090. /**
  115091. * Sets the mass of physics body
  115092. * @param impostor imposter to set the mass on
  115093. * @param mass mass to set
  115094. */
  115095. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  115096. if (impostor.soft) {
  115097. impostor.physicsBody.setTotalMass(mass, false);
  115098. }
  115099. else {
  115100. impostor.physicsBody.setMassProps(mass);
  115101. }
  115102. impostor._pluginData.mass = mass;
  115103. };
  115104. /**
  115105. * Gets the mass of the physics body
  115106. * @param impostor imposter to get the mass from
  115107. * @returns mass
  115108. */
  115109. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  115110. return impostor._pluginData.mass || 0;
  115111. };
  115112. /**
  115113. * Gets friction of the impostor
  115114. * @param impostor impostor to get friction from
  115115. * @returns friction value
  115116. */
  115117. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  115118. return impostor._pluginData.friction || 0;
  115119. };
  115120. /**
  115121. * Sets friction of the impostor
  115122. * @param impostor impostor to set friction on
  115123. * @param friction friction value
  115124. */
  115125. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  115126. if (impostor.soft) {
  115127. impostor.physicsBody.get_m_cfg().set_kDF(friction);
  115128. }
  115129. else {
  115130. impostor.physicsBody.setFriction(friction);
  115131. }
  115132. impostor._pluginData.friction = friction;
  115133. };
  115134. /**
  115135. * Gets restitution of the impostor
  115136. * @param impostor impostor to get restitution from
  115137. * @returns restitution value
  115138. */
  115139. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  115140. return impostor._pluginData.restitution || 0;
  115141. };
  115142. /**
  115143. * Sets resitution of the impostor
  115144. * @param impostor impostor to set resitution on
  115145. * @param restitution resitution value
  115146. */
  115147. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  115148. impostor.physicsBody.setRestitution(restitution);
  115149. impostor._pluginData.restitution = restitution;
  115150. };
  115151. /**
  115152. * Gets pressure inside the impostor
  115153. * @param impostor impostor to get pressure from
  115154. * @returns pressure value
  115155. */
  115156. AmmoJSPlugin.prototype.getBodyPressure = function (impostor) {
  115157. if (!impostor.soft) {
  115158. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure is not a property of a rigid body");
  115159. return 0;
  115160. }
  115161. return impostor._pluginData.pressure || 0;
  115162. };
  115163. /**
  115164. * Sets pressure inside a soft body impostor
  115165. * Cloth and rope must remain 0 pressure
  115166. * @param impostor impostor to set pressure on
  115167. * @param pressure pressure value
  115168. */
  115169. AmmoJSPlugin.prototype.setBodyPressure = function (impostor, pressure) {
  115170. if (impostor.soft) {
  115171. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  115172. impostor.physicsBody.get_m_cfg().set_kPR(pressure);
  115173. impostor._pluginData.pressure = pressure;
  115174. }
  115175. else {
  115176. impostor.physicsBody.get_m_cfg().set_kPR(0);
  115177. impostor._pluginData.pressure = 0;
  115178. }
  115179. }
  115180. else {
  115181. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure can only be applied to a softbody");
  115182. }
  115183. };
  115184. /**
  115185. * Gets stiffness of the impostor
  115186. * @param impostor impostor to get stiffness from
  115187. * @returns pressure value
  115188. */
  115189. AmmoJSPlugin.prototype.getBodyStiffness = function (impostor) {
  115190. if (!impostor.soft) {
  115191. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness is not a property of a rigid body");
  115192. return 0;
  115193. }
  115194. return impostor._pluginData.stiffness || 0;
  115195. };
  115196. /**
  115197. * Sets stiffness of the impostor
  115198. * @param impostor impostor to set stiffness on
  115199. * @param stiffness stiffness value from 0 to 1
  115200. */
  115201. AmmoJSPlugin.prototype.setBodyStiffness = function (impostor, stiffness) {
  115202. if (impostor.soft) {
  115203. stiffness = stiffness < 0 ? 0 : stiffness;
  115204. stiffness = stiffness > 1 ? 1 : stiffness;
  115205. impostor.physicsBody.get_m_materials().at(0).set_m_kLST(stiffness);
  115206. impostor._pluginData.stiffness = stiffness;
  115207. }
  115208. else {
  115209. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness cannot be applied to a rigid body");
  115210. }
  115211. };
  115212. /**
  115213. * Gets velocityIterations of the impostor
  115214. * @param impostor impostor to get velocity iterations from
  115215. * @returns velocityIterations value
  115216. */
  115217. AmmoJSPlugin.prototype.getBodyVelocityIterations = function (impostor) {
  115218. if (!impostor.soft) {
  115219. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations is not a property of a rigid body");
  115220. return 0;
  115221. }
  115222. return impostor._pluginData.velocityIterations || 0;
  115223. };
  115224. /**
  115225. * Sets velocityIterations of the impostor
  115226. * @param impostor impostor to set velocity iterations on
  115227. * @param velocityIterations velocityIterations value
  115228. */
  115229. AmmoJSPlugin.prototype.setBodyVelocityIterations = function (impostor, velocityIterations) {
  115230. if (impostor.soft) {
  115231. velocityIterations = velocityIterations < 0 ? 0 : velocityIterations;
  115232. impostor.physicsBody.get_m_cfg().set_viterations(velocityIterations);
  115233. impostor._pluginData.velocityIterations = velocityIterations;
  115234. }
  115235. else {
  115236. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations cannot be applied to a rigid body");
  115237. }
  115238. };
  115239. /**
  115240. * Gets positionIterations of the impostor
  115241. * @param impostor impostor to get position iterations from
  115242. * @returns positionIterations value
  115243. */
  115244. AmmoJSPlugin.prototype.getBodyPositionIterations = function (impostor) {
  115245. if (!impostor.soft) {
  115246. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations is not a property of a rigid body");
  115247. return 0;
  115248. }
  115249. return impostor._pluginData.positionIterations || 0;
  115250. };
  115251. /**
  115252. * Sets positionIterations of the impostor
  115253. * @param impostor impostor to set position on
  115254. * @param positionIterations positionIterations value
  115255. */
  115256. AmmoJSPlugin.prototype.setBodyPositionIterations = function (impostor, positionIterations) {
  115257. if (impostor.soft) {
  115258. positionIterations = positionIterations < 0 ? 0 : positionIterations;
  115259. impostor.physicsBody.get_m_cfg().set_piterations(positionIterations);
  115260. impostor._pluginData.positionIterations = positionIterations;
  115261. }
  115262. else {
  115263. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations cannot be applied to a rigid body");
  115264. }
  115265. };
  115266. /**
  115267. * Append an anchor to a cloth object
  115268. * @param impostor is the cloth impostor to add anchor to
  115269. * @param otherImpostor is the rigid impostor to anchor to
  115270. * @param width ratio across width from 0 to 1
  115271. * @param height ratio up height from 0 to 1
  115272. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  115273. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115274. */
  115275. AmmoJSPlugin.prototype.appendAnchor = function (impostor, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  115276. if (influence === void 0) { influence = 1; }
  115277. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  115278. var segs = impostor.segments;
  115279. var nbAcross = Math.round((segs - 1) * width);
  115280. var nbUp = Math.round((segs - 1) * height);
  115281. var nbDown = segs - 1 - nbUp;
  115282. var node = nbAcross + segs * nbDown;
  115283. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  115284. };
  115285. /**
  115286. * Append an hook to a rope object
  115287. * @param impostor is the rope impostor to add hook to
  115288. * @param otherImpostor is the rigid impostor to hook to
  115289. * @param length ratio along the rope from 0 to 1
  115290. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  115291. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  115292. */
  115293. AmmoJSPlugin.prototype.appendHook = function (impostor, otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  115294. if (influence === void 0) { influence = 1; }
  115295. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  115296. var node = Math.round(impostor.segments * length);
  115297. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  115298. };
  115299. /**
  115300. * Sleeps the physics body and stops it from being active
  115301. * @param impostor impostor to sleep
  115302. */
  115303. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  115304. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  115305. };
  115306. /**
  115307. * Activates the physics body
  115308. * @param impostor impostor to activate
  115309. */
  115310. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  115311. impostor.physicsBody.activate();
  115312. };
  115313. /**
  115314. * Updates the distance parameters of the joint
  115315. * @param joint joint to update
  115316. * @param maxDistance maximum distance of the joint
  115317. * @param minDistance minimum distance of the joint
  115318. */
  115319. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  115320. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  115321. };
  115322. /**
  115323. * Sets a motor on the joint
  115324. * @param joint joint to set motor on
  115325. * @param speed speed of the motor
  115326. * @param maxForce maximum force of the motor
  115327. * @param motorIndex index of the motor
  115328. */
  115329. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  115330. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  115331. };
  115332. /**
  115333. * Sets the motors limit
  115334. * @param joint joint to set limit on
  115335. * @param upperLimit upper limit
  115336. * @param lowerLimit lower limit
  115337. */
  115338. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  115339. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  115340. };
  115341. /**
  115342. * Syncs the position and rotation of a mesh with the impostor
  115343. * @param mesh mesh to sync
  115344. * @param impostor impostor to update the mesh with
  115345. */
  115346. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  115347. var body = impostor.physicsBody;
  115348. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  115349. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  115350. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  115351. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  115352. if (mesh.rotationQuaternion) {
  115353. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  115354. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  115355. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  115356. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  115357. }
  115358. };
  115359. /**
  115360. * Gets the radius of the impostor
  115361. * @param impostor impostor to get radius from
  115362. * @returns the radius
  115363. */
  115364. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  115365. var exntend = impostor.getObjectExtendSize();
  115366. return exntend.x / 2;
  115367. };
  115368. /**
  115369. * Gets the box size of the impostor
  115370. * @param impostor impostor to get box size from
  115371. * @param result the resulting box size
  115372. */
  115373. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  115374. var exntend = impostor.getObjectExtendSize();
  115375. result.x = exntend.x;
  115376. result.y = exntend.y;
  115377. result.z = exntend.z;
  115378. };
  115379. /**
  115380. * Disposes of the impostor
  115381. */
  115382. AmmoJSPlugin.prototype.dispose = function () {
  115383. // Dispose of world
  115384. Ammo.destroy(this.world);
  115385. Ammo.destroy(this._solver);
  115386. Ammo.destroy(this._overlappingPairCache);
  115387. Ammo.destroy(this._dispatcher);
  115388. Ammo.destroy(this._collisionConfiguration);
  115389. // Dispose of tmp variables
  115390. Ammo.destroy(this._tmpAmmoVectorA);
  115391. Ammo.destroy(this._tmpAmmoVectorB);
  115392. Ammo.destroy(this._tmpAmmoVectorC);
  115393. Ammo.destroy(this._tmpAmmoTransform);
  115394. Ammo.destroy(this._tmpAmmoQuaternion);
  115395. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  115396. this.world = null;
  115397. };
  115398. /**
  115399. * Does a raycast in the physics world
  115400. * @param from when should the ray start?
  115401. * @param to when should the ray end?
  115402. * @returns PhysicsRaycastResult
  115403. */
  115404. AmmoJSPlugin.prototype.raycast = function (from, to) {
  115405. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(from.x, from.y, from.z);
  115406. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(to.x, to.y, to.z);
  115407. var rayCallback = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
  115408. this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, rayCallback);
  115409. this._raycastResult.reset(from, to);
  115410. if (rayCallback.hasHit()) {
  115411. // TODO: do we want/need the body? If so, set all the data
  115412. /*
  115413. var rigidBody = this.bjsAMMO.btRigidBody.prototype.upcast(
  115414. rayCallback.get_m_collisionObject()
  115415. );
  115416. var body = {};
  115417. */
  115418. this._raycastResult.setHitData({
  115419. x: rayCallback.get_m_hitNormalWorld().x(),
  115420. y: rayCallback.get_m_hitNormalWorld().y(),
  115421. z: rayCallback.get_m_hitNormalWorld().z(),
  115422. }, {
  115423. x: rayCallback.get_m_hitPointWorld().x(),
  115424. y: rayCallback.get_m_hitPointWorld().y(),
  115425. z: rayCallback.get_m_hitPointWorld().z(),
  115426. });
  115427. this._raycastResult.calculateHitDistance();
  115428. }
  115429. return this._raycastResult;
  115430. };
  115431. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  115432. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  115433. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  115434. return AmmoJSPlugin;
  115435. }());
  115436. /***/ }),
  115437. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  115438. /*!*******************************************!*\
  115439. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  115440. \*******************************************/
  115441. /*! exports provided: CannonJSPlugin */
  115442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115443. "use strict";
  115444. __webpack_require__.r(__webpack_exports__);
  115445. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  115446. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  115447. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  115448. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  115449. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  115450. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  115451. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  115452. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  115453. /** @hidden */
  115454. var CannonJSPlugin = /** @class */ (function () {
  115455. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  115456. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  115457. if (iterations === void 0) { iterations = 10; }
  115458. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  115459. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  115460. this.name = "CannonJSPlugin";
  115461. this._physicsMaterials = new Array();
  115462. this._fixedTimeStep = 1 / 60;
  115463. this._removeAfterStep = new Array();
  115464. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  115465. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  115466. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  115467. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  115468. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  115469. this.BJSCANNON = cannonInjection;
  115470. if (!this.isSupported()) {
  115471. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  115472. return;
  115473. }
  115474. this._extendNamespace();
  115475. this.world = new this.BJSCANNON.World();
  115476. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  115477. this.world.solver.iterations = iterations;
  115478. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();
  115479. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__["PhysicsRaycastResult"]();
  115480. }
  115481. CannonJSPlugin.prototype.setGravity = function (gravity) {
  115482. this.world.gravity.copy(gravity);
  115483. };
  115484. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  115485. this._fixedTimeStep = timeStep;
  115486. };
  115487. CannonJSPlugin.prototype.getTimeStep = function () {
  115488. return this._fixedTimeStep;
  115489. };
  115490. CannonJSPlugin.prototype.executeStep = function (delta) {
  115491. var _this = this;
  115492. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  115493. if (this._removeAfterStep.length > 0) {
  115494. this._removeAfterStep.forEach(function (impostor) {
  115495. _this.world.remove(impostor.physicsBody);
  115496. });
  115497. this._removeAfterStep = [];
  115498. }
  115499. };
  115500. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  115501. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  115502. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  115503. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  115504. };
  115505. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  115506. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  115507. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  115508. impostor.physicsBody.applyForce(impulse, worldPoint);
  115509. };
  115510. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  115511. //parent-child relationship. Does this impostor has a parent impostor?
  115512. if (impostor.parent) {
  115513. if (impostor.physicsBody) {
  115514. this.removePhysicsBody(impostor);
  115515. //TODO is that needed?
  115516. impostor.forceUpdate();
  115517. }
  115518. return;
  115519. }
  115520. //should a new body be created for this impostor?
  115521. if (impostor.isBodyInitRequired()) {
  115522. var shape = this._createShape(impostor);
  115523. //unregister events, if body is being changed
  115524. var oldBody = impostor.physicsBody;
  115525. if (oldBody) {
  115526. this.removePhysicsBody(impostor);
  115527. }
  115528. //create the body and material
  115529. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  115530. var bodyCreationObject = {
  115531. mass: impostor.getParam("mass"),
  115532. material: material
  115533. };
  115534. // A simple extend, in case native options were used.
  115535. var nativeOptions = impostor.getParam("nativeOptions");
  115536. for (var key in nativeOptions) {
  115537. if (nativeOptions.hasOwnProperty(key)) {
  115538. bodyCreationObject[key] = nativeOptions[key];
  115539. }
  115540. }
  115541. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  115542. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  115543. this.world.addEventListener("preStep", impostor.beforeStep);
  115544. this.world.addEventListener("postStep", impostor.afterStep);
  115545. impostor.physicsBody.addShape(shape);
  115546. this.world.add(impostor.physicsBody);
  115547. //try to keep the body moving in the right direction by taking old properties.
  115548. //Should be tested!
  115549. if (oldBody) {
  115550. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  115551. impostor.physicsBody[param].copy(oldBody[param]);
  115552. });
  115553. }
  115554. this._processChildMeshes(impostor);
  115555. }
  115556. //now update the body's transformation
  115557. this._updatePhysicsBodyTransformation(impostor);
  115558. };
  115559. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  115560. var _this = this;
  115561. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  115562. var currentRotation = mainImpostor.object.rotationQuaternion;
  115563. if (meshChildren.length) {
  115564. var processMesh = function (localPosition, mesh) {
  115565. if (!currentRotation || !mesh.rotationQuaternion) {
  115566. return;
  115567. }
  115568. var childImpostor = mesh.getPhysicsImpostor();
  115569. if (childImpostor) {
  115570. var parent = childImpostor.parent;
  115571. if (parent !== mainImpostor) {
  115572. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  115573. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  115574. if (childImpostor.physicsBody) {
  115575. _this.removePhysicsBody(childImpostor);
  115576. childImpostor.physicsBody = null;
  115577. }
  115578. childImpostor.parent = mainImpostor;
  115579. childImpostor.resetUpdateFlags();
  115580. 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));
  115581. //Add the mass of the children.
  115582. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  115583. }
  115584. }
  115585. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  115586. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  115587. };
  115588. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  115589. }
  115590. };
  115591. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  115592. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  115593. this.world.removeEventListener("preStep", impostor.beforeStep);
  115594. this.world.removeEventListener("postStep", impostor.afterStep);
  115595. // Only remove the physics body after the physics step to avoid disrupting cannon's internal state
  115596. this._removeAfterStep.push(impostor);
  115597. };
  115598. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  115599. var mainBody = impostorJoint.mainImpostor.physicsBody;
  115600. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  115601. if (!mainBody || !connectedBody) {
  115602. return;
  115603. }
  115604. var constraint;
  115605. var jointData = impostorJoint.joint.jointData;
  115606. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  115607. var constraintData = {
  115608. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  115609. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  115610. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  115611. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  115612. maxForce: jointData.nativeParams.maxForce,
  115613. collideConnected: !!jointData.collision
  115614. };
  115615. switch (impostorJoint.joint.type) {
  115616. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  115617. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  115618. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  115619. break;
  115620. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  115621. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  115622. break;
  115623. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  115624. var springData = jointData;
  115625. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  115626. restLength: springData.length,
  115627. stiffness: springData.stiffness,
  115628. damping: springData.damping,
  115629. localAnchorA: constraintData.pivotA,
  115630. localAnchorB: constraintData.pivotB
  115631. });
  115632. break;
  115633. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  115634. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  115635. break;
  115636. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  115637. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  115638. default:
  115639. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  115640. break;
  115641. }
  115642. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  115643. constraint.collideConnected = !!jointData.collision;
  115644. impostorJoint.joint.physicsJoint = constraint;
  115645. //don't add spring as constraint, as it is not one.
  115646. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  115647. this.world.addConstraint(constraint);
  115648. }
  115649. else {
  115650. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  115651. constraint.applyForce();
  115652. };
  115653. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  115654. }
  115655. };
  115656. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  115657. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  115658. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  115659. }
  115660. else {
  115661. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  115662. }
  115663. };
  115664. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  115665. var index;
  115666. var mat;
  115667. for (index = 0; index < this._physicsMaterials.length; index++) {
  115668. mat = this._physicsMaterials[index];
  115669. if (mat.friction === friction && mat.restitution === restitution) {
  115670. return mat;
  115671. }
  115672. }
  115673. var currentMat = new this.BJSCANNON.Material(name);
  115674. currentMat.friction = friction;
  115675. currentMat.restitution = restitution;
  115676. this._physicsMaterials.push(currentMat);
  115677. return currentMat;
  115678. };
  115679. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  115680. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  115681. };
  115682. CannonJSPlugin.prototype._createShape = function (impostor) {
  115683. var object = impostor.object;
  115684. var returnValue;
  115685. var extendSize = impostor.getObjectExtendSize();
  115686. switch (impostor.type) {
  115687. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  115688. var radiusX = extendSize.x;
  115689. var radiusY = extendSize.y;
  115690. var radiusZ = extendSize.z;
  115691. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  115692. break;
  115693. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  115694. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  115695. var nativeParams = impostor.getParam("nativeOptions");
  115696. if (!nativeParams) {
  115697. nativeParams = {};
  115698. }
  115699. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  115700. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  115701. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  115702. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  115703. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  115704. // Rotate 90 degrees as this shape is horizontal in cannon
  115705. var quat = new this.BJSCANNON.Quaternion();
  115706. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  115707. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  115708. returnValue.transformAllPoints(translation, quat);
  115709. break;
  115710. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  115711. var box = extendSize.scale(0.5);
  115712. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  115713. break;
  115714. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  115715. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  115716. returnValue = new this.BJSCANNON.Plane();
  115717. break;
  115718. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  115719. // should transform the vertex data to world coordinates!!
  115720. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  115721. var rawFaces = object.getIndices ? object.getIndices() : [];
  115722. if (!rawVerts) {
  115723. return;
  115724. }
  115725. // get only scale! so the object could transform correctly.
  115726. var oldPosition = object.position.clone();
  115727. var oldRotation = object.rotation && object.rotation.clone();
  115728. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  115729. object.position.copyFromFloats(0, 0, 0);
  115730. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  115731. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  115732. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  115733. var transform = object.computeWorldMatrix(true);
  115734. // convert rawVerts to object space
  115735. var temp = new Array();
  115736. var index;
  115737. for (index = 0; index < rawVerts.length; index += 3) {
  115738. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  115739. }
  115740. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  115741. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  115742. //now set back the transformation!
  115743. object.position.copyFrom(oldPosition);
  115744. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  115745. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  115746. break;
  115747. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  115748. var oldPosition2 = object.position.clone();
  115749. var oldRotation2 = object.rotation && object.rotation.clone();
  115750. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  115751. object.position.copyFromFloats(0, 0, 0);
  115752. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  115753. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  115754. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  115755. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  115756. returnValue = this._createHeightmap(object);
  115757. object.position.copyFrom(oldPosition2);
  115758. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  115759. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  115760. object.computeWorldMatrix(true);
  115761. break;
  115762. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  115763. returnValue = new this.BJSCANNON.Particle();
  115764. break;
  115765. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  115766. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  115767. break;
  115768. }
  115769. return returnValue;
  115770. };
  115771. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  115772. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  115773. var transform = object.computeWorldMatrix(true);
  115774. // convert rawVerts to object space
  115775. var temp = new Array();
  115776. var index;
  115777. for (index = 0; index < pos.length; index += 3) {
  115778. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  115779. }
  115780. pos = temp;
  115781. var matrix = new Array();
  115782. //For now pointDepth will not be used and will be automatically calculated.
  115783. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  115784. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  115785. var boundingInfo = object.getBoundingInfo();
  115786. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  115787. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  115788. var elementSize = dim * 2 / arraySize;
  115789. for (var i = 0; i < pos.length; i = i + 3) {
  115790. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  115791. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  115792. var y = -pos[i + 2] + minY;
  115793. if (!matrix[x]) {
  115794. matrix[x] = [];
  115795. }
  115796. if (!matrix[x][z]) {
  115797. matrix[x][z] = y;
  115798. }
  115799. matrix[x][z] = Math.max(y, matrix[x][z]);
  115800. }
  115801. for (var x = 0; x <= arraySize; ++x) {
  115802. if (!matrix[x]) {
  115803. var loc = 1;
  115804. while (!matrix[(x + loc) % arraySize]) {
  115805. loc++;
  115806. }
  115807. matrix[x] = matrix[(x + loc) % arraySize].slice();
  115808. //console.log("missing x", x);
  115809. }
  115810. for (var z = 0; z <= arraySize; ++z) {
  115811. if (!matrix[x][z]) {
  115812. var loc = 1;
  115813. var newValue;
  115814. while (newValue === undefined) {
  115815. newValue = matrix[x][(z + loc++) % arraySize];
  115816. }
  115817. matrix[x][z] = newValue;
  115818. }
  115819. }
  115820. }
  115821. var shape = new this.BJSCANNON.Heightfield(matrix, {
  115822. elementSize: elementSize
  115823. });
  115824. //For future reference, needed for body transformation
  115825. shape.minY = minY;
  115826. return shape;
  115827. };
  115828. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  115829. var object = impostor.object;
  115830. //make sure it is updated...
  115831. object.computeWorldMatrix && object.computeWorldMatrix(true);
  115832. // The delta between the mesh position and the mesh bounding box center
  115833. var bInfo = object.getBoundingInfo();
  115834. if (!bInfo) {
  115835. return;
  115836. }
  115837. var center = impostor.getObjectCenter();
  115838. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  115839. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  115840. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  115841. this._tmpPosition.copyFrom(center);
  115842. var quaternion = object.rotationQuaternion;
  115843. if (!quaternion) {
  115844. return;
  115845. }
  115846. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  115847. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  115848. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  115849. //-90 DEG in X, precalculated
  115850. quaternion = quaternion.multiply(this._minus90X);
  115851. //Invert! (Precalculated, 90 deg in X)
  115852. //No need to clone. this will never change.
  115853. impostor.setDeltaRotation(this._plus90X);
  115854. }
  115855. //If it is a heightfield, if should be centered.
  115856. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  115857. var mesh = object;
  115858. var boundingInfo = mesh.getBoundingInfo();
  115859. //calculate the correct body position:
  115860. var rotationQuaternion = mesh.rotationQuaternion;
  115861. mesh.rotationQuaternion = this._tmpUnityRotation;
  115862. mesh.computeWorldMatrix(true);
  115863. //get original center with no rotation
  115864. var c = center.clone();
  115865. var oldPivot = mesh.getPivotMatrix();
  115866. if (oldPivot) {
  115867. // create a copy the pivot Matrix as it is modified in place
  115868. oldPivot = oldPivot.clone();
  115869. }
  115870. else {
  115871. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  115872. }
  115873. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  115874. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  115875. mesh.setPreTransformMatrix(p);
  115876. mesh.computeWorldMatrix(true);
  115877. //calculate the translation
  115878. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  115879. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  115880. //add it inverted to the delta
  115881. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  115882. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  115883. //rotation is back
  115884. mesh.rotationQuaternion = rotationQuaternion;
  115885. mesh.setPreTransformMatrix(oldPivot);
  115886. mesh.computeWorldMatrix(true);
  115887. }
  115888. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  115889. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  115890. //this._tmpPosition.copyFrom(object.position);
  115891. }
  115892. impostor.setDeltaPosition(this._tmpDeltaPosition);
  115893. //Now update the impostor object
  115894. impostor.physicsBody.position.copy(this._tmpPosition);
  115895. impostor.physicsBody.quaternion.copy(quaternion);
  115896. };
  115897. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  115898. impostor.object.position.copyFrom(impostor.physicsBody.position);
  115899. if (impostor.object.rotationQuaternion) {
  115900. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  115901. }
  115902. };
  115903. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  115904. impostor.physicsBody.position.copy(newPosition);
  115905. impostor.physicsBody.quaternion.copy(newRotation);
  115906. };
  115907. CannonJSPlugin.prototype.isSupported = function () {
  115908. return this.BJSCANNON !== undefined;
  115909. };
  115910. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  115911. impostor.physicsBody.velocity.copy(velocity);
  115912. };
  115913. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  115914. impostor.physicsBody.angularVelocity.copy(velocity);
  115915. };
  115916. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  115917. var v = impostor.physicsBody.velocity;
  115918. if (!v) {
  115919. return null;
  115920. }
  115921. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  115922. };
  115923. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  115924. var v = impostor.physicsBody.angularVelocity;
  115925. if (!v) {
  115926. return null;
  115927. }
  115928. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  115929. };
  115930. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  115931. impostor.physicsBody.mass = mass;
  115932. impostor.physicsBody.updateMassProperties();
  115933. };
  115934. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  115935. return impostor.physicsBody.mass;
  115936. };
  115937. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  115938. return impostor.physicsBody.material.friction;
  115939. };
  115940. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  115941. impostor.physicsBody.material.friction = friction;
  115942. };
  115943. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  115944. return impostor.physicsBody.material.restitution;
  115945. };
  115946. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  115947. impostor.physicsBody.material.restitution = restitution;
  115948. };
  115949. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  115950. impostor.physicsBody.sleep();
  115951. };
  115952. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  115953. impostor.physicsBody.wakeUp();
  115954. };
  115955. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  115956. joint.physicsJoint.distance = maxDistance;
  115957. };
  115958. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  115959. // if (!motorIndex) {
  115960. // joint.physicsJoint.enableMotor();
  115961. // }
  115962. // }
  115963. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  115964. // if (!motorIndex) {
  115965. // joint.physicsJoint.disableMotor();
  115966. // }
  115967. // }
  115968. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  115969. if (!motorIndex) {
  115970. joint.physicsJoint.enableMotor();
  115971. joint.physicsJoint.setMotorSpeed(speed);
  115972. if (maxForce) {
  115973. this.setLimit(joint, maxForce);
  115974. }
  115975. }
  115976. };
  115977. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  115978. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  115979. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  115980. };
  115981. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  115982. var body = impostor.physicsBody;
  115983. mesh.position.x = body.position.x;
  115984. mesh.position.y = body.position.y;
  115985. mesh.position.z = body.position.z;
  115986. if (mesh.rotationQuaternion) {
  115987. mesh.rotationQuaternion.x = body.quaternion.x;
  115988. mesh.rotationQuaternion.y = body.quaternion.y;
  115989. mesh.rotationQuaternion.z = body.quaternion.z;
  115990. mesh.rotationQuaternion.w = body.quaternion.w;
  115991. }
  115992. };
  115993. CannonJSPlugin.prototype.getRadius = function (impostor) {
  115994. var shape = impostor.physicsBody.shapes[0];
  115995. return shape.boundingSphereRadius;
  115996. };
  115997. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  115998. var shape = impostor.physicsBody.shapes[0];
  115999. result.x = shape.halfExtents.x * 2;
  116000. result.y = shape.halfExtents.y * 2;
  116001. result.z = shape.halfExtents.z * 2;
  116002. };
  116003. CannonJSPlugin.prototype.dispose = function () {
  116004. };
  116005. CannonJSPlugin.prototype._extendNamespace = function () {
  116006. //this will force cannon to execute at least one step when using interpolation
  116007. var step_tmp1 = new this.BJSCANNON.Vec3();
  116008. var Engine = this.BJSCANNON;
  116009. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  116010. maxSubSteps = maxSubSteps || 10;
  116011. timeSinceLastCalled = timeSinceLastCalled || 0;
  116012. if (timeSinceLastCalled === 0) {
  116013. this.internalStep(dt);
  116014. this.time += dt;
  116015. }
  116016. else {
  116017. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  116018. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  116019. var t0 = performance.now();
  116020. for (var i = 0; i !== internalSteps; i++) {
  116021. this.internalStep(dt);
  116022. if (performance.now() - t0 > dt * 1000) {
  116023. break;
  116024. }
  116025. }
  116026. this.time += timeSinceLastCalled;
  116027. var h = this.time % dt;
  116028. var h_div_dt = h / dt;
  116029. var interpvelo = step_tmp1;
  116030. var bodies = this.bodies;
  116031. for (var j = 0; j !== bodies.length; j++) {
  116032. var b = bodies[j];
  116033. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  116034. b.position.vsub(b.previousPosition, interpvelo);
  116035. interpvelo.scale(h_div_dt, interpvelo);
  116036. b.position.vadd(interpvelo, b.interpolatedPosition);
  116037. }
  116038. else {
  116039. b.interpolatedPosition.copy(b.position);
  116040. b.interpolatedQuaternion.copy(b.quaternion);
  116041. }
  116042. }
  116043. }
  116044. };
  116045. };
  116046. /**
  116047. * Does a raycast in the physics world
  116048. * @param from when should the ray start?
  116049. * @param to when should the ray end?
  116050. * @returns PhysicsRaycastResult
  116051. */
  116052. CannonJSPlugin.prototype.raycast = function (from, to) {
  116053. this._cannonRaycastResult.reset();
  116054. this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);
  116055. this._raycastResult.reset(from, to);
  116056. if (this._cannonRaycastResult.hasHit) {
  116057. // TODO: do we also want to get the body it hit?
  116058. this._raycastResult.setHitData({
  116059. x: this._cannonRaycastResult.hitNormalWorld.x,
  116060. y: this._cannonRaycastResult.hitNormalWorld.y,
  116061. z: this._cannonRaycastResult.hitNormalWorld.z,
  116062. }, {
  116063. x: this._cannonRaycastResult.hitPointWorld.x,
  116064. y: this._cannonRaycastResult.hitPointWorld.y,
  116065. z: this._cannonRaycastResult.hitPointWorld.z,
  116066. });
  116067. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);
  116068. }
  116069. return this._raycastResult;
  116070. };
  116071. return CannonJSPlugin;
  116072. }());
  116073. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  116074. /***/ }),
  116075. /***/ "./Physics/Plugins/index.ts":
  116076. /*!**********************************!*\
  116077. !*** ./Physics/Plugins/index.ts ***!
  116078. \**********************************/
  116079. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  116080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116081. "use strict";
  116082. __webpack_require__.r(__webpack_exports__);
  116083. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  116084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  116085. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  116086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  116087. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  116088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  116089. /***/ }),
  116090. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  116091. /*!*****************************************!*\
  116092. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  116093. \*****************************************/
  116094. /*! exports provided: OimoJSPlugin */
  116095. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116096. "use strict";
  116097. __webpack_require__.r(__webpack_exports__);
  116098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  116099. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  116100. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  116101. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  116102. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  116103. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  116104. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  116105. /** @hidden */
  116106. var OimoJSPlugin = /** @class */ (function () {
  116107. function OimoJSPlugin(iterations, oimoInjection) {
  116108. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  116109. this.name = "OimoJSPlugin";
  116110. this._tmpImpostorsArray = [];
  116111. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  116112. this.BJSOIMO = oimoInjection;
  116113. this.world = new this.BJSOIMO.World({
  116114. iterations: iterations
  116115. });
  116116. this.world.clear();
  116117. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__["PhysicsRaycastResult"]();
  116118. }
  116119. OimoJSPlugin.prototype.setGravity = function (gravity) {
  116120. this.world.gravity.copy(gravity);
  116121. };
  116122. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  116123. this.world.timeStep = timeStep;
  116124. };
  116125. OimoJSPlugin.prototype.getTimeStep = function () {
  116126. return this.world.timeStep;
  116127. };
  116128. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  116129. var _this = this;
  116130. impostors.forEach(function (impostor) {
  116131. impostor.beforeStep();
  116132. });
  116133. this.world.step();
  116134. impostors.forEach(function (impostor) {
  116135. impostor.afterStep();
  116136. //update the ordered impostors array
  116137. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  116138. });
  116139. //check for collisions
  116140. var contact = this.world.contacts;
  116141. while (contact !== null) {
  116142. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  116143. contact = contact.next;
  116144. continue;
  116145. }
  116146. //is this body colliding with any other? get the impostor
  116147. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  116148. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  116149. if (!mainImpostor || !collidingImpostor) {
  116150. contact = contact.next;
  116151. continue;
  116152. }
  116153. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  116154. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  116155. contact = contact.next;
  116156. }
  116157. };
  116158. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  116159. var mass = impostor.physicsBody.mass;
  116160. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  116161. };
  116162. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  116163. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  116164. this.applyImpulse(impostor, force, contactPoint);
  116165. };
  116166. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  116167. var _this = this;
  116168. //parent-child relationship. Does this impostor has a parent impostor?
  116169. if (impostor.parent) {
  116170. if (impostor.physicsBody) {
  116171. this.removePhysicsBody(impostor);
  116172. //TODO is that needed?
  116173. impostor.forceUpdate();
  116174. }
  116175. return;
  116176. }
  116177. if (impostor.isBodyInitRequired()) {
  116178. var bodyConfig = {
  116179. name: impostor.uniqueId,
  116180. //Oimo must have mass, also for static objects.
  116181. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  116182. size: [],
  116183. type: [],
  116184. pos: [],
  116185. posShape: [],
  116186. rot: [],
  116187. rotShape: [],
  116188. move: impostor.getParam("mass") !== 0,
  116189. density: impostor.getParam("mass"),
  116190. friction: impostor.getParam("friction"),
  116191. restitution: impostor.getParam("restitution"),
  116192. //Supporting older versions of Oimo
  116193. world: this.world
  116194. };
  116195. var impostors = [impostor];
  116196. var addToArray = function (parent) {
  116197. if (!parent.getChildMeshes) {
  116198. return;
  116199. }
  116200. parent.getChildMeshes().forEach(function (m) {
  116201. if (m.physicsImpostor) {
  116202. impostors.push(m.physicsImpostor);
  116203. //m.physicsImpostor._init();
  116204. }
  116205. });
  116206. };
  116207. addToArray(impostor.object);
  116208. var checkWithEpsilon_1 = function (value) {
  116209. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  116210. };
  116211. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  116212. impostors.forEach(function (i) {
  116213. if (!i.object.rotationQuaternion) {
  116214. return;
  116215. }
  116216. //get the correct bounding box
  116217. var oldQuaternion = i.object.rotationQuaternion;
  116218. globalQuaternion_1 = oldQuaternion.clone();
  116219. var rot = oldQuaternion.toEulerAngles();
  116220. var extendSize = i.getObjectExtendSize();
  116221. var radToDeg = 57.295779513082320876;
  116222. if (i === impostor) {
  116223. var center = impostor.getObjectCenter();
  116224. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  116225. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  116226. //Can also use Array.prototype.push.apply
  116227. bodyConfig.pos.push(center.x);
  116228. bodyConfig.pos.push(center.y);
  116229. bodyConfig.pos.push(center.z);
  116230. bodyConfig.posShape.push(0, 0, 0);
  116231. bodyConfig.rotShape.push(0, 0, 0);
  116232. }
  116233. else {
  116234. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  116235. bodyConfig.posShape.push(localPosition.x);
  116236. bodyConfig.posShape.push(localPosition.y);
  116237. bodyConfig.posShape.push(localPosition.z);
  116238. bodyConfig.pos.push(0, 0, 0);
  116239. bodyConfig.rotShape.push(rot.x * radToDeg);
  116240. bodyConfig.rotShape.push(rot.y * radToDeg);
  116241. bodyConfig.rotShape.push(rot.z * radToDeg);
  116242. }
  116243. // register mesh
  116244. switch (i.type) {
  116245. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  116246. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  116247. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  116248. var radiusX = extendSize.x;
  116249. var radiusY = extendSize.y;
  116250. var radiusZ = extendSize.z;
  116251. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  116252. bodyConfig.type.push('sphere');
  116253. //due to the way oimo works with compounds, add 3 times
  116254. bodyConfig.size.push(size);
  116255. bodyConfig.size.push(size);
  116256. bodyConfig.size.push(size);
  116257. break;
  116258. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  116259. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  116260. var sizeY = checkWithEpsilon_1(extendSize.y);
  116261. bodyConfig.type.push('cylinder');
  116262. bodyConfig.size.push(sizeX);
  116263. bodyConfig.size.push(sizeY);
  116264. //due to the way oimo works with compounds, add one more value.
  116265. bodyConfig.size.push(sizeY);
  116266. break;
  116267. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  116268. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  116269. default:
  116270. var sizeX = checkWithEpsilon_1(extendSize.x);
  116271. var sizeY = checkWithEpsilon_1(extendSize.y);
  116272. var sizeZ = checkWithEpsilon_1(extendSize.z);
  116273. bodyConfig.type.push('box');
  116274. //if (i === impostor) {
  116275. bodyConfig.size.push(sizeX);
  116276. bodyConfig.size.push(sizeY);
  116277. bodyConfig.size.push(sizeZ);
  116278. //} else {
  116279. // bodyConfig.size.push(0,0,0);
  116280. //}
  116281. break;
  116282. }
  116283. //actually not needed, but hey...
  116284. i.object.rotationQuaternion = oldQuaternion;
  116285. });
  116286. impostor.physicsBody = this.world.add(bodyConfig);
  116287. // set the quaternion, ignoring the previously defined (euler) rotation
  116288. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  116289. // update with delta 0, so the body will reveive the new rotation.
  116290. impostor.physicsBody.updatePosition(0);
  116291. }
  116292. else {
  116293. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  116294. }
  116295. impostor.setDeltaPosition(this._tmpPositionVector);
  116296. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  116297. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  116298. };
  116299. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  116300. //impostor.physicsBody.dispose();
  116301. //Same as : (older oimo versions)
  116302. this.world.removeRigidBody(impostor.physicsBody);
  116303. };
  116304. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  116305. var mainBody = impostorJoint.mainImpostor.physicsBody;
  116306. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  116307. if (!mainBody || !connectedBody) {
  116308. return;
  116309. }
  116310. var jointData = impostorJoint.joint.jointData;
  116311. var options = jointData.nativeParams || {};
  116312. var type;
  116313. var nativeJointData = {
  116314. body1: mainBody,
  116315. body2: connectedBody,
  116316. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  116317. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  116318. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  116319. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  116320. min: options.min,
  116321. max: options.max,
  116322. collision: options.collision || jointData.collision,
  116323. spring: options.spring,
  116324. //supporting older version of Oimo
  116325. world: this.world
  116326. };
  116327. switch (impostorJoint.joint.type) {
  116328. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  116329. type = "jointBall";
  116330. break;
  116331. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  116332. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  116333. var springData = jointData;
  116334. nativeJointData.min = springData.length || nativeJointData.min;
  116335. //Max should also be set, just make sure it is at least min
  116336. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  116337. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  116338. type = "jointDistance";
  116339. nativeJointData.max = jointData.maxDistance;
  116340. break;
  116341. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  116342. type = "jointPrisme";
  116343. break;
  116344. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  116345. type = "jointSlide";
  116346. break;
  116347. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  116348. type = "jointWheel";
  116349. break;
  116350. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  116351. default:
  116352. type = "jointHinge";
  116353. break;
  116354. }
  116355. nativeJointData.type = type;
  116356. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  116357. };
  116358. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  116359. //Bug in Oimo prevents us from disposing a joint in the playground
  116360. //joint.joint.physicsJoint.dispose();
  116361. //So we will bruteforce it!
  116362. try {
  116363. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  116364. }
  116365. catch (e) {
  116366. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  116367. }
  116368. };
  116369. OimoJSPlugin.prototype.isSupported = function () {
  116370. return this.BJSOIMO !== undefined;
  116371. };
  116372. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  116373. if (!impostor.physicsBody.sleeping) {
  116374. //TODO check that
  116375. /*if (impostor.physicsBody.shapes.next) {
  116376. var parentShape = this._getLastShape(impostor.physicsBody);
  116377. impostor.object.position.copyFrom(parentShape.position);
  116378. console.log(parentShape.position);
  116379. } else {*/
  116380. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  116381. //}
  116382. if (impostor.object.rotationQuaternion) {
  116383. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  116384. }
  116385. }
  116386. };
  116387. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  116388. var body = impostor.physicsBody;
  116389. body.position.copy(newPosition);
  116390. body.orientation.copy(newRotation);
  116391. body.syncShapes();
  116392. body.awake();
  116393. };
  116394. /*private _getLastShape(body: any): any {
  116395. var lastShape = body.shapes;
  116396. while (lastShape.next) {
  116397. lastShape = lastShape.next;
  116398. }
  116399. return lastShape;
  116400. }*/
  116401. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  116402. impostor.physicsBody.linearVelocity.copy(velocity);
  116403. };
  116404. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  116405. impostor.physicsBody.angularVelocity.copy(velocity);
  116406. };
  116407. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  116408. var v = impostor.physicsBody.linearVelocity;
  116409. if (!v) {
  116410. return null;
  116411. }
  116412. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  116413. };
  116414. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  116415. var v = impostor.physicsBody.angularVelocity;
  116416. if (!v) {
  116417. return null;
  116418. }
  116419. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  116420. };
  116421. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  116422. var staticBody = mass === 0;
  116423. //this will actually set the body's density and not its mass.
  116424. //But this is how oimo treats the mass variable.
  116425. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  116426. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  116427. };
  116428. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  116429. return impostor.physicsBody.shapes.density;
  116430. };
  116431. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  116432. return impostor.physicsBody.shapes.friction;
  116433. };
  116434. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  116435. impostor.physicsBody.shapes.friction = friction;
  116436. };
  116437. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  116438. return impostor.physicsBody.shapes.restitution;
  116439. };
  116440. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  116441. impostor.physicsBody.shapes.restitution = restitution;
  116442. };
  116443. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  116444. impostor.physicsBody.sleep();
  116445. };
  116446. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  116447. impostor.physicsBody.awake();
  116448. };
  116449. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  116450. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  116451. if (minDistance !== void 0) {
  116452. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  116453. }
  116454. };
  116455. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  116456. if (force !== undefined) {
  116457. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  116458. }
  116459. else {
  116460. force = 1e6;
  116461. }
  116462. speed *= -1;
  116463. //TODO separate rotational and transational motors.
  116464. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  116465. if (motor) {
  116466. motor.setMotor(speed, force);
  116467. }
  116468. };
  116469. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  116470. //TODO separate rotational and transational motors.
  116471. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  116472. if (motor) {
  116473. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  116474. }
  116475. };
  116476. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  116477. var body = impostor.physicsBody;
  116478. mesh.position.x = body.position.x;
  116479. mesh.position.y = body.position.y;
  116480. mesh.position.z = body.position.z;
  116481. if (mesh.rotationQuaternion) {
  116482. mesh.rotationQuaternion.x = body.orientation.x;
  116483. mesh.rotationQuaternion.y = body.orientation.y;
  116484. mesh.rotationQuaternion.z = body.orientation.z;
  116485. mesh.rotationQuaternion.w = body.orientation.s;
  116486. }
  116487. };
  116488. OimoJSPlugin.prototype.getRadius = function (impostor) {
  116489. return impostor.physicsBody.shapes.radius;
  116490. };
  116491. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  116492. var shape = impostor.physicsBody.shapes;
  116493. result.x = shape.halfWidth * 2;
  116494. result.y = shape.halfHeight * 2;
  116495. result.z = shape.halfDepth * 2;
  116496. };
  116497. OimoJSPlugin.prototype.dispose = function () {
  116498. this.world.clear();
  116499. };
  116500. /**
  116501. * Does a raycast in the physics world
  116502. * @param from when should the ray start?
  116503. * @param to when should the ray end?
  116504. * @returns PhysicsRaycastResult
  116505. */
  116506. OimoJSPlugin.prototype.raycast = function (from, to) {
  116507. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("raycast is not currently supported by the Oimo physics plugin");
  116508. this._raycastResult.reset(from, to);
  116509. return this._raycastResult;
  116510. };
  116511. return OimoJSPlugin;
  116512. }());
  116513. /***/ }),
  116514. /***/ "./Physics/index.ts":
  116515. /*!**************************!*\
  116516. !*** ./Physics/index.ts ***!
  116517. \**************************/
  116518. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  116519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116520. "use strict";
  116521. __webpack_require__.r(__webpack_exports__);
  116522. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  116523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  116524. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  116525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  116526. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  116527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  116528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEventOptions"]; });
  116529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEventOptions"]; });
  116530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEventOptions"]; });
  116531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  116532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  116533. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  116534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  116535. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  116536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  116537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  116538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  116539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  116540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  116541. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  116542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  116543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  116544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  116545. /***/ }),
  116546. /***/ "./Physics/physicsEngine.ts":
  116547. /*!**********************************!*\
  116548. !*** ./Physics/physicsEngine.ts ***!
  116549. \**********************************/
  116550. /*! exports provided: PhysicsEngine */
  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__, "PhysicsEngine", function() { return PhysicsEngine; });
  116555. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116556. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  116557. /**
  116558. * Class used to control physics engine
  116559. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116560. */
  116561. var PhysicsEngine = /** @class */ (function () {
  116562. /**
  116563. * Creates a new Physics Engine
  116564. * @param gravity defines the gravity vector used by the simulation
  116565. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116566. */
  116567. function PhysicsEngine(gravity, _physicsPlugin) {
  116568. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  116569. this._physicsPlugin = _physicsPlugin;
  116570. this._impostors = [];
  116571. this._joints = [];
  116572. if (!this._physicsPlugin.isSupported()) {
  116573. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  116574. + "Please make sure it is included.");
  116575. }
  116576. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  116577. this.setGravity(gravity);
  116578. this.setTimeStep();
  116579. }
  116580. /**
  116581. * Factory used to create the default physics plugin.
  116582. * @returns The default physics plugin
  116583. */
  116584. PhysicsEngine.DefaultPluginFactory = function () {
  116585. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  116586. };
  116587. /**
  116588. * Sets the gravity vector used by the simulation
  116589. * @param gravity defines the gravity vector to use
  116590. */
  116591. PhysicsEngine.prototype.setGravity = function (gravity) {
  116592. this.gravity = gravity;
  116593. this._physicsPlugin.setGravity(this.gravity);
  116594. };
  116595. /**
  116596. * Set the time step of the physics engine.
  116597. * Default is 1/60.
  116598. * To slow it down, enter 1/600 for example.
  116599. * To speed it up, 1/30
  116600. * @param newTimeStep defines the new timestep to apply to this world.
  116601. */
  116602. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  116603. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  116604. this._physicsPlugin.setTimeStep(newTimeStep);
  116605. };
  116606. /**
  116607. * Get the time step of the physics engine.
  116608. * @returns the current time step
  116609. */
  116610. PhysicsEngine.prototype.getTimeStep = function () {
  116611. return this._physicsPlugin.getTimeStep();
  116612. };
  116613. /**
  116614. * Release all resources
  116615. */
  116616. PhysicsEngine.prototype.dispose = function () {
  116617. this._impostors.forEach(function (impostor) {
  116618. impostor.dispose();
  116619. });
  116620. this._physicsPlugin.dispose();
  116621. };
  116622. /**
  116623. * Gets the name of the current physics plugin
  116624. * @returns the name of the plugin
  116625. */
  116626. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  116627. return this._physicsPlugin.name;
  116628. };
  116629. /**
  116630. * Adding a new impostor for the impostor tracking.
  116631. * This will be done by the impostor itself.
  116632. * @param impostor the impostor to add
  116633. */
  116634. PhysicsEngine.prototype.addImpostor = function (impostor) {
  116635. impostor.uniqueId = this._impostors.push(impostor);
  116636. //if no parent, generate the body
  116637. if (!impostor.parent) {
  116638. this._physicsPlugin.generatePhysicsBody(impostor);
  116639. }
  116640. };
  116641. /**
  116642. * Remove an impostor from the engine.
  116643. * This impostor and its mesh will not longer be updated by the physics engine.
  116644. * @param impostor the impostor to remove
  116645. */
  116646. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  116647. var index = this._impostors.indexOf(impostor);
  116648. if (index > -1) {
  116649. var removed = this._impostors.splice(index, 1);
  116650. //Is it needed?
  116651. if (removed.length) {
  116652. this.getPhysicsPlugin().removePhysicsBody(impostor);
  116653. }
  116654. }
  116655. };
  116656. /**
  116657. * Add a joint to the physics engine
  116658. * @param mainImpostor defines the main impostor to which the joint is added.
  116659. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116660. * @param joint defines the joint that will connect both impostors.
  116661. */
  116662. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  116663. var impostorJoint = {
  116664. mainImpostor: mainImpostor,
  116665. connectedImpostor: connectedImpostor,
  116666. joint: joint
  116667. };
  116668. joint.physicsPlugin = this._physicsPlugin;
  116669. this._joints.push(impostorJoint);
  116670. this._physicsPlugin.generateJoint(impostorJoint);
  116671. };
  116672. /**
  116673. * Removes a joint from the simulation
  116674. * @param mainImpostor defines the impostor used with the joint
  116675. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116676. * @param joint defines the joint to remove
  116677. */
  116678. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  116679. var matchingJoints = this._joints.filter(function (impostorJoint) {
  116680. return (impostorJoint.connectedImpostor === connectedImpostor
  116681. && impostorJoint.joint === joint
  116682. && impostorJoint.mainImpostor === mainImpostor);
  116683. });
  116684. if (matchingJoints.length) {
  116685. this._physicsPlugin.removeJoint(matchingJoints[0]);
  116686. //TODO remove it from the list as well
  116687. }
  116688. };
  116689. /**
  116690. * Called by the scene. No need to call it.
  116691. * @param delta defines the timespam between frames
  116692. */
  116693. PhysicsEngine.prototype._step = function (delta) {
  116694. var _this = this;
  116695. //check if any mesh has no body / requires an update
  116696. this._impostors.forEach(function (impostor) {
  116697. if (impostor.isBodyInitRequired()) {
  116698. _this._physicsPlugin.generatePhysicsBody(impostor);
  116699. }
  116700. });
  116701. if (delta > 0.1) {
  116702. delta = 0.1;
  116703. }
  116704. else if (delta <= 0) {
  116705. delta = 1.0 / 60.0;
  116706. }
  116707. this._physicsPlugin.executeStep(delta, this._impostors);
  116708. };
  116709. /**
  116710. * Gets the current plugin used to run the simulation
  116711. * @returns current plugin
  116712. */
  116713. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  116714. return this._physicsPlugin;
  116715. };
  116716. /**
  116717. * Gets the list of physic impostors
  116718. * @returns an array of PhysicsImpostor
  116719. */
  116720. PhysicsEngine.prototype.getImpostors = function () {
  116721. return this._impostors;
  116722. };
  116723. /**
  116724. * Gets the impostor for a physics enabled object
  116725. * @param object defines the object impersonated by the impostor
  116726. * @returns the PhysicsImpostor or null if not found
  116727. */
  116728. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  116729. for (var i = 0; i < this._impostors.length; ++i) {
  116730. if (this._impostors[i].object === object) {
  116731. return this._impostors[i];
  116732. }
  116733. }
  116734. return null;
  116735. };
  116736. /**
  116737. * Gets the impostor for a physics body object
  116738. * @param body defines physics body used by the impostor
  116739. * @returns the PhysicsImpostor or null if not found
  116740. */
  116741. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  116742. for (var i = 0; i < this._impostors.length; ++i) {
  116743. if (this._impostors[i].physicsBody === body) {
  116744. return this._impostors[i];
  116745. }
  116746. }
  116747. return null;
  116748. };
  116749. /**
  116750. * Does a raycast in the physics world
  116751. * @param from when should the ray start?
  116752. * @param to when should the ray end?
  116753. * @returns PhysicsRaycastResult
  116754. */
  116755. PhysicsEngine.prototype.raycast = function (from, to) {
  116756. return this._physicsPlugin.raycast(from, to);
  116757. };
  116758. /**
  116759. * Global value used to control the smallest number supported by the simulation
  116760. */
  116761. PhysicsEngine.Epsilon = 0.001;
  116762. return PhysicsEngine;
  116763. }());
  116764. /***/ }),
  116765. /***/ "./Physics/physicsEngineComponent.ts":
  116766. /*!*******************************************!*\
  116767. !*** ./Physics/physicsEngineComponent.ts ***!
  116768. \*******************************************/
  116769. /*! exports provided: PhysicsEngineSceneComponent */
  116770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116771. "use strict";
  116772. __webpack_require__.r(__webpack_exports__);
  116773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  116774. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116775. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  116776. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  116777. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  116778. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  116779. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  116780. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  116781. /**
  116782. * Gets the current physics engine
  116783. * @returns a IPhysicsEngine or null if none attached
  116784. */
  116785. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  116786. return this._physicsEngine;
  116787. };
  116788. /**
  116789. * Enables physics to the current scene
  116790. * @param gravity defines the scene's gravity for the physics engine
  116791. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116792. * @return a boolean indicating if the physics engine was initialized
  116793. */
  116794. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  116795. if (gravity === void 0) { gravity = null; }
  116796. if (this._physicsEngine) {
  116797. return true;
  116798. }
  116799. // Register the component to the scene
  116800. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  116801. if (!component) {
  116802. component = new PhysicsEngineSceneComponent(this);
  116803. this._addComponent(component);
  116804. }
  116805. try {
  116806. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  116807. return true;
  116808. }
  116809. catch (e) {
  116810. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  116811. return false;
  116812. }
  116813. };
  116814. /**
  116815. * Disables and disposes the physics engine associated with the scene
  116816. */
  116817. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  116818. if (!this._physicsEngine) {
  116819. return;
  116820. }
  116821. this._physicsEngine.dispose();
  116822. this._physicsEngine = null;
  116823. };
  116824. /**
  116825. * Gets a boolean indicating if there is an active physics engine
  116826. * @returns a boolean indicating if there is an active physics engine
  116827. */
  116828. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  116829. return this._physicsEngine !== undefined;
  116830. };
  116831. /**
  116832. * Deletes a physics compound impostor
  116833. * @param compound defines the compound to delete
  116834. */
  116835. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  116836. var mesh = compound.parts[0].mesh;
  116837. if (mesh.physicsImpostor) {
  116838. mesh.physicsImpostor.dispose( /*true*/);
  116839. mesh.physicsImpostor = null;
  116840. }
  116841. };
  116842. /** @hidden */
  116843. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  116844. if (this._physicsEngine) {
  116845. this.onBeforePhysicsObservable.notifyObservers(this);
  116846. this._physicsEngine._step(step / 1000);
  116847. this.onAfterPhysicsObservable.notifyObservers(this);
  116848. }
  116849. };
  116850. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  116851. get: function () {
  116852. return this._physicsImpostor;
  116853. },
  116854. set: function (value) {
  116855. var _this = this;
  116856. if (this._physicsImpostor === value) {
  116857. return;
  116858. }
  116859. if (this._disposePhysicsObserver) {
  116860. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  116861. }
  116862. this._physicsImpostor = value;
  116863. if (value) {
  116864. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  116865. // Physics
  116866. if (_this.physicsImpostor) {
  116867. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  116868. _this.physicsImpostor = null;
  116869. }
  116870. });
  116871. }
  116872. },
  116873. enumerable: true,
  116874. configurable: true
  116875. });
  116876. /**
  116877. * Gets the current physics impostor
  116878. * @see http://doc.babylonjs.com/features/physics_engine
  116879. * @returns a physics impostor or null
  116880. */
  116881. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  116882. return this.physicsImpostor;
  116883. };
  116884. /**
  116885. * Apply a physic impulse to the mesh
  116886. * @param force defines the force to apply
  116887. * @param contactPoint defines where to apply the force
  116888. * @returns the current mesh
  116889. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116890. */
  116891. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  116892. if (!this.physicsImpostor) {
  116893. return this;
  116894. }
  116895. this.physicsImpostor.applyImpulse(force, contactPoint);
  116896. return this;
  116897. };
  116898. /**
  116899. * Creates a physic joint between two meshes
  116900. * @param otherMesh defines the other mesh to use
  116901. * @param pivot1 defines the pivot to use on this mesh
  116902. * @param pivot2 defines the pivot to use on the other mesh
  116903. * @param options defines additional options (can be plugin dependent)
  116904. * @returns the current mesh
  116905. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116906. */
  116907. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  116908. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  116909. return this;
  116910. }
  116911. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  116912. mainPivot: pivot1,
  116913. connectedPivot: pivot2,
  116914. nativeParams: options
  116915. });
  116916. return this;
  116917. };
  116918. /**
  116919. * Defines the physics engine scene component responsible to manage a physics engine
  116920. */
  116921. var PhysicsEngineSceneComponent = /** @class */ (function () {
  116922. /**
  116923. * Creates a new instance of the component for the given scene
  116924. * @param scene Defines the scene to register the component in
  116925. */
  116926. function PhysicsEngineSceneComponent(scene) {
  116927. var _this = this;
  116928. /**
  116929. * The component name helpful to identify the component in the list of scene components.
  116930. */
  116931. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  116932. this.scene = scene;
  116933. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  116934. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  116935. // Replace the function used to get the deterministic frame time
  116936. this.scene.getDeterministicFrameTime = function () {
  116937. if (_this.scene._physicsEngine) {
  116938. return _this.scene._physicsEngine.getTimeStep() * 1000;
  116939. }
  116940. return 1000.0 / 60.0;
  116941. };
  116942. }
  116943. /**
  116944. * Registers the component in a given scene
  116945. */
  116946. PhysicsEngineSceneComponent.prototype.register = function () {
  116947. };
  116948. /**
  116949. * Rebuilds the elements related to this component in case of
  116950. * context lost for instance.
  116951. */
  116952. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  116953. // Nothing to do for this component
  116954. };
  116955. /**
  116956. * Disposes the component and the associated ressources
  116957. */
  116958. PhysicsEngineSceneComponent.prototype.dispose = function () {
  116959. this.scene.onBeforePhysicsObservable.clear();
  116960. this.scene.onAfterPhysicsObservable.clear();
  116961. if (this.scene._physicsEngine) {
  116962. this.scene.disablePhysicsEngine();
  116963. }
  116964. };
  116965. return PhysicsEngineSceneComponent;
  116966. }());
  116967. /***/ }),
  116968. /***/ "./Physics/physicsHelper.ts":
  116969. /*!**********************************!*\
  116970. !*** ./Physics/physicsHelper.ts ***!
  116971. \**********************************/
  116972. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  116973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116974. "use strict";
  116975. __webpack_require__.r(__webpack_exports__);
  116976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  116977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return PhysicsRadialExplosionEventOptions; });
  116978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return PhysicsUpdraftEventOptions; });
  116979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return PhysicsVortexEventOptions; });
  116980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  116981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  116982. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116983. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116984. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116985. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  116986. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  116987. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  116988. /**
  116989. * A helper for physics simulations
  116990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116991. */
  116992. var PhysicsHelper = /** @class */ (function () {
  116993. /**
  116994. * Initializes the Physics helper
  116995. * @param scene Babylon.js scene
  116996. */
  116997. function PhysicsHelper(scene) {
  116998. this._scene = scene;
  116999. this._physicsEngine = this._scene.getPhysicsEngine();
  117000. if (!this._physicsEngine) {
  117001. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  117002. return;
  117003. }
  117004. }
  117005. /**
  117006. * Applies a radial explosion impulse
  117007. * @param origin the origin of the explosion
  117008. * @param radiusOrEventOptions the radius or the options of radial explosion
  117009. * @param strength the explosion strength
  117010. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117011. * @returns A physics radial explosion event, or null
  117012. */
  117013. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radiusOrEventOptions, strength, falloff) {
  117014. if (!this._physicsEngine) {
  117015. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  117016. return null;
  117017. }
  117018. var impostors = this._physicsEngine.getImpostors();
  117019. if (impostors.length === 0) {
  117020. return null;
  117021. }
  117022. if (typeof radiusOrEventOptions === 'number') {
  117023. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  117024. radiusOrEventOptions.radius = radiusOrEventOptions;
  117025. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  117026. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  117027. }
  117028. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  117029. var affectedImpostorsWithData = Array();
  117030. impostors.forEach(function (impostor) {
  117031. var impostorHitData = event.getImpostorHitData(impostor, origin);
  117032. if (!impostorHitData) {
  117033. return;
  117034. }
  117035. impostor.applyImpulse(impostorHitData.force, impostorHitData.contactPoint);
  117036. affectedImpostorsWithData.push({
  117037. impostor: impostor,
  117038. hitData: impostorHitData,
  117039. });
  117040. });
  117041. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  117042. event.dispose(false);
  117043. return event;
  117044. };
  117045. /**
  117046. * Applies a radial explosion force
  117047. * @param origin the origin of the explosion
  117048. * @param radiusOrEventOptions the radius or the options of radial explosion
  117049. * @param strength the explosion strength
  117050. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117051. * @returns A physics radial explosion event, or null
  117052. */
  117053. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radiusOrEventOptions, strength, falloff) {
  117054. if (!this._physicsEngine) {
  117055. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  117056. return null;
  117057. }
  117058. var impostors = this._physicsEngine.getImpostors();
  117059. if (impostors.length === 0) {
  117060. return null;
  117061. }
  117062. if (typeof radiusOrEventOptions === 'number') {
  117063. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  117064. radiusOrEventOptions.radius = radiusOrEventOptions;
  117065. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  117066. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  117067. }
  117068. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  117069. var affectedImpostorsWithData = Array();
  117070. impostors.forEach(function (impostor) {
  117071. var impostorHitData = event.getImpostorHitData(impostor, origin);
  117072. if (!impostorHitData) {
  117073. return;
  117074. }
  117075. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  117076. affectedImpostorsWithData.push({
  117077. impostor: impostor,
  117078. hitData: impostorHitData,
  117079. });
  117080. });
  117081. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  117082. event.dispose(false);
  117083. return event;
  117084. };
  117085. /**
  117086. * Creates a gravitational field
  117087. * @param origin the origin of the explosion
  117088. * @param radiusOrEventOptions the radius or the options of radial explosion
  117089. * @param strength the explosion strength
  117090. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117091. * @returns A physics gravitational field event, or null
  117092. */
  117093. PhysicsHelper.prototype.gravitationalField = function (origin, radiusOrEventOptions, strength, falloff) {
  117094. if (!this._physicsEngine) {
  117095. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  117096. return null;
  117097. }
  117098. var impostors = this._physicsEngine.getImpostors();
  117099. if (impostors.length === 0) {
  117100. return null;
  117101. }
  117102. if (typeof radiusOrEventOptions === 'number') {
  117103. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  117104. radiusOrEventOptions.radius = radiusOrEventOptions;
  117105. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  117106. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  117107. }
  117108. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radiusOrEventOptions);
  117109. event.dispose(false);
  117110. return event;
  117111. };
  117112. /**
  117113. * Creates a physics updraft event
  117114. * @param origin the origin of the updraft
  117115. * @param radiusOrEventOptions the radius or the options of the updraft
  117116. * @param strength the strength of the updraft
  117117. * @param height the height of the updraft
  117118. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117119. * @returns A physics updraft event, or null
  117120. */
  117121. PhysicsHelper.prototype.updraft = function (origin, radiusOrEventOptions, strength, height, updraftMode) {
  117122. if (!this._physicsEngine) {
  117123. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  117124. return null;
  117125. }
  117126. if (this._physicsEngine.getImpostors().length === 0) {
  117127. return null;
  117128. }
  117129. if (typeof radiusOrEventOptions === 'number') {
  117130. radiusOrEventOptions = new PhysicsUpdraftEventOptions();
  117131. radiusOrEventOptions.radius = radiusOrEventOptions;
  117132. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  117133. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  117134. radiusOrEventOptions.updraftMode = updraftMode || radiusOrEventOptions.updraftMode;
  117135. }
  117136. var event = new PhysicsUpdraftEvent(this._scene, origin, radiusOrEventOptions);
  117137. event.dispose(false);
  117138. return event;
  117139. };
  117140. /**
  117141. * Creates a physics vortex event
  117142. * @param origin the of the vortex
  117143. * @param radiusOrEventOptions the radius or the options of the vortex
  117144. * @param strength the strength of the vortex
  117145. * @param height the height of the vortex
  117146. * @returns a Physics vortex event, or null
  117147. * A physics vortex event or null
  117148. */
  117149. PhysicsHelper.prototype.vortex = function (origin, radiusOrEventOptions, strength, height) {
  117150. if (!this._physicsEngine) {
  117151. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  117152. return null;
  117153. }
  117154. if (this._physicsEngine.getImpostors().length === 0) {
  117155. return null;
  117156. }
  117157. if (typeof radiusOrEventOptions === 'number') {
  117158. radiusOrEventOptions = new PhysicsVortexEventOptions();
  117159. radiusOrEventOptions.radius = radiusOrEventOptions;
  117160. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  117161. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  117162. }
  117163. var event = new PhysicsVortexEvent(this._scene, origin, radiusOrEventOptions);
  117164. event.dispose(false);
  117165. return event;
  117166. };
  117167. return PhysicsHelper;
  117168. }());
  117169. /**
  117170. * Represents a physics radial explosion event
  117171. */
  117172. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  117173. /**
  117174. * Initializes a radial explosioin event
  117175. * @param _scene BabylonJS scene
  117176. * @param _options The options for the vortex event
  117177. */
  117178. function PhysicsRadialExplosionEvent(_scene, _options) {
  117179. this._scene = _scene;
  117180. this._options = _options;
  117181. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  117182. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  117183. }
  117184. /**
  117185. * Returns the data related to the radial explosion event (sphere).
  117186. * @returns The radial explosion event data
  117187. */
  117188. PhysicsRadialExplosionEvent.prototype.getData = function () {
  117189. this._dataFetched = true;
  117190. return {
  117191. sphere: this._sphere,
  117192. };
  117193. };
  117194. /**
  117195. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117196. * @param impostor A physics imposter
  117197. * @param origin the origin of the explosion
  117198. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117199. */
  117200. PhysicsRadialExplosionEvent.prototype.getImpostorHitData = function (impostor, origin) {
  117201. if (impostor.mass === 0) {
  117202. return null;
  117203. }
  117204. if (!this._intersectsWithSphere(impostor, origin, this._options.radius)) {
  117205. return null;
  117206. }
  117207. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  117208. return null;
  117209. }
  117210. var impostorObjectCenter = impostor.getObjectCenter();
  117211. var direction = impostorObjectCenter.subtract(origin);
  117212. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, this._options.radius);
  117213. var hit = ray.intersectsMesh(impostor.object);
  117214. var contactPoint = hit.pickedPoint;
  117215. if (!contactPoint) {
  117216. return null;
  117217. }
  117218. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(origin, contactPoint);
  117219. if (distanceFromOrigin > this._options.radius) {
  117220. return null;
  117221. }
  117222. var multiplier = this._options.falloff === PhysicsRadialImpulseFalloff.Constant
  117223. ? this._options.strength
  117224. : this._options.strength * (1 - (distanceFromOrigin / this._options.radius));
  117225. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  117226. return { force: force, contactPoint: contactPoint, distanceFromOrigin: distanceFromOrigin };
  117227. };
  117228. /**
  117229. * Triggers affecterd impostors callbacks
  117230. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117231. */
  117232. PhysicsRadialExplosionEvent.prototype.triggerAffectedImpostorsCallback = function (affectedImpostorsWithData) {
  117233. if (this._options.affectedImpostorsCallback) {
  117234. this._options.affectedImpostorsCallback(affectedImpostorsWithData);
  117235. }
  117236. };
  117237. /**
  117238. * Disposes the sphere.
  117239. * @param force Specifies if the sphere should be disposed by force
  117240. */
  117241. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  117242. var _this = this;
  117243. if (force === void 0) { force = true; }
  117244. if (force) {
  117245. this._sphere.dispose();
  117246. }
  117247. else {
  117248. setTimeout(function () {
  117249. if (!_this._dataFetched) {
  117250. _this._sphere.dispose();
  117251. }
  117252. }, 0);
  117253. }
  117254. };
  117255. /*** Helpers ***/
  117256. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  117257. if (!this._sphere) {
  117258. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._options.sphere, this._scene);
  117259. this._sphere.isVisible = false;
  117260. }
  117261. };
  117262. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  117263. var impostorObject = impostor.object;
  117264. this._prepareSphere();
  117265. this._sphere.position = origin;
  117266. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * 2, radius * 2, radius * 2);
  117267. this._sphere._updateBoundingInfo();
  117268. this._sphere.computeWorldMatrix(true);
  117269. return this._sphere.intersectsMesh(impostorObject, true);
  117270. };
  117271. return PhysicsRadialExplosionEvent;
  117272. }());
  117273. /**
  117274. * Represents a gravitational field event
  117275. */
  117276. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  117277. /**
  117278. * Initializes the physics gravitational field event
  117279. * @param _physicsHelper A physics helper
  117280. * @param _scene BabylonJS scene
  117281. * @param _origin The origin position of the gravitational field event
  117282. * @param _options The options for the vortex event
  117283. */
  117284. function PhysicsGravitationalFieldEvent(_physicsHelper, _scene, _origin, _options) {
  117285. this._physicsHelper = _physicsHelper;
  117286. this._scene = _scene;
  117287. this._origin = _origin;
  117288. this._options = _options;
  117289. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  117290. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  117291. this._tickCallback = this._tick.bind(this);
  117292. this._options.strength = this._options.strength * -1;
  117293. }
  117294. /**
  117295. * Returns the data related to the gravitational field event (sphere).
  117296. * @returns A gravitational field event
  117297. */
  117298. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  117299. this._dataFetched = true;
  117300. return {
  117301. sphere: this._sphere,
  117302. };
  117303. };
  117304. /**
  117305. * Enables the gravitational field.
  117306. */
  117307. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  117308. this._tickCallback.call(this);
  117309. this._scene.registerBeforeRender(this._tickCallback);
  117310. };
  117311. /**
  117312. * Disables the gravitational field.
  117313. */
  117314. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  117315. this._scene.unregisterBeforeRender(this._tickCallback);
  117316. };
  117317. /**
  117318. * Disposes the sphere.
  117319. * @param force The force to dispose from the gravitational field event
  117320. */
  117321. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  117322. var _this = this;
  117323. if (force === void 0) { force = true; }
  117324. if (force) {
  117325. this._sphere.dispose();
  117326. }
  117327. else {
  117328. setTimeout(function () {
  117329. if (!_this._dataFetched) {
  117330. _this._sphere.dispose();
  117331. }
  117332. }, 0);
  117333. }
  117334. };
  117335. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  117336. // Since the params won't change, we fetch the event only once
  117337. if (this._sphere) {
  117338. this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  117339. }
  117340. else {
  117341. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  117342. if (radialExplosionEvent) {
  117343. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  117344. }
  117345. }
  117346. };
  117347. return PhysicsGravitationalFieldEvent;
  117348. }());
  117349. /**
  117350. * Represents a physics updraft event
  117351. */
  117352. var PhysicsUpdraftEvent = /** @class */ (function () {
  117353. /**
  117354. * Initializes the physics updraft event
  117355. * @param _scene BabylonJS scene
  117356. * @param _origin The origin position of the updraft
  117357. * @param _options The options for the updraft event
  117358. */
  117359. function PhysicsUpdraftEvent(_scene, _origin, _options) {
  117360. this._scene = _scene;
  117361. this._origin = _origin;
  117362. this._options = _options;
  117363. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  117364. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  117365. 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
  117366. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  117367. this._physicsEngine = this._scene.getPhysicsEngine();
  117368. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsUpdraftEventOptions()), this._options);
  117369. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  117370. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  117371. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  117372. this._originDirection = this._origin.subtract(this._originTop).normalize();
  117373. }
  117374. this._tickCallback = this._tick.bind(this);
  117375. this._prepareCylinder();
  117376. }
  117377. /**
  117378. * Returns the data related to the updraft event (cylinder).
  117379. * @returns A physics updraft event
  117380. */
  117381. PhysicsUpdraftEvent.prototype.getData = function () {
  117382. this._dataFetched = true;
  117383. return {
  117384. cylinder: this._cylinder,
  117385. };
  117386. };
  117387. /**
  117388. * Enables the updraft.
  117389. */
  117390. PhysicsUpdraftEvent.prototype.enable = function () {
  117391. this._tickCallback.call(this);
  117392. this._scene.registerBeforeRender(this._tickCallback);
  117393. };
  117394. /**
  117395. * Disables the updraft.
  117396. */
  117397. PhysicsUpdraftEvent.prototype.disable = function () {
  117398. this._scene.unregisterBeforeRender(this._tickCallback);
  117399. };
  117400. /**
  117401. * Disposes the cylinder.
  117402. * @param force Specifies if the updraft should be disposed by force
  117403. */
  117404. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  117405. var _this = this;
  117406. if (force === void 0) { force = true; }
  117407. if (!this._cylinder) {
  117408. return;
  117409. }
  117410. if (force) {
  117411. this._cylinder.dispose();
  117412. }
  117413. else {
  117414. setTimeout(function () {
  117415. if (!_this._dataFetched) {
  117416. _this._cylinder.dispose();
  117417. }
  117418. }, 0);
  117419. }
  117420. };
  117421. PhysicsUpdraftEvent.prototype.getImpostorHitData = function (impostor) {
  117422. if (impostor.mass === 0) {
  117423. return null;
  117424. }
  117425. if (!this._intersectsWithCylinder(impostor)) {
  117426. return null;
  117427. }
  117428. var impostorObjectCenter = impostor.getObjectCenter();
  117429. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  117430. var direction = this._originDirection;
  117431. }
  117432. else {
  117433. var direction = impostorObjectCenter.subtract(this._originTop);
  117434. }
  117435. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(this._origin, impostorObjectCenter);
  117436. var multiplier = this._options.strength * -1;
  117437. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  117438. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: distanceFromOrigin };
  117439. };
  117440. PhysicsUpdraftEvent.prototype._tick = function () {
  117441. var _this = this;
  117442. this._physicsEngine.getImpostors().forEach(function (impostor) {
  117443. var impostorHitData = _this.getImpostorHitData(impostor);
  117444. if (!impostorHitData) {
  117445. return;
  117446. }
  117447. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  117448. });
  117449. };
  117450. /*** Helpers ***/
  117451. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  117452. if (!this._cylinder) {
  117453. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  117454. height: this._options.height,
  117455. diameter: this._options.radius * 2,
  117456. }, this._scene);
  117457. this._cylinder.isVisible = false;
  117458. }
  117459. };
  117460. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  117461. var impostorObject = impostor.object;
  117462. this._cylinder.position = this._cylinderPosition;
  117463. return this._cylinder.intersectsMesh(impostorObject, true);
  117464. };
  117465. return PhysicsUpdraftEvent;
  117466. }());
  117467. /**
  117468. * Represents a physics vortex event
  117469. */
  117470. var PhysicsVortexEvent = /** @class */ (function () {
  117471. /**
  117472. * Initializes the physics vortex event
  117473. * @param _scene The BabylonJS scene
  117474. * @param _origin The origin position of the vortex
  117475. * @param _options The options for the vortex event
  117476. */
  117477. function PhysicsVortexEvent(_scene, _origin, _options) {
  117478. this._scene = _scene;
  117479. this._origin = _origin;
  117480. this._options = _options;
  117481. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  117482. 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
  117483. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  117484. this._physicsEngine = this._scene.getPhysicsEngine();
  117485. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsVortexEventOptions()), this._options);
  117486. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  117487. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  117488. this._tickCallback = this._tick.bind(this);
  117489. this._prepareCylinder();
  117490. }
  117491. /**
  117492. * Returns the data related to the vortex event (cylinder).
  117493. * @returns The physics vortex event data
  117494. */
  117495. PhysicsVortexEvent.prototype.getData = function () {
  117496. this._dataFetched = true;
  117497. return {
  117498. cylinder: this._cylinder,
  117499. };
  117500. };
  117501. /**
  117502. * Enables the vortex.
  117503. */
  117504. PhysicsVortexEvent.prototype.enable = function () {
  117505. this._tickCallback.call(this);
  117506. this._scene.registerBeforeRender(this._tickCallback);
  117507. };
  117508. /**
  117509. * Disables the cortex.
  117510. */
  117511. PhysicsVortexEvent.prototype.disable = function () {
  117512. this._scene.unregisterBeforeRender(this._tickCallback);
  117513. };
  117514. /**
  117515. * Disposes the sphere.
  117516. * @param force
  117517. */
  117518. PhysicsVortexEvent.prototype.dispose = function (force) {
  117519. var _this = this;
  117520. if (force === void 0) { force = true; }
  117521. if (force) {
  117522. this._cylinder.dispose();
  117523. }
  117524. else {
  117525. setTimeout(function () {
  117526. if (!_this._dataFetched) {
  117527. _this._cylinder.dispose();
  117528. }
  117529. }, 0);
  117530. }
  117531. };
  117532. PhysicsVortexEvent.prototype.getImpostorHitData = function (impostor) {
  117533. if (impostor.mass === 0) {
  117534. return null;
  117535. }
  117536. if (!this._intersectsWithCylinder(impostor)) {
  117537. return null;
  117538. }
  117539. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  117540. return null;
  117541. }
  117542. var impostorObjectCenter = impostor.getObjectCenter();
  117543. 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)
  117544. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  117545. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](originOnPlane, originToImpostorDirection, this._options.radius);
  117546. var hit = ray.intersectsMesh(impostor.object);
  117547. var contactPoint = hit.pickedPoint;
  117548. if (!contactPoint) {
  117549. return null;
  117550. }
  117551. var absoluteDistanceFromOrigin = hit.distance / this._options.radius;
  117552. var directionToOrigin = contactPoint.normalize();
  117553. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  117554. directionToOrigin = directionToOrigin.negate();
  117555. }
  117556. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  117557. var forceX = directionToOrigin.x * this._options.centripetalForceMultiplier;
  117558. var forceY = directionToOrigin.y * this._options.updraftForceMultiplier;
  117559. var forceZ = directionToOrigin.z * this._options.centripetalForceMultiplier;
  117560. }
  117561. else {
  117562. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  117563. var forceX = (perpendicularDirection.x + directionToOrigin.x) * this._options.centrifugalForceMultiplier;
  117564. var forceY = this._originTop.y * this._options.updraftForceMultiplier;
  117565. var forceZ = (perpendicularDirection.z + directionToOrigin.z) * this._options.centrifugalForceMultiplier;
  117566. }
  117567. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](forceX, forceY, forceZ);
  117568. force = force.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength);
  117569. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: absoluteDistanceFromOrigin };
  117570. };
  117571. PhysicsVortexEvent.prototype._tick = function () {
  117572. var _this = this;
  117573. this._physicsEngine.getImpostors().forEach(function (impostor) {
  117574. var impostorHitData = _this.getImpostorHitData(impostor);
  117575. if (!impostorHitData) {
  117576. return;
  117577. }
  117578. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  117579. });
  117580. };
  117581. /*** Helpers ***/
  117582. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  117583. if (!this._cylinder) {
  117584. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  117585. height: this._options.height,
  117586. diameter: this._options.radius * 2,
  117587. }, this._scene);
  117588. this._cylinder.isVisible = false;
  117589. }
  117590. };
  117591. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  117592. var impostorObject = impostor.object;
  117593. this._cylinder.position = this._cylinderPosition;
  117594. return this._cylinder.intersectsMesh(impostorObject, true);
  117595. };
  117596. return PhysicsVortexEvent;
  117597. }());
  117598. /**
  117599. * Options fot the radial explosion event
  117600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117601. */
  117602. var PhysicsRadialExplosionEventOptions = /** @class */ (function () {
  117603. function PhysicsRadialExplosionEventOptions() {
  117604. /**
  117605. * The radius of the sphere for the radial explosion.
  117606. */
  117607. this.radius = 5;
  117608. /**
  117609. * The strenth of the explosion.
  117610. */
  117611. this.strength = 10;
  117612. /**
  117613. * The strenght of the force in correspondence to the distance of the affected object
  117614. */
  117615. this.falloff = PhysicsRadialImpulseFalloff.Constant;
  117616. /**
  117617. * Sphere options for the radial explosion.
  117618. */
  117619. this.sphere = { segments: 32, diameter: 1 };
  117620. }
  117621. return PhysicsRadialExplosionEventOptions;
  117622. }());
  117623. /**
  117624. * Options fot the updraft event
  117625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117626. */
  117627. var PhysicsUpdraftEventOptions = /** @class */ (function () {
  117628. function PhysicsUpdraftEventOptions() {
  117629. /**
  117630. * The radius of the cylinder for the vortex
  117631. */
  117632. this.radius = 5;
  117633. /**
  117634. * The strenth of the updraft.
  117635. */
  117636. this.strength = 10;
  117637. /**
  117638. * The height of the cylinder for the updraft.
  117639. */
  117640. this.height = 10;
  117641. /**
  117642. * The mode for the the updraft.
  117643. */
  117644. this.updraftMode = PhysicsUpdraftMode.Center;
  117645. }
  117646. return PhysicsUpdraftEventOptions;
  117647. }());
  117648. /**
  117649. * Options fot the vortex event
  117650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117651. */
  117652. var PhysicsVortexEventOptions = /** @class */ (function () {
  117653. function PhysicsVortexEventOptions() {
  117654. /**
  117655. * The radius of the cylinder for the vortex
  117656. */
  117657. this.radius = 5;
  117658. /**
  117659. * The strenth of the vortex.
  117660. */
  117661. this.strength = 10;
  117662. /**
  117663. * The height of the cylinder for the vortex.
  117664. */
  117665. this.height = 10;
  117666. /**
  117667. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117668. */
  117669. this.centripetalForceThreshold = 0.7;
  117670. /**
  117671. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117672. */
  117673. this.centripetalForceMultiplier = 5;
  117674. /**
  117675. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117676. */
  117677. this.centrifugalForceMultiplier = 0.5;
  117678. /**
  117679. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117680. */
  117681. this.updraftForceMultiplier = 0.02;
  117682. }
  117683. return PhysicsVortexEventOptions;
  117684. }());
  117685. /**
  117686. * The strenght of the force in correspondence to the distance of the affected object
  117687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117688. */
  117689. var PhysicsRadialImpulseFalloff;
  117690. (function (PhysicsRadialImpulseFalloff) {
  117691. /** Defines that impulse is constant in strength across it's whole radius */
  117692. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  117693. /** Defines that impulse gets weaker if it's further from the origin */
  117694. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  117695. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  117696. /**
  117697. * The strength of the force in correspondence to the distance of the affected object
  117698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117699. */
  117700. var PhysicsUpdraftMode;
  117701. (function (PhysicsUpdraftMode) {
  117702. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117703. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  117704. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117705. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  117706. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  117707. /***/ }),
  117708. /***/ "./Physics/physicsImpostor.ts":
  117709. /*!************************************!*\
  117710. !*** ./Physics/physicsImpostor.ts ***!
  117711. \************************************/
  117712. /*! exports provided: PhysicsImpostor */
  117713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117714. "use strict";
  117715. __webpack_require__.r(__webpack_exports__);
  117716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  117717. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  117718. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  117719. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117720. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  117721. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  117722. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  117723. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  117724. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  117725. mass: jsonObject.physicsMass,
  117726. friction: jsonObject.physicsFriction,
  117727. restitution: jsonObject.physicsRestitution
  117728. }, scene);
  117729. };
  117730. /**
  117731. * Represents a physics imposter
  117732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117733. */
  117734. var PhysicsImpostor = /** @class */ (function () {
  117735. /**
  117736. * Initializes the physics imposter
  117737. * @param object The physics-enabled object used as the physics imposter
  117738. * @param type The type of the physics imposter
  117739. * @param _options The options for the physics imposter
  117740. * @param _scene The Babylon scene
  117741. */
  117742. function PhysicsImpostor(
  117743. /**
  117744. * The physics-enabled object used as the physics imposter
  117745. */
  117746. object,
  117747. /**
  117748. * The type of the physics imposter
  117749. */
  117750. type, _options, _scene) {
  117751. if (_options === void 0) { _options = { mass: 0 }; }
  117752. var _this = this;
  117753. this.object = object;
  117754. this.type = type;
  117755. this._options = _options;
  117756. this._scene = _scene;
  117757. /** @hidden */
  117758. this._pluginData = {};
  117759. this._bodyUpdateRequired = false;
  117760. this._onBeforePhysicsStepCallbacks = new Array();
  117761. this._onAfterPhysicsStepCallbacks = new Array();
  117762. /** @hidden */
  117763. this._onPhysicsCollideCallbacks = [];
  117764. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  117765. this._isDisposed = false;
  117766. /**
  117767. * @hidden
  117768. */
  117769. this.soft = false;
  117770. /**
  117771. * @hidden
  117772. */
  117773. this.segments = 0;
  117774. //temp variables for parent rotation calculations
  117775. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  117776. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117777. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117778. /**
  117779. * this function is executed by the physics engine.
  117780. */
  117781. this.beforeStep = function () {
  117782. if (!_this._physicsEngine) {
  117783. return;
  117784. }
  117785. _this.object.translate(_this._deltaPosition, -1);
  117786. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  117787. _this.object.computeWorldMatrix(false);
  117788. if (_this.object.parent && _this.object.rotationQuaternion) {
  117789. _this.getParentsRotation();
  117790. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  117791. }
  117792. else {
  117793. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  117794. }
  117795. if (!_this._options.disableBidirectionalTransformation) {
  117796. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  117797. }
  117798. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  117799. func(_this);
  117800. });
  117801. };
  117802. /**
  117803. * this function is executed by the physics engine
  117804. */
  117805. this.afterStep = function () {
  117806. if (!_this._physicsEngine) {
  117807. return;
  117808. }
  117809. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  117810. func(_this);
  117811. });
  117812. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  117813. // object has now its world rotation. needs to be converted to local.
  117814. if (_this.object.parent && _this.object.rotationQuaternion) {
  117815. _this.getParentsRotation();
  117816. _this._tmpQuat.conjugateInPlace();
  117817. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  117818. }
  117819. // take the position set and make it the absolute position of this object.
  117820. _this.object.setAbsolutePosition(_this.object.position);
  117821. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  117822. _this.object.translate(_this._deltaPosition, 1);
  117823. };
  117824. /**
  117825. * Legacy collision detection event support
  117826. */
  117827. this.onCollideEvent = null;
  117828. /**
  117829. * event and body object due to cannon's event-based architecture.
  117830. */
  117831. this.onCollide = function (e) {
  117832. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  117833. return;
  117834. }
  117835. if (!_this._physicsEngine) {
  117836. return;
  117837. }
  117838. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  117839. if (otherImpostor) {
  117840. // Legacy collision detection event support
  117841. if (_this.onCollideEvent) {
  117842. _this.onCollideEvent(_this, otherImpostor);
  117843. }
  117844. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  117845. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  117846. }).forEach(function (obj) {
  117847. obj.callback(_this, otherImpostor);
  117848. });
  117849. }
  117850. };
  117851. //sanity check!
  117852. if (!this.object) {
  117853. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  117854. return;
  117855. }
  117856. // Legacy support for old syntax.
  117857. if (!this._scene && object.getScene) {
  117858. this._scene = object.getScene();
  117859. }
  117860. if (!this._scene) {
  117861. return;
  117862. }
  117863. if (this.type > 100) {
  117864. this.soft = true;
  117865. }
  117866. this._physicsEngine = this._scene.getPhysicsEngine();
  117867. if (!this._physicsEngine) {
  117868. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  117869. }
  117870. else {
  117871. //set the object's quaternion, if not set
  117872. if (!this.object.rotationQuaternion) {
  117873. if (this.object.rotation) {
  117874. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  117875. }
  117876. else {
  117877. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117878. }
  117879. }
  117880. //default options params
  117881. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  117882. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  117883. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  117884. if (this.soft) {
  117885. //softbody mass must be above 0;
  117886. this._options.mass = this._options.mass > 0 ? this._options.mass : 1;
  117887. this._options.pressure = (_options.pressure === void 0) ? 200 : _options.pressure;
  117888. this._options.stiffness = (_options.stiffness === void 0) ? 1 : _options.stiffness;
  117889. this._options.velocityIterations = (_options.velocityIterations === void 0) ? 20 : _options.velocityIterations;
  117890. this._options.positionIterations = (_options.positionIterations === void 0) ? 20 : _options.positionIterations;
  117891. this._options.fixedPoints = (_options.fixedPoints === void 0) ? 0 : _options.fixedPoints;
  117892. this._options.margin = (_options.margin === void 0) ? 0 : _options.margin;
  117893. this._options.damping = (_options.damping === void 0) ? 0 : _options.damping;
  117894. this._options.path = (_options.path === void 0) ? null : _options.path;
  117895. this._options.shape = (_options.shape === void 0) ? null : _options.shape;
  117896. }
  117897. this._joints = [];
  117898. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  117899. if (!this.object.parent || this._options.ignoreParent) {
  117900. this._init();
  117901. }
  117902. else if (this.object.parent.physicsImpostor) {
  117903. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  117904. }
  117905. }
  117906. }
  117907. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  117908. /**
  117909. * Specifies if the physics imposter is disposed
  117910. */
  117911. get: function () {
  117912. return this._isDisposed;
  117913. },
  117914. enumerable: true,
  117915. configurable: true
  117916. });
  117917. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  117918. /**
  117919. * Gets the mass of the physics imposter
  117920. */
  117921. get: function () {
  117922. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  117923. },
  117924. set: function (value) {
  117925. this.setMass(value);
  117926. },
  117927. enumerable: true,
  117928. configurable: true
  117929. });
  117930. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  117931. /**
  117932. * Gets the coefficient of friction
  117933. */
  117934. get: function () {
  117935. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  117936. },
  117937. /**
  117938. * Sets the coefficient of friction
  117939. */
  117940. set: function (value) {
  117941. if (!this._physicsEngine) {
  117942. return;
  117943. }
  117944. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  117945. },
  117946. enumerable: true,
  117947. configurable: true
  117948. });
  117949. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  117950. /**
  117951. * Gets the coefficient of restitution
  117952. */
  117953. get: function () {
  117954. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  117955. },
  117956. /**
  117957. * Sets the coefficient of restitution
  117958. */
  117959. set: function (value) {
  117960. if (!this._physicsEngine) {
  117961. return;
  117962. }
  117963. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  117964. },
  117965. enumerable: true,
  117966. configurable: true
  117967. });
  117968. Object.defineProperty(PhysicsImpostor.prototype, "pressure", {
  117969. /**
  117970. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  117971. */
  117972. get: function () {
  117973. if (!this._physicsEngine) {
  117974. return 0;
  117975. }
  117976. var plugin = this._physicsEngine.getPhysicsPlugin();
  117977. if (!plugin.setBodyPressure) {
  117978. return 0;
  117979. }
  117980. return plugin.getBodyPressure(this);
  117981. },
  117982. /**
  117983. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  117984. */
  117985. set: function (value) {
  117986. if (!this._physicsEngine) {
  117987. return;
  117988. }
  117989. var plugin = this._physicsEngine.getPhysicsPlugin();
  117990. if (!plugin.setBodyPressure) {
  117991. return;
  117992. }
  117993. plugin.setBodyPressure(this, value);
  117994. },
  117995. enumerable: true,
  117996. configurable: true
  117997. });
  117998. Object.defineProperty(PhysicsImpostor.prototype, "stiffness", {
  117999. /**
  118000. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  118001. */
  118002. get: function () {
  118003. if (!this._physicsEngine) {
  118004. return 0;
  118005. }
  118006. var plugin = this._physicsEngine.getPhysicsPlugin();
  118007. if (!plugin.getBodyStiffness) {
  118008. return 0;
  118009. }
  118010. return plugin.getBodyStiffness(this);
  118011. },
  118012. /**
  118013. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  118014. */
  118015. set: function (value) {
  118016. if (!this._physicsEngine) {
  118017. return;
  118018. }
  118019. var plugin = this._physicsEngine.getPhysicsPlugin();
  118020. if (!plugin.setBodyStiffness) {
  118021. return;
  118022. }
  118023. plugin.setBodyStiffness(this, value);
  118024. },
  118025. enumerable: true,
  118026. configurable: true
  118027. });
  118028. Object.defineProperty(PhysicsImpostor.prototype, "velocityIterations", {
  118029. /**
  118030. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  118031. */
  118032. get: function () {
  118033. if (!this._physicsEngine) {
  118034. return 0;
  118035. }
  118036. var plugin = this._physicsEngine.getPhysicsPlugin();
  118037. if (!plugin.getBodyVelocityIterations) {
  118038. return 0;
  118039. }
  118040. return plugin.getBodyVelocityIterations(this);
  118041. },
  118042. /**
  118043. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  118044. */
  118045. set: function (value) {
  118046. if (!this._physicsEngine) {
  118047. return;
  118048. }
  118049. var plugin = this._physicsEngine.getPhysicsPlugin();
  118050. if (!plugin.setBodyVelocityIterations) {
  118051. return;
  118052. }
  118053. plugin.setBodyVelocityIterations(this, value);
  118054. },
  118055. enumerable: true,
  118056. configurable: true
  118057. });
  118058. Object.defineProperty(PhysicsImpostor.prototype, "positionIterations", {
  118059. /**
  118060. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  118061. */
  118062. get: function () {
  118063. if (!this._physicsEngine) {
  118064. return 0;
  118065. }
  118066. var plugin = this._physicsEngine.getPhysicsPlugin();
  118067. if (!plugin.getBodyPositionIterations) {
  118068. return 0;
  118069. }
  118070. return plugin.getBodyPositionIterations(this);
  118071. },
  118072. /**
  118073. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  118074. */
  118075. set: function (value) {
  118076. if (!this._physicsEngine) {
  118077. return;
  118078. }
  118079. var plugin = this._physicsEngine.getPhysicsPlugin();
  118080. if (!plugin.setBodyPositionIterations) {
  118081. return;
  118082. }
  118083. plugin.setBodyPositionIterations(this, value);
  118084. },
  118085. enumerable: true,
  118086. configurable: true
  118087. });
  118088. /**
  118089. * This function will completly initialize this impostor.
  118090. * It will create a new body - but only if this mesh has no parent.
  118091. * If it has, this impostor will not be used other than to define the impostor
  118092. * of the child mesh.
  118093. * @hidden
  118094. */
  118095. PhysicsImpostor.prototype._init = function () {
  118096. if (!this._physicsEngine) {
  118097. return;
  118098. }
  118099. this._physicsEngine.removeImpostor(this);
  118100. this.physicsBody = null;
  118101. this._parent = this._parent || this._getPhysicsParent();
  118102. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  118103. this._physicsEngine.addImpostor(this);
  118104. }
  118105. };
  118106. PhysicsImpostor.prototype._getPhysicsParent = function () {
  118107. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  118108. var parentMesh = this.object.parent;
  118109. return parentMesh.physicsImpostor;
  118110. }
  118111. return null;
  118112. };
  118113. /**
  118114. * Should a new body be generated.
  118115. * @returns boolean specifying if body initialization is required
  118116. */
  118117. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  118118. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  118119. };
  118120. /**
  118121. * Sets the updated scaling
  118122. * @param updated Specifies if the scaling is updated
  118123. */
  118124. PhysicsImpostor.prototype.setScalingUpdated = function () {
  118125. this.forceUpdate();
  118126. };
  118127. /**
  118128. * Force a regeneration of this or the parent's impostor's body.
  118129. * Use under cautious - This will remove all joints already implemented.
  118130. */
  118131. PhysicsImpostor.prototype.forceUpdate = function () {
  118132. this._init();
  118133. if (this.parent && !this._options.ignoreParent) {
  118134. this.parent.forceUpdate();
  118135. }
  118136. };
  118137. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  118138. /*public get mesh(): AbstractMesh {
  118139. return this._mesh;
  118140. }*/
  118141. /**
  118142. * Gets the body that holds this impostor. Either its own, or its parent.
  118143. */
  118144. get: function () {
  118145. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  118146. },
  118147. /**
  118148. * Set the physics body. Used mainly by the physics engine/plugin
  118149. */
  118150. set: function (physicsBody) {
  118151. if (this._physicsBody && this._physicsEngine) {
  118152. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  118153. }
  118154. this._physicsBody = physicsBody;
  118155. this.resetUpdateFlags();
  118156. },
  118157. enumerable: true,
  118158. configurable: true
  118159. });
  118160. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  118161. /**
  118162. * Get the parent of the physics imposter
  118163. * @returns Physics imposter or null
  118164. */
  118165. get: function () {
  118166. return !this._options.ignoreParent && this._parent ? this._parent : null;
  118167. },
  118168. /**
  118169. * Sets the parent of the physics imposter
  118170. */
  118171. set: function (value) {
  118172. this._parent = value;
  118173. },
  118174. enumerable: true,
  118175. configurable: true
  118176. });
  118177. /**
  118178. * Resets the update flags
  118179. */
  118180. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  118181. this._bodyUpdateRequired = false;
  118182. };
  118183. /**
  118184. * Gets the object extend size
  118185. * @returns the object extend size
  118186. */
  118187. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  118188. if (this.object.getBoundingInfo) {
  118189. var q = this.object.rotationQuaternion;
  118190. //reset rotation
  118191. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  118192. //calculate the world matrix with no rotation
  118193. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  118194. var boundingInfo = this.object.getBoundingInfo();
  118195. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  118196. //bring back the rotation
  118197. this.object.rotationQuaternion = q;
  118198. //calculate the world matrix with the new rotation
  118199. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  118200. return size;
  118201. }
  118202. else {
  118203. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  118204. }
  118205. };
  118206. /**
  118207. * Gets the object center
  118208. * @returns The object center
  118209. */
  118210. PhysicsImpostor.prototype.getObjectCenter = function () {
  118211. if (this.object.getBoundingInfo) {
  118212. var boundingInfo = this.object.getBoundingInfo();
  118213. return boundingInfo.boundingBox.centerWorld;
  118214. }
  118215. else {
  118216. return this.object.position;
  118217. }
  118218. };
  118219. /**
  118220. * Get a specific parametes from the options parameter
  118221. * @param paramName The object parameter name
  118222. * @returns The object parameter
  118223. */
  118224. PhysicsImpostor.prototype.getParam = function (paramName) {
  118225. return this._options[paramName];
  118226. };
  118227. /**
  118228. * Sets a specific parameter in the options given to the physics plugin
  118229. * @param paramName The parameter name
  118230. * @param value The value of the parameter
  118231. */
  118232. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  118233. this._options[paramName] = value;
  118234. this._bodyUpdateRequired = true;
  118235. };
  118236. /**
  118237. * Specifically change the body's mass option. Won't recreate the physics body object
  118238. * @param mass The mass of the physics imposter
  118239. */
  118240. PhysicsImpostor.prototype.setMass = function (mass) {
  118241. if (this.getParam("mass") !== mass) {
  118242. this.setParam("mass", mass);
  118243. }
  118244. if (this._physicsEngine) {
  118245. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  118246. }
  118247. };
  118248. /**
  118249. * Gets the linear velocity
  118250. * @returns linear velocity or null
  118251. */
  118252. PhysicsImpostor.prototype.getLinearVelocity = function () {
  118253. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  118254. };
  118255. /**
  118256. * Sets the linear velocity
  118257. * @param velocity linear velocity or null
  118258. */
  118259. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  118260. if (this._physicsEngine) {
  118261. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  118262. }
  118263. };
  118264. /**
  118265. * Gets the angular velocity
  118266. * @returns angular velocity or null
  118267. */
  118268. PhysicsImpostor.prototype.getAngularVelocity = function () {
  118269. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  118270. };
  118271. /**
  118272. * Sets the angular velocity
  118273. * @param velocity The velocity or null
  118274. */
  118275. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  118276. if (this._physicsEngine) {
  118277. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  118278. }
  118279. };
  118280. /**
  118281. * Execute a function with the physics plugin native code
  118282. * Provide a function the will have two variables - the world object and the physics body object
  118283. * @param func The function to execute with the physics plugin native code
  118284. */
  118285. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  118286. if (this._physicsEngine) {
  118287. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  118288. }
  118289. };
  118290. /**
  118291. * Register a function that will be executed before the physics world is stepping forward
  118292. * @param func The function to execute before the physics world is stepped forward
  118293. */
  118294. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  118295. this._onBeforePhysicsStepCallbacks.push(func);
  118296. };
  118297. /**
  118298. * Unregister a function that will be executed before the physics world is stepping forward
  118299. * @param func The function to execute before the physics world is stepped forward
  118300. */
  118301. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  118302. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  118303. if (index > -1) {
  118304. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  118305. }
  118306. else {
  118307. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  118308. }
  118309. };
  118310. /**
  118311. * Register a function that will be executed after the physics step
  118312. * @param func The function to execute after physics step
  118313. */
  118314. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  118315. this._onAfterPhysicsStepCallbacks.push(func);
  118316. };
  118317. /**
  118318. * Unregisters a function that will be executed after the physics step
  118319. * @param func The function to execute after physics step
  118320. */
  118321. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  118322. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  118323. if (index > -1) {
  118324. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  118325. }
  118326. else {
  118327. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  118328. }
  118329. };
  118330. /**
  118331. * register a function that will be executed when this impostor collides against a different body
  118332. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  118333. * @param func Callback that is executed on collision
  118334. */
  118335. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  118336. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  118337. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  118338. };
  118339. /**
  118340. * Unregisters the physics imposter on contact
  118341. * @param collideAgainst The physics object to collide against
  118342. * @param func Callback to execute on collision
  118343. */
  118344. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  118345. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  118346. var index = -1;
  118347. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  118348. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  118349. // chcek the arrays match
  118350. var sameList = cbDef.otherImpostors.every(function (impostor) {
  118351. return collidedAgainstList.indexOf(impostor) > -1;
  118352. });
  118353. if (sameList) {
  118354. index = idx;
  118355. }
  118356. return sameList;
  118357. }
  118358. return false;
  118359. });
  118360. if (found) {
  118361. this._onPhysicsCollideCallbacks.splice(index, 1);
  118362. }
  118363. else {
  118364. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  118365. }
  118366. };
  118367. /**
  118368. * Get the parent rotation
  118369. * @returns The parent rotation
  118370. */
  118371. PhysicsImpostor.prototype.getParentsRotation = function () {
  118372. var parent = this.object.parent;
  118373. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  118374. while (parent) {
  118375. if (parent.rotationQuaternion) {
  118376. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  118377. }
  118378. else {
  118379. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  118380. }
  118381. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  118382. parent = parent.parent;
  118383. }
  118384. return this._tmpQuat;
  118385. };
  118386. /**
  118387. * Apply a force
  118388. * @param force The force to apply
  118389. * @param contactPoint The contact point for the force
  118390. * @returns The physics imposter
  118391. */
  118392. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  118393. if (this._physicsEngine) {
  118394. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  118395. }
  118396. return this;
  118397. };
  118398. /**
  118399. * Apply an impulse
  118400. * @param force The impulse force
  118401. * @param contactPoint The contact point for the impulse force
  118402. * @returns The physics imposter
  118403. */
  118404. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  118405. if (this._physicsEngine) {
  118406. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  118407. }
  118408. return this;
  118409. };
  118410. /**
  118411. * A help function to create a joint
  118412. * @param otherImpostor A physics imposter used to create a joint
  118413. * @param jointType The type of joint
  118414. * @param jointData The data for the joint
  118415. * @returns The physics imposter
  118416. */
  118417. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  118418. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  118419. this.addJoint(otherImpostor, joint);
  118420. return this;
  118421. };
  118422. /**
  118423. * Add a joint to this impostor with a different impostor
  118424. * @param otherImpostor A physics imposter used to add a joint
  118425. * @param joint The joint to add
  118426. * @returns The physics imposter
  118427. */
  118428. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  118429. this._joints.push({
  118430. otherImpostor: otherImpostor,
  118431. joint: joint
  118432. });
  118433. if (this._physicsEngine) {
  118434. this._physicsEngine.addJoint(this, otherImpostor, joint);
  118435. }
  118436. return this;
  118437. };
  118438. /**
  118439. * Add an anchor to a cloth impostor
  118440. * @param otherImpostor rigid impostor to anchor to
  118441. * @param width ratio across width from 0 to 1
  118442. * @param height ratio up height from 0 to 1
  118443. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118444. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  118445. * @returns impostor the soft imposter
  118446. */
  118447. PhysicsImpostor.prototype.addAnchor = function (otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  118448. if (!this._physicsEngine) {
  118449. return this;
  118450. }
  118451. var plugin = this._physicsEngine.getPhysicsPlugin();
  118452. if (!plugin.appendAnchor) {
  118453. return this;
  118454. }
  118455. if (this._physicsEngine) {
  118456. plugin.appendAnchor(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);
  118457. }
  118458. return this;
  118459. };
  118460. /**
  118461. * Add a hook to a rope impostor
  118462. * @param otherImpostor rigid impostor to anchor to
  118463. * @param length ratio across rope from 0 to 1
  118464. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  118465. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118466. * @returns impostor the rope imposter
  118467. */
  118468. PhysicsImpostor.prototype.addHook = function (otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  118469. if (!this._physicsEngine) {
  118470. return this;
  118471. }
  118472. var plugin = this._physicsEngine.getPhysicsPlugin();
  118473. if (!plugin.appendAnchor) {
  118474. return this;
  118475. }
  118476. if (this._physicsEngine) {
  118477. plugin.appendHook(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);
  118478. }
  118479. return this;
  118480. };
  118481. /**
  118482. * Will keep this body still, in a sleep mode.
  118483. * @returns the physics imposter
  118484. */
  118485. PhysicsImpostor.prototype.sleep = function () {
  118486. if (this._physicsEngine) {
  118487. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  118488. }
  118489. return this;
  118490. };
  118491. /**
  118492. * Wake the body up.
  118493. * @returns The physics imposter
  118494. */
  118495. PhysicsImpostor.prototype.wakeUp = function () {
  118496. if (this._physicsEngine) {
  118497. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  118498. }
  118499. return this;
  118500. };
  118501. /**
  118502. * Clones the physics imposter
  118503. * @param newObject The physics imposter clones to this physics-enabled object
  118504. * @returns A nullable physics imposter
  118505. */
  118506. PhysicsImpostor.prototype.clone = function (newObject) {
  118507. if (!newObject) {
  118508. return null;
  118509. }
  118510. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  118511. };
  118512. /**
  118513. * Disposes the physics imposter
  118514. */
  118515. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  118516. var _this = this;
  118517. //no dispose if no physics engine is available.
  118518. if (!this._physicsEngine) {
  118519. return;
  118520. }
  118521. this._joints.forEach(function (j) {
  118522. if (_this._physicsEngine) {
  118523. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  118524. }
  118525. });
  118526. //dispose the physics body
  118527. this._physicsEngine.removeImpostor(this);
  118528. if (this.parent) {
  118529. this.parent.forceUpdate();
  118530. }
  118531. else {
  118532. /*this._object.getChildMeshes().forEach(function(mesh) {
  118533. if (mesh.physicsImpostor) {
  118534. if (disposeChildren) {
  118535. mesh.physicsImpostor.dispose();
  118536. mesh.physicsImpostor = null;
  118537. }
  118538. }
  118539. })*/
  118540. }
  118541. this._isDisposed = true;
  118542. };
  118543. /**
  118544. * Sets the delta position
  118545. * @param position The delta position amount
  118546. */
  118547. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  118548. this._deltaPosition.copyFrom(position);
  118549. };
  118550. /**
  118551. * Sets the delta rotation
  118552. * @param rotation The delta rotation amount
  118553. */
  118554. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  118555. if (!this._deltaRotation) {
  118556. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  118557. }
  118558. this._deltaRotation.copyFrom(rotation);
  118559. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  118560. };
  118561. /**
  118562. * Gets the box size of the physics imposter and stores the result in the input parameter
  118563. * @param result Stores the box size
  118564. * @returns The physics imposter
  118565. */
  118566. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  118567. if (this._physicsEngine) {
  118568. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  118569. }
  118570. return this;
  118571. };
  118572. /**
  118573. * Gets the radius of the physics imposter
  118574. * @returns Radius of the physics imposter
  118575. */
  118576. PhysicsImpostor.prototype.getRadius = function () {
  118577. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  118578. };
  118579. /**
  118580. * Sync a bone with this impostor
  118581. * @param bone The bone to sync to the impostor.
  118582. * @param boneMesh The mesh that the bone is influencing.
  118583. * @param jointPivot The pivot of the joint / bone in local space.
  118584. * @param distToJoint Optional distance from the impostor to the joint.
  118585. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  118586. */
  118587. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  118588. var tempVec = PhysicsImpostor._tmpVecs[0];
  118589. var mesh = this.object;
  118590. if (mesh.rotationQuaternion) {
  118591. if (adjustRotation) {
  118592. var tempQuat = PhysicsImpostor._tmpQuat;
  118593. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  118594. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  118595. }
  118596. else {
  118597. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  118598. }
  118599. }
  118600. tempVec.x = 0;
  118601. tempVec.y = 0;
  118602. tempVec.z = 0;
  118603. if (jointPivot) {
  118604. tempVec.x = jointPivot.x;
  118605. tempVec.y = jointPivot.y;
  118606. tempVec.z = jointPivot.z;
  118607. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  118608. if (distToJoint === undefined || distToJoint === null) {
  118609. distToJoint = jointPivot.length();
  118610. }
  118611. tempVec.x *= distToJoint;
  118612. tempVec.y *= distToJoint;
  118613. tempVec.z *= distToJoint;
  118614. }
  118615. if (bone.getParent()) {
  118616. tempVec.addInPlace(mesh.getAbsolutePosition());
  118617. bone.setAbsolutePosition(tempVec, boneMesh);
  118618. }
  118619. else {
  118620. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  118621. boneMesh.position.x -= tempVec.x;
  118622. boneMesh.position.y -= tempVec.y;
  118623. boneMesh.position.z -= tempVec.z;
  118624. }
  118625. };
  118626. /**
  118627. * Sync impostor to a bone
  118628. * @param bone The bone that the impostor will be synced to.
  118629. * @param boneMesh The mesh that the bone is influencing.
  118630. * @param jointPivot The pivot of the joint / bone in local space.
  118631. * @param distToJoint Optional distance from the impostor to the joint.
  118632. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  118633. * @param boneAxis Optional vector3 axis the bone is aligned with
  118634. */
  118635. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  118636. var mesh = this.object;
  118637. if (mesh.rotationQuaternion) {
  118638. if (adjustRotation) {
  118639. var tempQuat = PhysicsImpostor._tmpQuat;
  118640. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  118641. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  118642. }
  118643. else {
  118644. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  118645. }
  118646. }
  118647. var pos = PhysicsImpostor._tmpVecs[0];
  118648. var boneDir = PhysicsImpostor._tmpVecs[1];
  118649. if (!boneAxis) {
  118650. boneAxis = PhysicsImpostor._tmpVecs[2];
  118651. boneAxis.x = 0;
  118652. boneAxis.y = 1;
  118653. boneAxis.z = 0;
  118654. }
  118655. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  118656. bone.getAbsolutePositionToRef(boneMesh, pos);
  118657. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  118658. distToJoint = jointPivot.length();
  118659. }
  118660. if (distToJoint !== undefined && distToJoint !== null) {
  118661. pos.x += boneDir.x * distToJoint;
  118662. pos.y += boneDir.y * distToJoint;
  118663. pos.z += boneDir.z * distToJoint;
  118664. }
  118665. mesh.setAbsolutePosition(pos);
  118666. };
  118667. /**
  118668. * The default object size of the imposter
  118669. */
  118670. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  118671. /**
  118672. * The identity quaternion of the imposter
  118673. */
  118674. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  118675. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  118676. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  118677. //Impostor types
  118678. /**
  118679. * No-Imposter type
  118680. */
  118681. PhysicsImpostor.NoImpostor = 0;
  118682. /**
  118683. * Sphere-Imposter type
  118684. */
  118685. PhysicsImpostor.SphereImpostor = 1;
  118686. /**
  118687. * Box-Imposter type
  118688. */
  118689. PhysicsImpostor.BoxImpostor = 2;
  118690. /**
  118691. * Plane-Imposter type
  118692. */
  118693. PhysicsImpostor.PlaneImpostor = 3;
  118694. /**
  118695. * Mesh-imposter type
  118696. */
  118697. PhysicsImpostor.MeshImpostor = 4;
  118698. /**
  118699. * Cylinder-Imposter type
  118700. */
  118701. PhysicsImpostor.CylinderImpostor = 7;
  118702. /**
  118703. * Particle-Imposter type
  118704. */
  118705. PhysicsImpostor.ParticleImpostor = 8;
  118706. /**
  118707. * Heightmap-Imposter type
  118708. */
  118709. PhysicsImpostor.HeightmapImpostor = 9;
  118710. /**
  118711. * ConvexHull-Impostor type (Ammo.js plugin only)
  118712. */
  118713. PhysicsImpostor.ConvexHullImpostor = 10;
  118714. /**
  118715. * Rope-Imposter type
  118716. */
  118717. PhysicsImpostor.RopeImpostor = 101;
  118718. /**
  118719. * Cloth-Imposter type
  118720. */
  118721. PhysicsImpostor.ClothImpostor = 102;
  118722. /**
  118723. * Softbody-Imposter type
  118724. */
  118725. PhysicsImpostor.SoftbodyImpostor = 103;
  118726. return PhysicsImpostor;
  118727. }());
  118728. /***/ }),
  118729. /***/ "./Physics/physicsJoint.ts":
  118730. /*!*********************************!*\
  118731. !*** ./Physics/physicsJoint.ts ***!
  118732. \*********************************/
  118733. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  118734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118735. "use strict";
  118736. __webpack_require__.r(__webpack_exports__);
  118737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  118738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  118739. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  118740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  118741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  118742. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118743. /**
  118744. * This is a holder class for the physics joint created by the physics plugin
  118745. * It holds a set of functions to control the underlying joint
  118746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118747. */
  118748. var PhysicsJoint = /** @class */ (function () {
  118749. /**
  118750. * Initializes the physics joint
  118751. * @param type The type of the physics joint
  118752. * @param jointData The data for the physics joint
  118753. */
  118754. function PhysicsJoint(
  118755. /**
  118756. * The type of the physics joint
  118757. */
  118758. type,
  118759. /**
  118760. * The data for the physics joint
  118761. */
  118762. jointData) {
  118763. this.type = type;
  118764. this.jointData = jointData;
  118765. jointData.nativeParams = jointData.nativeParams || {};
  118766. }
  118767. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  118768. /**
  118769. * Gets the physics joint
  118770. */
  118771. get: function () {
  118772. return this._physicsJoint;
  118773. },
  118774. /**
  118775. * Sets the physics joint
  118776. */
  118777. set: function (newJoint) {
  118778. if (this._physicsJoint) {
  118779. //remove from the wolrd
  118780. }
  118781. this._physicsJoint = newJoint;
  118782. },
  118783. enumerable: true,
  118784. configurable: true
  118785. });
  118786. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  118787. /**
  118788. * Sets the physics plugin
  118789. */
  118790. set: function (physicsPlugin) {
  118791. this._physicsPlugin = physicsPlugin;
  118792. },
  118793. enumerable: true,
  118794. configurable: true
  118795. });
  118796. /**
  118797. * Execute a function that is physics-plugin specific.
  118798. * @param {Function} func the function that will be executed.
  118799. * It accepts two parameters: the physics world and the physics joint
  118800. */
  118801. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  118802. func(this._physicsPlugin.world, this._physicsJoint);
  118803. };
  118804. //TODO check if the native joints are the same
  118805. //Joint Types
  118806. /**
  118807. * Distance-Joint type
  118808. */
  118809. PhysicsJoint.DistanceJoint = 0;
  118810. /**
  118811. * Hinge-Joint type
  118812. */
  118813. PhysicsJoint.HingeJoint = 1;
  118814. /**
  118815. * Ball-and-Socket joint type
  118816. */
  118817. PhysicsJoint.BallAndSocketJoint = 2;
  118818. /**
  118819. * Wheel-Joint type
  118820. */
  118821. PhysicsJoint.WheelJoint = 3;
  118822. /**
  118823. * Slider-Joint type
  118824. */
  118825. PhysicsJoint.SliderJoint = 4;
  118826. //OIMO
  118827. /**
  118828. * Prismatic-Joint type
  118829. */
  118830. PhysicsJoint.PrismaticJoint = 5;
  118831. //
  118832. /**
  118833. * Universal-Joint type
  118834. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  118835. */
  118836. PhysicsJoint.UniversalJoint = 6;
  118837. /**
  118838. * Hinge-Joint 2 type
  118839. */
  118840. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  118841. //Cannon
  118842. /**
  118843. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  118844. */
  118845. PhysicsJoint.PointToPointJoint = 8;
  118846. //Cannon only at the moment
  118847. /**
  118848. * Spring-Joint type
  118849. */
  118850. PhysicsJoint.SpringJoint = 9;
  118851. /**
  118852. * Lock-Joint type
  118853. */
  118854. PhysicsJoint.LockJoint = 10;
  118855. return PhysicsJoint;
  118856. }());
  118857. /**
  118858. * A class representing a physics distance joint
  118859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118860. */
  118861. var DistanceJoint = /** @class */ (function (_super) {
  118862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  118863. /**
  118864. *
  118865. * @param jointData The data for the Distance-Joint
  118866. */
  118867. function DistanceJoint(jointData) {
  118868. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  118869. }
  118870. /**
  118871. * Update the predefined distance.
  118872. * @param maxDistance The maximum preferred distance
  118873. * @param minDistance The minimum preferred distance
  118874. */
  118875. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  118876. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  118877. };
  118878. return DistanceJoint;
  118879. }(PhysicsJoint));
  118880. /**
  118881. * Represents a Motor-Enabled Joint
  118882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118883. */
  118884. var MotorEnabledJoint = /** @class */ (function (_super) {
  118885. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  118886. /**
  118887. * Initializes the Motor-Enabled Joint
  118888. * @param type The type of the joint
  118889. * @param jointData The physica joint data for the joint
  118890. */
  118891. function MotorEnabledJoint(type, jointData) {
  118892. return _super.call(this, type, jointData) || this;
  118893. }
  118894. /**
  118895. * Set the motor values.
  118896. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118897. * @param force the force to apply
  118898. * @param maxForce max force for this motor.
  118899. */
  118900. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  118901. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  118902. };
  118903. /**
  118904. * Set the motor's limits.
  118905. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118906. * @param upperLimit The upper limit of the motor
  118907. * @param lowerLimit The lower limit of the motor
  118908. */
  118909. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  118910. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  118911. };
  118912. return MotorEnabledJoint;
  118913. }(PhysicsJoint));
  118914. /**
  118915. * This class represents a single physics Hinge-Joint
  118916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118917. */
  118918. var HingeJoint = /** @class */ (function (_super) {
  118919. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  118920. /**
  118921. * Initializes the Hinge-Joint
  118922. * @param jointData The joint data for the Hinge-Joint
  118923. */
  118924. function HingeJoint(jointData) {
  118925. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  118926. }
  118927. /**
  118928. * Set the motor values.
  118929. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118930. * @param {number} force the force to apply
  118931. * @param {number} maxForce max force for this motor.
  118932. */
  118933. HingeJoint.prototype.setMotor = function (force, maxForce) {
  118934. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  118935. };
  118936. /**
  118937. * Set the motor's limits.
  118938. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118939. * @param upperLimit The upper limit of the motor
  118940. * @param lowerLimit The lower limit of the motor
  118941. */
  118942. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  118943. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  118944. };
  118945. return HingeJoint;
  118946. }(MotorEnabledJoint));
  118947. /**
  118948. * This class represents a dual hinge physics joint (same as wheel joint)
  118949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118950. */
  118951. var Hinge2Joint = /** @class */ (function (_super) {
  118952. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  118953. /**
  118954. * Initializes the Hinge2-Joint
  118955. * @param jointData The joint data for the Hinge2-Joint
  118956. */
  118957. function Hinge2Joint(jointData) {
  118958. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  118959. }
  118960. /**
  118961. * Set the motor values.
  118962. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118963. * @param {number} targetSpeed the speed the motor is to reach
  118964. * @param {number} maxForce max force for this motor.
  118965. * @param {motorIndex} the motor's index, 0 or 1.
  118966. */
  118967. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  118968. if (motorIndex === void 0) { motorIndex = 0; }
  118969. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  118970. };
  118971. /**
  118972. * Set the motor limits.
  118973. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118974. * @param {number} upperLimit the upper limit
  118975. * @param {number} lowerLimit lower limit
  118976. * @param {motorIndex} the motor's index, 0 or 1.
  118977. */
  118978. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  118979. if (motorIndex === void 0) { motorIndex = 0; }
  118980. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  118981. };
  118982. return Hinge2Joint;
  118983. }(MotorEnabledJoint));
  118984. /***/ }),
  118985. /***/ "./Physics/physicsRaycastResult.ts":
  118986. /*!*****************************************!*\
  118987. !*** ./Physics/physicsRaycastResult.ts ***!
  118988. \*****************************************/
  118989. /*! exports provided: PhysicsRaycastResult */
  118990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118991. "use strict";
  118992. __webpack_require__.r(__webpack_exports__);
  118993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRaycastResult", function() { return PhysicsRaycastResult; });
  118994. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118995. /**
  118996. * Holds the data for the raycast result
  118997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118998. */
  118999. var PhysicsRaycastResult = /** @class */ (function () {
  119000. function PhysicsRaycastResult() {
  119001. this._hasHit = false;
  119002. this._hitDistance = 0;
  119003. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  119004. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  119005. this._rayFromWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  119006. this._rayToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  119007. }
  119008. Object.defineProperty(PhysicsRaycastResult.prototype, "hasHit", {
  119009. /**
  119010. * Gets if there was a hit
  119011. */
  119012. get: function () {
  119013. return this._hasHit;
  119014. },
  119015. enumerable: true,
  119016. configurable: true
  119017. });
  119018. Object.defineProperty(PhysicsRaycastResult.prototype, "hitDistance", {
  119019. /**
  119020. * Gets the distance from the hit
  119021. */
  119022. get: function () {
  119023. return this._hitDistance;
  119024. },
  119025. enumerable: true,
  119026. configurable: true
  119027. });
  119028. Object.defineProperty(PhysicsRaycastResult.prototype, "hitNormalWorld", {
  119029. /**
  119030. * Gets the hit normal/direction in the world
  119031. */
  119032. get: function () {
  119033. return this._hitNormalWorld;
  119034. },
  119035. enumerable: true,
  119036. configurable: true
  119037. });
  119038. Object.defineProperty(PhysicsRaycastResult.prototype, "hitPointWorld", {
  119039. /**
  119040. * Gets the hit point in the world
  119041. */
  119042. get: function () {
  119043. return this._hitPointWorld;
  119044. },
  119045. enumerable: true,
  119046. configurable: true
  119047. });
  119048. Object.defineProperty(PhysicsRaycastResult.prototype, "rayFromWorld", {
  119049. /**
  119050. * Gets the ray "start point" of the ray in the world
  119051. */
  119052. get: function () {
  119053. return this._rayFromWorld;
  119054. },
  119055. enumerable: true,
  119056. configurable: true
  119057. });
  119058. Object.defineProperty(PhysicsRaycastResult.prototype, "rayToWorld", {
  119059. /**
  119060. * Gets the ray "end point" of the ray in the world
  119061. */
  119062. get: function () {
  119063. return this._rayToWorld;
  119064. },
  119065. enumerable: true,
  119066. configurable: true
  119067. });
  119068. /**
  119069. * Sets the hit data (normal & point in world space)
  119070. * @param hitNormalWorld defines the normal in world space
  119071. * @param hitPointWorld defines the point in world space
  119072. */
  119073. PhysicsRaycastResult.prototype.setHitData = function (hitNormalWorld, hitPointWorld) {
  119074. this._hasHit = true;
  119075. this._hitNormalWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z);
  119076. this._hitPointWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitPointWorld.x, hitPointWorld.y, hitPointWorld.z);
  119077. };
  119078. /**
  119079. * Sets the distance from the start point to the hit point
  119080. * @param distance
  119081. */
  119082. PhysicsRaycastResult.prototype.setHitDistance = function (distance) {
  119083. this._hitDistance = distance;
  119084. };
  119085. /**
  119086. * Calculates the distance manually
  119087. */
  119088. PhysicsRaycastResult.prototype.calculateHitDistance = function () {
  119089. this._hitDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._rayFromWorld, this._hitPointWorld);
  119090. };
  119091. /**
  119092. * Resets all the values to default
  119093. * @param from The from point on world space
  119094. * @param to The to point on world space
  119095. */
  119096. PhysicsRaycastResult.prototype.reset = function (from, to) {
  119097. if (from === void 0) { from = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  119098. if (to === void 0) { to = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  119099. this._rayFromWorld = from;
  119100. this._rayToWorld = to;
  119101. this._hasHit = false;
  119102. this._hitDistance = 0;
  119103. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  119104. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  119105. };
  119106. return PhysicsRaycastResult;
  119107. }());
  119108. /***/ }),
  119109. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  119110. /*!****************************************************************************!*\
  119111. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  119112. \****************************************************************************/
  119113. /*! exports provided: DefaultRenderingPipeline */
  119114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119115. "use strict";
  119116. __webpack_require__.r(__webpack_exports__);
  119117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  119118. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119119. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  119120. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  119121. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119122. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  119123. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  119124. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  119125. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  119126. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  119127. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  119128. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  119129. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119130. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119131. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  119132. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  119133. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  119134. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  119135. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  119136. /**
  119137. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  119138. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  119139. */
  119140. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  119141. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  119142. /**
  119143. * @constructor
  119144. * @param name - The rendering pipeline name (default: "")
  119145. * @param hdr - If high dynamic range textures should be used (default: true)
  119146. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119147. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119148. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119149. */
  119150. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  119151. if (name === void 0) { name = ""; }
  119152. if (hdr === void 0) { hdr = true; }
  119153. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  119154. if (automaticBuild === void 0) { automaticBuild = true; }
  119155. var _this = _super.call(this, scene.getEngine(), name) || this;
  119156. _this._camerasToBeAttached = [];
  119157. /**
  119158. * ID of the sharpen post process,
  119159. */
  119160. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  119161. /**
  119162. * @ignore
  119163. * ID of the image processing post process;
  119164. */
  119165. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  119166. /**
  119167. * @ignore
  119168. * ID of the Fast Approximate Anti-Aliasing post process;
  119169. */
  119170. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  119171. /**
  119172. * ID of the chromatic aberration post process,
  119173. */
  119174. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  119175. /**
  119176. * ID of the grain post process
  119177. */
  119178. _this.GrainPostProcessId = "GrainPostProcessEffect";
  119179. /**
  119180. * Glow post process which adds a glow to emissive areas of the image
  119181. */
  119182. _this._glowLayer = null;
  119183. /**
  119184. * Animations which can be used to tweak settings over a period of time
  119185. */
  119186. _this.animations = [];
  119187. _this._imageProcessingConfigurationObserver = null;
  119188. // Values
  119189. _this._sharpenEnabled = false;
  119190. _this._bloomEnabled = false;
  119191. _this._depthOfFieldEnabled = false;
  119192. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  119193. _this._fxaaEnabled = false;
  119194. _this._imageProcessingEnabled = true;
  119195. _this._bloomScale = 0.5;
  119196. _this._chromaticAberrationEnabled = false;
  119197. _this._grainEnabled = false;
  119198. _this._buildAllowed = true;
  119199. _this._resizeObserver = null;
  119200. _this._hardwareScaleLevel = 1.0;
  119201. _this._bloomKernel = 64;
  119202. /**
  119203. * Specifies the weight of the bloom in the final rendering
  119204. */
  119205. _this._bloomWeight = 0.15;
  119206. /**
  119207. * Specifies the luma threshold for the area that will be blurred by the bloom
  119208. */
  119209. _this._bloomThreshold = 0.9;
  119210. _this._samples = 1;
  119211. _this._hasCleared = false;
  119212. _this._prevPostProcess = null;
  119213. _this._prevPrevPostProcess = null;
  119214. _this._depthOfFieldSceneObserver = null;
  119215. _this._cameras = cameras || scene.cameras;
  119216. _this._cameras = _this._cameras.slice();
  119217. _this._camerasToBeAttached = _this._cameras.slice();
  119218. _this._buildAllowed = automaticBuild;
  119219. // Initialize
  119220. _this._scene = scene;
  119221. var caps = _this._scene.getEngine().getCaps();
  119222. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  119223. // Misc
  119224. if (_this._hdr) {
  119225. if (caps.textureHalfFloatRender) {
  119226. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  119227. }
  119228. else if (caps.textureFloatRender) {
  119229. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  119230. }
  119231. }
  119232. else {
  119233. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  119234. }
  119235. // Attach
  119236. scene.postProcessRenderPipelineManager.addPipeline(_this);
  119237. var engine = _this._scene.getEngine();
  119238. // Create post processes before hand so they can be modified before enabled.
  119239. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  119240. _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);
  119241. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  119242. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  119243. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  119244. _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);
  119245. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  119246. _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);
  119247. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  119248. _this._resizeObserver = engine.onResizeObservable.add(function () {
  119249. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  119250. _this.bloomKernel = _this.bloomKernel;
  119251. });
  119252. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  119253. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  119254. });
  119255. _this._buildPipeline();
  119256. return _this;
  119257. }
  119258. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  119259. /**
  119260. * Gets active scene
  119261. */
  119262. get: function () {
  119263. return this._scene;
  119264. },
  119265. enumerable: true,
  119266. configurable: true
  119267. });
  119268. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  119269. get: function () {
  119270. return this._sharpenEnabled;
  119271. },
  119272. /**
  119273. * Enable or disable the sharpen process from the pipeline
  119274. */
  119275. set: function (enabled) {
  119276. if (this._sharpenEnabled === enabled) {
  119277. return;
  119278. }
  119279. this._sharpenEnabled = enabled;
  119280. this._buildPipeline();
  119281. },
  119282. enumerable: true,
  119283. configurable: true
  119284. });
  119285. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  119286. /**
  119287. * Specifies the size of the bloom blur kernel, relative to the final output size
  119288. */
  119289. get: function () {
  119290. return this._bloomKernel;
  119291. },
  119292. set: function (value) {
  119293. this._bloomKernel = value;
  119294. this.bloom.kernel = value / this._hardwareScaleLevel;
  119295. },
  119296. enumerable: true,
  119297. configurable: true
  119298. });
  119299. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  119300. get: function () {
  119301. return this._bloomWeight;
  119302. },
  119303. /**
  119304. * The strength of the bloom.
  119305. */
  119306. set: function (value) {
  119307. if (this._bloomWeight === value) {
  119308. return;
  119309. }
  119310. this.bloom.weight = value;
  119311. this._bloomWeight = value;
  119312. },
  119313. enumerable: true,
  119314. configurable: true
  119315. });
  119316. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  119317. get: function () {
  119318. return this._bloomThreshold;
  119319. },
  119320. /**
  119321. * The strength of the bloom.
  119322. */
  119323. set: function (value) {
  119324. if (this._bloomThreshold === value) {
  119325. return;
  119326. }
  119327. this.bloom.threshold = value;
  119328. this._bloomThreshold = value;
  119329. },
  119330. enumerable: true,
  119331. configurable: true
  119332. });
  119333. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  119334. get: function () {
  119335. return this._bloomScale;
  119336. },
  119337. /**
  119338. * The scale of the bloom, lower value will provide better performance.
  119339. */
  119340. set: function (value) {
  119341. if (this._bloomScale === value) {
  119342. return;
  119343. }
  119344. this._bloomScale = value;
  119345. // recreate bloom and dispose old as this setting is not dynamic
  119346. this._rebuildBloom();
  119347. this._buildPipeline();
  119348. },
  119349. enumerable: true,
  119350. configurable: true
  119351. });
  119352. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  119353. get: function () {
  119354. return this._bloomEnabled;
  119355. },
  119356. /**
  119357. * Enable or disable the bloom from the pipeline
  119358. */
  119359. set: function (enabled) {
  119360. if (this._bloomEnabled === enabled) {
  119361. return;
  119362. }
  119363. this._bloomEnabled = enabled;
  119364. this._buildPipeline();
  119365. },
  119366. enumerable: true,
  119367. configurable: true
  119368. });
  119369. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  119370. // recreate bloom and dispose old as this setting is not dynamic
  119371. var oldBloom = this.bloom;
  119372. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  119373. this.bloom.threshold = oldBloom.threshold;
  119374. for (var i = 0; i < this._cameras.length; i++) {
  119375. oldBloom.disposeEffects(this._cameras[i]);
  119376. }
  119377. };
  119378. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  119379. /**
  119380. * If the depth of field is enabled.
  119381. */
  119382. get: function () {
  119383. return this._depthOfFieldEnabled;
  119384. },
  119385. set: function (enabled) {
  119386. if (this._depthOfFieldEnabled === enabled) {
  119387. return;
  119388. }
  119389. this._depthOfFieldEnabled = enabled;
  119390. this._buildPipeline();
  119391. },
  119392. enumerable: true,
  119393. configurable: true
  119394. });
  119395. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  119396. /**
  119397. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119398. */
  119399. get: function () {
  119400. return this._depthOfFieldBlurLevel;
  119401. },
  119402. set: function (value) {
  119403. if (this._depthOfFieldBlurLevel === value) {
  119404. return;
  119405. }
  119406. this._depthOfFieldBlurLevel = value;
  119407. // recreate dof and dispose old as this setting is not dynamic
  119408. var oldDof = this.depthOfField;
  119409. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  119410. this.depthOfField.focalLength = oldDof.focalLength;
  119411. this.depthOfField.focusDistance = oldDof.focusDistance;
  119412. this.depthOfField.fStop = oldDof.fStop;
  119413. this.depthOfField.lensSize = oldDof.lensSize;
  119414. for (var i = 0; i < this._cameras.length; i++) {
  119415. oldDof.disposeEffects(this._cameras[i]);
  119416. }
  119417. this._buildPipeline();
  119418. },
  119419. enumerable: true,
  119420. configurable: true
  119421. });
  119422. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  119423. get: function () {
  119424. return this._fxaaEnabled;
  119425. },
  119426. /**
  119427. * If the anti aliasing is enabled.
  119428. */
  119429. set: function (enabled) {
  119430. if (this._fxaaEnabled === enabled) {
  119431. return;
  119432. }
  119433. this._fxaaEnabled = enabled;
  119434. this._buildPipeline();
  119435. },
  119436. enumerable: true,
  119437. configurable: true
  119438. });
  119439. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  119440. get: function () {
  119441. return this._samples;
  119442. },
  119443. /**
  119444. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119445. */
  119446. set: function (sampleCount) {
  119447. if (this._samples === sampleCount) {
  119448. return;
  119449. }
  119450. this._samples = sampleCount;
  119451. this._buildPipeline();
  119452. },
  119453. enumerable: true,
  119454. configurable: true
  119455. });
  119456. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  119457. get: function () {
  119458. return this._imageProcessingEnabled;
  119459. },
  119460. /**
  119461. * If image processing is enabled.
  119462. */
  119463. set: function (enabled) {
  119464. if (this._imageProcessingEnabled === enabled) {
  119465. return;
  119466. }
  119467. this._imageProcessingEnabled = enabled;
  119468. this._buildPipeline();
  119469. },
  119470. enumerable: true,
  119471. configurable: true
  119472. });
  119473. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  119474. get: function () {
  119475. return this._glowLayer != null;
  119476. },
  119477. /**
  119478. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119479. */
  119480. set: function (enabled) {
  119481. if (enabled && !this._glowLayer) {
  119482. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  119483. }
  119484. else if (!enabled && this._glowLayer) {
  119485. this._glowLayer.dispose();
  119486. this._glowLayer = null;
  119487. }
  119488. },
  119489. enumerable: true,
  119490. configurable: true
  119491. });
  119492. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  119493. get: function () {
  119494. return this._chromaticAberrationEnabled;
  119495. },
  119496. /**
  119497. * Enable or disable the chromaticAberration process from the pipeline
  119498. */
  119499. set: function (enabled) {
  119500. if (this._chromaticAberrationEnabled === enabled) {
  119501. return;
  119502. }
  119503. this._chromaticAberrationEnabled = enabled;
  119504. this._buildPipeline();
  119505. },
  119506. enumerable: true,
  119507. configurable: true
  119508. });
  119509. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  119510. get: function () {
  119511. return this._grainEnabled;
  119512. },
  119513. /**
  119514. * Enable or disable the grain process from the pipeline
  119515. */
  119516. set: function (enabled) {
  119517. if (this._grainEnabled === enabled) {
  119518. return;
  119519. }
  119520. this._grainEnabled = enabled;
  119521. this._buildPipeline();
  119522. },
  119523. enumerable: true,
  119524. configurable: true
  119525. });
  119526. /**
  119527. * Get the class name
  119528. * @returns "DefaultRenderingPipeline"
  119529. */
  119530. DefaultRenderingPipeline.prototype.getClassName = function () {
  119531. return "DefaultRenderingPipeline";
  119532. };
  119533. /**
  119534. * Force the compilation of the entire pipeline.
  119535. */
  119536. DefaultRenderingPipeline.prototype.prepare = function () {
  119537. var previousState = this._buildAllowed;
  119538. this._buildAllowed = true;
  119539. this._buildPipeline();
  119540. this._buildAllowed = previousState;
  119541. };
  119542. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  119543. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  119544. if (this._hasCleared) {
  119545. postProcess.autoClear = false;
  119546. }
  119547. else {
  119548. postProcess.autoClear = true;
  119549. this._scene.autoClear = false;
  119550. this._hasCleared = true;
  119551. }
  119552. if (!skipTextureSharing) {
  119553. if (this._prevPrevPostProcess) {
  119554. postProcess.shareOutputWith(this._prevPrevPostProcess);
  119555. }
  119556. else {
  119557. postProcess.useOwnOutput();
  119558. }
  119559. if (this._prevPostProcess) {
  119560. this._prevPrevPostProcess = this._prevPostProcess;
  119561. }
  119562. this._prevPostProcess = postProcess;
  119563. }
  119564. };
  119565. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  119566. var _this = this;
  119567. if (!this._buildAllowed) {
  119568. return;
  119569. }
  119570. this._scene.autoClear = true;
  119571. var engine = this._scene.getEngine();
  119572. this._disposePostProcesses();
  119573. if (this._cameras !== null) {
  119574. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  119575. // get back cameras to be used to reattach pipeline
  119576. this._cameras = this._camerasToBeAttached.slice();
  119577. }
  119578. this._reset();
  119579. this._prevPostProcess = null;
  119580. this._prevPrevPostProcess = null;
  119581. this._hasCleared = false;
  119582. if (this.depthOfFieldEnabled) {
  119583. // Multi camera suport
  119584. if (this._cameras.length > 1) {
  119585. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  119586. var camera = _a[_i];
  119587. var depthRenderer = this._scene.enableDepthRenderer(camera);
  119588. depthRenderer.useOnlyInActiveCamera = true;
  119589. }
  119590. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  119591. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  119592. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  119593. }
  119594. });
  119595. }
  119596. else {
  119597. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  119598. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  119599. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  119600. }
  119601. if (!this.depthOfField._isReady()) {
  119602. this.depthOfField._updateEffects();
  119603. }
  119604. this.addEffect(this.depthOfField);
  119605. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  119606. }
  119607. else {
  119608. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  119609. }
  119610. if (this.bloomEnabled) {
  119611. if (!this.bloom._isReady()) {
  119612. this.bloom._updateEffects();
  119613. }
  119614. this.addEffect(this.bloom);
  119615. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  119616. }
  119617. if (this._imageProcessingEnabled) {
  119618. 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);
  119619. if (this._hdr) {
  119620. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  119621. this._setAutoClearAndTextureSharing(this.imageProcessing);
  119622. }
  119623. else {
  119624. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  119625. }
  119626. }
  119627. if (this.sharpenEnabled) {
  119628. if (!this.sharpen.isReady()) {
  119629. this.sharpen.updateEffect();
  119630. }
  119631. this.addEffect(this._sharpenEffect);
  119632. this._setAutoClearAndTextureSharing(this.sharpen);
  119633. }
  119634. if (this.grainEnabled) {
  119635. if (!this.grain.isReady()) {
  119636. this.grain.updateEffect();
  119637. }
  119638. this.addEffect(this._grainEffect);
  119639. this._setAutoClearAndTextureSharing(this.grain);
  119640. }
  119641. if (this.chromaticAberrationEnabled) {
  119642. if (!this.chromaticAberration.isReady()) {
  119643. this.chromaticAberration.updateEffect();
  119644. }
  119645. this.addEffect(this._chromaticAberrationEffect);
  119646. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  119647. }
  119648. if (this.fxaaEnabled) {
  119649. 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);
  119650. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  119651. this._setAutoClearAndTextureSharing(this.fxaa, true);
  119652. }
  119653. if (this._cameras !== null) {
  119654. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  119655. }
  119656. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  119657. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  119658. }
  119659. };
  119660. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  119661. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  119662. for (var i = 0; i < this._cameras.length; i++) {
  119663. var camera = this._cameras[i];
  119664. if (this.imageProcessing) {
  119665. this.imageProcessing.dispose(camera);
  119666. }
  119667. if (this.fxaa) {
  119668. this.fxaa.dispose(camera);
  119669. }
  119670. // These are created in the constructor and should not be disposed on every pipeline change
  119671. if (disposeNonRecreated) {
  119672. if (this.sharpen) {
  119673. this.sharpen.dispose(camera);
  119674. }
  119675. if (this.depthOfField) {
  119676. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  119677. this.depthOfField.disposeEffects(camera);
  119678. }
  119679. if (this.bloom) {
  119680. this.bloom.disposeEffects(camera);
  119681. }
  119682. if (this.chromaticAberration) {
  119683. this.chromaticAberration.dispose(camera);
  119684. }
  119685. if (this.grain) {
  119686. this.grain.dispose(camera);
  119687. }
  119688. if (this._glowLayer) {
  119689. this._glowLayer.dispose();
  119690. }
  119691. }
  119692. }
  119693. this.imageProcessing = null;
  119694. this.fxaa = null;
  119695. if (disposeNonRecreated) {
  119696. this.sharpen = null;
  119697. this._sharpenEffect = null;
  119698. this.depthOfField = null;
  119699. this.bloom = null;
  119700. this.chromaticAberration = null;
  119701. this._chromaticAberrationEffect = null;
  119702. this.grain = null;
  119703. this._grainEffect = null;
  119704. this._glowLayer = null;
  119705. }
  119706. };
  119707. /**
  119708. * Adds a camera to the pipeline
  119709. * @param camera the camera to be added
  119710. */
  119711. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  119712. this._camerasToBeAttached.push(camera);
  119713. this._buildPipeline();
  119714. };
  119715. /**
  119716. * Removes a camera from the pipeline
  119717. * @param camera the camera to remove
  119718. */
  119719. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  119720. var index = this._camerasToBeAttached.indexOf(camera);
  119721. this._camerasToBeAttached.splice(index, 1);
  119722. this._buildPipeline();
  119723. };
  119724. /**
  119725. * Dispose of the pipeline and stop all post processes
  119726. */
  119727. DefaultRenderingPipeline.prototype.dispose = function () {
  119728. this._disposePostProcesses(true);
  119729. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  119730. this._scene.autoClear = true;
  119731. if (this._resizeObserver) {
  119732. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  119733. this._resizeObserver = null;
  119734. }
  119735. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  119736. _super.prototype.dispose.call(this);
  119737. };
  119738. /**
  119739. * Serialize the rendering pipeline (Used when exporting)
  119740. * @returns the serialized object
  119741. */
  119742. DefaultRenderingPipeline.prototype.serialize = function () {
  119743. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  119744. serializationObject.customType = "DefaultRenderingPipeline";
  119745. return serializationObject;
  119746. };
  119747. /**
  119748. * Parse the serialized pipeline
  119749. * @param source Source pipeline.
  119750. * @param scene The scene to load the pipeline to.
  119751. * @param rootUrl The URL of the serialized pipeline.
  119752. * @returns An instantiated pipeline from the serialized object.
  119753. */
  119754. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  119755. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  119756. };
  119757. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119758. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119759. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  119760. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119761. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119762. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  119763. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119764. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119765. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  119766. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119767. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119768. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  119769. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119770. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119771. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  119772. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119773. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119774. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  119775. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119776. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119777. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  119778. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119779. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119780. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  119781. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119782. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119783. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  119784. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119785. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119786. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  119787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119789. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  119790. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119791. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119792. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  119793. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119794. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119795. ], DefaultRenderingPipeline.prototype, "samples", null);
  119796. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119797. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119798. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  119799. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119800. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119801. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  119802. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119803. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119804. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  119805. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119807. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  119808. return DefaultRenderingPipeline;
  119809. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  119810. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  119811. /***/ }),
  119812. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  119813. /*!*********************************************************!*\
  119814. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  119815. \*********************************************************/
  119816. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  119817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119818. "use strict";
  119819. __webpack_require__.r(__webpack_exports__);
  119820. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  119821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  119822. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  119823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  119824. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  119825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  119826. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  119827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  119828. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  119829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  119830. /***/ }),
  119831. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  119832. /*!*************************************************************************!*\
  119833. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  119834. \*************************************************************************/
  119835. /*! exports provided: LensRenderingPipeline */
  119836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119837. "use strict";
  119838. __webpack_require__.r(__webpack_exports__);
  119839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  119840. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119841. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119842. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  119843. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  119844. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119845. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119846. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  119847. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  119848. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  119849. /**
  119850. * BABYLON.JS Chromatic Aberration GLSL Shader
  119851. * Author: Olivier Guyot
  119852. * Separates very slightly R, G and B colors on the edges of the screen
  119853. * Inspired by Francois Tarlier & Martins Upitis
  119854. */
  119855. var LensRenderingPipeline = /** @class */ (function (_super) {
  119856. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  119857. /**
  119858. * @constructor
  119859. *
  119860. * Effect parameters are as follow:
  119861. * {
  119862. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119863. * edge_blur: number; // from 0 to x (1 for realism)
  119864. * distortion: number; // from 0 to x (1 for realism)
  119865. * grain_amount: number; // from 0 to 1
  119866. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119867. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119868. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119869. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119870. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119871. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119872. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119873. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119874. * }
  119875. * Note: if an effect parameter is unset, effect is disabled
  119876. *
  119877. * @param name The rendering pipeline name
  119878. * @param parameters - An object containing all parameters (see above)
  119879. * @param scene The scene linked to this pipeline
  119880. * @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)
  119881. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119882. */
  119883. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  119884. if (ratio === void 0) { ratio = 1.0; }
  119885. var _this = _super.call(this, scene.getEngine(), name) || this;
  119886. // Lens effects can be of the following:
  119887. // - chromatic aberration (slight shift of RGB colors)
  119888. // - blur on the edge of the lens
  119889. // - lens distortion
  119890. // - depth-of-field blur & highlights enhancing
  119891. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  119892. // - grain effect (noise or custom texture)
  119893. // Two additional texture samplers are needed:
  119894. // - depth map (for depth-of-field)
  119895. // - grain texture
  119896. /**
  119897. * @ignore
  119898. * The chromatic aberration PostProcess id in the pipeline
  119899. */
  119900. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  119901. /**
  119902. * @ignore
  119903. * The highlights enhancing PostProcess id in the pipeline
  119904. */
  119905. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  119906. /**
  119907. * @ignore
  119908. * The depth-of-field PostProcess id in the pipeline
  119909. */
  119910. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  119911. _this._pentagonBokehIsEnabled = false;
  119912. _this._scene = scene;
  119913. // Fetch texture samplers
  119914. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  119915. if (parameters.grain_texture) {
  119916. _this._grainTexture = parameters.grain_texture;
  119917. }
  119918. else {
  119919. _this._createGrainTexture();
  119920. }
  119921. // save parameters
  119922. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  119923. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  119924. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  119925. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  119926. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  119927. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  119928. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  119929. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  119930. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  119931. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  119932. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  119933. // Create effects
  119934. _this._createChromaticAberrationPostProcess(ratio);
  119935. _this._createHighlightsPostProcess(ratio);
  119936. _this._createDepthOfFieldPostProcess(ratio / 4);
  119937. // Set up pipeline
  119938. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  119939. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  119940. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  119941. if (_this._highlightsGain === -1) {
  119942. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  119943. }
  119944. // Finish
  119945. scene.postProcessRenderPipelineManager.addPipeline(_this);
  119946. if (cameras) {
  119947. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  119948. }
  119949. return _this;
  119950. }
  119951. /**
  119952. * Get the class name
  119953. * @returns "LensRenderingPipeline"
  119954. */
  119955. LensRenderingPipeline.prototype.getClassName = function () {
  119956. return "LensRenderingPipeline";
  119957. };
  119958. Object.defineProperty(LensRenderingPipeline.prototype, "scene", {
  119959. // Properties
  119960. /**
  119961. * Gets associated scene
  119962. */
  119963. get: function () {
  119964. return this._scene;
  119965. },
  119966. enumerable: true,
  119967. configurable: true
  119968. });
  119969. Object.defineProperty(LensRenderingPipeline.prototype, "edgeBlur", {
  119970. /**
  119971. * Gets or sets the edge blur
  119972. */
  119973. get: function () {
  119974. return this._edgeBlur;
  119975. },
  119976. set: function (value) {
  119977. this.setEdgeBlur(value);
  119978. },
  119979. enumerable: true,
  119980. configurable: true
  119981. });
  119982. Object.defineProperty(LensRenderingPipeline.prototype, "grainAmount", {
  119983. /**
  119984. * Gets or sets the grain amount
  119985. */
  119986. get: function () {
  119987. return this._grainAmount;
  119988. },
  119989. set: function (value) {
  119990. this.setGrainAmount(value);
  119991. },
  119992. enumerable: true,
  119993. configurable: true
  119994. });
  119995. Object.defineProperty(LensRenderingPipeline.prototype, "chromaticAberration", {
  119996. /**
  119997. * Gets or sets the chromatic aberration amount
  119998. */
  119999. get: function () {
  120000. return this._chromaticAberration;
  120001. },
  120002. set: function (value) {
  120003. this.setChromaticAberration(value);
  120004. },
  120005. enumerable: true,
  120006. configurable: true
  120007. });
  120008. Object.defineProperty(LensRenderingPipeline.prototype, "dofAperture", {
  120009. /**
  120010. * Gets or sets the depth of field aperture
  120011. */
  120012. get: function () {
  120013. return this._dofAperture;
  120014. },
  120015. set: function (value) {
  120016. this.setAperture(value);
  120017. },
  120018. enumerable: true,
  120019. configurable: true
  120020. });
  120021. Object.defineProperty(LensRenderingPipeline.prototype, "edgeDistortion", {
  120022. /**
  120023. * Gets or sets the edge distortion
  120024. */
  120025. get: function () {
  120026. return this._distortion;
  120027. },
  120028. set: function (value) {
  120029. this.setEdgeDistortion(value);
  120030. },
  120031. enumerable: true,
  120032. configurable: true
  120033. });
  120034. Object.defineProperty(LensRenderingPipeline.prototype, "dofDistortion", {
  120035. /**
  120036. * Gets or sets the depth of field distortion
  120037. */
  120038. get: function () {
  120039. return this._dofDistance;
  120040. },
  120041. set: function (value) {
  120042. this.setFocusDistance(value);
  120043. },
  120044. enumerable: true,
  120045. configurable: true
  120046. });
  120047. Object.defineProperty(LensRenderingPipeline.prototype, "darkenOutOfFocus", {
  120048. /**
  120049. * Gets or sets the darken out of focus amount
  120050. */
  120051. get: function () {
  120052. return this._dofDarken;
  120053. },
  120054. set: function (value) {
  120055. this.setDarkenOutOfFocus(value);
  120056. },
  120057. enumerable: true,
  120058. configurable: true
  120059. });
  120060. Object.defineProperty(LensRenderingPipeline.prototype, "blurNoise", {
  120061. /**
  120062. * Gets or sets a boolean indicating if blur noise is enabled
  120063. */
  120064. get: function () {
  120065. return this._blurNoise;
  120066. },
  120067. set: function (value) {
  120068. this._blurNoise = value;
  120069. },
  120070. enumerable: true,
  120071. configurable: true
  120072. });
  120073. Object.defineProperty(LensRenderingPipeline.prototype, "pentagonBokeh", {
  120074. /**
  120075. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  120076. */
  120077. get: function () {
  120078. return this._pentagonBokehIsEnabled;
  120079. },
  120080. set: function (value) {
  120081. if (value) {
  120082. this.enablePentagonBokeh();
  120083. }
  120084. else {
  120085. this.disablePentagonBokeh();
  120086. }
  120087. },
  120088. enumerable: true,
  120089. configurable: true
  120090. });
  120091. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsGain", {
  120092. /**
  120093. * Gets or sets the highlight grain amount
  120094. */
  120095. get: function () {
  120096. return this._highlightsGain;
  120097. },
  120098. set: function (value) {
  120099. this.setHighlightsGain(value);
  120100. },
  120101. enumerable: true,
  120102. configurable: true
  120103. });
  120104. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsThreshold", {
  120105. /**
  120106. * Gets or sets the highlight threshold
  120107. */
  120108. get: function () {
  120109. return this._highlightsThreshold;
  120110. },
  120111. set: function (value) {
  120112. this.setHighlightsThreshold(value);
  120113. },
  120114. enumerable: true,
  120115. configurable: true
  120116. });
  120117. // public methods (self explanatory)
  120118. /**
  120119. * Sets the amount of blur at the edges
  120120. * @param amount blur amount
  120121. */
  120122. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  120123. /**
  120124. * Sets edge blur to 0
  120125. */
  120126. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  120127. /**
  120128. * Sets the amout of grain
  120129. * @param amount Amount of grain
  120130. */
  120131. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  120132. /**
  120133. * Set grain amount to 0
  120134. */
  120135. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  120136. /**
  120137. * Sets the chromatic aberration amount
  120138. * @param amount amount of chromatic aberration
  120139. */
  120140. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  120141. /**
  120142. * Sets chromatic aberration amount to 0
  120143. */
  120144. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  120145. /**
  120146. * Sets the EdgeDistortion amount
  120147. * @param amount amount of EdgeDistortion
  120148. */
  120149. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  120150. /**
  120151. * Sets edge distortion to 0
  120152. */
  120153. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  120154. /**
  120155. * Sets the FocusDistance amount
  120156. * @param amount amount of FocusDistance
  120157. */
  120158. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  120159. /**
  120160. * Disables depth of field
  120161. */
  120162. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  120163. /**
  120164. * Sets the Aperture amount
  120165. * @param amount amount of Aperture
  120166. */
  120167. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  120168. /**
  120169. * Sets the DarkenOutOfFocus amount
  120170. * @param amount amount of DarkenOutOfFocus
  120171. */
  120172. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  120173. /**
  120174. * Creates a pentagon bokeh effect
  120175. */
  120176. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  120177. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  120178. this._pentagonBokehIsEnabled = true;
  120179. };
  120180. /**
  120181. * Disables the pentagon bokeh effect
  120182. */
  120183. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  120184. this._pentagonBokehIsEnabled = false;
  120185. this._highlightsPostProcess.updateEffect();
  120186. };
  120187. /**
  120188. * Enables noise blur
  120189. */
  120190. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  120191. /**
  120192. * Disables noise blur
  120193. */
  120194. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  120195. /**
  120196. * Sets the HighlightsGain amount
  120197. * @param amount amount of HighlightsGain
  120198. */
  120199. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  120200. this._highlightsGain = amount;
  120201. };
  120202. /**
  120203. * Sets the HighlightsThreshold amount
  120204. * @param amount amount of HighlightsThreshold
  120205. */
  120206. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  120207. if (this._highlightsGain === -1) {
  120208. this._highlightsGain = 1.0;
  120209. }
  120210. this._highlightsThreshold = amount;
  120211. };
  120212. /**
  120213. * Disables highlights
  120214. */
  120215. LensRenderingPipeline.prototype.disableHighlights = function () {
  120216. this._highlightsGain = -1;
  120217. };
  120218. /**
  120219. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  120220. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  120221. */
  120222. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  120223. if (disableDepthRender === void 0) { disableDepthRender = false; }
  120224. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  120225. this._chromaticAberrationPostProcess = null;
  120226. this._highlightsPostProcess = null;
  120227. this._depthOfFieldPostProcess = null;
  120228. this._grainTexture.dispose();
  120229. if (disableDepthRender) {
  120230. this._scene.disableDepthRenderer();
  120231. }
  120232. };
  120233. // colors shifting and distortion
  120234. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  120235. var _this = this;
  120236. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  120237. [], // samplers
  120238. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  120239. this._chromaticAberrationPostProcess.onApply = function (effect) {
  120240. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  120241. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  120242. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  120243. effect.setFloat('radialIntensity', 1);
  120244. effect.setFloat2('direction', 17, 17);
  120245. effect.setFloat2('centerPosition', 0.5, 0.5);
  120246. };
  120247. };
  120248. // highlights enhancing
  120249. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  120250. var _this = this;
  120251. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  120252. [], // samplers
  120253. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  120254. this._highlightsPostProcess.onApply = function (effect) {
  120255. effect.setFloat('gain', _this._highlightsGain);
  120256. effect.setFloat('threshold', _this._highlightsThreshold);
  120257. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  120258. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  120259. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  120260. };
  120261. };
  120262. // colors shifting and distortion
  120263. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  120264. var _this = this;
  120265. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  120266. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  120267. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  120268. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  120269. this._depthOfFieldPostProcess.onApply = function (effect) {
  120270. effect.setTexture("depthSampler", _this._depthTexture);
  120271. effect.setTexture("grainSampler", _this._grainTexture);
  120272. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  120273. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  120274. effect.setFloat('grain_amount', _this._grainAmount);
  120275. effect.setBool('blur_noise', _this._blurNoise);
  120276. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  120277. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  120278. effect.setFloat('distortion', _this._distortion);
  120279. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  120280. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  120281. effect.setFloat('aperture', _this._dofAperture);
  120282. effect.setFloat('darken', _this._dofDarken);
  120283. effect.setFloat('edge_blur', _this._edgeBlur);
  120284. effect.setBool('highlights', (_this._highlightsGain !== -1));
  120285. if (_this._scene.activeCamera) {
  120286. effect.setFloat('near', _this._scene.activeCamera.minZ);
  120287. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  120288. }
  120289. };
  120290. };
  120291. // creates a black and white random noise texture, 512x512
  120292. LensRenderingPipeline.prototype._createGrainTexture = function () {
  120293. var size = 512;
  120294. 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);
  120295. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  120296. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  120297. var context = this._grainTexture.getContext();
  120298. var rand = function (min, max) {
  120299. return Math.random() * (max - min) + min;
  120300. };
  120301. var value;
  120302. for (var x = 0; x < size; x++) {
  120303. for (var y = 0; y < size; y++) {
  120304. value = Math.floor(rand(0.42, 0.58) * 255);
  120305. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  120306. context.fillRect(x, y, 1, 1);
  120307. }
  120308. }
  120309. this._grainTexture.update(false);
  120310. };
  120311. return LensRenderingPipeline;
  120312. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  120313. /***/ }),
  120314. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  120315. /*!**************************************************************************!*\
  120316. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  120317. \**************************************************************************/
  120318. /*! exports provided: SSAO2RenderingPipeline */
  120319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120320. "use strict";
  120321. __webpack_require__.r(__webpack_exports__);
  120322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  120323. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120324. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  120325. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  120326. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  120327. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120328. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  120329. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  120330. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120331. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120332. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  120333. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  120334. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  120335. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  120336. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  120337. /**
  120338. * Render pipeline to produce ssao effect
  120339. */
  120340. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  120341. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  120342. /**
  120343. * @constructor
  120344. * @param name The rendering pipeline name
  120345. * @param scene The scene linked to this pipeline
  120346. * @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 }
  120347. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120348. */
  120349. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  120350. var _this = _super.call(this, scene.getEngine(), name) || this;
  120351. // Members
  120352. /**
  120353. * @ignore
  120354. * The PassPostProcess id in the pipeline that contains the original scene color
  120355. */
  120356. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  120357. /**
  120358. * @ignore
  120359. * The SSAO PostProcess id in the pipeline
  120360. */
  120361. _this.SSAORenderEffect = "SSAORenderEffect";
  120362. /**
  120363. * @ignore
  120364. * The horizontal blur PostProcess id in the pipeline
  120365. */
  120366. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  120367. /**
  120368. * @ignore
  120369. * The vertical blur PostProcess id in the pipeline
  120370. */
  120371. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  120372. /**
  120373. * @ignore
  120374. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  120375. */
  120376. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  120377. /**
  120378. * The output strength of the SSAO post-process. Default value is 1.0.
  120379. */
  120380. _this.totalStrength = 1.0;
  120381. /**
  120382. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  120383. */
  120384. _this.maxZ = 100.0;
  120385. /**
  120386. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  120387. */
  120388. _this.minZAspect = 0.2;
  120389. _this._samples = 8;
  120390. _this._textureSamples = 1;
  120391. _this._expensiveBlur = true;
  120392. /**
  120393. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  120394. */
  120395. _this.radius = 2.0;
  120396. /**
  120397. * The base color of the SSAO post-process
  120398. * The final result is "base + ssao" between [0, 1]
  120399. */
  120400. _this.base = 0;
  120401. _this._firstUpdate = true;
  120402. _this._bits = new Uint32Array(1);
  120403. _this._scene = scene;
  120404. _this._ratio = ratio;
  120405. if (!_this.isSupported) {
  120406. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  120407. return _this;
  120408. }
  120409. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  120410. var blurRatio = _this._ratio.blurRatio || ratio;
  120411. // Set up assets
  120412. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  120413. _this._createRandomTexture();
  120414. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  120415. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  120416. _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);
  120417. _this._originalColorPostProcess.samples = _this.textureSamples;
  120418. _this._createSSAOPostProcess(1.0);
  120419. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  120420. _this._createSSAOCombinePostProcess(blurRatio);
  120421. // Set up pipeline
  120422. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  120423. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  120424. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  120425. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  120426. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  120427. // Finish
  120428. scene.postProcessRenderPipelineManager.addPipeline(_this);
  120429. if (cameras) {
  120430. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  120431. }
  120432. return _this;
  120433. }
  120434. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  120435. get: function () {
  120436. return this._samples;
  120437. },
  120438. /**
  120439. * Number of samples used for the SSAO calculations. Default value is 8
  120440. */
  120441. set: function (n) {
  120442. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  120443. this._samples = n;
  120444. this._sampleSphere = this._generateHemisphere();
  120445. this._firstUpdate = true;
  120446. },
  120447. enumerable: true,
  120448. configurable: true
  120449. });
  120450. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  120451. get: function () {
  120452. return this._textureSamples;
  120453. },
  120454. /**
  120455. * Number of samples to use for antialiasing
  120456. */
  120457. set: function (n) {
  120458. this._textureSamples = n;
  120459. this._originalColorPostProcess.samples = n;
  120460. this._blurHPostProcess.samples = n;
  120461. this._blurVPostProcess.samples = n;
  120462. this._ssaoPostProcess.samples = n;
  120463. this._ssaoCombinePostProcess.samples = n;
  120464. },
  120465. enumerable: true,
  120466. configurable: true
  120467. });
  120468. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  120469. get: function () {
  120470. return this._expensiveBlur;
  120471. },
  120472. /**
  120473. * If bilateral blur should be used
  120474. */
  120475. set: function (b) {
  120476. 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"]);
  120477. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  120478. this._expensiveBlur = b;
  120479. this._firstUpdate = true;
  120480. },
  120481. enumerable: true,
  120482. configurable: true
  120483. });
  120484. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  120485. /**
  120486. * Support test.
  120487. */
  120488. get: function () {
  120489. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  120490. if (!engine) {
  120491. return false;
  120492. }
  120493. return engine.getCaps().drawBuffersExtension;
  120494. },
  120495. enumerable: true,
  120496. configurable: true
  120497. });
  120498. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  120499. /**
  120500. * Gets active scene
  120501. */
  120502. get: function () {
  120503. return this._scene;
  120504. },
  120505. enumerable: true,
  120506. configurable: true
  120507. });
  120508. // Public Methods
  120509. /**
  120510. * Get the class name
  120511. * @returns "SSAO2RenderingPipeline"
  120512. */
  120513. SSAO2RenderingPipeline.prototype.getClassName = function () {
  120514. return "SSAO2RenderingPipeline";
  120515. };
  120516. /**
  120517. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  120518. */
  120519. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  120520. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  120521. for (var i = 0; i < this._scene.cameras.length; i++) {
  120522. var camera = this._scene.cameras[i];
  120523. this._originalColorPostProcess.dispose(camera);
  120524. this._ssaoPostProcess.dispose(camera);
  120525. this._blurHPostProcess.dispose(camera);
  120526. this._blurVPostProcess.dispose(camera);
  120527. this._ssaoCombinePostProcess.dispose(camera);
  120528. }
  120529. this._randomTexture.dispose();
  120530. if (disableGeometryBufferRenderer) {
  120531. this._scene.disableGeometryBufferRenderer();
  120532. }
  120533. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  120534. _super.prototype.dispose.call(this);
  120535. };
  120536. // Private Methods
  120537. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  120538. var _this = this;
  120539. this._samplerOffsets = [];
  120540. var expensive = this.expensiveBlur;
  120541. for (var i = -8; i < 8; i++) {
  120542. this._samplerOffsets.push(i * 2 + 0.5);
  120543. }
  120544. 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");
  120545. this._blurHPostProcess.onApply = function (effect) {
  120546. if (!_this._scene.activeCamera) {
  120547. return;
  120548. }
  120549. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  120550. effect.setFloat("near", _this._scene.activeCamera.minZ);
  120551. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  120552. effect.setFloat("radius", _this.radius);
  120553. effect.setTexture("depthSampler", _this._depthTexture);
  120554. if (_this._firstUpdate) {
  120555. effect.setArray("samplerOffsets", _this._samplerOffsets);
  120556. }
  120557. };
  120558. 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");
  120559. this._blurVPostProcess.onApply = function (effect) {
  120560. if (!_this._scene.activeCamera) {
  120561. return;
  120562. }
  120563. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  120564. effect.setFloat("near", _this._scene.activeCamera.minZ);
  120565. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  120566. effect.setFloat("radius", _this.radius);
  120567. effect.setTexture("depthSampler", _this._depthTexture);
  120568. if (_this._firstUpdate) {
  120569. effect.setArray("samplerOffsets", _this._samplerOffsets);
  120570. _this._firstUpdate = false;
  120571. }
  120572. };
  120573. this._blurHPostProcess.samples = this.textureSamples;
  120574. this._blurVPostProcess.samples = this.textureSamples;
  120575. };
  120576. /** @hidden */
  120577. SSAO2RenderingPipeline.prototype._rebuild = function () {
  120578. this._firstUpdate = true;
  120579. _super.prototype._rebuild.call(this);
  120580. };
  120581. //Van der Corput radical inverse
  120582. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  120583. this._bits[0] = i;
  120584. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  120585. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  120586. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  120587. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  120588. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  120589. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  120590. };
  120591. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  120592. return [i / n, this._radicalInverse_VdC(i)];
  120593. };
  120594. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  120595. var phi = v * 2.0 * Math.PI;
  120596. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  120597. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  120598. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  120599. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  120600. };
  120601. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  120602. var numSamples = this.samples;
  120603. var result = [];
  120604. var vector;
  120605. var i = 0;
  120606. while (i < numSamples) {
  120607. if (numSamples < 16) {
  120608. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  120609. }
  120610. else {
  120611. var rand = this._hammersley(i, numSamples);
  120612. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  120613. }
  120614. result.push(vector.x, vector.y, vector.z);
  120615. i++;
  120616. }
  120617. return result;
  120618. };
  120619. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  120620. var _this = this;
  120621. var numSamples = this.samples;
  120622. this._sampleSphere = this._generateHemisphere();
  120623. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  120624. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  120625. "base", "range", "projection", "near", "far", "texelSize",
  120626. "xViewport", "yViewport", "maxZ", "minZAspect"
  120627. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  120628. this._ssaoPostProcess.onApply = function (effect) {
  120629. if (_this._firstUpdate) {
  120630. effect.setArray3("sampleSphere", _this._sampleSphere);
  120631. effect.setFloat("randTextureTiles", 32.0);
  120632. }
  120633. if (!_this._scene.activeCamera) {
  120634. return;
  120635. }
  120636. effect.setFloat("samplesFactor", 1 / _this.samples);
  120637. effect.setFloat("totalStrength", _this.totalStrength);
  120638. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  120639. effect.setFloat("radius", _this.radius);
  120640. effect.setFloat("maxZ", _this.maxZ);
  120641. effect.setFloat("minZAspect", _this.minZAspect);
  120642. effect.setFloat("base", _this.base);
  120643. effect.setFloat("near", _this._scene.activeCamera.minZ);
  120644. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  120645. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  120646. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  120647. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  120648. effect.setTexture("textureSampler", _this._depthTexture);
  120649. effect.setTexture("normalSampler", _this._normalTexture);
  120650. effect.setTexture("randomSampler", _this._randomTexture);
  120651. };
  120652. this._ssaoPostProcess.samples = this.textureSamples;
  120653. };
  120654. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  120655. var _this = this;
  120656. 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);
  120657. this._ssaoCombinePostProcess.onApply = function (effect) {
  120658. var viewport = _this._scene.activeCamera.viewport;
  120659. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  120660. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  120661. };
  120662. this._ssaoCombinePostProcess.samples = this.textureSamples;
  120663. };
  120664. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  120665. var size = 128;
  120666. 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);
  120667. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  120668. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  120669. var context = this._randomTexture.getContext();
  120670. var rand = function (min, max) {
  120671. return Math.random() * (max - min) + min;
  120672. };
  120673. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120674. for (var x = 0; x < size; x++) {
  120675. for (var y = 0; y < size; y++) {
  120676. randVector.x = rand(0.0, 1.0);
  120677. randVector.y = rand(0.0, 1.0);
  120678. randVector.z = 0.0;
  120679. randVector.normalize();
  120680. randVector.scaleInPlace(255);
  120681. randVector.x = Math.floor(randVector.x);
  120682. randVector.y = Math.floor(randVector.y);
  120683. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  120684. context.fillRect(x, y, 1, 1);
  120685. }
  120686. }
  120687. this._randomTexture.update(false);
  120688. };
  120689. /**
  120690. * Serialize the rendering pipeline (Used when exporting)
  120691. * @returns the serialized object
  120692. */
  120693. SSAO2RenderingPipeline.prototype.serialize = function () {
  120694. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  120695. serializationObject.customType = "SSAO2RenderingPipeline";
  120696. return serializationObject;
  120697. };
  120698. /**
  120699. * Parse the serialized pipeline
  120700. * @param source Source pipeline.
  120701. * @param scene The scene to load the pipeline to.
  120702. * @param rootUrl The URL of the serialized pipeline.
  120703. * @returns An instantiated pipeline from the serialized object.
  120704. */
  120705. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  120706. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  120707. };
  120708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120710. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  120711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120713. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  120714. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120715. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120716. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  120717. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120718. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  120719. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  120720. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120721. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  120722. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  120723. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120724. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120725. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  120726. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120727. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  120728. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  120729. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120730. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120731. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  120732. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120733. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120734. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  120735. return SSAO2RenderingPipeline;
  120736. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  120737. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  120738. /***/ }),
  120739. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  120740. /*!*************************************************************************!*\
  120741. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  120742. \*************************************************************************/
  120743. /*! exports provided: SSAORenderingPipeline */
  120744. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120745. "use strict";
  120746. __webpack_require__.r(__webpack_exports__);
  120747. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  120748. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120749. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  120750. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120751. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  120752. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  120753. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120754. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120755. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  120756. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  120757. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  120758. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  120759. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  120760. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  120761. /**
  120762. * Render pipeline to produce ssao effect
  120763. */
  120764. var SSAORenderingPipeline = /** @class */ (function (_super) {
  120765. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  120766. /**
  120767. * @constructor
  120768. * @param name - The rendering pipeline name
  120769. * @param scene - The scene linked to this pipeline
  120770. * @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 }
  120771. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  120772. */
  120773. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  120774. var _this = _super.call(this, scene.getEngine(), name) || this;
  120775. // Members
  120776. /**
  120777. * @ignore
  120778. * The PassPostProcess id in the pipeline that contains the original scene color
  120779. */
  120780. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  120781. /**
  120782. * @ignore
  120783. * The SSAO PostProcess id in the pipeline
  120784. */
  120785. _this.SSAORenderEffect = "SSAORenderEffect";
  120786. /**
  120787. * @ignore
  120788. * The horizontal blur PostProcess id in the pipeline
  120789. */
  120790. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  120791. /**
  120792. * @ignore
  120793. * The vertical blur PostProcess id in the pipeline
  120794. */
  120795. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  120796. /**
  120797. * @ignore
  120798. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  120799. */
  120800. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  120801. /**
  120802. * The output strength of the SSAO post-process. Default value is 1.0.
  120803. */
  120804. _this.totalStrength = 1.0;
  120805. /**
  120806. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  120807. */
  120808. _this.radius = 0.0001;
  120809. /**
  120810. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  120811. * Must not be equal to fallOff and superior to fallOff.
  120812. * Default value is 0.0075
  120813. */
  120814. _this.area = 0.0075;
  120815. /**
  120816. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  120817. * Must not be equal to area and inferior to area.
  120818. * Default value is 0.000001
  120819. */
  120820. _this.fallOff = 0.000001;
  120821. /**
  120822. * The base color of the SSAO post-process
  120823. * The final result is "base + ssao" between [0, 1]
  120824. */
  120825. _this.base = 0.5;
  120826. _this._firstUpdate = true;
  120827. _this._scene = scene;
  120828. // Set up assets
  120829. _this._createRandomTexture();
  120830. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  120831. var ssaoRatio = ratio.ssaoRatio || ratio;
  120832. var combineRatio = ratio.combineRatio || ratio;
  120833. _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);
  120834. _this._createSSAOPostProcess(ssaoRatio);
  120835. _this._createBlurPostProcess(ssaoRatio);
  120836. _this._createSSAOCombinePostProcess(combineRatio);
  120837. // Set up pipeline
  120838. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  120839. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  120840. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  120841. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  120842. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  120843. // Finish
  120844. scene.postProcessRenderPipelineManager.addPipeline(_this);
  120845. if (cameras) {
  120846. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  120847. }
  120848. return _this;
  120849. }
  120850. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  120851. /**
  120852. * Gets active scene
  120853. */
  120854. get: function () {
  120855. return this._scene;
  120856. },
  120857. enumerable: true,
  120858. configurable: true
  120859. });
  120860. // Public Methods
  120861. /**
  120862. * Get the class name
  120863. * @returns "SSAORenderingPipeline"
  120864. */
  120865. SSAORenderingPipeline.prototype.getClassName = function () {
  120866. return "SSAORenderingPipeline";
  120867. };
  120868. /**
  120869. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  120870. */
  120871. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  120872. if (disableDepthRender === void 0) { disableDepthRender = false; }
  120873. for (var i = 0; i < this._scene.cameras.length; i++) {
  120874. var camera = this._scene.cameras[i];
  120875. this._originalColorPostProcess.dispose(camera);
  120876. this._ssaoPostProcess.dispose(camera);
  120877. this._blurHPostProcess.dispose(camera);
  120878. this._blurVPostProcess.dispose(camera);
  120879. this._ssaoCombinePostProcess.dispose(camera);
  120880. }
  120881. this._randomTexture.dispose();
  120882. if (disableDepthRender) {
  120883. this._scene.disableDepthRenderer();
  120884. }
  120885. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  120886. _super.prototype.dispose.call(this);
  120887. };
  120888. // Private Methods
  120889. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  120890. var _this = this;
  120891. var size = 16;
  120892. 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);
  120893. 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);
  120894. this._blurHPostProcess.onActivateObservable.add(function () {
  120895. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  120896. _this._blurHPostProcess.kernel = size * dw;
  120897. });
  120898. this._blurVPostProcess.onActivateObservable.add(function () {
  120899. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  120900. _this._blurVPostProcess.kernel = size * dw;
  120901. });
  120902. };
  120903. /** @hidden */
  120904. SSAORenderingPipeline.prototype._rebuild = function () {
  120905. this._firstUpdate = true;
  120906. _super.prototype._rebuild.call(this);
  120907. };
  120908. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  120909. var _this = this;
  120910. var numSamples = 16;
  120911. var sampleSphere = [
  120912. 0.5381, 0.1856, -0.4319,
  120913. 0.1379, 0.2486, 0.4430,
  120914. 0.3371, 0.5679, -0.0057,
  120915. -0.6999, -0.0451, -0.0019,
  120916. 0.0689, -0.1598, -0.8547,
  120917. 0.0560, 0.0069, -0.1843,
  120918. -0.0146, 0.1402, 0.0762,
  120919. 0.0100, -0.1924, -0.0344,
  120920. -0.3577, -0.5301, -0.4358,
  120921. -0.3169, 0.1063, 0.0158,
  120922. 0.0103, -0.5869, 0.0046,
  120923. -0.0897, -0.4940, 0.3287,
  120924. 0.7119, -0.0154, -0.0918,
  120925. -0.0533, 0.0596, -0.5411,
  120926. 0.0352, -0.0631, 0.5460,
  120927. -0.4776, 0.2847, -0.0271
  120928. ];
  120929. var samplesFactor = 1.0 / numSamples;
  120930. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  120931. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  120932. "area", "fallOff", "base", "range", "viewport"
  120933. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  120934. this._ssaoPostProcess.onApply = function (effect) {
  120935. if (_this._firstUpdate) {
  120936. effect.setArray3("sampleSphere", sampleSphere);
  120937. effect.setFloat("samplesFactor", samplesFactor);
  120938. effect.setFloat("randTextureTiles", 4.0);
  120939. }
  120940. effect.setFloat("totalStrength", _this.totalStrength);
  120941. effect.setFloat("radius", _this.radius);
  120942. effect.setFloat("area", _this.area);
  120943. effect.setFloat("fallOff", _this.fallOff);
  120944. effect.setFloat("base", _this.base);
  120945. effect.setTexture("textureSampler", _this._depthTexture);
  120946. effect.setTexture("randomSampler", _this._randomTexture);
  120947. };
  120948. };
  120949. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  120950. var _this = this;
  120951. 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);
  120952. this._ssaoCombinePostProcess.onApply = function (effect) {
  120953. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  120954. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  120955. };
  120956. };
  120957. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  120958. var size = 512;
  120959. 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);
  120960. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  120961. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  120962. var context = this._randomTexture.getContext();
  120963. var rand = function (min, max) {
  120964. return Math.random() * (max - min) + min;
  120965. };
  120966. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  120967. for (var x = 0; x < size; x++) {
  120968. for (var y = 0; y < size; y++) {
  120969. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  120970. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  120971. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  120972. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  120973. context.fillRect(x, y, 1, 1);
  120974. }
  120975. }
  120976. this._randomTexture.update(false);
  120977. };
  120978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120980. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  120981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120983. ], SSAORenderingPipeline.prototype, "radius", void 0);
  120984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120986. ], SSAORenderingPipeline.prototype, "area", void 0);
  120987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120989. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  120990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120992. ], SSAORenderingPipeline.prototype, "base", void 0);
  120993. return SSAORenderingPipeline;
  120994. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  120995. /***/ }),
  120996. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  120997. /*!*****************************************************************************!*\
  120998. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  120999. \*****************************************************************************/
  121000. /*! exports provided: StandardRenderingPipeline */
  121001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121002. "use strict";
  121003. __webpack_require__.r(__webpack_exports__);
  121004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  121005. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121006. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  121007. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  121008. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  121009. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  121010. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121011. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  121012. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  121013. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  121014. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  121015. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  121016. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  121017. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  121018. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  121019. /**
  121020. * Standard rendering pipeline
  121021. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  121022. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  121023. */
  121024. var StandardRenderingPipeline = /** @class */ (function (_super) {
  121025. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  121026. /**
  121027. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  121028. * @constructor
  121029. * @param name The rendering pipeline name
  121030. * @param scene The scene linked to this pipeline
  121031. * @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)
  121032. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  121033. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121034. */
  121035. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  121036. if (originalPostProcess === void 0) { originalPostProcess = null; }
  121037. var _this = _super.call(this, scene.getEngine(), name) || this;
  121038. /**
  121039. * Post-process used to down scale an image x4
  121040. */
  121041. _this.downSampleX4PostProcess = null;
  121042. /**
  121043. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  121044. */
  121045. _this.brightPassPostProcess = null;
  121046. /**
  121047. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  121048. */
  121049. _this.blurHPostProcesses = [];
  121050. /**
  121051. * Post-process array storing all the vertical blur post-processes used by the pipeline
  121052. */
  121053. _this.blurVPostProcesses = [];
  121054. /**
  121055. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  121056. */
  121057. _this.textureAdderPostProcess = null;
  121058. /**
  121059. * Post-process used to create volumetric lighting effect
  121060. */
  121061. _this.volumetricLightPostProcess = null;
  121062. /**
  121063. * Post-process used to smooth the previous volumetric light post-process on the X axis
  121064. */
  121065. _this.volumetricLightSmoothXPostProcess = null;
  121066. /**
  121067. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  121068. */
  121069. _this.volumetricLightSmoothYPostProcess = null;
  121070. /**
  121071. * Post-process used to merge the volumetric light effect and the real scene color
  121072. */
  121073. _this.volumetricLightMergePostProces = null;
  121074. /**
  121075. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  121076. */
  121077. _this.volumetricLightFinalPostProcess = null;
  121078. /**
  121079. * Base post-process used to calculate the average luminance of the final image for HDR
  121080. */
  121081. _this.luminancePostProcess = null;
  121082. /**
  121083. * Post-processes used to create down sample post-processes in order to get
  121084. * the average luminance of the final image for HDR
  121085. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  121086. */
  121087. _this.luminanceDownSamplePostProcesses = [];
  121088. /**
  121089. * Post-process used to create a HDR effect (light adaptation)
  121090. */
  121091. _this.hdrPostProcess = null;
  121092. /**
  121093. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  121094. */
  121095. _this.textureAdderFinalPostProcess = null;
  121096. /**
  121097. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  121098. */
  121099. _this.lensFlareFinalPostProcess = null;
  121100. /**
  121101. * Post-process used to merge the final HDR post-process and the real scene color
  121102. */
  121103. _this.hdrFinalPostProcess = null;
  121104. /**
  121105. * Post-process used to create a lens flare effect
  121106. */
  121107. _this.lensFlarePostProcess = null;
  121108. /**
  121109. * Post-process that merges the result of the lens flare post-process and the real scene color
  121110. */
  121111. _this.lensFlareComposePostProcess = null;
  121112. /**
  121113. * Post-process used to create a motion blur effect
  121114. */
  121115. _this.motionBlurPostProcess = null;
  121116. /**
  121117. * Post-process used to create a depth of field effect
  121118. */
  121119. _this.depthOfFieldPostProcess = null;
  121120. /**
  121121. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121122. */
  121123. _this.fxaaPostProcess = null;
  121124. // Values
  121125. /**
  121126. * Represents the brightness threshold in order to configure the illuminated surfaces
  121127. */
  121128. _this.brightThreshold = 1.0;
  121129. /**
  121130. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  121131. */
  121132. _this.blurWidth = 512.0;
  121133. /**
  121134. * Sets if the blur for highlighted surfaces must be only horizontal
  121135. */
  121136. _this.horizontalBlur = false;
  121137. /**
  121138. * Texture used typically to simulate "dirty" on camera lens
  121139. */
  121140. _this.lensTexture = null;
  121141. /**
  121142. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  121143. */
  121144. _this.volumetricLightCoefficient = 0.2;
  121145. /**
  121146. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  121147. */
  121148. _this.volumetricLightPower = 4.0;
  121149. /**
  121150. * Used the set the blur intensity to smooth the volumetric lights
  121151. */
  121152. _this.volumetricLightBlurScale = 64.0;
  121153. /**
  121154. * Light (spot or directional) used to generate the volumetric lights rays
  121155. * The source light must have a shadow generate so the pipeline can get its
  121156. * depth map
  121157. */
  121158. _this.sourceLight = null;
  121159. /**
  121160. * For eye adaptation, represents the minimum luminance the eye can see
  121161. */
  121162. _this.hdrMinimumLuminance = 1.0;
  121163. /**
  121164. * For eye adaptation, represents the decrease luminance speed
  121165. */
  121166. _this.hdrDecreaseRate = 0.5;
  121167. /**
  121168. * For eye adaptation, represents the increase luminance speed
  121169. */
  121170. _this.hdrIncreaseRate = 0.5;
  121171. /**
  121172. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  121173. */
  121174. _this.lensColorTexture = null;
  121175. /**
  121176. * The overall strengh for the lens flare effect
  121177. */
  121178. _this.lensFlareStrength = 20.0;
  121179. /**
  121180. * Dispersion coefficient for lens flare ghosts
  121181. */
  121182. _this.lensFlareGhostDispersal = 1.4;
  121183. /**
  121184. * Main lens flare halo width
  121185. */
  121186. _this.lensFlareHaloWidth = 0.7;
  121187. /**
  121188. * Based on the lens distortion effect, defines how much the lens flare result
  121189. * is distorted
  121190. */
  121191. _this.lensFlareDistortionStrength = 16.0;
  121192. /**
  121193. * Lens star texture must be used to simulate rays on the flares and is available
  121194. * in the documentation
  121195. */
  121196. _this.lensStarTexture = null;
  121197. /**
  121198. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  121199. * flare effect by taking account of the dirt texture
  121200. */
  121201. _this.lensFlareDirtTexture = null;
  121202. /**
  121203. * Represents the focal length for the depth of field effect
  121204. */
  121205. _this.depthOfFieldDistance = 10.0;
  121206. /**
  121207. * Represents the blur intensity for the blurred part of the depth of field effect
  121208. */
  121209. _this.depthOfFieldBlurWidth = 64.0;
  121210. /**
  121211. * For motion blur, defines how much the image is blurred by the movement
  121212. */
  121213. _this.motionStrength = 1.0;
  121214. /**
  121215. * List of animations for the pipeline (IAnimatable implementation)
  121216. */
  121217. _this.animations = [];
  121218. _this._currentDepthOfFieldSource = null;
  121219. _this._fixedExposure = 1.0;
  121220. _this._currentExposure = 1.0;
  121221. _this._hdrAutoExposure = false;
  121222. _this._hdrCurrentLuminance = 1.0;
  121223. // Getters and setters
  121224. _this._bloomEnabled = false;
  121225. _this._depthOfFieldEnabled = false;
  121226. _this._vlsEnabled = false;
  121227. _this._lensFlareEnabled = false;
  121228. _this._hdrEnabled = false;
  121229. _this._motionBlurEnabled = false;
  121230. _this._fxaaEnabled = false;
  121231. _this._motionBlurSamples = 64.0;
  121232. _this._volumetricLightStepsCount = 50.0;
  121233. _this._samples = 1;
  121234. _this._cameras = cameras || [];
  121235. // Initialize
  121236. _this._scene = scene;
  121237. _this._basePostProcess = originalPostProcess;
  121238. _this._ratio = ratio;
  121239. // Misc
  121240. _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;
  121241. // Finish
  121242. scene.postProcessRenderPipelineManager.addPipeline(_this);
  121243. _this._buildPipeline();
  121244. return _this;
  121245. }
  121246. Object.defineProperty(StandardRenderingPipeline.prototype, "exposure", {
  121247. /**
  121248. * Gets the overall exposure used by the pipeline
  121249. */
  121250. get: function () {
  121251. return this._fixedExposure;
  121252. },
  121253. /**
  121254. * Sets the overall exposure used by the pipeline
  121255. */
  121256. set: function (value) {
  121257. this._fixedExposure = value;
  121258. this._currentExposure = value;
  121259. },
  121260. enumerable: true,
  121261. configurable: true
  121262. });
  121263. Object.defineProperty(StandardRenderingPipeline.prototype, "hdrAutoExposure", {
  121264. /**
  121265. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  121266. */
  121267. get: function () {
  121268. return this._hdrAutoExposure;
  121269. },
  121270. /**
  121271. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  121272. */
  121273. set: function (value) {
  121274. this._hdrAutoExposure = value;
  121275. if (this.hdrPostProcess) {
  121276. var defines = ["#define HDR"];
  121277. if (value) {
  121278. defines.push("#define AUTO_EXPOSURE");
  121279. }
  121280. this.hdrPostProcess.updateEffect(defines.join("\n"));
  121281. }
  121282. },
  121283. enumerable: true,
  121284. configurable: true
  121285. });
  121286. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  121287. /**
  121288. * @ignore
  121289. * Specifies if the bloom pipeline is enabled
  121290. */
  121291. get: function () {
  121292. return this._bloomEnabled;
  121293. },
  121294. set: function (enabled) {
  121295. if (this._bloomEnabled === enabled) {
  121296. return;
  121297. }
  121298. this._bloomEnabled = enabled;
  121299. this._buildPipeline();
  121300. },
  121301. enumerable: true,
  121302. configurable: true
  121303. });
  121304. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  121305. /**
  121306. * @ignore
  121307. * Specifies if the depth of field pipeline is enabed
  121308. */
  121309. get: function () {
  121310. return this._depthOfFieldEnabled;
  121311. },
  121312. set: function (enabled) {
  121313. if (this._depthOfFieldEnabled === enabled) {
  121314. return;
  121315. }
  121316. this._depthOfFieldEnabled = enabled;
  121317. this._buildPipeline();
  121318. },
  121319. enumerable: true,
  121320. configurable: true
  121321. });
  121322. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  121323. /**
  121324. * @ignore
  121325. * Specifies if the lens flare pipeline is enabed
  121326. */
  121327. get: function () {
  121328. return this._lensFlareEnabled;
  121329. },
  121330. set: function (enabled) {
  121331. if (this._lensFlareEnabled === enabled) {
  121332. return;
  121333. }
  121334. this._lensFlareEnabled = enabled;
  121335. this._buildPipeline();
  121336. },
  121337. enumerable: true,
  121338. configurable: true
  121339. });
  121340. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  121341. /**
  121342. * @ignore
  121343. * Specifies if the HDR pipeline is enabled
  121344. */
  121345. get: function () {
  121346. return this._hdrEnabled;
  121347. },
  121348. set: function (enabled) {
  121349. if (this._hdrEnabled === enabled) {
  121350. return;
  121351. }
  121352. this._hdrEnabled = enabled;
  121353. this._buildPipeline();
  121354. },
  121355. enumerable: true,
  121356. configurable: true
  121357. });
  121358. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  121359. /**
  121360. * @ignore
  121361. * Specifies if the volumetric lights scattering effect is enabled
  121362. */
  121363. get: function () {
  121364. return this._vlsEnabled;
  121365. },
  121366. set: function (enabled) {
  121367. if (this._vlsEnabled === enabled) {
  121368. return;
  121369. }
  121370. if (enabled) {
  121371. var geometry = this._scene.enableGeometryBufferRenderer();
  121372. if (!geometry) {
  121373. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  121374. return;
  121375. }
  121376. }
  121377. this._vlsEnabled = enabled;
  121378. this._buildPipeline();
  121379. },
  121380. enumerable: true,
  121381. configurable: true
  121382. });
  121383. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  121384. /**
  121385. * @ignore
  121386. * Specifies if the motion blur effect is enabled
  121387. */
  121388. get: function () {
  121389. return this._motionBlurEnabled;
  121390. },
  121391. set: function (enabled) {
  121392. if (this._motionBlurEnabled === enabled) {
  121393. return;
  121394. }
  121395. this._motionBlurEnabled = enabled;
  121396. this._buildPipeline();
  121397. },
  121398. enumerable: true,
  121399. configurable: true
  121400. });
  121401. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  121402. /**
  121403. * Specifies if anti-aliasing is enabled
  121404. */
  121405. get: function () {
  121406. return this._fxaaEnabled;
  121407. },
  121408. set: function (enabled) {
  121409. if (this._fxaaEnabled === enabled) {
  121410. return;
  121411. }
  121412. this._fxaaEnabled = enabled;
  121413. this._buildPipeline();
  121414. },
  121415. enumerable: true,
  121416. configurable: true
  121417. });
  121418. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  121419. /**
  121420. * Specifies the number of steps used to calculate the volumetric lights
  121421. * Typically in interval [50, 200]
  121422. */
  121423. get: function () {
  121424. return this._volumetricLightStepsCount;
  121425. },
  121426. set: function (count) {
  121427. if (this.volumetricLightPostProcess) {
  121428. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  121429. }
  121430. this._volumetricLightStepsCount = count;
  121431. },
  121432. enumerable: true,
  121433. configurable: true
  121434. });
  121435. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  121436. /**
  121437. * Specifies the number of samples used for the motion blur effect
  121438. * Typically in interval [16, 64]
  121439. */
  121440. get: function () {
  121441. return this._motionBlurSamples;
  121442. },
  121443. set: function (samples) {
  121444. if (this.motionBlurPostProcess) {
  121445. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  121446. }
  121447. this._motionBlurSamples = samples;
  121448. },
  121449. enumerable: true,
  121450. configurable: true
  121451. });
  121452. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  121453. /**
  121454. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121455. */
  121456. get: function () {
  121457. return this._samples;
  121458. },
  121459. set: function (sampleCount) {
  121460. if (this._samples === sampleCount) {
  121461. return;
  121462. }
  121463. this._samples = sampleCount;
  121464. this._buildPipeline();
  121465. },
  121466. enumerable: true,
  121467. configurable: true
  121468. });
  121469. StandardRenderingPipeline.prototype._buildPipeline = function () {
  121470. var _this = this;
  121471. var ratio = this._ratio;
  121472. var scene = this._scene;
  121473. this._disposePostProcesses();
  121474. this._reset();
  121475. // Create pass post-process
  121476. if (!this._basePostProcess) {
  121477. 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);
  121478. this.originalPostProcess.onApply = function () {
  121479. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  121480. };
  121481. }
  121482. else {
  121483. this.originalPostProcess = this._basePostProcess;
  121484. }
  121485. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  121486. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  121487. }
  121488. this._currentDepthOfFieldSource = this.originalPostProcess;
  121489. if (this._bloomEnabled) {
  121490. // Create down sample X4 post-process
  121491. this._createDownSampleX4PostProcess(scene, ratio / 2);
  121492. // Create bright pass post-process
  121493. this._createBrightPassPostProcess(scene, ratio / 2);
  121494. // Create gaussian blur post-processes (down sampling blurs)
  121495. this._createBlurPostProcesses(scene, ratio / 4, 1);
  121496. // Create texture adder post-process
  121497. this._createTextureAdderPostProcess(scene, ratio);
  121498. // Create depth-of-field source post-process
  121499. 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);
  121500. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  121501. }
  121502. if (this._vlsEnabled) {
  121503. // Create volumetric light
  121504. this._createVolumetricLightPostProcess(scene, ratio);
  121505. // Create volumetric light final post-process
  121506. 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);
  121507. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  121508. }
  121509. if (this._lensFlareEnabled) {
  121510. // Create lens flare post-process
  121511. this._createLensFlarePostProcess(scene, ratio);
  121512. // Create depth-of-field source post-process post lens-flare and disable it now
  121513. 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);
  121514. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  121515. }
  121516. if (this._hdrEnabled) {
  121517. // Create luminance
  121518. this._createLuminancePostProcesses(scene, this._floatTextureType);
  121519. // Create HDR
  121520. this._createHdrPostProcess(scene, ratio);
  121521. // Create depth-of-field source post-process post hdr and disable it now
  121522. 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);
  121523. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  121524. }
  121525. if (this._depthOfFieldEnabled) {
  121526. // Create gaussian blur used by depth-of-field
  121527. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  121528. // Create depth-of-field post-process
  121529. this._createDepthOfFieldPostProcess(scene, ratio);
  121530. }
  121531. if (this._motionBlurEnabled) {
  121532. // Create motion blur post-process
  121533. this._createMotionBlurPostProcess(scene, ratio);
  121534. }
  121535. if (this._fxaaEnabled) {
  121536. // Create fxaa post-process
  121537. 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);
  121538. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  121539. }
  121540. if (this._cameras !== null) {
  121541. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  121542. }
  121543. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  121544. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  121545. }
  121546. };
  121547. // Down Sample X4 Post-Processs
  121548. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  121549. var _this = this;
  121550. var downSampleX4Offsets = new Array(32);
  121551. 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);
  121552. this.downSampleX4PostProcess.onApply = function (effect) {
  121553. var id = 0;
  121554. var width = _this.downSampleX4PostProcess.width;
  121555. var height = _this.downSampleX4PostProcess.height;
  121556. for (var i = -2; i < 2; i++) {
  121557. for (var j = -2; j < 2; j++) {
  121558. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  121559. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  121560. id += 2;
  121561. }
  121562. }
  121563. effect.setArray2("dsOffsets", downSampleX4Offsets);
  121564. };
  121565. // Add to pipeline
  121566. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  121567. };
  121568. // Brightpass Post-Process
  121569. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  121570. var _this = this;
  121571. var brightOffsets = new Array(8);
  121572. 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);
  121573. this.brightPassPostProcess.onApply = function (effect) {
  121574. var sU = (1.0 / _this.brightPassPostProcess.width);
  121575. var sV = (1.0 / _this.brightPassPostProcess.height);
  121576. brightOffsets[0] = -0.5 * sU;
  121577. brightOffsets[1] = 0.5 * sV;
  121578. brightOffsets[2] = 0.5 * sU;
  121579. brightOffsets[3] = 0.5 * sV;
  121580. brightOffsets[4] = -0.5 * sU;
  121581. brightOffsets[5] = -0.5 * sV;
  121582. brightOffsets[6] = 0.5 * sU;
  121583. brightOffsets[7] = -0.5 * sV;
  121584. effect.setArray2("dsOffsets", brightOffsets);
  121585. effect.setFloat("brightThreshold", _this.brightThreshold);
  121586. };
  121587. // Add to pipeline
  121588. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  121589. };
  121590. // Create blur H&V post-processes
  121591. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  121592. var _this = this;
  121593. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  121594. var engine = scene.getEngine();
  121595. 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);
  121596. 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);
  121597. blurX.onActivateObservable.add(function () {
  121598. var dw = blurX.width / engine.getRenderWidth();
  121599. blurX.kernel = _this[blurWidthKey] * dw;
  121600. });
  121601. blurY.onActivateObservable.add(function () {
  121602. var dw = blurY.height / engine.getRenderHeight();
  121603. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  121604. });
  121605. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  121606. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  121607. this.blurHPostProcesses.push(blurX);
  121608. this.blurVPostProcesses.push(blurY);
  121609. };
  121610. // Create texture adder post-process
  121611. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  121612. var _this = this;
  121613. 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);
  121614. this.textureAdderPostProcess.onApply = function (effect) {
  121615. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  121616. effect.setTexture("lensSampler", _this.lensTexture);
  121617. effect.setFloat("exposure", _this._currentExposure);
  121618. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  121619. };
  121620. // Add to pipeline
  121621. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  121622. };
  121623. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  121624. var _this = this;
  121625. var geometryRenderer = scene.enableGeometryBufferRenderer();
  121626. geometryRenderer.enablePosition = true;
  121627. var geometry = geometryRenderer.getGBuffer();
  121628. // Base post-process
  121629. 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));
  121630. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  121631. this.volumetricLightPostProcess.onApply = function (effect) {
  121632. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  121633. var generator = _this.sourceLight.getShadowGenerator();
  121634. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  121635. effect.setTexture("positionSampler", geometry.textures[2]);
  121636. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  121637. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  121638. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  121639. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  121640. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  121641. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  121642. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  121643. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  121644. effect.setVector2("depthValues", depthValues);
  121645. }
  121646. };
  121647. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  121648. // Smooth
  121649. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  121650. // Merge
  121651. 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");
  121652. this.volumetricLightMergePostProces.onApply = function (effect) {
  121653. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  121654. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  121655. };
  121656. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  121657. };
  121658. // Create luminance
  121659. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  121660. var _this = this;
  121661. // Create luminance
  121662. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  121663. 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);
  121664. var offsets = [];
  121665. this.luminancePostProcess.onApply = function (effect) {
  121666. var sU = (1.0 / _this.luminancePostProcess.width);
  121667. var sV = (1.0 / _this.luminancePostProcess.height);
  121668. offsets[0] = -0.5 * sU;
  121669. offsets[1] = 0.5 * sV;
  121670. offsets[2] = 0.5 * sU;
  121671. offsets[3] = 0.5 * sV;
  121672. offsets[4] = -0.5 * sU;
  121673. offsets[5] = -0.5 * sV;
  121674. offsets[6] = 0.5 * sU;
  121675. offsets[7] = -0.5 * sV;
  121676. effect.setArray2("lumOffsets", offsets);
  121677. };
  121678. // Add to pipeline
  121679. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  121680. // Create down sample luminance
  121681. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  121682. var size = Math.pow(3, i);
  121683. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  121684. if (i === 0) {
  121685. defines += "#define FINAL_DOWN_SAMPLER";
  121686. }
  121687. 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);
  121688. this.luminanceDownSamplePostProcesses.push(postProcess);
  121689. }
  121690. // Create callbacks and add effects
  121691. var lastLuminance = this.luminancePostProcess;
  121692. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  121693. var downSampleOffsets = new Array(18);
  121694. pp.onApply = function (effect) {
  121695. if (!lastLuminance) {
  121696. return;
  121697. }
  121698. var id = 0;
  121699. for (var x = -1; x < 2; x++) {
  121700. for (var y = -1; y < 2; y++) {
  121701. downSampleOffsets[id] = x / lastLuminance.width;
  121702. downSampleOffsets[id + 1] = y / lastLuminance.height;
  121703. id += 2;
  121704. }
  121705. }
  121706. effect.setArray2("dsOffsets", downSampleOffsets);
  121707. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  121708. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  121709. lastLuminance = _this.luminancePostProcess;
  121710. }
  121711. else {
  121712. lastLuminance = pp;
  121713. }
  121714. };
  121715. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  121716. pp.onAfterRender = function () {
  121717. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  121718. 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);
  121719. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  121720. };
  121721. }
  121722. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  121723. });
  121724. };
  121725. // Create HDR post-process
  121726. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  121727. var _this = this;
  121728. var defines = ["#define HDR"];
  121729. if (this._hdrAutoExposure) {
  121730. defines.push("#define AUTO_EXPOSURE");
  121731. }
  121732. 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);
  121733. var outputLiminance = 1;
  121734. var time = 0;
  121735. var lastTime = 0;
  121736. this.hdrPostProcess.onApply = function (effect) {
  121737. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  121738. time += scene.getEngine().getDeltaTime();
  121739. if (outputLiminance < 0) {
  121740. outputLiminance = _this._hdrCurrentLuminance;
  121741. }
  121742. else {
  121743. var dt = (lastTime - time) / 1000.0;
  121744. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  121745. outputLiminance += _this.hdrDecreaseRate * dt;
  121746. }
  121747. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  121748. outputLiminance -= _this.hdrIncreaseRate * dt;
  121749. }
  121750. else {
  121751. outputLiminance = _this._hdrCurrentLuminance;
  121752. }
  121753. }
  121754. if (_this.hdrAutoExposure) {
  121755. _this._currentExposure = _this._fixedExposure / outputLiminance;
  121756. }
  121757. else {
  121758. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  121759. effect.setFloat("averageLuminance", outputLiminance);
  121760. }
  121761. lastTime = time;
  121762. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  121763. };
  121764. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  121765. };
  121766. // Create lens flare post-process
  121767. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  121768. var _this = this;
  121769. 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);
  121770. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  121771. this._createBlurPostProcesses(scene, ratio / 4, 2);
  121772. 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);
  121773. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  121774. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  121775. // Lens flare
  121776. this.lensFlarePostProcess.onApply = function (effect) {
  121777. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  121778. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  121779. effect.setFloat("strength", _this.lensFlareStrength);
  121780. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  121781. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  121782. // Shift
  121783. resolution.x = _this.lensFlarePostProcess.width;
  121784. resolution.y = _this.lensFlarePostProcess.height;
  121785. effect.setVector2("resolution", resolution);
  121786. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  121787. };
  121788. // Compose
  121789. 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);
  121790. 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);
  121791. this.lensFlareComposePostProcess.onApply = function (effect) {
  121792. if (!_this._scene.activeCamera) {
  121793. return;
  121794. }
  121795. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  121796. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  121797. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  121798. // Lens start rotation matrix
  121799. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  121800. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  121801. 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));
  121802. camRot *= 4.0;
  121803. 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);
  121804. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  121805. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  121806. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  121807. };
  121808. };
  121809. // Create depth-of-field post-process
  121810. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  121811. var _this = this;
  121812. 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);
  121813. this.depthOfFieldPostProcess.onApply = function (effect) {
  121814. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  121815. effect.setTexture("depthSampler", _this._getDepthTexture());
  121816. effect.setFloat("distance", _this.depthOfFieldDistance);
  121817. };
  121818. // Add to pipeline
  121819. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  121820. };
  121821. // Create motion blur post-process
  121822. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  121823. var _this = this;
  121824. 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);
  121825. var motionScale = 0;
  121826. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121827. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121828. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121829. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  121830. this.motionBlurPostProcess.onApply = function (effect) {
  121831. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  121832. viewProjection.invertToRef(invViewProjection);
  121833. effect.setMatrix("inverseViewProjection", invViewProjection);
  121834. effect.setMatrix("prevViewProjection", prevViewProjection);
  121835. prevViewProjection = viewProjection;
  121836. screenSize.x = _this.motionBlurPostProcess.width;
  121837. screenSize.y = _this.motionBlurPostProcess.height;
  121838. effect.setVector2("screenSize", screenSize);
  121839. motionScale = scene.getEngine().getFps() / 60.0;
  121840. effect.setFloat("motionScale", motionScale);
  121841. effect.setFloat("motionStrength", _this.motionStrength);
  121842. effect.setTexture("depthSampler", _this._getDepthTexture());
  121843. };
  121844. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  121845. };
  121846. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  121847. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  121848. var renderer = this._scene.enableGeometryBufferRenderer();
  121849. return renderer.getGBuffer().textures[0];
  121850. }
  121851. return this._scene.enableDepthRenderer().getDepthMap();
  121852. };
  121853. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  121854. for (var i = 0; i < this._cameras.length; i++) {
  121855. var camera = this._cameras[i];
  121856. if (this.originalPostProcess) {
  121857. this.originalPostProcess.dispose(camera);
  121858. }
  121859. if (this.downSampleX4PostProcess) {
  121860. this.downSampleX4PostProcess.dispose(camera);
  121861. }
  121862. if (this.brightPassPostProcess) {
  121863. this.brightPassPostProcess.dispose(camera);
  121864. }
  121865. if (this.textureAdderPostProcess) {
  121866. this.textureAdderPostProcess.dispose(camera);
  121867. }
  121868. if (this.textureAdderFinalPostProcess) {
  121869. this.textureAdderFinalPostProcess.dispose(camera);
  121870. }
  121871. if (this.volumetricLightPostProcess) {
  121872. this.volumetricLightPostProcess.dispose(camera);
  121873. }
  121874. if (this.volumetricLightSmoothXPostProcess) {
  121875. this.volumetricLightSmoothXPostProcess.dispose(camera);
  121876. }
  121877. if (this.volumetricLightSmoothYPostProcess) {
  121878. this.volumetricLightSmoothYPostProcess.dispose(camera);
  121879. }
  121880. if (this.volumetricLightMergePostProces) {
  121881. this.volumetricLightMergePostProces.dispose(camera);
  121882. }
  121883. if (this.volumetricLightFinalPostProcess) {
  121884. this.volumetricLightFinalPostProcess.dispose(camera);
  121885. }
  121886. if (this.lensFlarePostProcess) {
  121887. this.lensFlarePostProcess.dispose(camera);
  121888. }
  121889. if (this.lensFlareComposePostProcess) {
  121890. this.lensFlareComposePostProcess.dispose(camera);
  121891. }
  121892. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  121893. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  121894. }
  121895. if (this.luminancePostProcess) {
  121896. this.luminancePostProcess.dispose(camera);
  121897. }
  121898. if (this.hdrPostProcess) {
  121899. this.hdrPostProcess.dispose(camera);
  121900. }
  121901. if (this.hdrFinalPostProcess) {
  121902. this.hdrFinalPostProcess.dispose(camera);
  121903. }
  121904. if (this.depthOfFieldPostProcess) {
  121905. this.depthOfFieldPostProcess.dispose(camera);
  121906. }
  121907. if (this.motionBlurPostProcess) {
  121908. this.motionBlurPostProcess.dispose(camera);
  121909. }
  121910. if (this.fxaaPostProcess) {
  121911. this.fxaaPostProcess.dispose(camera);
  121912. }
  121913. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  121914. this.blurHPostProcesses[j].dispose(camera);
  121915. }
  121916. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  121917. this.blurVPostProcesses[j].dispose(camera);
  121918. }
  121919. }
  121920. this.originalPostProcess = null;
  121921. this.downSampleX4PostProcess = null;
  121922. this.brightPassPostProcess = null;
  121923. this.textureAdderPostProcess = null;
  121924. this.textureAdderFinalPostProcess = null;
  121925. this.volumetricLightPostProcess = null;
  121926. this.volumetricLightSmoothXPostProcess = null;
  121927. this.volumetricLightSmoothYPostProcess = null;
  121928. this.volumetricLightMergePostProces = null;
  121929. this.volumetricLightFinalPostProcess = null;
  121930. this.lensFlarePostProcess = null;
  121931. this.lensFlareComposePostProcess = null;
  121932. this.luminancePostProcess = null;
  121933. this.hdrPostProcess = null;
  121934. this.hdrFinalPostProcess = null;
  121935. this.depthOfFieldPostProcess = null;
  121936. this.motionBlurPostProcess = null;
  121937. this.fxaaPostProcess = null;
  121938. this.luminanceDownSamplePostProcesses = [];
  121939. this.blurHPostProcesses = [];
  121940. this.blurVPostProcesses = [];
  121941. };
  121942. /**
  121943. * Dispose of the pipeline and stop all post processes
  121944. */
  121945. StandardRenderingPipeline.prototype.dispose = function () {
  121946. this._disposePostProcesses();
  121947. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  121948. _super.prototype.dispose.call(this);
  121949. };
  121950. /**
  121951. * Serialize the rendering pipeline (Used when exporting)
  121952. * @returns the serialized object
  121953. */
  121954. StandardRenderingPipeline.prototype.serialize = function () {
  121955. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  121956. if (this.sourceLight) {
  121957. serializationObject.sourceLightId = this.sourceLight.id;
  121958. }
  121959. serializationObject.customType = "StandardRenderingPipeline";
  121960. return serializationObject;
  121961. };
  121962. /**
  121963. * Parse the serialized pipeline
  121964. * @param source Source pipeline.
  121965. * @param scene The scene to load the pipeline to.
  121966. * @param rootUrl The URL of the serialized pipeline.
  121967. * @returns An instantiated pipeline from the serialized object.
  121968. */
  121969. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  121970. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  121971. if (source.sourceLightId) {
  121972. p.sourceLight = scene.getLightByID(source.sourceLightId);
  121973. }
  121974. return p;
  121975. };
  121976. /**
  121977. * Luminance steps
  121978. */
  121979. StandardRenderingPipeline.LuminanceSteps = 6;
  121980. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121981. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121982. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  121983. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121984. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121985. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  121986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121988. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  121989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121991. ], StandardRenderingPipeline.prototype, "exposure", null);
  121992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  121994. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  121995. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121997. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  121998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122000. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  122001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122003. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  122004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122006. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  122007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122009. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  122010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122012. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  122013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122015. ], StandardRenderingPipeline.prototype, "hdrAutoExposure", null);
  122016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  122018. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  122019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122021. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  122022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122024. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  122025. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122026. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122027. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  122028. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122029. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122030. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  122031. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  122033. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  122034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  122036. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  122037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122039. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  122040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122042. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  122043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122045. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  122046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122048. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  122049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122051. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  122052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122054. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  122055. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122057. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  122058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122060. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  122061. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122062. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122063. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  122064. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122065. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122066. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  122067. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122069. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  122070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122072. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  122073. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122074. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122075. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  122076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  122078. ], StandardRenderingPipeline.prototype, "samples", null);
  122079. return StandardRenderingPipeline;
  122080. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  122081. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  122082. /***/ }),
  122083. /***/ "./PostProcesses/RenderPipeline/index.ts":
  122084. /*!***********************************************!*\
  122085. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  122086. \***********************************************/
  122087. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  122088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122089. "use strict";
  122090. __webpack_require__.r(__webpack_exports__);
  122091. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  122092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  122093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  122094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  122095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  122096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  122097. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  122098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  122099. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  122100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  122101. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  122102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  122103. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  122104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  122105. /***/ }),
  122106. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  122107. /*!*****************************************************************!*\
  122108. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  122109. \*****************************************************************/
  122110. /*! exports provided: PostProcessRenderEffect */
  122111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122112. "use strict";
  122113. __webpack_require__.r(__webpack_exports__);
  122114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  122115. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  122116. /**
  122117. * This represents a set of one or more post processes in Babylon.
  122118. * A post process can be used to apply a shader to a texture after it is rendered.
  122119. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122120. */
  122121. var PostProcessRenderEffect = /** @class */ (function () {
  122122. /**
  122123. * Instantiates a post process render effect.
  122124. * A post process can be used to apply a shader to a texture after it is rendered.
  122125. * @param engine The engine the effect is tied to
  122126. * @param name The name of the effect
  122127. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  122128. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  122129. */
  122130. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  122131. this._name = name;
  122132. this._singleInstance = singleInstance || true;
  122133. this._getPostProcesses = getPostProcesses;
  122134. this._cameras = {};
  122135. this._indicesForCamera = {};
  122136. this._postProcesses = {};
  122137. }
  122138. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  122139. /**
  122140. * Checks if all the post processes in the effect are supported.
  122141. */
  122142. get: function () {
  122143. for (var index in this._postProcesses) {
  122144. if (this._postProcesses.hasOwnProperty(index)) {
  122145. var pps = this._postProcesses[index];
  122146. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  122147. if (!pps[ppIndex].isSupported) {
  122148. return false;
  122149. }
  122150. }
  122151. }
  122152. }
  122153. return true;
  122154. },
  122155. enumerable: true,
  122156. configurable: true
  122157. });
  122158. /**
  122159. * Updates the current state of the effect
  122160. * @hidden
  122161. */
  122162. PostProcessRenderEffect.prototype._update = function () {
  122163. };
  122164. /**
  122165. * Attaches the effect on cameras
  122166. * @param cameras The camera to attach to.
  122167. * @hidden
  122168. */
  122169. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  122170. var _this = this;
  122171. var cameraKey;
  122172. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  122173. if (!cams) {
  122174. return;
  122175. }
  122176. for (var i = 0; i < cams.length; i++) {
  122177. var camera = cams[i];
  122178. var cameraName = camera.name;
  122179. if (this._singleInstance) {
  122180. cameraKey = 0;
  122181. }
  122182. else {
  122183. cameraKey = cameraName;
  122184. }
  122185. if (!this._postProcesses[cameraKey]) {
  122186. var postProcess = this._getPostProcesses();
  122187. if (postProcess) {
  122188. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  122189. }
  122190. }
  122191. if (!this._indicesForCamera[cameraName]) {
  122192. this._indicesForCamera[cameraName] = [];
  122193. }
  122194. this._postProcesses[cameraKey].forEach(function (postProcess) {
  122195. var index = camera.attachPostProcess(postProcess);
  122196. _this._indicesForCamera[cameraName].push(index);
  122197. });
  122198. if (!this._cameras[cameraName]) {
  122199. this._cameras[cameraName] = camera;
  122200. }
  122201. }
  122202. };
  122203. /**
  122204. * Detatches the effect on cameras
  122205. * @param cameras The camera to detatch from.
  122206. * @hidden
  122207. */
  122208. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  122209. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  122210. if (!cams) {
  122211. return;
  122212. }
  122213. for (var i = 0; i < cams.length; i++) {
  122214. var camera = cams[i];
  122215. var cameraName = camera.name;
  122216. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  122217. if (postProcesses) {
  122218. postProcesses.forEach(function (postProcess) {
  122219. camera.detachPostProcess(postProcess);
  122220. });
  122221. }
  122222. if (this._cameras[cameraName]) {
  122223. this._cameras[cameraName] = null;
  122224. }
  122225. }
  122226. };
  122227. /**
  122228. * Enables the effect on given cameras
  122229. * @param cameras The camera to enable.
  122230. * @hidden
  122231. */
  122232. PostProcessRenderEffect.prototype._enable = function (cameras) {
  122233. var _this = this;
  122234. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  122235. if (!cams) {
  122236. return;
  122237. }
  122238. for (var i = 0; i < cams.length; i++) {
  122239. var camera = cams[i];
  122240. var cameraName = camera.name;
  122241. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  122242. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  122243. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  122244. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  122245. });
  122246. }
  122247. }
  122248. }
  122249. };
  122250. /**
  122251. * Disables the effect on the given cameras
  122252. * @param cameras The camera to disable.
  122253. * @hidden
  122254. */
  122255. PostProcessRenderEffect.prototype._disable = function (cameras) {
  122256. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  122257. if (!cams) {
  122258. return;
  122259. }
  122260. for (var i = 0; i < cams.length; i++) {
  122261. var camera = cams[i];
  122262. var cameraName = camera.name;
  122263. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  122264. camera.detachPostProcess(postProcess);
  122265. });
  122266. }
  122267. };
  122268. /**
  122269. * Gets a list of the post processes contained in the effect.
  122270. * @param camera The camera to get the post processes on.
  122271. * @returns The list of the post processes in the effect.
  122272. */
  122273. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  122274. if (this._singleInstance) {
  122275. return this._postProcesses[0];
  122276. }
  122277. else {
  122278. if (!camera) {
  122279. return null;
  122280. }
  122281. return this._postProcesses[camera.name];
  122282. }
  122283. };
  122284. return PostProcessRenderEffect;
  122285. }());
  122286. /***/ }),
  122287. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  122288. /*!*******************************************************************!*\
  122289. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  122290. \*******************************************************************/
  122291. /*! exports provided: PostProcessRenderPipeline */
  122292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122293. "use strict";
  122294. __webpack_require__.r(__webpack_exports__);
  122295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  122296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122297. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  122298. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  122299. /**
  122300. * PostProcessRenderPipeline
  122301. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122302. */
  122303. var PostProcessRenderPipeline = /** @class */ (function () {
  122304. /**
  122305. * Initializes a PostProcessRenderPipeline
  122306. * @param engine engine to add the pipeline to
  122307. * @param name name of the pipeline
  122308. */
  122309. function PostProcessRenderPipeline(engine, name) {
  122310. this.engine = engine;
  122311. this._name = name;
  122312. this._renderEffects = {};
  122313. this._renderEffectsForIsolatedPass = new Array();
  122314. this._cameras = [];
  122315. }
  122316. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  122317. /**
  122318. * Gets pipeline name
  122319. */
  122320. get: function () {
  122321. return this._name;
  122322. },
  122323. enumerable: true,
  122324. configurable: true
  122325. });
  122326. /**
  122327. * Gets the class name
  122328. * @returns "PostProcessRenderPipeline"
  122329. */
  122330. PostProcessRenderPipeline.prototype.getClassName = function () {
  122331. return "PostProcessRenderPipeline";
  122332. };
  122333. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  122334. /**
  122335. * If all the render effects in the pipeline are supported
  122336. */
  122337. get: function () {
  122338. for (var renderEffectName in this._renderEffects) {
  122339. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122340. if (!this._renderEffects[renderEffectName].isSupported) {
  122341. return false;
  122342. }
  122343. }
  122344. }
  122345. return true;
  122346. },
  122347. enumerable: true,
  122348. configurable: true
  122349. });
  122350. /**
  122351. * Adds an effect to the pipeline
  122352. * @param renderEffect the effect to add
  122353. */
  122354. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  122355. this._renderEffects[renderEffect._name] = renderEffect;
  122356. };
  122357. // private
  122358. /** @hidden */
  122359. PostProcessRenderPipeline.prototype._rebuild = function () {
  122360. };
  122361. /** @hidden */
  122362. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  122363. var renderEffects = this._renderEffects[renderEffectName];
  122364. if (!renderEffects) {
  122365. return;
  122366. }
  122367. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  122368. };
  122369. /** @hidden */
  122370. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  122371. var renderEffects = this._renderEffects[renderEffectName];
  122372. if (!renderEffects) {
  122373. return;
  122374. }
  122375. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  122376. };
  122377. /** @hidden */
  122378. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  122379. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  122380. if (!cams) {
  122381. return;
  122382. }
  122383. var indicesToDelete = [];
  122384. var i;
  122385. for (i = 0; i < cams.length; i++) {
  122386. var camera = cams[i];
  122387. var cameraName = camera.name;
  122388. if (this._cameras.indexOf(camera) === -1) {
  122389. this._cameras[cameraName] = camera;
  122390. }
  122391. else if (unique) {
  122392. indicesToDelete.push(i);
  122393. }
  122394. }
  122395. for (i = 0; i < indicesToDelete.length; i++) {
  122396. cameras.splice(indicesToDelete[i], 1);
  122397. }
  122398. for (var renderEffectName in this._renderEffects) {
  122399. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122400. this._renderEffects[renderEffectName]._attachCameras(cams);
  122401. }
  122402. }
  122403. };
  122404. /** @hidden */
  122405. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  122406. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  122407. if (!cams) {
  122408. return;
  122409. }
  122410. for (var renderEffectName in this._renderEffects) {
  122411. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122412. this._renderEffects[renderEffectName]._detachCameras(cams);
  122413. }
  122414. }
  122415. for (var i = 0; i < cams.length; i++) {
  122416. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  122417. }
  122418. };
  122419. /** @hidden */
  122420. PostProcessRenderPipeline.prototype._update = function () {
  122421. for (var renderEffectName in this._renderEffects) {
  122422. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122423. this._renderEffects[renderEffectName]._update();
  122424. }
  122425. }
  122426. for (var i = 0; i < this._cameras.length; i++) {
  122427. var cameraName = this._cameras[i].name;
  122428. if (this._renderEffectsForIsolatedPass[cameraName]) {
  122429. this._renderEffectsForIsolatedPass[cameraName]._update();
  122430. }
  122431. }
  122432. };
  122433. /** @hidden */
  122434. PostProcessRenderPipeline.prototype._reset = function () {
  122435. this._renderEffects = {};
  122436. this._renderEffectsForIsolatedPass = new Array();
  122437. };
  122438. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  122439. // 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)
  122440. var effectKeys = Object.keys(this._renderEffects);
  122441. if (this.engine.webGLVersion === 1) {
  122442. return false;
  122443. }
  122444. if (effectKeys.length > 0) {
  122445. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  122446. if (postProcesses) {
  122447. postProcesses[0].samples = sampleCount;
  122448. }
  122449. }
  122450. return true;
  122451. };
  122452. /**
  122453. * Disposes of the pipeline
  122454. */
  122455. PostProcessRenderPipeline.prototype.dispose = function () {
  122456. // Must be implemented by children
  122457. };
  122458. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122459. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  122460. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  122461. return PostProcessRenderPipeline;
  122462. }());
  122463. /***/ }),
  122464. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  122465. /*!**************************************************************************!*\
  122466. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  122467. \**************************************************************************/
  122468. /*! exports provided: PostProcessRenderPipelineManager */
  122469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122470. "use strict";
  122471. __webpack_require__.r(__webpack_exports__);
  122472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  122473. /**
  122474. * PostProcessRenderPipelineManager class
  122475. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122476. */
  122477. var PostProcessRenderPipelineManager = /** @class */ (function () {
  122478. /**
  122479. * Initializes a PostProcessRenderPipelineManager
  122480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122481. */
  122482. function PostProcessRenderPipelineManager() {
  122483. this._renderPipelines = {};
  122484. }
  122485. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  122486. /**
  122487. * Gets the list of supported render pipelines
  122488. */
  122489. get: function () {
  122490. var result = [];
  122491. for (var renderPipelineName in this._renderPipelines) {
  122492. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122493. var pipeline = this._renderPipelines[renderPipelineName];
  122494. if (pipeline.isSupported) {
  122495. result.push(pipeline);
  122496. }
  122497. }
  122498. }
  122499. return result;
  122500. },
  122501. enumerable: true,
  122502. configurable: true
  122503. });
  122504. /**
  122505. * Adds a pipeline to the manager
  122506. * @param renderPipeline The pipeline to add
  122507. */
  122508. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  122509. this._renderPipelines[renderPipeline._name] = renderPipeline;
  122510. };
  122511. /**
  122512. * Attaches a camera to the pipeline
  122513. * @param renderPipelineName The name of the pipeline to attach to
  122514. * @param cameras the camera to attach
  122515. * @param unique if the camera can be attached multiple times to the pipeline
  122516. */
  122517. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  122518. if (unique === void 0) { unique = false; }
  122519. var renderPipeline = this._renderPipelines[renderPipelineName];
  122520. if (!renderPipeline) {
  122521. return;
  122522. }
  122523. renderPipeline._attachCameras(cameras, unique);
  122524. };
  122525. /**
  122526. * Detaches a camera from the pipeline
  122527. * @param renderPipelineName The name of the pipeline to detach from
  122528. * @param cameras the camera to detach
  122529. */
  122530. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  122531. var renderPipeline = this._renderPipelines[renderPipelineName];
  122532. if (!renderPipeline) {
  122533. return;
  122534. }
  122535. renderPipeline._detachCameras(cameras);
  122536. };
  122537. /**
  122538. * Enables an effect by name on a pipeline
  122539. * @param renderPipelineName the name of the pipeline to enable the effect in
  122540. * @param renderEffectName the name of the effect to enable
  122541. * @param cameras the cameras that the effect should be enabled on
  122542. */
  122543. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  122544. var renderPipeline = this._renderPipelines[renderPipelineName];
  122545. if (!renderPipeline) {
  122546. return;
  122547. }
  122548. renderPipeline._enableEffect(renderEffectName, cameras);
  122549. };
  122550. /**
  122551. * Disables an effect by name on a pipeline
  122552. * @param renderPipelineName the name of the pipeline to disable the effect in
  122553. * @param renderEffectName the name of the effect to disable
  122554. * @param cameras the cameras that the effect should be disabled on
  122555. */
  122556. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  122557. var renderPipeline = this._renderPipelines[renderPipelineName];
  122558. if (!renderPipeline) {
  122559. return;
  122560. }
  122561. renderPipeline._disableEffect(renderEffectName, cameras);
  122562. };
  122563. /**
  122564. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  122565. */
  122566. PostProcessRenderPipelineManager.prototype.update = function () {
  122567. for (var renderPipelineName in this._renderPipelines) {
  122568. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122569. var pipeline = this._renderPipelines[renderPipelineName];
  122570. if (!pipeline.isSupported) {
  122571. pipeline.dispose();
  122572. delete this._renderPipelines[renderPipelineName];
  122573. }
  122574. else {
  122575. pipeline._update();
  122576. }
  122577. }
  122578. }
  122579. };
  122580. /** @hidden */
  122581. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  122582. for (var renderPipelineName in this._renderPipelines) {
  122583. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122584. var pipeline = this._renderPipelines[renderPipelineName];
  122585. pipeline._rebuild();
  122586. }
  122587. }
  122588. };
  122589. /**
  122590. * Disposes of the manager and pipelines
  122591. */
  122592. PostProcessRenderPipelineManager.prototype.dispose = function () {
  122593. for (var renderPipelineName in this._renderPipelines) {
  122594. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122595. var pipeline = this._renderPipelines[renderPipelineName];
  122596. pipeline.dispose();
  122597. }
  122598. }
  122599. };
  122600. return PostProcessRenderPipelineManager;
  122601. }());
  122602. /***/ }),
  122603. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  122604. /*!****************************************************************************************!*\
  122605. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  122606. \****************************************************************************************/
  122607. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  122608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122609. "use strict";
  122610. __webpack_require__.r(__webpack_exports__);
  122611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  122612. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  122613. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  122614. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  122615. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  122616. get: function () {
  122617. if (!this._postProcessRenderPipelineManager) {
  122618. // Register the G Buffer component to the scene.
  122619. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  122620. if (!component) {
  122621. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  122622. this._addComponent(component);
  122623. }
  122624. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  122625. }
  122626. return this._postProcessRenderPipelineManager;
  122627. },
  122628. enumerable: true,
  122629. configurable: true
  122630. });
  122631. /**
  122632. * Defines the Render Pipeline scene component responsible to rendering pipelines
  122633. */
  122634. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  122635. /**
  122636. * Creates a new instance of the component for the given scene
  122637. * @param scene Defines the scene to register the component in
  122638. */
  122639. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  122640. /**
  122641. * The component name helpfull to identify the component in the list of scene components.
  122642. */
  122643. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  122644. this.scene = scene;
  122645. }
  122646. /**
  122647. * Registers the component in a given scene
  122648. */
  122649. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  122650. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  122651. };
  122652. /**
  122653. * Rebuilds the elements related to this component in case of
  122654. * context lost for instance.
  122655. */
  122656. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  122657. if (this.scene._postProcessRenderPipelineManager) {
  122658. this.scene._postProcessRenderPipelineManager._rebuild();
  122659. }
  122660. };
  122661. /**
  122662. * Disposes the component and the associated ressources
  122663. */
  122664. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  122665. if (this.scene._postProcessRenderPipelineManager) {
  122666. this.scene._postProcessRenderPipelineManager.dispose();
  122667. }
  122668. };
  122669. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  122670. if (this.scene._postProcessRenderPipelineManager) {
  122671. this.scene._postProcessRenderPipelineManager.update();
  122672. }
  122673. };
  122674. return PostProcessRenderPipelineManagerSceneComponent;
  122675. }());
  122676. /***/ }),
  122677. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  122678. /*!**********************************************!*\
  122679. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  122680. \**********************************************/
  122681. /*! exports provided: AnaglyphPostProcess */
  122682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122683. "use strict";
  122684. __webpack_require__.r(__webpack_exports__);
  122685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  122686. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122687. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122688. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  122689. /**
  122690. * Postprocess used to generate anaglyphic rendering
  122691. */
  122692. var AnaglyphPostProcess = /** @class */ (function (_super) {
  122693. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  122694. /**
  122695. * Creates a new AnaglyphPostProcess
  122696. * @param name defines postprocess name
  122697. * @param options defines creation options or target ratio scale
  122698. * @param rigCameras defines cameras using this postprocess
  122699. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122700. * @param engine defines hosting engine
  122701. * @param reusable defines if the postprocess will be reused multiple times per frame
  122702. */
  122703. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  122704. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  122705. _this._passedProcess = rigCameras[0]._rigPostProcess;
  122706. _this.onApplyObservable.add(function (effect) {
  122707. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  122708. });
  122709. return _this;
  122710. }
  122711. return AnaglyphPostProcess;
  122712. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122713. /***/ }),
  122714. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  122715. /*!***************************************************!*\
  122716. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  122717. \***************************************************/
  122718. /*! exports provided: BlackAndWhitePostProcess */
  122719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122720. "use strict";
  122721. __webpack_require__.r(__webpack_exports__);
  122722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  122723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122724. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122725. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  122726. /**
  122727. * Post process used to render in black and white
  122728. */
  122729. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  122730. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  122731. /**
  122732. * Creates a black and white post process
  122733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  122734. * @param name The name of the effect.
  122735. * @param options The required width/height ratio to downsize to before computing the render pass.
  122736. * @param camera The camera to apply the render pass to.
  122737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122738. * @param engine The engine which the post process will be applied. (default: current engine)
  122739. * @param reusable If the post process can be reused on the same frame. (default: false)
  122740. */
  122741. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  122742. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  122743. /**
  122744. * Linear about to convert he result to black and white (default: 1)
  122745. */
  122746. _this.degree = 1;
  122747. _this.onApplyObservable.add(function (effect) {
  122748. effect.setFloat("degree", _this.degree);
  122749. });
  122750. return _this;
  122751. }
  122752. return BlackAndWhitePostProcess;
  122753. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122754. /***/ }),
  122755. /***/ "./PostProcesses/bloomEffect.ts":
  122756. /*!**************************************!*\
  122757. !*** ./PostProcesses/bloomEffect.ts ***!
  122758. \**************************************/
  122759. /*! exports provided: BloomEffect */
  122760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122761. "use strict";
  122762. __webpack_require__.r(__webpack_exports__);
  122763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  122764. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122765. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  122766. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  122767. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  122768. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  122769. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122770. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122771. /**
  122772. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  122773. */
  122774. var BloomEffect = /** @class */ (function (_super) {
  122775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  122776. /**
  122777. * Creates a new instance of @see BloomEffect
  122778. * @param scene The scene the effect belongs to.
  122779. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  122780. * @param bloomKernel The size of the kernel to be used when applying the blur.
  122781. * @param bloomWeight The the strength of bloom.
  122782. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122783. * @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)
  122784. */
  122785. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  122786. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  122787. if (blockCompilation === void 0) { blockCompilation = false; }
  122788. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  122789. return _this._effects;
  122790. }, true) || this;
  122791. _this.bloomScale = bloomScale;
  122792. /**
  122793. * @hidden Internal
  122794. */
  122795. _this._effects = [];
  122796. _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);
  122797. _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);
  122798. _this._blurX.alwaysForcePOT = true;
  122799. _this._blurX.autoClear = false;
  122800. _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);
  122801. _this._blurY.alwaysForcePOT = true;
  122802. _this._blurY.autoClear = false;
  122803. _this.kernel = bloomKernel;
  122804. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  122805. _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);
  122806. _this._merge.autoClear = false;
  122807. _this._effects.push(_this._merge);
  122808. return _this;
  122809. }
  122810. Object.defineProperty(BloomEffect.prototype, "threshold", {
  122811. /**
  122812. * The luminance threshold to find bright areas of the image to bloom.
  122813. */
  122814. get: function () {
  122815. return this._downscale.threshold;
  122816. },
  122817. set: function (value) {
  122818. this._downscale.threshold = value;
  122819. },
  122820. enumerable: true,
  122821. configurable: true
  122822. });
  122823. Object.defineProperty(BloomEffect.prototype, "weight", {
  122824. /**
  122825. * The strength of the bloom.
  122826. */
  122827. get: function () {
  122828. return this._merge.weight;
  122829. },
  122830. set: function (value) {
  122831. this._merge.weight = value;
  122832. },
  122833. enumerable: true,
  122834. configurable: true
  122835. });
  122836. Object.defineProperty(BloomEffect.prototype, "kernel", {
  122837. /**
  122838. * Specifies the size of the bloom blur kernel, relative to the final output size
  122839. */
  122840. get: function () {
  122841. return this._blurX.kernel / this.bloomScale;
  122842. },
  122843. set: function (value) {
  122844. this._blurX.kernel = value * this.bloomScale;
  122845. this._blurY.kernel = value * this.bloomScale;
  122846. },
  122847. enumerable: true,
  122848. configurable: true
  122849. });
  122850. /**
  122851. * Disposes each of the internal effects for a given camera.
  122852. * @param camera The camera to dispose the effect on.
  122853. */
  122854. BloomEffect.prototype.disposeEffects = function (camera) {
  122855. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122856. this._effects[effectIndex].dispose(camera);
  122857. }
  122858. };
  122859. /**
  122860. * @hidden Internal
  122861. */
  122862. BloomEffect.prototype._updateEffects = function () {
  122863. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122864. this._effects[effectIndex].updateEffect();
  122865. }
  122866. };
  122867. /**
  122868. * Internal
  122869. * @returns if all the contained post processes are ready.
  122870. * @hidden
  122871. */
  122872. BloomEffect.prototype._isReady = function () {
  122873. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122874. if (!this._effects[effectIndex].isReady()) {
  122875. return false;
  122876. }
  122877. }
  122878. return true;
  122879. };
  122880. return BloomEffect;
  122881. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  122882. /***/ }),
  122883. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  122884. /*!************************************************!*\
  122885. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  122886. \************************************************/
  122887. /*! exports provided: BloomMergePostProcess */
  122888. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122889. "use strict";
  122890. __webpack_require__.r(__webpack_exports__);
  122891. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  122892. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122893. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122894. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122895. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  122896. /**
  122897. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122898. */
  122899. var BloomMergePostProcess = /** @class */ (function (_super) {
  122900. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  122901. /**
  122902. * Creates a new instance of @see BloomMergePostProcess
  122903. * @param name The name of the effect.
  122904. * @param originalFromInput Post process which's input will be used for the merge.
  122905. * @param blurred Blurred highlights post process which's output will be used.
  122906. * @param weight Weight of the bloom to be added to the original input.
  122907. * @param options The required width/height ratio to downsize to before computing the render pass.
  122908. * @param camera The camera to apply the render pass to.
  122909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122910. * @param engine The engine which the post process will be applied. (default: current engine)
  122911. * @param reusable If the post process can be reused on the same frame. (default: false)
  122912. * @param textureType Type of textures used when performing the post process. (default: 0)
  122913. * @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)
  122914. */
  122915. function BloomMergePostProcess(name, originalFromInput, blurred,
  122916. /** Weight of the bloom to be added to the original input. */
  122917. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122918. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122919. if (blockCompilation === void 0) { blockCompilation = false; }
  122920. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  122921. _this.weight = weight;
  122922. _this.onApplyObservable.add(function (effect) {
  122923. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  122924. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  122925. effect.setFloat("bloomWeight", _this.weight);
  122926. });
  122927. if (!blockCompilation) {
  122928. _this.updateEffect();
  122929. }
  122930. return _this;
  122931. }
  122932. return BloomMergePostProcess;
  122933. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122934. /***/ }),
  122935. /***/ "./PostProcesses/blurPostProcess.ts":
  122936. /*!******************************************!*\
  122937. !*** ./PostProcesses/blurPostProcess.ts ***!
  122938. \******************************************/
  122939. /*! exports provided: BlurPostProcess */
  122940. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122941. "use strict";
  122942. __webpack_require__.r(__webpack_exports__);
  122943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  122944. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122945. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122946. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122947. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122948. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  122949. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  122950. /**
  122951. * The Blur Post Process which blurs an image based on a kernel and direction.
  122952. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  122953. */
  122954. var BlurPostProcess = /** @class */ (function (_super) {
  122955. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  122956. /**
  122957. * Creates a new instance BlurPostProcess
  122958. * @param name The name of the effect.
  122959. * @param direction The direction in which to blur the image.
  122960. * @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.
  122961. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  122962. * @param camera The camera to apply the render pass to.
  122963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122964. * @param engine The engine which the post process will be applied. (default: current engine)
  122965. * @param reusable If the post process can be reused on the same frame. (default: false)
  122966. * @param textureType Type of textures used when performing the post process. (default: 0)
  122967. * @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)
  122968. */
  122969. function BlurPostProcess(name,
  122970. /** The direction in which to blur the image. */
  122971. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  122972. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  122973. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122974. if (defines === void 0) { defines = ""; }
  122975. if (blockCompilation === void 0) { blockCompilation = false; }
  122976. 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;
  122977. _this.direction = direction;
  122978. _this.blockCompilation = blockCompilation;
  122979. _this._packedFloat = false;
  122980. _this._staticDefines = "";
  122981. _this._staticDefines = defines;
  122982. _this.onApplyObservable.add(function (effect) {
  122983. if (_this._outputTexture) {
  122984. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  122985. }
  122986. else {
  122987. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  122988. }
  122989. });
  122990. _this.kernel = kernel;
  122991. return _this;
  122992. }
  122993. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  122994. /**
  122995. * Gets the length in pixels of the blur sample region
  122996. */
  122997. get: function () {
  122998. return this._idealKernel;
  122999. },
  123000. /**
  123001. * Sets the length in pixels of the blur sample region
  123002. */
  123003. set: function (v) {
  123004. if (this._idealKernel === v) {
  123005. return;
  123006. }
  123007. v = Math.max(v, 1);
  123008. this._idealKernel = v;
  123009. this._kernel = this._nearestBestKernel(v);
  123010. if (!this.blockCompilation) {
  123011. this._updateParameters();
  123012. }
  123013. },
  123014. enumerable: true,
  123015. configurable: true
  123016. });
  123017. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  123018. /**
  123019. * Gets wether or not the blur is unpacking/repacking floats
  123020. */
  123021. get: function () {
  123022. return this._packedFloat;
  123023. },
  123024. /**
  123025. * Sets wether or not the blur needs to unpack/repack floats
  123026. */
  123027. set: function (v) {
  123028. if (this._packedFloat === v) {
  123029. return;
  123030. }
  123031. this._packedFloat = v;
  123032. if (!this.blockCompilation) {
  123033. this._updateParameters();
  123034. }
  123035. },
  123036. enumerable: true,
  123037. configurable: true
  123038. });
  123039. /**
  123040. * Updates the effect with the current post process compile time values and recompiles the shader.
  123041. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  123042. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  123043. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  123044. * @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
  123045. * @param onCompiled Called when the shader has been compiled.
  123046. * @param onError Called if there is an error when compiling a shader.
  123047. */
  123048. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  123049. if (defines === void 0) { defines = null; }
  123050. if (uniforms === void 0) { uniforms = null; }
  123051. if (samplers === void 0) { samplers = null; }
  123052. this._updateParameters(onCompiled, onError);
  123053. };
  123054. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  123055. // Generate sampling offsets and weights
  123056. var N = this._kernel;
  123057. var centerIndex = (N - 1) / 2;
  123058. // Generate Gaussian sampling weights over kernel
  123059. var offsets = [];
  123060. var weights = [];
  123061. var totalWeight = 0;
  123062. for (var i = 0; i < N; i++) {
  123063. var u = i / (N - 1);
  123064. var w = this._gaussianWeight(u * 2.0 - 1);
  123065. offsets[i] = (i - centerIndex);
  123066. weights[i] = w;
  123067. totalWeight += w;
  123068. }
  123069. // Normalize weights
  123070. for (var i = 0; i < weights.length; i++) {
  123071. weights[i] /= totalWeight;
  123072. }
  123073. // Optimize: combine samples to take advantage of hardware linear sampling
  123074. // Walk from left to center, combining pairs (symmetrically)
  123075. var linearSamplingWeights = [];
  123076. var linearSamplingOffsets = [];
  123077. var linearSamplingMap = [];
  123078. for (var i = 0; i <= centerIndex; i += 2) {
  123079. var j = Math.min(i + 1, Math.floor(centerIndex));
  123080. var singleCenterSample = i === j;
  123081. if (singleCenterSample) {
  123082. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  123083. }
  123084. else {
  123085. var sharedCell = j === centerIndex;
  123086. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  123087. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  123088. if (offsetLinear === 0) {
  123089. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  123090. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  123091. }
  123092. else {
  123093. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  123094. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  123095. }
  123096. }
  123097. }
  123098. for (var i = 0; i < linearSamplingMap.length; i++) {
  123099. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  123100. linearSamplingWeights[i] = linearSamplingMap[i].w;
  123101. }
  123102. // Replace with optimized
  123103. offsets = linearSamplingOffsets;
  123104. weights = linearSamplingWeights;
  123105. // Generate shaders
  123106. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  123107. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  123108. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  123109. var defines = "";
  123110. defines += this._staticDefines;
  123111. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  123112. if (this._staticDefines.indexOf("DOF") != -1) {
  123113. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  123114. varyingCount--;
  123115. }
  123116. for (var i = 0; i < varyingCount; i++) {
  123117. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  123118. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  123119. }
  123120. var depCount = 0;
  123121. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  123122. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  123123. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  123124. depCount++;
  123125. }
  123126. if (this.packedFloat) {
  123127. defines += "#define PACKEDFLOAT 1";
  123128. }
  123129. this.blockCompilation = false;
  123130. _super.prototype.updateEffect.call(this, defines, null, null, {
  123131. varyingCount: varyingCount,
  123132. depCount: depCount
  123133. }, onCompiled, onError);
  123134. };
  123135. /**
  123136. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  123137. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  123138. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  123139. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  123140. * The gaps between physical kernels are compensated for in the weighting of the samples
  123141. * @param idealKernel Ideal blur kernel.
  123142. * @return Nearest best kernel.
  123143. */
  123144. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  123145. var v = Math.round(idealKernel);
  123146. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  123147. var k = _a[_i];
  123148. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  123149. return Math.max(k, 3);
  123150. }
  123151. }
  123152. return Math.max(v, 3);
  123153. };
  123154. /**
  123155. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  123156. * @param x The point on the Gaussian distribution to sample.
  123157. * @return the value of the Gaussian function at x.
  123158. */
  123159. BlurPostProcess.prototype._gaussianWeight = function (x) {
  123160. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  123161. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  123162. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  123163. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  123164. // truncated at around 1.3% of peak strength.
  123165. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  123166. var sigma = (1 / 3);
  123167. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  123168. var exponent = -((x * x) / (2.0 * sigma * sigma));
  123169. var weight = (1.0 / denominator) * Math.exp(exponent);
  123170. return weight;
  123171. };
  123172. /**
  123173. * Generates a string that can be used as a floating point number in GLSL.
  123174. * @param x Value to print.
  123175. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  123176. * @return GLSL float string.
  123177. */
  123178. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  123179. if (decimalFigures === void 0) { decimalFigures = 8; }
  123180. return x.toFixed(decimalFigures).replace(/0+$/, '');
  123181. };
  123182. return BlurPostProcess;
  123183. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123184. /***/ }),
  123185. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  123186. /*!*********************************************************!*\
  123187. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  123188. \*********************************************************/
  123189. /*! exports provided: ChromaticAberrationPostProcess */
  123190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123191. "use strict";
  123192. __webpack_require__.r(__webpack_exports__);
  123193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  123194. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123195. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123196. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123197. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123198. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  123199. /**
  123200. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123201. */
  123202. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  123203. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  123204. /**
  123205. * Creates a new instance ChromaticAberrationPostProcess
  123206. * @param name The name of the effect.
  123207. * @param screenWidth The width of the screen to apply the effect on.
  123208. * @param screenHeight The height of the screen to apply the effect on.
  123209. * @param options The required width/height ratio to downsize to before computing the render pass.
  123210. * @param camera The camera to apply the render pass to.
  123211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123212. * @param engine The engine which the post process will be applied. (default: current engine)
  123213. * @param reusable If the post process can be reused on the same frame. (default: false)
  123214. * @param textureType Type of textures used when performing the post process. (default: 0)
  123215. * @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)
  123216. */
  123217. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123218. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123219. if (blockCompilation === void 0) { blockCompilation = false; }
  123220. 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;
  123221. /**
  123222. * The amount of seperation of rgb channels (default: 30)
  123223. */
  123224. _this.aberrationAmount = 30;
  123225. /**
  123226. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123227. */
  123228. _this.radialIntensity = 0;
  123229. /**
  123230. * 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))
  123231. */
  123232. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  123233. /**
  123234. * 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))
  123235. */
  123236. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  123237. _this.onApplyObservable.add(function (effect) {
  123238. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  123239. effect.setFloat('screen_width', screenWidth);
  123240. effect.setFloat('screen_height', screenHeight);
  123241. effect.setFloat('radialIntensity', _this.radialIntensity);
  123242. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  123243. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  123244. });
  123245. return _this;
  123246. }
  123247. return ChromaticAberrationPostProcess;
  123248. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123249. /***/ }),
  123250. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  123251. /*!*******************************************************!*\
  123252. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  123253. \*******************************************************/
  123254. /*! exports provided: CircleOfConfusionPostProcess */
  123255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123256. "use strict";
  123257. __webpack_require__.r(__webpack_exports__);
  123258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  123259. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123260. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123261. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  123262. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123263. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  123264. /**
  123265. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123266. */
  123267. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  123268. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  123269. /**
  123270. * Creates a new instance CircleOfConfusionPostProcess
  123271. * @param name The name of the effect.
  123272. * @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.
  123273. * @param options The required width/height ratio to downsize to before computing the render pass.
  123274. * @param camera The camera to apply the render pass to.
  123275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123276. * @param engine The engine which the post process will be applied. (default: current engine)
  123277. * @param reusable If the post process can be reused on the same frame. (default: false)
  123278. * @param textureType Type of textures used when performing the post process. (default: 0)
  123279. * @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)
  123280. */
  123281. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123282. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123283. if (blockCompilation === void 0) { blockCompilation = false; }
  123284. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  123285. /**
  123286. * 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.
  123287. */
  123288. _this.lensSize = 50;
  123289. /**
  123290. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123291. */
  123292. _this.fStop = 1.4;
  123293. /**
  123294. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123295. */
  123296. _this.focusDistance = 2000;
  123297. /**
  123298. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123299. */
  123300. _this.focalLength = 50;
  123301. _this._depthTexture = null;
  123302. _this._depthTexture = depthTexture;
  123303. _this.onApplyObservable.add(function (effect) {
  123304. if (!_this._depthTexture) {
  123305. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  123306. return;
  123307. }
  123308. effect.setTexture("depthSampler", _this._depthTexture);
  123309. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  123310. var aperture = _this.lensSize / _this.fStop;
  123311. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  123312. effect.setFloat('focusDistance', _this.focusDistance);
  123313. effect.setFloat('cocPrecalculation', cocPrecalculation);
  123314. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  123315. });
  123316. return _this;
  123317. }
  123318. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  123319. /**
  123320. * 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.
  123321. */
  123322. set: function (value) {
  123323. this._depthTexture = value;
  123324. },
  123325. enumerable: true,
  123326. configurable: true
  123327. });
  123328. return CircleOfConfusionPostProcess;
  123329. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123330. /***/ }),
  123331. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  123332. /*!*****************************************************!*\
  123333. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  123334. \*****************************************************/
  123335. /*! exports provided: ColorCorrectionPostProcess */
  123336. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123337. "use strict";
  123338. __webpack_require__.r(__webpack_exports__);
  123339. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  123340. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123341. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123342. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123343. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  123344. /**
  123345. *
  123346. * This post-process allows the modification of rendered colors by using
  123347. * a 'look-up table' (LUT). This effect is also called Color Grading.
  123348. *
  123349. * The object needs to be provided an url to a texture containing the color
  123350. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  123351. * Use an image editing software to tweak the LUT to match your needs.
  123352. *
  123353. * For an example of a color LUT, see here:
  123354. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  123355. * For explanations on color grading, see here:
  123356. * @see http://udn.epicgames.com/Three/ColorGrading.html
  123357. *
  123358. */
  123359. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  123360. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  123361. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  123362. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  123363. _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);
  123364. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  123365. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  123366. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  123367. _this.onApply = function (effect) {
  123368. effect.setTexture("colorTable", _this._colorTableTexture);
  123369. };
  123370. return _this;
  123371. }
  123372. return ColorCorrectionPostProcess;
  123373. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123374. /***/ }),
  123375. /***/ "./PostProcesses/convolutionPostProcess.ts":
  123376. /*!*************************************************!*\
  123377. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  123378. \*************************************************/
  123379. /*! exports provided: ConvolutionPostProcess */
  123380. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123381. "use strict";
  123382. __webpack_require__.r(__webpack_exports__);
  123383. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  123384. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123385. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123386. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123387. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  123388. /**
  123389. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  123390. * input texture to perform effects such as edge detection or sharpening
  123391. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123392. */
  123393. var ConvolutionPostProcess = /** @class */ (function (_super) {
  123394. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  123395. /**
  123396. * Creates a new instance ConvolutionPostProcess
  123397. * @param name The name of the effect.
  123398. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  123399. * @param options The required width/height ratio to downsize to before computing the render pass.
  123400. * @param camera The camera to apply the render pass to.
  123401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123402. * @param engine The engine which the post process will be applied. (default: current engine)
  123403. * @param reusable If the post process can be reused on the same frame. (default: false)
  123404. * @param textureType Type of textures used when performing the post process. (default: 0)
  123405. */
  123406. function ConvolutionPostProcess(name,
  123407. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  123408. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  123409. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123410. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  123411. _this.kernel = kernel;
  123412. _this.onApply = function (effect) {
  123413. effect.setFloat2("screenSize", _this.width, _this.height);
  123414. effect.setArray("kernel", _this.kernel);
  123415. };
  123416. return _this;
  123417. }
  123418. // Statics
  123419. /**
  123420. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123421. */
  123422. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  123423. /**
  123424. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123425. */
  123426. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  123427. /**
  123428. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123429. */
  123430. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  123431. /**
  123432. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123433. */
  123434. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  123435. /**
  123436. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123437. */
  123438. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  123439. /**
  123440. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123441. */
  123442. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  123443. return ConvolutionPostProcess;
  123444. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123445. /***/ }),
  123446. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  123447. /*!******************************************************!*\
  123448. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  123449. \******************************************************/
  123450. /*! exports provided: DepthOfFieldBlurPostProcess */
  123451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123452. "use strict";
  123453. __webpack_require__.r(__webpack_exports__);
  123454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  123455. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123456. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123457. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  123458. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123459. /**
  123460. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  123461. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  123462. * based on samples that have a large difference in distance than the center pixel.
  123463. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123464. */
  123465. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  123466. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  123467. /**
  123468. * Creates a new instance CircleOfConfusionPostProcess
  123469. * @param name The name of the effect.
  123470. * @param scene The scene the effect belongs to.
  123471. * @param direction The direction the blur should be applied.
  123472. * @param kernel The size of the kernel used to blur.
  123473. * @param options The required width/height ratio to downsize to before computing the render pass.
  123474. * @param camera The camera to apply the render pass to.
  123475. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  123476. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  123477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123478. * @param engine The engine which the post process will be applied. (default: current engine)
  123479. * @param reusable If the post process can be reused on the same frame. (default: false)
  123480. * @param textureType Type of textures used when performing the post process. (default: 0)
  123481. * @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)
  123482. */
  123483. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  123484. if (imageToBlur === void 0) { imageToBlur = null; }
  123485. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  123486. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123487. if (blockCompilation === void 0) { blockCompilation = false; }
  123488. 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;
  123489. _this.direction = direction;
  123490. _this.onApplyObservable.add(function (effect) {
  123491. if (imageToBlur != null) {
  123492. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  123493. }
  123494. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  123495. if (scene.activeCamera) {
  123496. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  123497. }
  123498. });
  123499. return _this;
  123500. }
  123501. return DepthOfFieldBlurPostProcess;
  123502. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  123503. /***/ }),
  123504. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  123505. /*!*********************************************!*\
  123506. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  123507. \*********************************************/
  123508. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  123509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123510. "use strict";
  123511. __webpack_require__.r(__webpack_exports__);
  123512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  123513. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  123514. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123515. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123516. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123517. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  123518. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  123519. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  123520. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  123521. /**
  123522. * Specifies the level of max blur that should be applied when using the depth of field effect
  123523. */
  123524. var DepthOfFieldEffectBlurLevel;
  123525. (function (DepthOfFieldEffectBlurLevel) {
  123526. /**
  123527. * Subtle blur
  123528. */
  123529. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  123530. /**
  123531. * Medium blur
  123532. */
  123533. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  123534. /**
  123535. * Large blur
  123536. */
  123537. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  123538. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  123539. /**
  123540. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  123541. */
  123542. var DepthOfFieldEffect = /** @class */ (function (_super) {
  123543. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  123544. /**
  123545. * Creates a new instance DepthOfFieldEffect
  123546. * @param scene The scene the effect belongs to.
  123547. * @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.
  123548. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123549. * @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)
  123550. */
  123551. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  123552. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  123553. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  123554. if (blockCompilation === void 0) { blockCompilation = false; }
  123555. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  123556. return _this._effects;
  123557. }, true) || this;
  123558. /**
  123559. * @hidden Internal post processes in depth of field effect
  123560. */
  123561. _this._effects = [];
  123562. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  123563. _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);
  123564. // 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)
  123565. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  123566. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123567. _this._depthOfFieldBlurY = [];
  123568. _this._depthOfFieldBlurX = [];
  123569. var blurCount = 1;
  123570. var kernelSize = 15;
  123571. switch (blurLevel) {
  123572. case DepthOfFieldEffectBlurLevel.High: {
  123573. blurCount = 3;
  123574. kernelSize = 51;
  123575. break;
  123576. }
  123577. case DepthOfFieldEffectBlurLevel.Medium: {
  123578. blurCount = 2;
  123579. kernelSize = 31;
  123580. break;
  123581. }
  123582. default: {
  123583. kernelSize = 15;
  123584. blurCount = 1;
  123585. break;
  123586. }
  123587. }
  123588. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  123589. var ratio = 1.0;
  123590. for (var i = 0; i < blurCount; i++) {
  123591. 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);
  123592. blurY.autoClear = false;
  123593. ratio = 0.75 / Math.pow(2, i);
  123594. 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);
  123595. blurX.autoClear = false;
  123596. _this._depthOfFieldBlurY.push(blurY);
  123597. _this._depthOfFieldBlurX.push(blurX);
  123598. }
  123599. // Set all post processes on the effect.
  123600. _this._effects = [_this._circleOfConfusion];
  123601. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  123602. _this._effects.push(_this._depthOfFieldBlurY[i]);
  123603. _this._effects.push(_this._depthOfFieldBlurX[i]);
  123604. }
  123605. // Merge blurred images with original image based on circleOfConfusion
  123606. _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);
  123607. _this._dofMerge.autoClear = false;
  123608. _this._effects.push(_this._dofMerge);
  123609. return _this;
  123610. }
  123611. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  123612. get: function () {
  123613. return this._circleOfConfusion.focalLength;
  123614. },
  123615. /**
  123616. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  123617. */
  123618. set: function (value) {
  123619. this._circleOfConfusion.focalLength = value;
  123620. },
  123621. enumerable: true,
  123622. configurable: true
  123623. });
  123624. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  123625. get: function () {
  123626. return this._circleOfConfusion.fStop;
  123627. },
  123628. /**
  123629. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123630. */
  123631. set: function (value) {
  123632. this._circleOfConfusion.fStop = value;
  123633. },
  123634. enumerable: true,
  123635. configurable: true
  123636. });
  123637. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  123638. get: function () {
  123639. return this._circleOfConfusion.focusDistance;
  123640. },
  123641. /**
  123642. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123643. */
  123644. set: function (value) {
  123645. this._circleOfConfusion.focusDistance = value;
  123646. },
  123647. enumerable: true,
  123648. configurable: true
  123649. });
  123650. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  123651. get: function () {
  123652. return this._circleOfConfusion.lensSize;
  123653. },
  123654. /**
  123655. * 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.
  123656. */
  123657. set: function (value) {
  123658. this._circleOfConfusion.lensSize = value;
  123659. },
  123660. enumerable: true,
  123661. configurable: true
  123662. });
  123663. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  123664. /**
  123665. * 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.
  123666. */
  123667. set: function (value) {
  123668. this._circleOfConfusion.depthTexture = value;
  123669. },
  123670. enumerable: true,
  123671. configurable: true
  123672. });
  123673. /**
  123674. * Disposes each of the internal effects for a given camera.
  123675. * @param camera The camera to dispose the effect on.
  123676. */
  123677. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  123678. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  123679. this._effects[effectIndex].dispose(camera);
  123680. }
  123681. };
  123682. /**
  123683. * @hidden Internal
  123684. */
  123685. DepthOfFieldEffect.prototype._updateEffects = function () {
  123686. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  123687. this._effects[effectIndex].updateEffect();
  123688. }
  123689. };
  123690. /**
  123691. * Internal
  123692. * @returns if all the contained post processes are ready.
  123693. * @hidden
  123694. */
  123695. DepthOfFieldEffect.prototype._isReady = function () {
  123696. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  123697. if (!this._effects[effectIndex].isReady()) {
  123698. return false;
  123699. }
  123700. }
  123701. return true;
  123702. };
  123703. return DepthOfFieldEffect;
  123704. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  123705. /***/ }),
  123706. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  123707. /*!*******************************************************!*\
  123708. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  123709. \*******************************************************/
  123710. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  123711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123712. "use strict";
  123713. __webpack_require__.r(__webpack_exports__);
  123714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  123715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  123716. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123717. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123718. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123719. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  123720. /**
  123721. * Options to be set when merging outputs from the default pipeline.
  123722. */
  123723. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  123724. function DepthOfFieldMergePostProcessOptions() {
  123725. }
  123726. return DepthOfFieldMergePostProcessOptions;
  123727. }());
  123728. /**
  123729. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123730. */
  123731. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  123732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  123733. /**
  123734. * Creates a new instance of DepthOfFieldMergePostProcess
  123735. * @param name The name of the effect.
  123736. * @param originalFromInput Post process which's input will be used for the merge.
  123737. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  123738. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  123739. * @param options The required width/height ratio to downsize to before computing the render pass.
  123740. * @param camera The camera to apply the render pass to.
  123741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123742. * @param engine The engine which the post process will be applied. (default: current engine)
  123743. * @param reusable If the post process can be reused on the same frame. (default: false)
  123744. * @param textureType Type of textures used when performing the post process. (default: 0)
  123745. * @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)
  123746. */
  123747. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123748. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123749. if (blockCompilation === void 0) { blockCompilation = false; }
  123750. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  123751. _this.blurSteps = blurSteps;
  123752. _this.onApplyObservable.add(function (effect) {
  123753. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  123754. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  123755. blurSteps.forEach(function (step, index) {
  123756. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  123757. });
  123758. });
  123759. if (!blockCompilation) {
  123760. _this.updateEffect();
  123761. }
  123762. return _this;
  123763. }
  123764. /**
  123765. * Updates the effect with the current post process compile time values and recompiles the shader.
  123766. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  123767. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  123768. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  123769. * @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
  123770. * @param onCompiled Called when the shader has been compiled.
  123771. * @param onError Called if there is an error when compiling a shader.
  123772. */
  123773. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  123774. if (defines === void 0) { defines = null; }
  123775. if (uniforms === void 0) { uniforms = null; }
  123776. if (samplers === void 0) { samplers = null; }
  123777. if (!defines) {
  123778. defines = "";
  123779. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  123780. }
  123781. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  123782. };
  123783. return DepthOfFieldMergePostProcess;
  123784. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123785. /***/ }),
  123786. /***/ "./PostProcesses/displayPassPostProcess.ts":
  123787. /*!*************************************************!*\
  123788. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  123789. \*************************************************/
  123790. /*! exports provided: DisplayPassPostProcess */
  123791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123792. "use strict";
  123793. __webpack_require__.r(__webpack_exports__);
  123794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  123795. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123796. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123797. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  123798. /**
  123799. * DisplayPassPostProcess which produces an output the same as it's input
  123800. */
  123801. var DisplayPassPostProcess = /** @class */ (function (_super) {
  123802. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  123803. /**
  123804. * Creates the DisplayPassPostProcess
  123805. * @param name The name of the effect.
  123806. * @param options The required width/height ratio to downsize to before computing the render pass.
  123807. * @param camera The camera to apply the render pass to.
  123808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123809. * @param engine The engine which the post process will be applied. (default: current engine)
  123810. * @param reusable If the post process can be reused on the same frame. (default: false)
  123811. */
  123812. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  123813. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  123814. }
  123815. return DisplayPassPostProcess;
  123816. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123817. /***/ }),
  123818. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  123819. /*!*******************************************************!*\
  123820. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  123821. \*******************************************************/
  123822. /*! exports provided: ExtractHighlightsPostProcess */
  123823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123824. "use strict";
  123825. __webpack_require__.r(__webpack_exports__);
  123826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  123827. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123828. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123829. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123830. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123831. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  123832. /**
  123833. * 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.
  123834. */
  123835. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  123836. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  123837. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123838. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123839. if (blockCompilation === void 0) { blockCompilation = false; }
  123840. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  123841. /**
  123842. * The luminance threshold, pixels below this value will be set to black.
  123843. */
  123844. _this.threshold = 0.9;
  123845. /** @hidden */
  123846. _this._exposure = 1;
  123847. /**
  123848. * Post process which has the input texture to be used when performing highlight extraction
  123849. * @hidden
  123850. */
  123851. _this._inputPostProcess = null;
  123852. _this.onApplyObservable.add(function (effect) {
  123853. if (_this._inputPostProcess) {
  123854. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  123855. }
  123856. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  123857. effect.setFloat('exposure', _this._exposure);
  123858. });
  123859. return _this;
  123860. }
  123861. return ExtractHighlightsPostProcess;
  123862. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123863. /***/ }),
  123864. /***/ "./PostProcesses/filterPostProcess.ts":
  123865. /*!********************************************!*\
  123866. !*** ./PostProcesses/filterPostProcess.ts ***!
  123867. \********************************************/
  123868. /*! exports provided: FilterPostProcess */
  123869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123870. "use strict";
  123871. __webpack_require__.r(__webpack_exports__);
  123872. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  123873. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123874. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123875. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  123876. /**
  123877. * Applies a kernel filter to the image
  123878. */
  123879. var FilterPostProcess = /** @class */ (function (_super) {
  123880. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  123881. /**
  123882. *
  123883. * @param name The name of the effect.
  123884. * @param kernelMatrix The matrix to be applied to the image
  123885. * @param options The required width/height ratio to downsize to before computing the render pass.
  123886. * @param camera The camera to apply the render pass to.
  123887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123888. * @param engine The engine which the post process will be applied. (default: current engine)
  123889. * @param reusable If the post process can be reused on the same frame. (default: false)
  123890. */
  123891. function FilterPostProcess(name,
  123892. /** The matrix to be applied to the image */
  123893. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  123894. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  123895. _this.kernelMatrix = kernelMatrix;
  123896. _this.onApply = function (effect) {
  123897. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  123898. };
  123899. return _this;
  123900. }
  123901. return FilterPostProcess;
  123902. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123903. /***/ }),
  123904. /***/ "./PostProcesses/fxaaPostProcess.ts":
  123905. /*!******************************************!*\
  123906. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  123907. \******************************************/
  123908. /*! exports provided: FxaaPostProcess */
  123909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123910. "use strict";
  123911. __webpack_require__.r(__webpack_exports__);
  123912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  123913. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123914. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123915. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123916. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123917. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  123918. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  123919. /**
  123920. * Fxaa post process
  123921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  123922. */
  123923. var FxaaPostProcess = /** @class */ (function (_super) {
  123924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  123925. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  123926. if (camera === void 0) { camera = null; }
  123927. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123928. 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;
  123929. var defines = _this._getDefines();
  123930. _this.updateEffect(defines);
  123931. _this.onApplyObservable.add(function (effect) {
  123932. var texelSize = _this.texelSize;
  123933. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  123934. });
  123935. return _this;
  123936. }
  123937. FxaaPostProcess.prototype._getDefines = function () {
  123938. var engine = this.getEngine();
  123939. if (!engine) {
  123940. return null;
  123941. }
  123942. var glInfo = engine.getGlInfo();
  123943. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  123944. return "#define MALI 1\n";
  123945. }
  123946. return null;
  123947. };
  123948. return FxaaPostProcess;
  123949. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123950. /***/ }),
  123951. /***/ "./PostProcesses/grainPostProcess.ts":
  123952. /*!*******************************************!*\
  123953. !*** ./PostProcesses/grainPostProcess.ts ***!
  123954. \*******************************************/
  123955. /*! exports provided: GrainPostProcess */
  123956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123957. "use strict";
  123958. __webpack_require__.r(__webpack_exports__);
  123959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  123960. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123961. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123962. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123963. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  123964. /**
  123965. * The GrainPostProcess adds noise to the image at mid luminance levels
  123966. */
  123967. var GrainPostProcess = /** @class */ (function (_super) {
  123968. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  123969. /**
  123970. * Creates a new instance of @see GrainPostProcess
  123971. * @param name The name of the effect.
  123972. * @param options The required width/height ratio to downsize to before computing the render pass.
  123973. * @param camera The camera to apply the render pass to.
  123974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123975. * @param engine The engine which the post process will be applied. (default: current engine)
  123976. * @param reusable If the post process can be reused on the same frame. (default: false)
  123977. * @param textureType Type of textures used when performing the post process. (default: 0)
  123978. * @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)
  123979. */
  123980. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123981. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123982. if (blockCompilation === void 0) { blockCompilation = false; }
  123983. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  123984. /**
  123985. * The intensity of the grain added (default: 30)
  123986. */
  123987. _this.intensity = 30;
  123988. /**
  123989. * If the grain should be randomized on every frame
  123990. */
  123991. _this.animated = false;
  123992. _this.onApplyObservable.add(function (effect) {
  123993. effect.setFloat('intensity', _this.intensity);
  123994. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  123995. });
  123996. return _this;
  123997. }
  123998. return GrainPostProcess;
  123999. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  124000. /***/ }),
  124001. /***/ "./PostProcesses/highlightsPostProcess.ts":
  124002. /*!************************************************!*\
  124003. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  124004. \************************************************/
  124005. /*! exports provided: HighlightsPostProcess */
  124006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124007. "use strict";
  124008. __webpack_require__.r(__webpack_exports__);
  124009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  124010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124011. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124012. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124013. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  124014. /**
  124015. * Extracts highlights from the image
  124016. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124017. */
  124018. var HighlightsPostProcess = /** @class */ (function (_super) {
  124019. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  124020. /**
  124021. * Extracts highlights from the image
  124022. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124023. * @param name The name of the effect.
  124024. * @param options The required width/height ratio to downsize to before computing the render pass.
  124025. * @param camera The camera to apply the render pass to.
  124026. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124027. * @param engine The engine which the post process will be applied. (default: current engine)
  124028. * @param reusable If the post process can be reused on the same frame. (default: false)
  124029. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124030. */
  124031. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  124032. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124033. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  124034. }
  124035. return HighlightsPostProcess;
  124036. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  124037. /***/ }),
  124038. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  124039. /*!*****************************************************!*\
  124040. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  124041. \*****************************************************/
  124042. /*! exports provided: ImageProcessingPostProcess */
  124043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124044. "use strict";
  124045. __webpack_require__.r(__webpack_exports__);
  124046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  124047. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124048. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  124049. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  124050. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124051. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  124052. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124053. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  124054. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  124055. /**
  124056. * ImageProcessingPostProcess
  124057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  124058. */
  124059. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  124060. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  124061. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  124062. if (camera === void 0) { camera = null; }
  124063. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124064. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  124065. _this._fromLinearSpace = true;
  124066. /**
  124067. * Defines cache preventing GC.
  124068. */
  124069. _this._defines = {
  124070. IMAGEPROCESSING: false,
  124071. VIGNETTE: false,
  124072. VIGNETTEBLENDMODEMULTIPLY: false,
  124073. VIGNETTEBLENDMODEOPAQUE: false,
  124074. TONEMAPPING: false,
  124075. TONEMAPPING_ACES: false,
  124076. CONTRAST: false,
  124077. COLORCURVES: false,
  124078. COLORGRADING: false,
  124079. COLORGRADING3D: false,
  124080. FROMLINEARSPACE: false,
  124081. SAMPLER3DGREENDEPTH: false,
  124082. SAMPLER3DBGRMAP: false,
  124083. IMAGEPROCESSINGPOSTPROCESS: false,
  124084. EXPOSURE: false,
  124085. };
  124086. // Setup the configuration as forced by the constructor. This would then not force the
  124087. // scene materials output in linear space and let untouched the default forward pass.
  124088. if (imageProcessingConfiguration) {
  124089. imageProcessingConfiguration.applyByPostProcess = true;
  124090. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  124091. // This will cause the shader to be compiled
  124092. _this.fromLinearSpace = false;
  124093. }
  124094. // Setup the default processing configuration to the scene.
  124095. else {
  124096. _this._attachImageProcessingConfiguration(null, true);
  124097. _this.imageProcessingConfiguration.applyByPostProcess = true;
  124098. }
  124099. _this.onApply = function (effect) {
  124100. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  124101. };
  124102. return _this;
  124103. }
  124104. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  124105. /**
  124106. * Gets the image processing configuration used either in this material.
  124107. */
  124108. get: function () {
  124109. return this._imageProcessingConfiguration;
  124110. },
  124111. /**
  124112. * Sets the Default image processing configuration used either in the this material.
  124113. *
  124114. * If sets to null, the scene one is in use.
  124115. */
  124116. set: function (value) {
  124117. this._attachImageProcessingConfiguration(value);
  124118. },
  124119. enumerable: true,
  124120. configurable: true
  124121. });
  124122. /**
  124123. * Attaches a new image processing configuration to the PBR Material.
  124124. * @param configuration
  124125. */
  124126. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  124127. var _this = this;
  124128. if (doNotBuild === void 0) { doNotBuild = false; }
  124129. if (configuration === this._imageProcessingConfiguration) {
  124130. return;
  124131. }
  124132. // Detaches observer.
  124133. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  124134. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  124135. }
  124136. // Pick the scene configuration if needed.
  124137. if (!configuration) {
  124138. var scene = null;
  124139. var engine = this.getEngine();
  124140. var camera = this.getCamera();
  124141. if (camera) {
  124142. scene = camera.getScene();
  124143. }
  124144. else if (engine && engine.scenes) {
  124145. var scenes = engine.scenes;
  124146. scene = scenes[scenes.length - 1];
  124147. }
  124148. else {
  124149. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  124150. }
  124151. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  124152. }
  124153. else {
  124154. this._imageProcessingConfiguration = configuration;
  124155. }
  124156. // Attaches observer.
  124157. if (this._imageProcessingConfiguration) {
  124158. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  124159. _this._updateParameters();
  124160. });
  124161. }
  124162. // Ensure the effect will be rebuilt.
  124163. if (!doNotBuild) {
  124164. this._updateParameters();
  124165. }
  124166. };
  124167. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  124168. /**
  124169. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  124170. */
  124171. get: function () {
  124172. return this.imageProcessingConfiguration.colorCurves;
  124173. },
  124174. /**
  124175. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  124176. */
  124177. set: function (value) {
  124178. this.imageProcessingConfiguration.colorCurves = value;
  124179. },
  124180. enumerable: true,
  124181. configurable: true
  124182. });
  124183. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  124184. /**
  124185. * Gets wether the color curves effect is enabled.
  124186. */
  124187. get: function () {
  124188. return this.imageProcessingConfiguration.colorCurvesEnabled;
  124189. },
  124190. /**
  124191. * Sets wether the color curves effect is enabled.
  124192. */
  124193. set: function (value) {
  124194. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  124195. },
  124196. enumerable: true,
  124197. configurable: true
  124198. });
  124199. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  124200. /**
  124201. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  124202. */
  124203. get: function () {
  124204. return this.imageProcessingConfiguration.colorGradingTexture;
  124205. },
  124206. /**
  124207. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  124208. */
  124209. set: function (value) {
  124210. this.imageProcessingConfiguration.colorGradingTexture = value;
  124211. },
  124212. enumerable: true,
  124213. configurable: true
  124214. });
  124215. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  124216. /**
  124217. * Gets wether the color grading effect is enabled.
  124218. */
  124219. get: function () {
  124220. return this.imageProcessingConfiguration.colorGradingEnabled;
  124221. },
  124222. /**
  124223. * Gets wether the color grading effect is enabled.
  124224. */
  124225. set: function (value) {
  124226. this.imageProcessingConfiguration.colorGradingEnabled = value;
  124227. },
  124228. enumerable: true,
  124229. configurable: true
  124230. });
  124231. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  124232. /**
  124233. * Gets exposure used in the effect.
  124234. */
  124235. get: function () {
  124236. return this.imageProcessingConfiguration.exposure;
  124237. },
  124238. /**
  124239. * Sets exposure used in the effect.
  124240. */
  124241. set: function (value) {
  124242. this.imageProcessingConfiguration.exposure = value;
  124243. },
  124244. enumerable: true,
  124245. configurable: true
  124246. });
  124247. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  124248. /**
  124249. * Gets wether tonemapping is enabled or not.
  124250. */
  124251. get: function () {
  124252. return this._imageProcessingConfiguration.toneMappingEnabled;
  124253. },
  124254. /**
  124255. * Sets wether tonemapping is enabled or not
  124256. */
  124257. set: function (value) {
  124258. this._imageProcessingConfiguration.toneMappingEnabled = value;
  124259. },
  124260. enumerable: true,
  124261. configurable: true
  124262. });
  124263. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  124264. /**
  124265. * Gets the type of tone mapping effect.
  124266. */
  124267. get: function () {
  124268. return this._imageProcessingConfiguration.toneMappingType;
  124269. },
  124270. /**
  124271. * Sets the type of tone mapping effect.
  124272. */
  124273. set: function (value) {
  124274. this._imageProcessingConfiguration.toneMappingType = value;
  124275. },
  124276. enumerable: true,
  124277. configurable: true
  124278. });
  124279. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  124280. /**
  124281. * Gets contrast used in the effect.
  124282. */
  124283. get: function () {
  124284. return this.imageProcessingConfiguration.contrast;
  124285. },
  124286. /**
  124287. * Sets contrast used in the effect.
  124288. */
  124289. set: function (value) {
  124290. this.imageProcessingConfiguration.contrast = value;
  124291. },
  124292. enumerable: true,
  124293. configurable: true
  124294. });
  124295. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  124296. /**
  124297. * Gets Vignette stretch size.
  124298. */
  124299. get: function () {
  124300. return this.imageProcessingConfiguration.vignetteStretch;
  124301. },
  124302. /**
  124303. * Sets Vignette stretch size.
  124304. */
  124305. set: function (value) {
  124306. this.imageProcessingConfiguration.vignetteStretch = value;
  124307. },
  124308. enumerable: true,
  124309. configurable: true
  124310. });
  124311. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  124312. /**
  124313. * Gets Vignette centre X Offset.
  124314. */
  124315. get: function () {
  124316. return this.imageProcessingConfiguration.vignetteCentreX;
  124317. },
  124318. /**
  124319. * Sets Vignette centre X Offset.
  124320. */
  124321. set: function (value) {
  124322. this.imageProcessingConfiguration.vignetteCentreX = value;
  124323. },
  124324. enumerable: true,
  124325. configurable: true
  124326. });
  124327. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  124328. /**
  124329. * Gets Vignette centre Y Offset.
  124330. */
  124331. get: function () {
  124332. return this.imageProcessingConfiguration.vignetteCentreY;
  124333. },
  124334. /**
  124335. * Sets Vignette centre Y Offset.
  124336. */
  124337. set: function (value) {
  124338. this.imageProcessingConfiguration.vignetteCentreY = value;
  124339. },
  124340. enumerable: true,
  124341. configurable: true
  124342. });
  124343. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  124344. /**
  124345. * Gets Vignette weight or intensity of the vignette effect.
  124346. */
  124347. get: function () {
  124348. return this.imageProcessingConfiguration.vignetteWeight;
  124349. },
  124350. /**
  124351. * Sets Vignette weight or intensity of the vignette effect.
  124352. */
  124353. set: function (value) {
  124354. this.imageProcessingConfiguration.vignetteWeight = value;
  124355. },
  124356. enumerable: true,
  124357. configurable: true
  124358. });
  124359. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  124360. /**
  124361. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  124362. * if vignetteEnabled is set to true.
  124363. */
  124364. get: function () {
  124365. return this.imageProcessingConfiguration.vignetteColor;
  124366. },
  124367. /**
  124368. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  124369. * if vignetteEnabled is set to true.
  124370. */
  124371. set: function (value) {
  124372. this.imageProcessingConfiguration.vignetteColor = value;
  124373. },
  124374. enumerable: true,
  124375. configurable: true
  124376. });
  124377. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  124378. /**
  124379. * Gets Camera field of view used by the Vignette effect.
  124380. */
  124381. get: function () {
  124382. return this.imageProcessingConfiguration.vignetteCameraFov;
  124383. },
  124384. /**
  124385. * Sets Camera field of view used by the Vignette effect.
  124386. */
  124387. set: function (value) {
  124388. this.imageProcessingConfiguration.vignetteCameraFov = value;
  124389. },
  124390. enumerable: true,
  124391. configurable: true
  124392. });
  124393. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  124394. /**
  124395. * Gets the vignette blend mode allowing different kind of effect.
  124396. */
  124397. get: function () {
  124398. return this.imageProcessingConfiguration.vignetteBlendMode;
  124399. },
  124400. /**
  124401. * Sets the vignette blend mode allowing different kind of effect.
  124402. */
  124403. set: function (value) {
  124404. this.imageProcessingConfiguration.vignetteBlendMode = value;
  124405. },
  124406. enumerable: true,
  124407. configurable: true
  124408. });
  124409. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  124410. /**
  124411. * Gets wether the vignette effect is enabled.
  124412. */
  124413. get: function () {
  124414. return this.imageProcessingConfiguration.vignetteEnabled;
  124415. },
  124416. /**
  124417. * Sets wether the vignette effect is enabled.
  124418. */
  124419. set: function (value) {
  124420. this.imageProcessingConfiguration.vignetteEnabled = value;
  124421. },
  124422. enumerable: true,
  124423. configurable: true
  124424. });
  124425. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  124426. /**
  124427. * Gets wether the input of the processing is in Gamma or Linear Space.
  124428. */
  124429. get: function () {
  124430. return this._fromLinearSpace;
  124431. },
  124432. /**
  124433. * Sets wether the input of the processing is in Gamma or Linear Space.
  124434. */
  124435. set: function (value) {
  124436. if (this._fromLinearSpace === value) {
  124437. return;
  124438. }
  124439. this._fromLinearSpace = value;
  124440. this._updateParameters();
  124441. },
  124442. enumerable: true,
  124443. configurable: true
  124444. });
  124445. /**
  124446. * "ImageProcessingPostProcess"
  124447. * @returns "ImageProcessingPostProcess"
  124448. */
  124449. ImageProcessingPostProcess.prototype.getClassName = function () {
  124450. return "ImageProcessingPostProcess";
  124451. };
  124452. ImageProcessingPostProcess.prototype._updateParameters = function () {
  124453. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  124454. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  124455. var defines = "";
  124456. for (var define in this._defines) {
  124457. if (this._defines[define]) {
  124458. defines += "#define " + define + ";\r\n";
  124459. }
  124460. }
  124461. var samplers = ["textureSampler"];
  124462. var uniforms = ["scale"];
  124463. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  124464. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  124465. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  124466. }
  124467. this.updateEffect(defines, uniforms, samplers);
  124468. };
  124469. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  124470. _super.prototype.dispose.call(this, camera);
  124471. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  124472. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  124473. }
  124474. if (this._imageProcessingConfiguration) {
  124475. this.imageProcessingConfiguration.applyByPostProcess = false;
  124476. }
  124477. };
  124478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124480. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  124481. return ImageProcessingPostProcess;
  124482. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  124483. /***/ }),
  124484. /***/ "./PostProcesses/index.ts":
  124485. /*!********************************!*\
  124486. !*** ./PostProcesses/index.ts ***!
  124487. \********************************/
  124488. /*! 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 */
  124489. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124490. "use strict";
  124491. __webpack_require__.r(__webpack_exports__);
  124492. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  124493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  124494. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  124495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  124496. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  124497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  124498. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  124499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  124500. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  124501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  124502. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  124503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  124504. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  124505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  124506. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  124507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  124508. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  124509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  124510. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  124511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  124512. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  124513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  124514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  124515. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  124516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  124517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  124518. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  124519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  124520. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  124521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  124522. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  124523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  124524. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  124525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  124526. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  124527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  124528. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  124529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  124530. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  124531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  124532. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  124533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  124534. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  124535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  124536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  124537. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  124539. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  124540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  124541. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  124542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  124543. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  124544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  124545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  124546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  124547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  124548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  124549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  124550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  124551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  124552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  124553. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  124554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  124555. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  124556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  124557. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  124558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  124559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  124560. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  124561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  124562. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  124563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  124564. /* harmony import */ var _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  124565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__["VRMultiviewToSingleviewPostProcess"]; });
  124566. /***/ }),
  124567. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  124568. /*!************************************************!*\
  124569. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  124570. \************************************************/
  124571. /*! exports provided: MotionBlurPostProcess */
  124572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124573. "use strict";
  124574. __webpack_require__.r(__webpack_exports__);
  124575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  124576. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124577. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  124578. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124579. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124580. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124581. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  124582. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animatable */ "./Animations/animatable.ts");
  124583. /* harmony import */ var _Rendering_geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  124584. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  124585. /**
  124586. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124587. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124588. * As an example, all you have to do is to create the post-process:
  124589. * var mb = new BABYLON.MotionBlurPostProcess(
  124590. * 'mb', // The name of the effect.
  124591. * scene, // The scene containing the objects to blur according to their velocity.
  124592. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124593. * camera // The camera to apply the render pass to.
  124594. * );
  124595. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124596. */
  124597. var MotionBlurPostProcess = /** @class */ (function (_super) {
  124598. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  124599. /**
  124600. * Creates a new instance MotionBlurPostProcess
  124601. * @param name The name of the effect.
  124602. * @param scene The scene containing the objects to blur according to their velocity.
  124603. * @param options The required width/height ratio to downsize to before computing the render pass.
  124604. * @param camera The camera to apply the render pass to.
  124605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124606. * @param engine The engine which the post process will be applied. (default: current engine)
  124607. * @param reusable If the post process can be reused on the same frame. (default: false)
  124608. * @param textureType Type of textures used when performing the post process. (default: 0)
  124609. * @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)
  124610. */
  124611. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124612. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124613. if (blockCompilation === void 0) { blockCompilation = false; }
  124614. 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;
  124615. /**
  124616. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124617. */
  124618. _this.motionStrength = 1;
  124619. _this._motionBlurSamples = 32;
  124620. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  124621. if (!_this._geometryBufferRenderer) {
  124622. // Geometry buffer renderer is not supported. So, work as a passthrough.
  124623. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  124624. _this.updateEffect();
  124625. }
  124626. else {
  124627. // Geometry buffer renderer is supported.
  124628. _this._geometryBufferRenderer.enableVelocity = true;
  124629. _this.onApply = function (effect) {
  124630. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  124631. effect.setFloat("motionScale", scene.getAnimationRatio());
  124632. effect.setFloat("motionStrength", _this.motionStrength);
  124633. if (_this._geometryBufferRenderer) {
  124634. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  124635. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  124636. }
  124637. };
  124638. }
  124639. return _this;
  124640. }
  124641. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  124642. /**
  124643. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124644. */
  124645. get: function () {
  124646. return this._motionBlurSamples;
  124647. },
  124648. /**
  124649. * Sets the number of iterations to be used for motion blur quality
  124650. */
  124651. set: function (samples) {
  124652. this._motionBlurSamples = samples;
  124653. if (this._geometryBufferRenderer) {
  124654. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  124655. }
  124656. },
  124657. enumerable: true,
  124658. configurable: true
  124659. });
  124660. /**
  124661. * Disposes the post process.
  124662. * @param camera The camera to dispose the post process on.
  124663. */
  124664. MotionBlurPostProcess.prototype.dispose = function (camera) {
  124665. if (this._geometryBufferRenderer) {
  124666. // Clear previous transformation matrices dictionary used to compute objects velocities
  124667. this._geometryBufferRenderer._previousTransformationMatrices = {};
  124668. }
  124669. _super.prototype.dispose.call(this, camera);
  124670. };
  124671. return MotionBlurPostProcess;
  124672. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  124673. /***/ }),
  124674. /***/ "./PostProcesses/passPostProcess.ts":
  124675. /*!******************************************!*\
  124676. !*** ./PostProcesses/passPostProcess.ts ***!
  124677. \******************************************/
  124678. /*! exports provided: PassPostProcess, PassCubePostProcess */
  124679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124680. "use strict";
  124681. __webpack_require__.r(__webpack_exports__);
  124682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  124683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  124684. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124685. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124686. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124687. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  124688. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  124689. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  124690. /**
  124691. * PassPostProcess which produces an output the same as it's input
  124692. */
  124693. var PassPostProcess = /** @class */ (function (_super) {
  124694. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  124695. /**
  124696. * Creates the PassPostProcess
  124697. * @param name The name of the effect.
  124698. * @param options The required width/height ratio to downsize to before computing the render pass.
  124699. * @param camera The camera to apply the render pass to.
  124700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124701. * @param engine The engine which the post process will be applied. (default: current engine)
  124702. * @param reusable If the post process can be reused on the same frame. (default: false)
  124703. * @param textureType The type of texture to be used when performing the post processing.
  124704. * @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)
  124705. */
  124706. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124707. if (camera === void 0) { camera = null; }
  124708. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124709. if (blockCompilation === void 0) { blockCompilation = false; }
  124710. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  124711. }
  124712. return PassPostProcess;
  124713. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  124714. /**
  124715. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124716. */
  124717. var PassCubePostProcess = /** @class */ (function (_super) {
  124718. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  124719. /**
  124720. * Creates the PassCubePostProcess
  124721. * @param name The name of the effect.
  124722. * @param options The required width/height ratio to downsize to before computing the render pass.
  124723. * @param camera The camera to apply the render pass to.
  124724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124725. * @param engine The engine which the post process will be applied. (default: current engine)
  124726. * @param reusable If the post process can be reused on the same frame. (default: false)
  124727. * @param textureType The type of texture to be used when performing the post processing.
  124728. * @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)
  124729. */
  124730. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124731. if (camera === void 0) { camera = null; }
  124732. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124733. if (blockCompilation === void 0) { blockCompilation = false; }
  124734. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  124735. _this._face = 0;
  124736. return _this;
  124737. }
  124738. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  124739. /**
  124740. * Gets or sets the cube face to display.
  124741. * * 0 is +X
  124742. * * 1 is -X
  124743. * * 2 is +Y
  124744. * * 3 is -Y
  124745. * * 4 is +Z
  124746. * * 5 is -Z
  124747. */
  124748. get: function () {
  124749. return this._face;
  124750. },
  124751. set: function (value) {
  124752. if (value < 0 || value > 5) {
  124753. return;
  124754. }
  124755. this._face = value;
  124756. switch (this._face) {
  124757. case 0:
  124758. this.updateEffect("#define POSITIVEX");
  124759. break;
  124760. case 1:
  124761. this.updateEffect("#define NEGATIVEX");
  124762. break;
  124763. case 2:
  124764. this.updateEffect("#define POSITIVEY");
  124765. break;
  124766. case 3:
  124767. this.updateEffect("#define NEGATIVEY");
  124768. break;
  124769. case 4:
  124770. this.updateEffect("#define POSITIVEZ");
  124771. break;
  124772. case 5:
  124773. this.updateEffect("#define NEGATIVEZ");
  124774. break;
  124775. }
  124776. },
  124777. enumerable: true,
  124778. configurable: true
  124779. });
  124780. return PassCubePostProcess;
  124781. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  124782. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  124783. 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);
  124784. };
  124785. /***/ }),
  124786. /***/ "./PostProcesses/postProcess.ts":
  124787. /*!**************************************!*\
  124788. !*** ./PostProcesses/postProcess.ts ***!
  124789. \**************************************/
  124790. /*! exports provided: PostProcess */
  124791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124792. "use strict";
  124793. __webpack_require__.r(__webpack_exports__);
  124794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  124795. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  124796. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  124797. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124798. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124799. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124800. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  124801. /**
  124802. * PostProcess can be used to apply a shader to a texture after it has been rendered
  124803. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124804. */
  124805. var PostProcess = /** @class */ (function () {
  124806. /**
  124807. * Creates a new instance PostProcess
  124808. * @param name The name of the PostProcess.
  124809. * @param fragmentUrl The url of the fragment shader to be used.
  124810. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  124811. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  124812. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  124813. * @param camera The camera to apply the render pass to.
  124814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124815. * @param engine The engine which the post process will be applied. (default: current engine)
  124816. * @param reusable If the post process can be reused on the same frame. (default: false)
  124817. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  124818. * @param textureType Type of textures used when performing the post process. (default: 0)
  124819. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  124820. * @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
  124821. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  124822. */
  124823. function PostProcess(
  124824. /** Name of the PostProcess. */
  124825. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  124826. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  124827. if (defines === void 0) { defines = null; }
  124828. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124829. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  124830. if (blockCompilation === void 0) { blockCompilation = false; }
  124831. this.name = name;
  124832. /**
  124833. * Width of the texture to apply the post process on
  124834. */
  124835. this.width = -1;
  124836. /**
  124837. * Height of the texture to apply the post process on
  124838. */
  124839. this.height = -1;
  124840. /**
  124841. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  124842. * @hidden
  124843. */
  124844. this._outputTexture = null;
  124845. /**
  124846. * If the buffer needs to be cleared before applying the post process. (default: true)
  124847. * Should be set to false if shader will overwrite all previous pixels.
  124848. */
  124849. this.autoClear = true;
  124850. /**
  124851. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  124852. */
  124853. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  124854. /**
  124855. * Animations to be used for the post processing
  124856. */
  124857. this.animations = new Array();
  124858. /**
  124859. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  124860. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  124861. */
  124862. this.enablePixelPerfectMode = false;
  124863. /**
  124864. * Force the postprocess to be applied without taking in account viewport
  124865. */
  124866. this.forceFullscreenViewport = true;
  124867. /**
  124868. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  124869. *
  124870. * | Value | Type | Description |
  124871. * | ----- | ----------------------------------- | ----------- |
  124872. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  124873. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  124874. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  124875. *
  124876. */
  124877. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  124878. /**
  124879. * Force textures to be a power of two (default: false)
  124880. */
  124881. this.alwaysForcePOT = false;
  124882. this._samples = 1;
  124883. /**
  124884. * Modify the scale of the post process to be the same as the viewport (default: false)
  124885. */
  124886. this.adaptScaleToCurrentViewport = false;
  124887. this._reusable = false;
  124888. /**
  124889. * Smart array of input and output textures for the post process.
  124890. * @hidden
  124891. */
  124892. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  124893. /**
  124894. * The index in _textures that corresponds to the output texture.
  124895. * @hidden
  124896. */
  124897. this._currentRenderTextureInd = 0;
  124898. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  124899. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  124900. // Events
  124901. /**
  124902. * An event triggered when the postprocess is activated.
  124903. */
  124904. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124905. /**
  124906. * An event triggered when the postprocess changes its size.
  124907. */
  124908. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124909. /**
  124910. * An event triggered when the postprocess applies its effect.
  124911. */
  124912. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124913. /**
  124914. * An event triggered before rendering the postprocess
  124915. */
  124916. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124917. /**
  124918. * An event triggered after rendering the postprocess
  124919. */
  124920. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124921. if (camera != null) {
  124922. this._camera = camera;
  124923. this._scene = camera.getScene();
  124924. camera.attachPostProcess(this);
  124925. this._engine = this._scene.getEngine();
  124926. this._scene.postProcesses.push(this);
  124927. this.uniqueId = this._scene.getUniqueId();
  124928. }
  124929. else if (engine) {
  124930. this._engine = engine;
  124931. this._engine.postProcesses.push(this);
  124932. }
  124933. this._options = options;
  124934. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  124935. this._reusable = reusable || false;
  124936. this._textureType = textureType;
  124937. this._samplers = samplers || [];
  124938. this._samplers.push("textureSampler");
  124939. this._fragmentUrl = fragmentUrl;
  124940. this._vertexUrl = vertexUrl;
  124941. this._parameters = parameters || [];
  124942. this._parameters.push("scale");
  124943. this._indexParameters = indexParameters;
  124944. if (!blockCompilation) {
  124945. this.updateEffect(defines);
  124946. }
  124947. }
  124948. Object.defineProperty(PostProcess.prototype, "samples", {
  124949. /**
  124950. * Number of sample textures (default: 1)
  124951. */
  124952. get: function () {
  124953. return this._samples;
  124954. },
  124955. set: function (n) {
  124956. var _this = this;
  124957. this._samples = n;
  124958. this._textures.forEach(function (texture) {
  124959. if (texture.samples !== _this._samples) {
  124960. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  124961. }
  124962. });
  124963. },
  124964. enumerable: true,
  124965. configurable: true
  124966. });
  124967. /**
  124968. * Returns the fragment url or shader name used in the post process.
  124969. * @returns the fragment url or name in the shader store.
  124970. */
  124971. PostProcess.prototype.getEffectName = function () {
  124972. return this._fragmentUrl;
  124973. };
  124974. Object.defineProperty(PostProcess.prototype, "onActivate", {
  124975. /**
  124976. * A function that is added to the onActivateObservable
  124977. */
  124978. set: function (callback) {
  124979. if (this._onActivateObserver) {
  124980. this.onActivateObservable.remove(this._onActivateObserver);
  124981. }
  124982. if (callback) {
  124983. this._onActivateObserver = this.onActivateObservable.add(callback);
  124984. }
  124985. },
  124986. enumerable: true,
  124987. configurable: true
  124988. });
  124989. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  124990. /**
  124991. * A function that is added to the onSizeChangedObservable
  124992. */
  124993. set: function (callback) {
  124994. if (this._onSizeChangedObserver) {
  124995. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  124996. }
  124997. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  124998. },
  124999. enumerable: true,
  125000. configurable: true
  125001. });
  125002. Object.defineProperty(PostProcess.prototype, "onApply", {
  125003. /**
  125004. * A function that is added to the onApplyObservable
  125005. */
  125006. set: function (callback) {
  125007. if (this._onApplyObserver) {
  125008. this.onApplyObservable.remove(this._onApplyObserver);
  125009. }
  125010. this._onApplyObserver = this.onApplyObservable.add(callback);
  125011. },
  125012. enumerable: true,
  125013. configurable: true
  125014. });
  125015. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  125016. /**
  125017. * A function that is added to the onBeforeRenderObservable
  125018. */
  125019. set: function (callback) {
  125020. if (this._onBeforeRenderObserver) {
  125021. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  125022. }
  125023. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  125024. },
  125025. enumerable: true,
  125026. configurable: true
  125027. });
  125028. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  125029. /**
  125030. * A function that is added to the onAfterRenderObservable
  125031. */
  125032. set: function (callback) {
  125033. if (this._onAfterRenderObserver) {
  125034. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  125035. }
  125036. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  125037. },
  125038. enumerable: true,
  125039. configurable: true
  125040. });
  125041. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  125042. /**
  125043. * 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
  125044. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  125045. */
  125046. get: function () {
  125047. return this._textures.data[this._currentRenderTextureInd];
  125048. },
  125049. set: function (value) {
  125050. this._forcedOutputTexture = value;
  125051. },
  125052. enumerable: true,
  125053. configurable: true
  125054. });
  125055. /**
  125056. * Gets the camera which post process is applied to.
  125057. * @returns The camera the post process is applied to.
  125058. */
  125059. PostProcess.prototype.getCamera = function () {
  125060. return this._camera;
  125061. };
  125062. Object.defineProperty(PostProcess.prototype, "texelSize", {
  125063. /**
  125064. * Gets the texel size of the postprocess.
  125065. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  125066. */
  125067. get: function () {
  125068. if (this._shareOutputWithPostProcess) {
  125069. return this._shareOutputWithPostProcess.texelSize;
  125070. }
  125071. if (this._forcedOutputTexture) {
  125072. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  125073. }
  125074. return this._texelSize;
  125075. },
  125076. enumerable: true,
  125077. configurable: true
  125078. });
  125079. /**
  125080. * Gets a string idenfifying the name of the class
  125081. * @returns "PostProcess" string
  125082. */
  125083. PostProcess.prototype.getClassName = function () {
  125084. return "PostProcess";
  125085. };
  125086. /**
  125087. * Gets the engine which this post process belongs to.
  125088. * @returns The engine the post process was enabled with.
  125089. */
  125090. PostProcess.prototype.getEngine = function () {
  125091. return this._engine;
  125092. };
  125093. /**
  125094. * The effect that is created when initializing the post process.
  125095. * @returns The created effect corrisponding the the postprocess.
  125096. */
  125097. PostProcess.prototype.getEffect = function () {
  125098. return this._effect;
  125099. };
  125100. /**
  125101. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  125102. * @param postProcess The post process to share the output with.
  125103. * @returns This post process.
  125104. */
  125105. PostProcess.prototype.shareOutputWith = function (postProcess) {
  125106. this._disposeTextures();
  125107. this._shareOutputWithPostProcess = postProcess;
  125108. return this;
  125109. };
  125110. /**
  125111. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  125112. * This should be called if the post process that shares output with this post process is disabled/disposed.
  125113. */
  125114. PostProcess.prototype.useOwnOutput = function () {
  125115. if (this._textures.length == 0) {
  125116. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  125117. }
  125118. this._shareOutputWithPostProcess = null;
  125119. };
  125120. /**
  125121. * Updates the effect with the current post process compile time values and recompiles the shader.
  125122. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  125123. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  125124. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  125125. * @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
  125126. * @param onCompiled Called when the shader has been compiled.
  125127. * @param onError Called if there is an error when compiling a shader.
  125128. */
  125129. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  125130. if (defines === void 0) { defines = null; }
  125131. if (uniforms === void 0) { uniforms = null; }
  125132. if (samplers === void 0) { samplers = null; }
  125133. 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);
  125134. };
  125135. /**
  125136. * The post process is reusable if it can be used multiple times within one frame.
  125137. * @returns If the post process is reusable
  125138. */
  125139. PostProcess.prototype.isReusable = function () {
  125140. return this._reusable;
  125141. };
  125142. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  125143. PostProcess.prototype.markTextureDirty = function () {
  125144. this.width = -1;
  125145. };
  125146. /**
  125147. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  125148. * 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.
  125149. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  125150. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  125151. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  125152. * @returns The target texture that was bound to be written to.
  125153. */
  125154. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  125155. var _this = this;
  125156. if (sourceTexture === void 0) { sourceTexture = null; }
  125157. camera = camera || this._camera;
  125158. var scene = camera.getScene();
  125159. var engine = scene.getEngine();
  125160. var maxSize = engine.getCaps().maxTextureSize;
  125161. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  125162. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  125163. // 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
  125164. var webVRCamera = camera.parent;
  125165. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  125166. requiredWidth /= 2;
  125167. }
  125168. var desiredWidth = (this._options.width || requiredWidth);
  125169. var desiredHeight = this._options.height || requiredHeight;
  125170. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  125171. if (this.adaptScaleToCurrentViewport) {
  125172. var currentViewport = engine.currentViewport;
  125173. if (currentViewport) {
  125174. desiredWidth *= currentViewport.width;
  125175. desiredHeight *= currentViewport.height;
  125176. }
  125177. }
  125178. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  125179. if (!this._options.width) {
  125180. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  125181. }
  125182. if (!this._options.height) {
  125183. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  125184. }
  125185. }
  125186. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  125187. if (this._textures.length > 0) {
  125188. for (var i = 0; i < this._textures.length; i++) {
  125189. this._engine._releaseTexture(this._textures.data[i]);
  125190. }
  125191. this._textures.reset();
  125192. }
  125193. this.width = desiredWidth;
  125194. this.height = desiredHeight;
  125195. var textureSize = { width: this.width, height: this.height };
  125196. var textureOptions = {
  125197. generateMipMaps: false,
  125198. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  125199. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  125200. samplingMode: this.renderTargetSamplingMode,
  125201. type: this._textureType
  125202. };
  125203. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  125204. if (this._reusable) {
  125205. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  125206. }
  125207. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  125208. this.onSizeChangedObservable.notifyObservers(this);
  125209. }
  125210. this._textures.forEach(function (texture) {
  125211. if (texture.samples !== _this.samples) {
  125212. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  125213. }
  125214. });
  125215. }
  125216. var target;
  125217. if (this._shareOutputWithPostProcess) {
  125218. target = this._shareOutputWithPostProcess.inputTexture;
  125219. }
  125220. else if (this._forcedOutputTexture) {
  125221. target = this._forcedOutputTexture;
  125222. this.width = this._forcedOutputTexture.width;
  125223. this.height = this._forcedOutputTexture.height;
  125224. }
  125225. else {
  125226. target = this.inputTexture;
  125227. }
  125228. // Bind the input of this post process to be used as the output of the previous post process.
  125229. if (this.enablePixelPerfectMode) {
  125230. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  125231. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  125232. }
  125233. else {
  125234. this._scaleRatio.copyFromFloats(1, 1);
  125235. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  125236. }
  125237. this.onActivateObservable.notifyObservers(camera);
  125238. // Clear
  125239. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  125240. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  125241. }
  125242. if (this._reusable) {
  125243. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  125244. }
  125245. return target;
  125246. };
  125247. Object.defineProperty(PostProcess.prototype, "isSupported", {
  125248. /**
  125249. * If the post process is supported.
  125250. */
  125251. get: function () {
  125252. return this._effect.isSupported;
  125253. },
  125254. enumerable: true,
  125255. configurable: true
  125256. });
  125257. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  125258. /**
  125259. * The aspect ratio of the output texture.
  125260. */
  125261. get: function () {
  125262. if (this._shareOutputWithPostProcess) {
  125263. return this._shareOutputWithPostProcess.aspectRatio;
  125264. }
  125265. if (this._forcedOutputTexture) {
  125266. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  125267. }
  125268. return this.width / this.height;
  125269. },
  125270. enumerable: true,
  125271. configurable: true
  125272. });
  125273. /**
  125274. * Get a value indicating if the post-process is ready to be used
  125275. * @returns true if the post-process is ready (shader is compiled)
  125276. */
  125277. PostProcess.prototype.isReady = function () {
  125278. return this._effect && this._effect.isReady();
  125279. };
  125280. /**
  125281. * Binds all textures and uniforms to the shader, this will be run on every pass.
  125282. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  125283. */
  125284. PostProcess.prototype.apply = function () {
  125285. // Check
  125286. if (!this._effect || !this._effect.isReady()) {
  125287. return null;
  125288. }
  125289. // States
  125290. this._engine.enableEffect(this._effect);
  125291. this._engine.setState(false);
  125292. this._engine.setDepthBuffer(false);
  125293. this._engine.setDepthWrite(false);
  125294. // Alpha
  125295. this._engine.setAlphaMode(this.alphaMode);
  125296. if (this.alphaConstants) {
  125297. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  125298. }
  125299. // Bind the output texture of the preivous post process as the input to this post process.
  125300. var source;
  125301. if (this._shareOutputWithPostProcess) {
  125302. source = this._shareOutputWithPostProcess.inputTexture;
  125303. }
  125304. else if (this._forcedOutputTexture) {
  125305. source = this._forcedOutputTexture;
  125306. }
  125307. else {
  125308. source = this.inputTexture;
  125309. }
  125310. this._effect._bindTexture("textureSampler", source);
  125311. // Parameters
  125312. this._effect.setVector2("scale", this._scaleRatio);
  125313. this.onApplyObservable.notifyObservers(this._effect);
  125314. return this._effect;
  125315. };
  125316. PostProcess.prototype._disposeTextures = function () {
  125317. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  125318. return;
  125319. }
  125320. if (this._textures.length > 0) {
  125321. for (var i = 0; i < this._textures.length; i++) {
  125322. this._engine._releaseTexture(this._textures.data[i]);
  125323. }
  125324. }
  125325. this._textures.dispose();
  125326. };
  125327. /**
  125328. * Disposes the post process.
  125329. * @param camera The camera to dispose the post process on.
  125330. */
  125331. PostProcess.prototype.dispose = function (camera) {
  125332. camera = camera || this._camera;
  125333. this._disposeTextures();
  125334. if (this._scene) {
  125335. var index_1 = this._scene.postProcesses.indexOf(this);
  125336. if (index_1 !== -1) {
  125337. this._scene.postProcesses.splice(index_1, 1);
  125338. }
  125339. }
  125340. else {
  125341. var index_2 = this._engine.postProcesses.indexOf(this);
  125342. if (index_2 !== -1) {
  125343. this._engine.postProcesses.splice(index_2, 1);
  125344. }
  125345. }
  125346. if (!camera) {
  125347. return;
  125348. }
  125349. camera.detachPostProcess(this);
  125350. var index = camera._postProcesses.indexOf(this);
  125351. if (index === 0 && camera._postProcesses.length > 0) {
  125352. var firstPostProcess = this._camera._getFirstPostProcess();
  125353. if (firstPostProcess) {
  125354. firstPostProcess.markTextureDirty();
  125355. }
  125356. }
  125357. this.onActivateObservable.clear();
  125358. this.onAfterRenderObservable.clear();
  125359. this.onApplyObservable.clear();
  125360. this.onBeforeRenderObservable.clear();
  125361. this.onSizeChangedObservable.clear();
  125362. };
  125363. return PostProcess;
  125364. }());
  125365. /***/ }),
  125366. /***/ "./PostProcesses/postProcessManager.ts":
  125367. /*!*********************************************!*\
  125368. !*** ./PostProcesses/postProcessManager.ts ***!
  125369. \*********************************************/
  125370. /*! exports provided: PostProcessManager */
  125371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125372. "use strict";
  125373. __webpack_require__.r(__webpack_exports__);
  125374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  125375. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125376. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125377. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125378. /**
  125379. * PostProcessManager is used to manage one or more post processes or post process pipelines
  125380. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125381. */
  125382. var PostProcessManager = /** @class */ (function () {
  125383. /**
  125384. * Creates a new instance PostProcess
  125385. * @param scene The scene that the post process is associated with.
  125386. */
  125387. function PostProcessManager(scene) {
  125388. this._vertexBuffers = {};
  125389. this._scene = scene;
  125390. }
  125391. PostProcessManager.prototype._prepareBuffers = function () {
  125392. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  125393. return;
  125394. }
  125395. // VBO
  125396. var vertices = [];
  125397. vertices.push(1, 1);
  125398. vertices.push(-1, 1);
  125399. vertices.push(-1, -1);
  125400. vertices.push(1, -1);
  125401. 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);
  125402. this._buildIndexBuffer();
  125403. };
  125404. PostProcessManager.prototype._buildIndexBuffer = function () {
  125405. // Indices
  125406. var indices = [];
  125407. indices.push(0);
  125408. indices.push(1);
  125409. indices.push(2);
  125410. indices.push(0);
  125411. indices.push(2);
  125412. indices.push(3);
  125413. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  125414. };
  125415. /**
  125416. * Rebuilds the vertex buffers of the manager.
  125417. * @hidden
  125418. */
  125419. PostProcessManager.prototype._rebuild = function () {
  125420. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125421. if (!vb) {
  125422. return;
  125423. }
  125424. vb._rebuild();
  125425. this._buildIndexBuffer();
  125426. };
  125427. // Methods
  125428. /**
  125429. * Prepares a frame to be run through a post process.
  125430. * @param sourceTexture The input texture to the post procesess. (default: null)
  125431. * @param postProcesses An array of post processes to be run. (default: null)
  125432. * @returns True if the post processes were able to be run.
  125433. * @hidden
  125434. */
  125435. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  125436. if (sourceTexture === void 0) { sourceTexture = null; }
  125437. if (postProcesses === void 0) { postProcesses = null; }
  125438. var camera = this._scene.activeCamera;
  125439. if (!camera) {
  125440. return false;
  125441. }
  125442. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  125443. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  125444. return false;
  125445. }
  125446. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  125447. return true;
  125448. };
  125449. /**
  125450. * Manually render a set of post processes to a texture.
  125451. * @param postProcesses An array of post processes to be run.
  125452. * @param targetTexture The target texture to render to.
  125453. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  125454. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  125455. * @param lodLevel defines which lod of the texture to render to
  125456. */
  125457. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  125458. if (targetTexture === void 0) { targetTexture = null; }
  125459. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  125460. if (faceIndex === void 0) { faceIndex = 0; }
  125461. if (lodLevel === void 0) { lodLevel = 0; }
  125462. var engine = this._scene.getEngine();
  125463. for (var index = 0; index < postProcesses.length; index++) {
  125464. if (index < postProcesses.length - 1) {
  125465. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  125466. }
  125467. else {
  125468. if (targetTexture) {
  125469. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  125470. }
  125471. else {
  125472. engine.restoreDefaultFramebuffer();
  125473. }
  125474. }
  125475. var pp = postProcesses[index];
  125476. var effect = pp.apply();
  125477. if (effect) {
  125478. pp.onBeforeRenderObservable.notifyObservers(effect);
  125479. // VBOs
  125480. this._prepareBuffers();
  125481. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125482. // Draw order
  125483. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  125484. pp.onAfterRenderObservable.notifyObservers(effect);
  125485. }
  125486. }
  125487. // Restore depth buffer
  125488. engine.setDepthBuffer(true);
  125489. engine.setDepthWrite(true);
  125490. };
  125491. /**
  125492. * Finalize the result of the output of the postprocesses.
  125493. * @param doNotPresent If true the result will not be displayed to the screen.
  125494. * @param targetTexture The target texture to render to.
  125495. * @param faceIndex The index of the face to bind the target texture to.
  125496. * @param postProcesses The array of post processes to render.
  125497. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  125498. * @hidden
  125499. */
  125500. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  125501. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  125502. var camera = this._scene.activeCamera;
  125503. if (!camera) {
  125504. return;
  125505. }
  125506. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  125507. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  125508. return;
  125509. }
  125510. var engine = this._scene.getEngine();
  125511. for (var index = 0, len = postProcesses.length; index < len; index++) {
  125512. var pp = postProcesses[index];
  125513. if (index < len - 1) {
  125514. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  125515. }
  125516. else {
  125517. if (targetTexture) {
  125518. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  125519. pp._outputTexture = targetTexture;
  125520. }
  125521. else {
  125522. engine.restoreDefaultFramebuffer();
  125523. pp._outputTexture = null;
  125524. }
  125525. }
  125526. if (doNotPresent) {
  125527. break;
  125528. }
  125529. var effect = pp.apply();
  125530. if (effect) {
  125531. pp.onBeforeRenderObservable.notifyObservers(effect);
  125532. // VBOs
  125533. this._prepareBuffers();
  125534. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125535. // Draw order
  125536. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  125537. pp.onAfterRenderObservable.notifyObservers(effect);
  125538. }
  125539. }
  125540. // Restore states
  125541. engine.setDepthBuffer(true);
  125542. engine.setDepthWrite(true);
  125543. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  125544. };
  125545. /**
  125546. * Disposes of the post process manager.
  125547. */
  125548. PostProcessManager.prototype.dispose = function () {
  125549. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125550. if (buffer) {
  125551. buffer.dispose();
  125552. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  125553. }
  125554. if (this._indexBuffer) {
  125555. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  125556. this._indexBuffer = null;
  125557. }
  125558. };
  125559. return PostProcessManager;
  125560. }());
  125561. /***/ }),
  125562. /***/ "./PostProcesses/refractionPostProcess.ts":
  125563. /*!************************************************!*\
  125564. !*** ./PostProcesses/refractionPostProcess.ts ***!
  125565. \************************************************/
  125566. /*! exports provided: RefractionPostProcess */
  125567. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125568. "use strict";
  125569. __webpack_require__.r(__webpack_exports__);
  125570. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  125571. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125572. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125573. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125574. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  125575. /**
  125576. * Post process which applies a refractin texture
  125577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125578. */
  125579. var RefractionPostProcess = /** @class */ (function (_super) {
  125580. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  125581. /**
  125582. * Initializes the RefractionPostProcess
  125583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125584. * @param name The name of the effect.
  125585. * @param refractionTextureUrl Url of the refraction texture to use
  125586. * @param color the base color of the refraction (used to taint the rendering)
  125587. * @param depth simulated refraction depth
  125588. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  125589. * @param camera The camera to apply the render pass to.
  125590. * @param options The required width/height ratio to downsize to before computing the render pass.
  125591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125592. * @param engine The engine which the post process will be applied. (default: current engine)
  125593. * @param reusable If the post process can be reused on the same frame. (default: false)
  125594. */
  125595. function RefractionPostProcess(name, refractionTextureUrl,
  125596. /** the base color of the refraction (used to taint the rendering) */
  125597. color,
  125598. /** simulated refraction depth */
  125599. depth,
  125600. /** the coefficient of the base color (0 to remove base color tainting) */
  125601. colorLevel, options, camera, samplingMode, engine, reusable) {
  125602. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  125603. _this.color = color;
  125604. _this.depth = depth;
  125605. _this.colorLevel = colorLevel;
  125606. _this._ownRefractionTexture = true;
  125607. _this.onActivateObservable.add(function (cam) {
  125608. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  125609. });
  125610. _this.onApplyObservable.add(function (effect) {
  125611. effect.setColor3("baseColor", _this.color);
  125612. effect.setFloat("depth", _this.depth);
  125613. effect.setFloat("colorLevel", _this.colorLevel);
  125614. effect.setTexture("refractionSampler", _this._refTexture);
  125615. });
  125616. return _this;
  125617. }
  125618. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  125619. /**
  125620. * Gets or sets the refraction texture
  125621. * Please note that you are responsible for disposing the texture if you set it manually
  125622. */
  125623. get: function () {
  125624. return this._refTexture;
  125625. },
  125626. set: function (value) {
  125627. if (this._refTexture && this._ownRefractionTexture) {
  125628. this._refTexture.dispose();
  125629. }
  125630. this._refTexture = value;
  125631. this._ownRefractionTexture = false;
  125632. },
  125633. enumerable: true,
  125634. configurable: true
  125635. });
  125636. // Methods
  125637. /**
  125638. * Disposes of the post process
  125639. * @param camera Camera to dispose post process on
  125640. */
  125641. RefractionPostProcess.prototype.dispose = function (camera) {
  125642. if (this._refTexture && this._ownRefractionTexture) {
  125643. this._refTexture.dispose();
  125644. this._refTexture = null;
  125645. }
  125646. _super.prototype.dispose.call(this, camera);
  125647. };
  125648. return RefractionPostProcess;
  125649. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125650. /***/ }),
  125651. /***/ "./PostProcesses/sharpenPostProcess.ts":
  125652. /*!*********************************************!*\
  125653. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  125654. \*********************************************/
  125655. /*! exports provided: SharpenPostProcess */
  125656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125657. "use strict";
  125658. __webpack_require__.r(__webpack_exports__);
  125659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  125660. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125661. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125662. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125663. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  125664. /**
  125665. * The SharpenPostProcess applies a sharpen kernel to every pixel
  125666. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125667. */
  125668. var SharpenPostProcess = /** @class */ (function (_super) {
  125669. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  125670. /**
  125671. * Creates a new instance ConvolutionPostProcess
  125672. * @param name The name of the effect.
  125673. * @param options The required width/height ratio to downsize to before computing the render pass.
  125674. * @param camera The camera to apply the render pass to.
  125675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125676. * @param engine The engine which the post process will be applied. (default: current engine)
  125677. * @param reusable If the post process can be reused on the same frame. (default: false)
  125678. * @param textureType Type of textures used when performing the post process. (default: 0)
  125679. * @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)
  125680. */
  125681. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  125682. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125683. if (blockCompilation === void 0) { blockCompilation = false; }
  125684. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  125685. /**
  125686. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  125687. */
  125688. _this.colorAmount = 1.0;
  125689. /**
  125690. * How much sharpness should be applied (default: 0.3)
  125691. */
  125692. _this.edgeAmount = 0.3;
  125693. _this.onApply = function (effect) {
  125694. effect.setFloat2("screenSize", _this.width, _this.height);
  125695. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  125696. };
  125697. return _this;
  125698. }
  125699. return SharpenPostProcess;
  125700. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125701. /***/ }),
  125702. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  125703. /*!***********************************************************!*\
  125704. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  125705. \***********************************************************/
  125706. /*! exports provided: StereoscopicInterlacePostProcess */
  125707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125708. "use strict";
  125709. __webpack_require__.r(__webpack_exports__);
  125710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  125711. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125712. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125713. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125714. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  125715. /**
  125716. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  125717. */
  125718. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  125719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  125720. /**
  125721. * Initializes a StereoscopicInterlacePostProcess
  125722. * @param name The name of the effect.
  125723. * @param rigCameras The rig cameras to be appled to the post process
  125724. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  125725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125726. * @param engine The engine which the post process will be applied. (default: current engine)
  125727. * @param reusable If the post process can be reused on the same frame. (default: false)
  125728. */
  125729. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  125730. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  125731. _this._passedProcess = rigCameras[0]._rigPostProcess;
  125732. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  125733. _this.onSizeChangedObservable.add(function () {
  125734. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  125735. });
  125736. _this.onApplyObservable.add(function (effect) {
  125737. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  125738. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  125739. });
  125740. return _this;
  125741. }
  125742. return StereoscopicInterlacePostProcess;
  125743. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125744. /***/ }),
  125745. /***/ "./PostProcesses/tonemapPostProcess.ts":
  125746. /*!*********************************************!*\
  125747. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  125748. \*********************************************/
  125749. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  125750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125751. "use strict";
  125752. __webpack_require__.r(__webpack_exports__);
  125753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  125754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  125755. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125756. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125757. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125758. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  125759. /** Defines operator used for tonemapping */
  125760. var TonemappingOperator;
  125761. (function (TonemappingOperator) {
  125762. /** Hable */
  125763. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  125764. /** Reinhard */
  125765. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  125766. /** HejiDawson */
  125767. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  125768. /** Photographic */
  125769. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  125770. })(TonemappingOperator || (TonemappingOperator = {}));
  125771. /**
  125772. * Defines a post process to apply tone mapping
  125773. */
  125774. var TonemapPostProcess = /** @class */ (function (_super) {
  125775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  125776. /**
  125777. * Creates a new TonemapPostProcess
  125778. * @param name defines the name of the postprocess
  125779. * @param _operator defines the operator to use
  125780. * @param exposureAdjustment defines the required exposure adjustement
  125781. * @param camera defines the camera to use (can be null)
  125782. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125783. * @param engine defines the hosting engine (can be ignore if camera is set)
  125784. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125785. */
  125786. function TonemapPostProcess(name, _operator,
  125787. /** Defines the required exposure adjustement */
  125788. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  125789. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  125790. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125791. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  125792. _this._operator = _operator;
  125793. _this.exposureAdjustment = exposureAdjustment;
  125794. var defines = "#define ";
  125795. if (_this._operator === TonemappingOperator.Hable) {
  125796. defines += "HABLE_TONEMAPPING";
  125797. }
  125798. else if (_this._operator === TonemappingOperator.Reinhard) {
  125799. defines += "REINHARD_TONEMAPPING";
  125800. }
  125801. else if (_this._operator === TonemappingOperator.HejiDawson) {
  125802. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  125803. }
  125804. else if (_this._operator === TonemappingOperator.Photographic) {
  125805. defines += "PHOTOGRAPHIC_TONEMAPPING";
  125806. }
  125807. //sadly a second call to create the effect.
  125808. _this.updateEffect(defines);
  125809. _this.onApply = function (effect) {
  125810. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  125811. };
  125812. return _this;
  125813. }
  125814. return TonemapPostProcess;
  125815. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125816. /***/ }),
  125817. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  125818. /*!***************************************************************!*\
  125819. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  125820. \***************************************************************/
  125821. /*! exports provided: VolumetricLightScatteringPostProcess */
  125822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125823. "use strict";
  125824. __webpack_require__.r(__webpack_exports__);
  125825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  125826. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125827. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  125828. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  125829. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125830. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125831. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  125832. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  125833. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125834. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  125835. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125836. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  125837. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125838. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125839. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  125840. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  125841. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  125842. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  125843. /**
  125844. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  125845. */
  125846. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  125847. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  125848. /**
  125849. * @constructor
  125850. * @param name The post-process name
  125851. * @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)
  125852. * @param camera The camera that the post-process will be attached to
  125853. * @param mesh The mesh used to create the light scattering
  125854. * @param samples The post-process quality, default 100
  125855. * @param samplingModeThe post-process filtering mode
  125856. * @param engine The babylon engine
  125857. * @param reusable If the post-process is reusable
  125858. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  125859. */
  125860. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  125861. if (samples === void 0) { samples = 100; }
  125862. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  125863. 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;
  125864. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  125865. /**
  125866. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  125867. */
  125868. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125869. /**
  125870. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  125871. */
  125872. _this.useCustomMeshPosition = false;
  125873. /**
  125874. * If the post-process should inverse the light scattering direction
  125875. */
  125876. _this.invert = true;
  125877. /**
  125878. * Array containing the excluded meshes not rendered in the internal pass
  125879. */
  125880. _this.excludedMeshes = new Array();
  125881. /**
  125882. * Controls the overall intensity of the post-process
  125883. */
  125884. _this.exposure = 0.3;
  125885. /**
  125886. * Dissipates each sample's contribution in range [0, 1]
  125887. */
  125888. _this.decay = 0.96815;
  125889. /**
  125890. * Controls the overall intensity of each sample
  125891. */
  125892. _this.weight = 0.58767;
  125893. /**
  125894. * Controls the density of each sample
  125895. */
  125896. _this.density = 0.926;
  125897. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  125898. engine = scene.getEngine();
  125899. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  125900. // Configure mesh
  125901. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  125902. // Configure
  125903. _this._createPass(scene, ratio.passRatio || ratio);
  125904. _this.onActivate = function (camera) {
  125905. if (!_this.isSupported) {
  125906. _this.dispose(camera);
  125907. }
  125908. _this.onActivate = null;
  125909. };
  125910. _this.onApplyObservable.add(function (effect) {
  125911. _this._updateMeshScreenCoordinates(scene);
  125912. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  125913. effect.setFloat("exposure", _this.exposure);
  125914. effect.setFloat("decay", _this.decay);
  125915. effect.setFloat("weight", _this.weight);
  125916. effect.setFloat("density", _this.density);
  125917. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  125918. });
  125919. return _this;
  125920. }
  125921. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  125922. /**
  125923. * @hidden
  125924. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  125925. */
  125926. get: function () {
  125927. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  125928. return false;
  125929. },
  125930. set: function (useDiffuseColor) {
  125931. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  125932. },
  125933. enumerable: true,
  125934. configurable: true
  125935. });
  125936. /**
  125937. * Returns the string "VolumetricLightScatteringPostProcess"
  125938. * @returns "VolumetricLightScatteringPostProcess"
  125939. */
  125940. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  125941. return "VolumetricLightScatteringPostProcess";
  125942. };
  125943. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  125944. var mesh = subMesh.getMesh();
  125945. // Render this.mesh as default
  125946. if (mesh === this.mesh && mesh.material) {
  125947. return mesh.material.isReady(mesh);
  125948. }
  125949. var defines = [];
  125950. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  125951. var material = subMesh.getMaterial();
  125952. // Alpha test
  125953. if (material) {
  125954. if (material.needAlphaTesting()) {
  125955. defines.push("#define ALPHATEST");
  125956. }
  125957. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  125958. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  125959. defines.push("#define UV1");
  125960. }
  125961. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  125962. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  125963. defines.push("#define UV2");
  125964. }
  125965. }
  125966. // Bones
  125967. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  125968. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  125969. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  125970. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  125971. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  125972. }
  125973. else {
  125974. defines.push("#define NUM_BONE_INFLUENCERS 0");
  125975. }
  125976. // Instances
  125977. if (useInstances) {
  125978. defines.push("#define INSTANCES");
  125979. attribs.push("world0");
  125980. attribs.push("world1");
  125981. attribs.push("world2");
  125982. attribs.push("world3");
  125983. }
  125984. // Get correct effect
  125985. var join = defines.join("\n");
  125986. if (this._cachedDefines !== join) {
  125987. this._cachedDefines = join;
  125988. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  125989. }
  125990. return this._volumetricLightScatteringPass.isReady();
  125991. };
  125992. /**
  125993. * Sets the new light position for light scattering effect
  125994. * @param position The new custom light position
  125995. */
  125996. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  125997. this.customMeshPosition = position;
  125998. };
  125999. /**
  126000. * Returns the light position for light scattering effect
  126001. * @return Vector3 The custom light position
  126002. */
  126003. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  126004. return this.customMeshPosition;
  126005. };
  126006. /**
  126007. * Disposes the internal assets and detaches the post-process from the camera
  126008. */
  126009. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  126010. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  126011. if (rttIndex !== -1) {
  126012. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  126013. }
  126014. this._volumetricLightScatteringRTT.dispose();
  126015. _super.prototype.dispose.call(this, camera);
  126016. };
  126017. /**
  126018. * Returns the render target texture used by the post-process
  126019. * @return the render target texture used by the post-process
  126020. */
  126021. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  126022. return this._volumetricLightScatteringRTT;
  126023. };
  126024. // Private methods
  126025. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  126026. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  126027. return true;
  126028. }
  126029. return false;
  126030. };
  126031. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  126032. var _this = this;
  126033. var engine = scene.getEngine();
  126034. 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);
  126035. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  126036. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  126037. this._volumetricLightScatteringRTT.renderList = null;
  126038. this._volumetricLightScatteringRTT.renderParticles = false;
  126039. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  126040. var camera = this.getCamera();
  126041. if (camera) {
  126042. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  126043. }
  126044. else {
  126045. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  126046. }
  126047. // Custom render function for submeshes
  126048. var renderSubMesh = function (subMesh) {
  126049. var mesh = subMesh.getRenderingMesh();
  126050. if (_this._meshExcluded(mesh)) {
  126051. return;
  126052. }
  126053. var material = subMesh.getMaterial();
  126054. if (!material) {
  126055. return;
  126056. }
  126057. var scene = mesh.getScene();
  126058. var engine = scene.getEngine();
  126059. // Culling
  126060. engine.setState(material.backFaceCulling);
  126061. // Managing instances
  126062. var batch = mesh._getInstancesRenderList(subMesh._id);
  126063. if (batch.mustReturn) {
  126064. return;
  126065. }
  126066. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  126067. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  126068. var effect = _this._volumetricLightScatteringPass;
  126069. if (mesh === _this.mesh) {
  126070. if (subMesh.effect) {
  126071. effect = subMesh.effect;
  126072. }
  126073. else {
  126074. effect = material.getEffect();
  126075. }
  126076. }
  126077. engine.enableEffect(effect);
  126078. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  126079. if (mesh === _this.mesh) {
  126080. material.bind(mesh.getWorldMatrix(), mesh);
  126081. }
  126082. else {
  126083. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  126084. // Alpha test
  126085. if (material && material.needAlphaTesting()) {
  126086. var alphaTexture = material.getAlphaTestTexture();
  126087. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  126088. if (alphaTexture) {
  126089. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  126090. }
  126091. }
  126092. // Bones
  126093. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  126094. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  126095. }
  126096. }
  126097. // Draw
  126098. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  126099. }
  126100. };
  126101. // Render target texture callbacks
  126102. var savedSceneClearColor;
  126103. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  126104. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  126105. savedSceneClearColor = scene.clearColor;
  126106. scene.clearColor = sceneClearColor;
  126107. });
  126108. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  126109. scene.clearColor = savedSceneClearColor;
  126110. });
  126111. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  126112. var engine = scene.getEngine();
  126113. var index;
  126114. if (depthOnlySubMeshes.length) {
  126115. engine.setColorWrite(false);
  126116. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  126117. renderSubMesh(depthOnlySubMeshes.data[index]);
  126118. }
  126119. engine.setColorWrite(true);
  126120. }
  126121. for (index = 0; index < opaqueSubMeshes.length; index++) {
  126122. renderSubMesh(opaqueSubMeshes.data[index]);
  126123. }
  126124. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  126125. renderSubMesh(alphaTestSubMeshes.data[index]);
  126126. }
  126127. if (transparentSubMeshes.length) {
  126128. // Sort sub meshes
  126129. for (index = 0; index < transparentSubMeshes.length; index++) {
  126130. var submesh = transparentSubMeshes.data[index];
  126131. var boundingInfo = submesh.getBoundingInfo();
  126132. if (boundingInfo && scene.activeCamera) {
  126133. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  126134. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  126135. }
  126136. }
  126137. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  126138. sortedArray.sort(function (a, b) {
  126139. // Alpha index first
  126140. if (a._alphaIndex > b._alphaIndex) {
  126141. return 1;
  126142. }
  126143. if (a._alphaIndex < b._alphaIndex) {
  126144. return -1;
  126145. }
  126146. // Then distance to camera
  126147. if (a._distanceToCamera < b._distanceToCamera) {
  126148. return 1;
  126149. }
  126150. if (a._distanceToCamera > b._distanceToCamera) {
  126151. return -1;
  126152. }
  126153. return 0;
  126154. });
  126155. // Render sub meshes
  126156. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  126157. for (index = 0; index < sortedArray.length; index++) {
  126158. renderSubMesh(sortedArray[index]);
  126159. }
  126160. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  126161. }
  126162. };
  126163. };
  126164. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  126165. var transform = scene.getTransformMatrix();
  126166. var meshPosition;
  126167. if (this.useCustomMeshPosition) {
  126168. meshPosition = this.customMeshPosition;
  126169. }
  126170. else if (this.attachedNode) {
  126171. meshPosition = this.attachedNode.position;
  126172. }
  126173. else {
  126174. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  126175. }
  126176. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  126177. this._screenCoordinates.x = pos.x / this._viewPort.width;
  126178. this._screenCoordinates.y = pos.y / this._viewPort.height;
  126179. if (this.invert) {
  126180. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  126181. }
  126182. };
  126183. // Static methods
  126184. /**
  126185. * Creates a default mesh for the Volumeric Light Scattering post-process
  126186. * @param name The mesh name
  126187. * @param scene The scene where to create the mesh
  126188. * @return the default mesh
  126189. */
  126190. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  126191. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  126192. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  126193. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  126194. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  126195. mesh.material = material;
  126196. return mesh;
  126197. };
  126198. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126199. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  126200. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  126201. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126202. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  126203. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  126204. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126205. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  126206. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  126207. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126208. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  126209. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  126210. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126211. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  126212. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  126213. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126214. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  126215. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  126216. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  126218. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  126219. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126220. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  126221. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  126222. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126223. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  126224. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  126225. return VolumetricLightScatteringPostProcess;
  126226. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  126227. /***/ }),
  126228. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  126229. /*!************************************************************!*\
  126230. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  126231. \************************************************************/
  126232. /*! exports provided: VRDistortionCorrectionPostProcess */
  126233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126234. "use strict";
  126235. __webpack_require__.r(__webpack_exports__);
  126236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  126237. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126238. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126239. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  126240. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  126241. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  126242. /**
  126243. * VRDistortionCorrectionPostProcess used for mobile VR
  126244. */
  126245. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  126246. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  126247. /**
  126248. * Initializes the VRDistortionCorrectionPostProcess
  126249. * @param name The name of the effect.
  126250. * @param camera The camera to apply the render pass to.
  126251. * @param isRightEye If this is for the right eye distortion
  126252. * @param vrMetrics All the required metrics for the VR camera
  126253. */
  126254. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  126255. var _this = _super.call(this, name, "vrDistortionCorrection", [
  126256. 'LensCenter',
  126257. 'Scale',
  126258. 'ScaleIn',
  126259. 'HmdWarpParam'
  126260. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  126261. _this._isRightEye = isRightEye;
  126262. _this._distortionFactors = vrMetrics.distortionK;
  126263. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  126264. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  126265. _this.adaptScaleToCurrentViewport = true;
  126266. _this.onSizeChangedObservable.add(function () {
  126267. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  126268. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  126269. _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);
  126270. });
  126271. _this.onApplyObservable.add(function (effect) {
  126272. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  126273. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  126274. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  126275. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  126276. });
  126277. return _this;
  126278. }
  126279. return VRDistortionCorrectionPostProcess;
  126280. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  126281. /***/ }),
  126282. /***/ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts":
  126283. /*!*************************************************************!*\
  126284. !*** ./PostProcesses/vrMultiviewToSingleviewPostProcess.ts ***!
  126285. \*************************************************************/
  126286. /*! exports provided: VRMultiviewToSingleviewPostProcess */
  126287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126288. "use strict";
  126289. __webpack_require__.r(__webpack_exports__);
  126290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return VRMultiviewToSingleviewPostProcess; });
  126291. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126292. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  126293. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  126294. /* harmony import */ var _Shaders_vrMultiviewToSingleview_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/vrMultiviewToSingleview.fragment */ "./Shaders/vrMultiviewToSingleview.fragment.ts");
  126295. /* harmony import */ var _Engines_Extensions_engine_multiview__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/Extensions/engine.multiview */ "./Engines/Extensions/engine.multiview.ts");
  126296. /**
  126297. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  126298. * This will not be used for webXR as it supports displaying texture arrays directly
  126299. */
  126300. var VRMultiviewToSingleviewPostProcess = /** @class */ (function (_super) {
  126301. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRMultiviewToSingleviewPostProcess, _super);
  126302. /**
  126303. * Initializes a VRMultiviewToSingleview
  126304. * @param name name of the post process
  126305. * @param camera camera to be applied to
  126306. * @param scaleFactor scaling factor to the size of the output texture
  126307. */
  126308. function VRMultiviewToSingleviewPostProcess(name, camera, scaleFactor) {
  126309. var _this = _super.call(this, name, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], scaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  126310. _this.onSizeChangedObservable.add(function () {
  126311. });
  126312. _this.onApplyObservable.add(function (effect) {
  126313. if (camera._scene.activeCamera && camera._scene.activeCamera.isLeftCamera) {
  126314. effect.setInt("imageIndex", 0);
  126315. }
  126316. else {
  126317. effect.setInt("imageIndex", 1);
  126318. }
  126319. effect.setTexture("multiviewSampler", camera._multiviewTexture);
  126320. });
  126321. return _this;
  126322. }
  126323. return VRMultiviewToSingleviewPostProcess;
  126324. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  126325. /***/ }),
  126326. /***/ "./Probes/index.ts":
  126327. /*!*************************!*\
  126328. !*** ./Probes/index.ts ***!
  126329. \*************************/
  126330. /*! exports provided: ReflectionProbe */
  126331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126332. "use strict";
  126333. __webpack_require__.r(__webpack_exports__);
  126334. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  126335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  126336. /***/ }),
  126337. /***/ "./Probes/reflectionProbe.ts":
  126338. /*!***********************************!*\
  126339. !*** ./Probes/reflectionProbe.ts ***!
  126340. \***********************************/
  126341. /*! exports provided: ReflectionProbe */
  126342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126343. "use strict";
  126344. __webpack_require__.r(__webpack_exports__);
  126345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  126346. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126347. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  126348. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  126349. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126350. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  126351. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126352. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  126353. if (!this.reflectionProbes) {
  126354. return -1;
  126355. }
  126356. var index = this.reflectionProbes.indexOf(toRemove);
  126357. if (index !== -1) {
  126358. this.reflectionProbes.splice(index, 1);
  126359. }
  126360. return index;
  126361. };
  126362. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  126363. if (!this.reflectionProbes) {
  126364. this.reflectionProbes = [];
  126365. }
  126366. this.reflectionProbes.push(newReflectionProbe);
  126367. };
  126368. /**
  126369. * Class used to generate realtime reflection / refraction cube textures
  126370. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  126371. */
  126372. var ReflectionProbe = /** @class */ (function () {
  126373. /**
  126374. * Creates a new reflection probe
  126375. * @param name defines the name of the probe
  126376. * @param size defines the texture resolution (for each face)
  126377. * @param scene defines the hosting scene
  126378. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  126379. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  126380. */
  126381. function ReflectionProbe(
  126382. /** defines the name of the probe */
  126383. name, size, scene, generateMipMaps, useFloat) {
  126384. if (generateMipMaps === void 0) { generateMipMaps = true; }
  126385. if (useFloat === void 0) { useFloat = false; }
  126386. var _this = this;
  126387. this.name = name;
  126388. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  126389. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126390. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126391. this._invertYAxis = false;
  126392. /** Gets or sets probe position (center of the cube map) */
  126393. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126394. this._scene = scene;
  126395. // Create the scene field if not exist.
  126396. if (!this._scene.reflectionProbes) {
  126397. this._scene.reflectionProbes = new Array();
  126398. }
  126399. this._scene.reflectionProbes.push(this);
  126400. 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);
  126401. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  126402. switch (faceIndex) {
  126403. case 0:
  126404. _this._add.copyFromFloats(1, 0, 0);
  126405. break;
  126406. case 1:
  126407. _this._add.copyFromFloats(-1, 0, 0);
  126408. break;
  126409. case 2:
  126410. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  126411. break;
  126412. case 3:
  126413. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  126414. break;
  126415. case 4:
  126416. _this._add.copyFromFloats(0, 0, 1);
  126417. break;
  126418. case 5:
  126419. _this._add.copyFromFloats(0, 0, -1);
  126420. break;
  126421. }
  126422. if (_this._attachedMesh) {
  126423. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  126424. }
  126425. _this.position.addToRef(_this._add, _this._target);
  126426. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  126427. if (scene.activeCamera) {
  126428. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  126429. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  126430. }
  126431. scene._forcedViewPosition = _this.position;
  126432. });
  126433. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  126434. scene._forcedViewPosition = null;
  126435. scene.updateTransformMatrix(true);
  126436. });
  126437. }
  126438. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  126439. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  126440. get: function () {
  126441. return this._renderTargetTexture.samples;
  126442. },
  126443. set: function (value) {
  126444. this._renderTargetTexture.samples = value;
  126445. },
  126446. enumerable: true,
  126447. configurable: true
  126448. });
  126449. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  126450. /** Gets or sets the refresh rate to use (on every frame by default) */
  126451. get: function () {
  126452. return this._renderTargetTexture.refreshRate;
  126453. },
  126454. set: function (value) {
  126455. this._renderTargetTexture.refreshRate = value;
  126456. },
  126457. enumerable: true,
  126458. configurable: true
  126459. });
  126460. /**
  126461. * Gets the hosting scene
  126462. * @returns a Scene
  126463. */
  126464. ReflectionProbe.prototype.getScene = function () {
  126465. return this._scene;
  126466. };
  126467. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  126468. /** Gets the internal CubeTexture used to render to */
  126469. get: function () {
  126470. return this._renderTargetTexture;
  126471. },
  126472. enumerable: true,
  126473. configurable: true
  126474. });
  126475. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  126476. /** Gets the list of meshes to render */
  126477. get: function () {
  126478. return this._renderTargetTexture.renderList;
  126479. },
  126480. enumerable: true,
  126481. configurable: true
  126482. });
  126483. /**
  126484. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  126485. * @param mesh defines the mesh to attach to
  126486. */
  126487. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  126488. this._attachedMesh = mesh;
  126489. };
  126490. /**
  126491. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  126492. * @param renderingGroupId The rendering group id corresponding to its index
  126493. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126494. */
  126495. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  126496. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  126497. };
  126498. /**
  126499. * Clean all associated resources
  126500. */
  126501. ReflectionProbe.prototype.dispose = function () {
  126502. var index = this._scene.reflectionProbes.indexOf(this);
  126503. if (index !== -1) {
  126504. // Remove from the scene if found
  126505. this._scene.reflectionProbes.splice(index, 1);
  126506. }
  126507. if (this._renderTargetTexture) {
  126508. this._renderTargetTexture.dispose();
  126509. this._renderTargetTexture = null;
  126510. }
  126511. };
  126512. /**
  126513. * Converts the reflection probe information to a readable string for debug purpose.
  126514. * @param fullDetails Supports for multiple levels of logging within scene loading
  126515. * @returns the human readable reflection probe info
  126516. */
  126517. ReflectionProbe.prototype.toString = function (fullDetails) {
  126518. var ret = "Name: " + this.name;
  126519. if (fullDetails) {
  126520. ret += ", position: " + this.position.toString();
  126521. if (this._attachedMesh) {
  126522. ret += ", attached mesh: " + this._attachedMesh.name;
  126523. }
  126524. }
  126525. return ret;
  126526. };
  126527. /**
  126528. * Get the class name of the relfection probe.
  126529. * @returns "ReflectionProbe"
  126530. */
  126531. ReflectionProbe.prototype.getClassName = function () {
  126532. return "ReflectionProbe";
  126533. };
  126534. /**
  126535. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  126536. * @returns The JSON representation of the texture
  126537. */
  126538. ReflectionProbe.prototype.serialize = function () {
  126539. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  126540. serializationObject.isReflectionProbe = true;
  126541. return serializationObject;
  126542. };
  126543. /**
  126544. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  126545. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  126546. * @param scene Define the scene the parsed reflection probe should be instantiated in
  126547. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  126548. * @returns The parsed reflection probe if successful
  126549. */
  126550. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  126551. var reflectionProbe = null;
  126552. if (scene.reflectionProbes) {
  126553. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  126554. var rp = scene.reflectionProbes[index];
  126555. if (rp.name === parsedReflectionProbe.name) {
  126556. reflectionProbe = rp;
  126557. break;
  126558. }
  126559. }
  126560. }
  126561. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  126562. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  126563. if (parsedReflectionProbe._attachedMesh) {
  126564. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  126565. }
  126566. return reflectionProbe;
  126567. };
  126568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  126570. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  126571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  126573. ], ReflectionProbe.prototype, "position", void 0);
  126574. return ReflectionProbe;
  126575. }());
  126576. /***/ }),
  126577. /***/ "./Rendering/boundingBoxRenderer.ts":
  126578. /*!******************************************!*\
  126579. !*** ./Rendering/boundingBoxRenderer.ts ***!
  126580. \******************************************/
  126581. /*! exports provided: BoundingBoxRenderer */
  126582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126583. "use strict";
  126584. __webpack_require__.r(__webpack_exports__);
  126585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  126586. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126587. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126588. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126589. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  126590. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126591. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  126592. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126593. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126594. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  126595. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  126596. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  126597. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  126598. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  126599. get: function () {
  126600. return this._forceShowBoundingBoxes || false;
  126601. },
  126602. set: function (value) {
  126603. this._forceShowBoundingBoxes = value;
  126604. // Lazyly creates a BB renderer if needed.
  126605. if (value) {
  126606. this.getBoundingBoxRenderer();
  126607. }
  126608. },
  126609. enumerable: true,
  126610. configurable: true
  126611. });
  126612. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  126613. if (!this._boundingBoxRenderer) {
  126614. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  126615. }
  126616. return this._boundingBoxRenderer;
  126617. };
  126618. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  126619. get: function () {
  126620. return this._showBoundingBox || false;
  126621. },
  126622. set: function (value) {
  126623. this._showBoundingBox = value;
  126624. // Lazyly creates a BB renderer if needed.
  126625. if (value) {
  126626. this.getScene().getBoundingBoxRenderer();
  126627. }
  126628. },
  126629. enumerable: true,
  126630. configurable: true
  126631. });
  126632. /**
  126633. * Component responsible of rendering the bounding box of the meshes in a scene.
  126634. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126635. */
  126636. var BoundingBoxRenderer = /** @class */ (function () {
  126637. /**
  126638. * Instantiates a new bounding box renderer in a scene.
  126639. * @param scene the scene the renderer renders in
  126640. */
  126641. function BoundingBoxRenderer(scene) {
  126642. /**
  126643. * The component name helpfull to identify the component in the list of scene components.
  126644. */
  126645. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  126646. /**
  126647. * Color of the bounding box lines placed in front of an object
  126648. */
  126649. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  126650. /**
  126651. * Color of the bounding box lines placed behind an object
  126652. */
  126653. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  126654. /**
  126655. * Defines if the renderer should show the back lines or not
  126656. */
  126657. this.showBackLines = true;
  126658. /**
  126659. * @hidden
  126660. */
  126661. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  126662. this._vertexBuffers = {};
  126663. this.scene = scene;
  126664. scene._addComponent(this);
  126665. }
  126666. /**
  126667. * Registers the component in a given scene
  126668. */
  126669. BoundingBoxRenderer.prototype.register = function () {
  126670. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  126671. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  126672. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  126673. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  126674. };
  126675. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  126676. if (mesh.showSubMeshesBoundingBox) {
  126677. var boundingInfo = subMesh.getBoundingInfo();
  126678. if (boundingInfo !== null && boundingInfo !== undefined) {
  126679. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  126680. this.renderList.push(boundingInfo.boundingBox);
  126681. }
  126682. }
  126683. };
  126684. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  126685. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  126686. var boundingInfo = sourceMesh.getBoundingInfo();
  126687. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  126688. this.renderList.push(boundingInfo.boundingBox);
  126689. }
  126690. };
  126691. BoundingBoxRenderer.prototype._prepareRessources = function () {
  126692. if (this._colorShader) {
  126693. return;
  126694. }
  126695. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  126696. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  126697. uniforms: ["world", "viewProjection", "color"]
  126698. });
  126699. var engine = this.scene.getEngine();
  126700. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  126701. 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);
  126702. this._createIndexBuffer();
  126703. };
  126704. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  126705. var engine = this.scene.getEngine();
  126706. 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]);
  126707. };
  126708. /**
  126709. * Rebuilds the elements related to this component in case of
  126710. * context lost for instance.
  126711. */
  126712. BoundingBoxRenderer.prototype.rebuild = function () {
  126713. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126714. if (vb) {
  126715. vb._rebuild();
  126716. }
  126717. this._createIndexBuffer();
  126718. };
  126719. /**
  126720. * @hidden
  126721. */
  126722. BoundingBoxRenderer.prototype.reset = function () {
  126723. this.renderList.reset();
  126724. };
  126725. /**
  126726. * Render the bounding boxes of a specific rendering group
  126727. * @param renderingGroupId defines the rendering group to render
  126728. */
  126729. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  126730. if (this.renderList.length === 0) {
  126731. return;
  126732. }
  126733. this._prepareRessources();
  126734. if (!this._colorShader.isReady()) {
  126735. return;
  126736. }
  126737. var engine = this.scene.getEngine();
  126738. engine.setDepthWrite(false);
  126739. this._colorShader._preBind();
  126740. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  126741. var boundingBox = this.renderList.data[boundingBoxIndex];
  126742. if (boundingBox._tag !== renderingGroupId) {
  126743. continue;
  126744. }
  126745. var min = boundingBox.minimum;
  126746. var max = boundingBox.maximum;
  126747. var diff = max.subtract(min);
  126748. var median = min.add(diff.scale(0.5));
  126749. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  126750. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  126751. .multiply(boundingBox.getWorldMatrix());
  126752. // VBOs
  126753. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  126754. if (this.showBackLines) {
  126755. // Back
  126756. engine.setDepthFunctionToGreaterOrEqual();
  126757. this.scene.resetCachedMaterial();
  126758. this._colorShader.setColor4("color", this.backColor.toColor4());
  126759. this._colorShader.bind(worldMatrix);
  126760. // Draw order
  126761. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  126762. }
  126763. // Front
  126764. engine.setDepthFunctionToLess();
  126765. this.scene.resetCachedMaterial();
  126766. this._colorShader.setColor4("color", this.frontColor.toColor4());
  126767. this._colorShader.bind(worldMatrix);
  126768. // Draw order
  126769. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  126770. }
  126771. this._colorShader.unbind();
  126772. engine.setDepthFunctionToLessOrEqual();
  126773. engine.setDepthWrite(true);
  126774. };
  126775. /**
  126776. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126777. * @param mesh Define the mesh to render the occlusion bounding box for
  126778. */
  126779. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  126780. this._prepareRessources();
  126781. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  126782. return;
  126783. }
  126784. var engine = this.scene.getEngine();
  126785. engine.setDepthWrite(false);
  126786. engine.setColorWrite(false);
  126787. this._colorShader._preBind();
  126788. var boundingBox = mesh._boundingInfo.boundingBox;
  126789. var min = boundingBox.minimum;
  126790. var max = boundingBox.maximum;
  126791. var diff = max.subtract(min);
  126792. var median = min.add(diff.scale(0.5));
  126793. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  126794. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  126795. .multiply(boundingBox.getWorldMatrix());
  126796. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  126797. engine.setDepthFunctionToLess();
  126798. this.scene.resetCachedMaterial();
  126799. this._colorShader.bind(worldMatrix);
  126800. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  126801. this._colorShader.unbind();
  126802. engine.setDepthFunctionToLessOrEqual();
  126803. engine.setDepthWrite(true);
  126804. engine.setColorWrite(true);
  126805. };
  126806. /**
  126807. * Dispose and release the resources attached to this renderer.
  126808. */
  126809. BoundingBoxRenderer.prototype.dispose = function () {
  126810. if (!this._colorShader) {
  126811. return;
  126812. }
  126813. this.renderList.dispose();
  126814. this._colorShader.dispose();
  126815. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126816. if (buffer) {
  126817. buffer.dispose();
  126818. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  126819. }
  126820. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  126821. };
  126822. return BoundingBoxRenderer;
  126823. }());
  126824. /***/ }),
  126825. /***/ "./Rendering/depthRenderer.ts":
  126826. /*!************************************!*\
  126827. !*** ./Rendering/depthRenderer.ts ***!
  126828. \************************************/
  126829. /*! exports provided: DepthRenderer */
  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__, "DepthRenderer", function() { return DepthRenderer; });
  126834. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126835. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126836. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  126837. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  126838. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126839. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126840. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  126841. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  126842. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  126843. /**
  126844. * This represents a depth renderer in Babylon.
  126845. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126846. */
  126847. var DepthRenderer = /** @class */ (function () {
  126848. /**
  126849. * Instantiates a depth renderer
  126850. * @param scene The scene the renderer belongs to
  126851. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126852. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126853. */
  126854. function DepthRenderer(scene, type, camera) {
  126855. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  126856. if (camera === void 0) { camera = null; }
  126857. var _this = this;
  126858. /**
  126859. * Specifiess that the depth renderer will only be used within
  126860. * the camera it is created for.
  126861. * This can help forcing its rendering during the camera processing.
  126862. */
  126863. this.useOnlyInActiveCamera = false;
  126864. this._scene = scene;
  126865. DepthRenderer._SceneComponentInitialization(this._scene);
  126866. this._camera = camera;
  126867. var engine = scene.getEngine();
  126868. // Render target
  126869. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  126870. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  126871. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  126872. this._depthMap.refreshRate = 1;
  126873. this._depthMap.renderParticles = false;
  126874. this._depthMap.renderList = null;
  126875. // Camera to get depth map from to support multiple concurrent cameras
  126876. this._depthMap.activeCamera = this._camera;
  126877. this._depthMap.ignoreCameraViewport = true;
  126878. this._depthMap.useCameraPostProcesses = false;
  126879. // set default depth value to 1.0 (far away)
  126880. this._depthMap.onClearObservable.add(function (engine) {
  126881. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  126882. });
  126883. // Custom render function
  126884. var renderSubMesh = function (subMesh) {
  126885. var mesh = subMesh.getRenderingMesh();
  126886. var scene = _this._scene;
  126887. var engine = scene.getEngine();
  126888. var material = subMesh.getMaterial();
  126889. if (!material) {
  126890. return;
  126891. }
  126892. // Culling and reverse (right handed system)
  126893. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  126894. // Managing instances
  126895. var batch = mesh._getInstancesRenderList(subMesh._id);
  126896. if (batch.mustReturn) {
  126897. return;
  126898. }
  126899. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  126900. var camera = _this._camera || scene.activeCamera;
  126901. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  126902. engine.enableEffect(_this._effect);
  126903. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  126904. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  126905. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  126906. // Alpha test
  126907. if (material && material.needAlphaTesting()) {
  126908. var alphaTexture = material.getAlphaTestTexture();
  126909. if (alphaTexture) {
  126910. _this._effect.setTexture("diffuseSampler", alphaTexture);
  126911. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  126912. }
  126913. }
  126914. // Bones
  126915. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  126916. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  126917. }
  126918. // Draw
  126919. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  126920. }
  126921. };
  126922. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  126923. var index;
  126924. if (depthOnlySubMeshes.length) {
  126925. engine.setColorWrite(false);
  126926. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  126927. renderSubMesh(depthOnlySubMeshes.data[index]);
  126928. }
  126929. engine.setColorWrite(true);
  126930. }
  126931. for (index = 0; index < opaqueSubMeshes.length; index++) {
  126932. renderSubMesh(opaqueSubMeshes.data[index]);
  126933. }
  126934. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  126935. renderSubMesh(alphaTestSubMeshes.data[index]);
  126936. }
  126937. };
  126938. }
  126939. /**
  126940. * Creates the depth rendering effect and checks if the effect is ready.
  126941. * @param subMesh The submesh to be used to render the depth map of
  126942. * @param useInstances If multiple world instances should be used
  126943. * @returns if the depth renderer is ready to render the depth map
  126944. */
  126945. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  126946. var material = subMesh.getMaterial();
  126947. if (material.disableDepthWrite) {
  126948. return false;
  126949. }
  126950. var defines = [];
  126951. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126952. var mesh = subMesh.getMesh();
  126953. // Alpha test
  126954. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  126955. defines.push("#define ALPHATEST");
  126956. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  126957. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  126958. defines.push("#define UV1");
  126959. }
  126960. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  126961. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  126962. defines.push("#define UV2");
  126963. }
  126964. }
  126965. // Bones
  126966. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  126967. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  126968. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  126969. if (mesh.numBoneInfluencers > 4) {
  126970. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  126971. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  126972. }
  126973. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  126974. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  126975. }
  126976. else {
  126977. defines.push("#define NUM_BONE_INFLUENCERS 0");
  126978. }
  126979. // Instances
  126980. if (useInstances) {
  126981. defines.push("#define INSTANCES");
  126982. attribs.push("world0");
  126983. attribs.push("world1");
  126984. attribs.push("world2");
  126985. attribs.push("world3");
  126986. }
  126987. // Get correct effect
  126988. var join = defines.join("\n");
  126989. if (this._cachedDefines !== join) {
  126990. this._cachedDefines = join;
  126991. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  126992. }
  126993. return this._effect.isReady();
  126994. };
  126995. /**
  126996. * Gets the texture which the depth map will be written to.
  126997. * @returns The depth map texture
  126998. */
  126999. DepthRenderer.prototype.getDepthMap = function () {
  127000. return this._depthMap;
  127001. };
  127002. /**
  127003. * Disposes of the depth renderer.
  127004. */
  127005. DepthRenderer.prototype.dispose = function () {
  127006. this._depthMap.dispose();
  127007. };
  127008. /** @hidden */
  127009. DepthRenderer._SceneComponentInitialization = function (_) {
  127010. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  127011. };
  127012. return DepthRenderer;
  127013. }());
  127014. /***/ }),
  127015. /***/ "./Rendering/depthRendererSceneComponent.ts":
  127016. /*!**************************************************!*\
  127017. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  127018. \**************************************************/
  127019. /*! exports provided: DepthRendererSceneComponent */
  127020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127021. "use strict";
  127022. __webpack_require__.r(__webpack_exports__);
  127023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  127024. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127025. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  127026. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127027. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  127028. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  127029. camera = camera || this.activeCamera;
  127030. if (!camera) {
  127031. throw "No camera available to enable depth renderer";
  127032. }
  127033. if (!this._depthRenderer) {
  127034. this._depthRenderer = {};
  127035. }
  127036. if (!this._depthRenderer[camera.id]) {
  127037. var textureType = 0;
  127038. if (this.getEngine().getCaps().textureHalfFloatRender) {
  127039. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  127040. }
  127041. else if (this.getEngine().getCaps().textureFloatRender) {
  127042. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  127043. }
  127044. else {
  127045. throw "Depth renderer does not support int texture type";
  127046. }
  127047. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  127048. }
  127049. return this._depthRenderer[camera.id];
  127050. };
  127051. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  127052. camera = camera || this.activeCamera;
  127053. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  127054. return;
  127055. }
  127056. this._depthRenderer[camera.id].dispose();
  127057. delete this._depthRenderer[camera.id];
  127058. };
  127059. /**
  127060. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  127061. * in several rendering techniques.
  127062. */
  127063. var DepthRendererSceneComponent = /** @class */ (function () {
  127064. /**
  127065. * Creates a new instance of the component for the given scene
  127066. * @param scene Defines the scene to register the component in
  127067. */
  127068. function DepthRendererSceneComponent(scene) {
  127069. /**
  127070. * The component name helpfull to identify the component in the list of scene components.
  127071. */
  127072. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  127073. this.scene = scene;
  127074. }
  127075. /**
  127076. * Registers the component in a given scene
  127077. */
  127078. DepthRendererSceneComponent.prototype.register = function () {
  127079. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  127080. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  127081. };
  127082. /**
  127083. * Rebuilds the elements related to this component in case of
  127084. * context lost for instance.
  127085. */
  127086. DepthRendererSceneComponent.prototype.rebuild = function () {
  127087. // Nothing to do for this component
  127088. };
  127089. /**
  127090. * Disposes the component and the associated ressources
  127091. */
  127092. DepthRendererSceneComponent.prototype.dispose = function () {
  127093. for (var key in this.scene._depthRenderer) {
  127094. this.scene._depthRenderer[key].dispose();
  127095. }
  127096. };
  127097. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  127098. if (this.scene._depthRenderer) {
  127099. for (var key in this.scene._depthRenderer) {
  127100. var depthRenderer = this.scene._depthRenderer[key];
  127101. if (!depthRenderer.useOnlyInActiveCamera) {
  127102. renderTargets.push(depthRenderer.getDepthMap());
  127103. }
  127104. }
  127105. }
  127106. };
  127107. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  127108. if (this.scene._depthRenderer) {
  127109. for (var key in this.scene._depthRenderer) {
  127110. var depthRenderer = this.scene._depthRenderer[key];
  127111. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  127112. renderTargets.push(depthRenderer.getDepthMap());
  127113. }
  127114. }
  127115. }
  127116. };
  127117. return DepthRendererSceneComponent;
  127118. }());
  127119. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  127120. // Register the G Buffer component to the scene.
  127121. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  127122. if (!component) {
  127123. component = new DepthRendererSceneComponent(scene);
  127124. scene._addComponent(component);
  127125. }
  127126. };
  127127. /***/ }),
  127128. /***/ "./Rendering/edgesRenderer.ts":
  127129. /*!************************************!*\
  127130. !*** ./Rendering/edgesRenderer.ts ***!
  127131. \************************************/
  127132. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  127133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127134. "use strict";
  127135. __webpack_require__.r(__webpack_exports__);
  127136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  127137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  127138. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127139. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127140. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  127141. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  127142. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127143. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  127144. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  127145. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  127146. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127147. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  127148. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  127149. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  127150. if (this._edgesRenderer) {
  127151. this._edgesRenderer.dispose();
  127152. this._edgesRenderer = null;
  127153. }
  127154. return this;
  127155. };
  127156. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  127157. if (epsilon === void 0) { epsilon = 0.95; }
  127158. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  127159. this.disableEdgesRendering();
  127160. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  127161. return this;
  127162. };
  127163. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  127164. get: function () {
  127165. return this._edgesRenderer;
  127166. },
  127167. enumerable: true,
  127168. configurable: true
  127169. });
  127170. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  127171. if (epsilon === void 0) { epsilon = 0.95; }
  127172. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  127173. this.disableEdgesRendering();
  127174. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  127175. return this;
  127176. };
  127177. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  127178. if (epsilon === void 0) { epsilon = 0.95; }
  127179. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  127180. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  127181. return this;
  127182. };
  127183. /**
  127184. * FaceAdjacencies Helper class to generate edges
  127185. */
  127186. var FaceAdjacencies = /** @class */ (function () {
  127187. function FaceAdjacencies() {
  127188. this.edges = new Array();
  127189. this.edgesConnectedCount = 0;
  127190. }
  127191. return FaceAdjacencies;
  127192. }());
  127193. /**
  127194. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  127195. */
  127196. var EdgesRenderer = /** @class */ (function () {
  127197. /**
  127198. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  127199. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  127200. * @param source Mesh used to create edges
  127201. * @param epsilon sum of angles in adjacency to check for edge
  127202. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  127203. * @param generateEdgesLines - should generate Lines or only prepare resources.
  127204. */
  127205. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  127206. if (epsilon === void 0) { epsilon = 0.95; }
  127207. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  127208. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  127209. var _this = this;
  127210. /**
  127211. * Define the size of the edges with an orthographic camera
  127212. */
  127213. this.edgesWidthScalerForOrthographic = 1000.0;
  127214. /**
  127215. * Define the size of the edges with a perspective camera
  127216. */
  127217. this.edgesWidthScalerForPerspective = 50.0;
  127218. this._linesPositions = new Array();
  127219. this._linesNormals = new Array();
  127220. this._linesIndices = new Array();
  127221. this._buffers = {};
  127222. this._checkVerticesInsteadOfIndices = false;
  127223. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  127224. this.isEnabled = true;
  127225. this._source = source;
  127226. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  127227. this._epsilon = epsilon;
  127228. this._prepareRessources();
  127229. if (generateEdgesLines) {
  127230. this._generateEdgesLines();
  127231. }
  127232. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  127233. _this._rebuild();
  127234. });
  127235. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  127236. _this.dispose();
  127237. });
  127238. }
  127239. EdgesRenderer.prototype._prepareRessources = function () {
  127240. if (this._lineShader) {
  127241. return;
  127242. }
  127243. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  127244. attributes: ["position", "normal"],
  127245. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  127246. });
  127247. this._lineShader.disableDepthWrite = true;
  127248. this._lineShader.backFaceCulling = false;
  127249. };
  127250. /** @hidden */
  127251. EdgesRenderer.prototype._rebuild = function () {
  127252. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  127253. if (buffer) {
  127254. buffer._rebuild();
  127255. }
  127256. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  127257. if (buffer) {
  127258. buffer._rebuild();
  127259. }
  127260. var scene = this._source.getScene();
  127261. var engine = scene.getEngine();
  127262. this._ib = engine.createIndexBuffer(this._linesIndices);
  127263. };
  127264. /**
  127265. * Releases the required resources for the edges renderer
  127266. */
  127267. EdgesRenderer.prototype.dispose = function () {
  127268. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  127269. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  127270. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  127271. if (buffer) {
  127272. buffer.dispose();
  127273. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  127274. }
  127275. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  127276. if (buffer) {
  127277. buffer.dispose();
  127278. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  127279. }
  127280. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  127281. this._lineShader.dispose();
  127282. };
  127283. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  127284. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  127285. return 0;
  127286. }
  127287. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  127288. return 1;
  127289. }
  127290. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  127291. return 2;
  127292. }
  127293. return -1;
  127294. };
  127295. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  127296. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  127297. return 0;
  127298. }
  127299. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  127300. return 1;
  127301. }
  127302. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  127303. return 2;
  127304. }
  127305. return -1;
  127306. };
  127307. /**
  127308. * Checks if the pair of p0 and p1 is en edge
  127309. * @param faceIndex
  127310. * @param edge
  127311. * @param faceNormals
  127312. * @param p0
  127313. * @param p1
  127314. * @private
  127315. */
  127316. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  127317. var needToCreateLine;
  127318. if (edge === undefined) {
  127319. needToCreateLine = true;
  127320. }
  127321. else {
  127322. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  127323. needToCreateLine = dotProduct < this._epsilon;
  127324. }
  127325. if (needToCreateLine) {
  127326. this.createLine(p0, p1, this._linesPositions.length / 3);
  127327. }
  127328. };
  127329. /**
  127330. * push line into the position, normal and index buffer
  127331. * @protected
  127332. */
  127333. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  127334. // Positions
  127335. 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);
  127336. // Normals
  127337. 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);
  127338. // Indices
  127339. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  127340. };
  127341. /**
  127342. * Generates lines edges from adjacencjes
  127343. * @private
  127344. */
  127345. EdgesRenderer.prototype._generateEdgesLines = function () {
  127346. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  127347. var indices = this._source.getIndices();
  127348. if (!indices || !positions) {
  127349. return;
  127350. }
  127351. // First let's find adjacencies
  127352. var adjacencies = new Array();
  127353. var faceNormals = new Array();
  127354. var index;
  127355. var faceAdjacencies;
  127356. // Prepare faces
  127357. for (index = 0; index < indices.length; index += 3) {
  127358. faceAdjacencies = new FaceAdjacencies();
  127359. var p0Index = indices[index];
  127360. var p1Index = indices[index + 1];
  127361. var p2Index = indices[index + 2];
  127362. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  127363. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  127364. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  127365. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  127366. faceNormal.normalize();
  127367. faceNormals.push(faceNormal);
  127368. adjacencies.push(faceAdjacencies);
  127369. }
  127370. // Scan
  127371. for (index = 0; index < adjacencies.length; index++) {
  127372. faceAdjacencies = adjacencies[index];
  127373. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  127374. var otherFaceAdjacencies = adjacencies[otherIndex];
  127375. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  127376. break;
  127377. }
  127378. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  127379. continue;
  127380. }
  127381. var otherP0 = indices[otherIndex * 3];
  127382. var otherP1 = indices[otherIndex * 3 + 1];
  127383. var otherP2 = indices[otherIndex * 3 + 2];
  127384. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  127385. var otherEdgeIndex = 0;
  127386. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  127387. continue;
  127388. }
  127389. switch (edgeIndex) {
  127390. case 0:
  127391. if (this._checkVerticesInsteadOfIndices) {
  127392. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  127393. }
  127394. else {
  127395. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  127396. }
  127397. break;
  127398. case 1:
  127399. if (this._checkVerticesInsteadOfIndices) {
  127400. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  127401. }
  127402. else {
  127403. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  127404. }
  127405. break;
  127406. case 2:
  127407. if (this._checkVerticesInsteadOfIndices) {
  127408. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  127409. }
  127410. else {
  127411. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  127412. }
  127413. break;
  127414. }
  127415. if (otherEdgeIndex === -1) {
  127416. continue;
  127417. }
  127418. faceAdjacencies.edges[edgeIndex] = otherIndex;
  127419. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  127420. faceAdjacencies.edgesConnectedCount++;
  127421. otherFaceAdjacencies.edgesConnectedCount++;
  127422. if (faceAdjacencies.edgesConnectedCount === 3) {
  127423. break;
  127424. }
  127425. }
  127426. }
  127427. }
  127428. // Create lines
  127429. for (index = 0; index < adjacencies.length; index++) {
  127430. // 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
  127431. var current = adjacencies[index];
  127432. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  127433. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  127434. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  127435. }
  127436. // Merge into a single mesh
  127437. var engine = this._source.getScene().getEngine();
  127438. 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);
  127439. 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);
  127440. this._ib = engine.createIndexBuffer(this._linesIndices);
  127441. this._indicesCount = this._linesIndices.length;
  127442. };
  127443. /**
  127444. * Checks wether or not the edges renderer is ready to render.
  127445. * @return true if ready, otherwise false.
  127446. */
  127447. EdgesRenderer.prototype.isReady = function () {
  127448. return this._lineShader.isReady();
  127449. };
  127450. /**
  127451. * Renders the edges of the attached mesh,
  127452. */
  127453. EdgesRenderer.prototype.render = function () {
  127454. var scene = this._source.getScene();
  127455. if (!this.isReady() || !scene.activeCamera) {
  127456. return;
  127457. }
  127458. var engine = scene.getEngine();
  127459. this._lineShader._preBind();
  127460. if (this._source.edgesColor.a !== 1) {
  127461. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  127462. }
  127463. else {
  127464. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  127465. }
  127466. // VBOs
  127467. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  127468. scene.resetCachedMaterial();
  127469. this._lineShader.setColor4("color", this._source.edgesColor);
  127470. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  127471. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  127472. }
  127473. else {
  127474. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  127475. }
  127476. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  127477. this._lineShader.bind(this._source.getWorldMatrix());
  127478. // Draw order
  127479. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  127480. this._lineShader.unbind();
  127481. };
  127482. return EdgesRenderer;
  127483. }());
  127484. /**
  127485. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  127486. */
  127487. var LineEdgesRenderer = /** @class */ (function (_super) {
  127488. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  127489. /**
  127490. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  127491. * @param source LineMesh used to generate edges
  127492. * @param epsilon not important (specified angle for edge detection)
  127493. * @param checkVerticesInsteadOfIndices not important for LineMesh
  127494. */
  127495. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  127496. if (epsilon === void 0) { epsilon = 0.95; }
  127497. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  127498. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  127499. _this._generateEdgesLines();
  127500. return _this;
  127501. }
  127502. /**
  127503. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  127504. */
  127505. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  127506. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  127507. var indices = this._source.getIndices();
  127508. if (!indices || !positions) {
  127509. return;
  127510. }
  127511. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  127512. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  127513. var len = indices.length - 1;
  127514. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  127515. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  127516. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  127517. this.createLine(p0, p1, offset);
  127518. }
  127519. // Merge into a single mesh
  127520. var engine = this._source.getScene().getEngine();
  127521. 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);
  127522. 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);
  127523. this._ib = engine.createIndexBuffer(this._linesIndices);
  127524. this._indicesCount = this._linesIndices.length;
  127525. };
  127526. return LineEdgesRenderer;
  127527. }(EdgesRenderer));
  127528. /***/ }),
  127529. /***/ "./Rendering/geometryBufferRenderer.ts":
  127530. /*!*********************************************!*\
  127531. !*** ./Rendering/geometryBufferRenderer.ts ***!
  127532. \*********************************************/
  127533. /*! exports provided: GeometryBufferRenderer */
  127534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127535. "use strict";
  127536. __webpack_require__.r(__webpack_exports__);
  127537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  127538. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127539. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127540. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127541. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  127542. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  127543. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  127544. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  127545. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  127546. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  127547. /**
  127548. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127549. */
  127550. var GeometryBufferRenderer = /** @class */ (function () {
  127551. /**
  127552. * Creates a new G Buffer for the scene
  127553. * @param scene The scene the buffer belongs to
  127554. * @param ratio How big is the buffer related to the main canvas.
  127555. */
  127556. function GeometryBufferRenderer(scene, ratio) {
  127557. if (ratio === void 0) { ratio = 1; }
  127558. /**
  127559. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127560. * in order to compute objects velocities when enableVelocity is set to "true"
  127561. * @hidden
  127562. */
  127563. this._previousTransformationMatrices = {};
  127564. this._enablePosition = false;
  127565. this._enableVelocity = false;
  127566. this._positionIndex = -1;
  127567. this._velocityIndex = -1;
  127568. this._scene = scene;
  127569. this._ratio = ratio;
  127570. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  127571. // Render target
  127572. this._createRenderTargets();
  127573. }
  127574. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  127575. /**
  127576. * Set the render list (meshes to be rendered) used in the G buffer.
  127577. */
  127578. set: function (meshes) {
  127579. this._multiRenderTarget.renderList = meshes;
  127580. },
  127581. enumerable: true,
  127582. configurable: true
  127583. });
  127584. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  127585. /**
  127586. * Gets wether or not G buffer are supported by the running hardware.
  127587. * This requires draw buffer supports
  127588. */
  127589. get: function () {
  127590. return this._multiRenderTarget.isSupported;
  127591. },
  127592. enumerable: true,
  127593. configurable: true
  127594. });
  127595. /**
  127596. * Returns the index of the given texture type in the G-Buffer textures array
  127597. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127598. * @returns the index of the given texture type in the G-Buffer textures array
  127599. */
  127600. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  127601. switch (textureType) {
  127602. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  127603. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  127604. default: return -1;
  127605. }
  127606. };
  127607. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  127608. /**
  127609. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127610. */
  127611. get: function () {
  127612. return this._enablePosition;
  127613. },
  127614. /**
  127615. * Sets whether or not objects positions are enabled for the G buffer.
  127616. */
  127617. set: function (enable) {
  127618. this._enablePosition = enable;
  127619. this.dispose();
  127620. this._createRenderTargets();
  127621. },
  127622. enumerable: true,
  127623. configurable: true
  127624. });
  127625. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  127626. /**
  127627. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127628. */
  127629. get: function () {
  127630. return this._enableVelocity;
  127631. },
  127632. /**
  127633. * Sets wether or not objects velocities are enabled for the G buffer.
  127634. */
  127635. set: function (enable) {
  127636. this._enableVelocity = enable;
  127637. this.dispose();
  127638. this._createRenderTargets();
  127639. },
  127640. enumerable: true,
  127641. configurable: true
  127642. });
  127643. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  127644. /**
  127645. * Gets the scene associated with the buffer.
  127646. */
  127647. get: function () {
  127648. return this._scene;
  127649. },
  127650. enumerable: true,
  127651. configurable: true
  127652. });
  127653. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  127654. /**
  127655. * Gets the ratio used by the buffer during its creation.
  127656. * How big is the buffer related to the main canvas.
  127657. */
  127658. get: function () {
  127659. return this._ratio;
  127660. },
  127661. enumerable: true,
  127662. configurable: true
  127663. });
  127664. /**
  127665. * Checks wether everything is ready to render a submesh to the G buffer.
  127666. * @param subMesh the submesh to check readiness for
  127667. * @param useInstances is the mesh drawn using instance or not
  127668. * @returns true if ready otherwise false
  127669. */
  127670. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  127671. var material = subMesh.getMaterial();
  127672. if (material && material.disableDepthWrite) {
  127673. return false;
  127674. }
  127675. var defines = [];
  127676. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  127677. var mesh = subMesh.getMesh();
  127678. // Alpha test
  127679. if (material && material.needAlphaTesting()) {
  127680. defines.push("#define ALPHATEST");
  127681. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  127682. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  127683. defines.push("#define UV1");
  127684. }
  127685. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  127686. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  127687. defines.push("#define UV2");
  127688. }
  127689. }
  127690. // Buffers
  127691. if (this._enablePosition) {
  127692. defines.push("#define POSITION");
  127693. defines.push("#define POSITION_INDEX " + this._positionIndex);
  127694. }
  127695. if (this._enableVelocity) {
  127696. defines.push("#define VELOCITY");
  127697. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  127698. }
  127699. // Bones
  127700. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  127701. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  127702. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  127703. if (mesh.numBoneInfluencers > 4) {
  127704. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  127705. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  127706. }
  127707. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  127708. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  127709. }
  127710. else {
  127711. defines.push("#define NUM_BONE_INFLUENCERS 0");
  127712. }
  127713. // Instances
  127714. if (useInstances) {
  127715. defines.push("#define INSTANCES");
  127716. attribs.push("world0");
  127717. attribs.push("world1");
  127718. attribs.push("world2");
  127719. attribs.push("world3");
  127720. }
  127721. // Setup textures count
  127722. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  127723. // Get correct effect
  127724. var join = defines.join("\n");
  127725. if (this._cachedDefines !== join) {
  127726. this._cachedDefines = join;
  127727. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  127728. }
  127729. return this._effect.isReady();
  127730. };
  127731. /**
  127732. * Gets the current underlying G Buffer.
  127733. * @returns the buffer
  127734. */
  127735. GeometryBufferRenderer.prototype.getGBuffer = function () {
  127736. return this._multiRenderTarget;
  127737. };
  127738. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  127739. /**
  127740. * Gets the number of samples used to render the buffer (anti aliasing).
  127741. */
  127742. get: function () {
  127743. return this._multiRenderTarget.samples;
  127744. },
  127745. /**
  127746. * Sets the number of samples used to render the buffer (anti aliasing).
  127747. */
  127748. set: function (value) {
  127749. this._multiRenderTarget.samples = value;
  127750. },
  127751. enumerable: true,
  127752. configurable: true
  127753. });
  127754. /**
  127755. * Disposes the renderer and frees up associated resources.
  127756. */
  127757. GeometryBufferRenderer.prototype.dispose = function () {
  127758. this.getGBuffer().dispose();
  127759. };
  127760. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  127761. var _this = this;
  127762. var engine = this._scene.getEngine();
  127763. var count = 2;
  127764. if (this._enablePosition) {
  127765. this._positionIndex = count;
  127766. count++;
  127767. }
  127768. if (this._enableVelocity) {
  127769. this._velocityIndex = count;
  127770. count++;
  127771. }
  127772. 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 });
  127773. if (!this.isSupported) {
  127774. return;
  127775. }
  127776. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  127777. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  127778. this._multiRenderTarget.refreshRate = 1;
  127779. this._multiRenderTarget.renderParticles = false;
  127780. this._multiRenderTarget.renderList = null;
  127781. // set default depth value to 1.0 (far away)
  127782. this._multiRenderTarget.onClearObservable.add(function (engine) {
  127783. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  127784. });
  127785. // Custom render function
  127786. var renderSubMesh = function (subMesh) {
  127787. var mesh = subMesh.getRenderingMesh();
  127788. var scene = _this._scene;
  127789. var engine = scene.getEngine();
  127790. var material = subMesh.getMaterial();
  127791. if (!material) {
  127792. return;
  127793. }
  127794. // Velocity
  127795. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  127796. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  127797. }
  127798. // Culling
  127799. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  127800. // Managing instances
  127801. var batch = mesh._getInstancesRenderList(subMesh._id);
  127802. if (batch.mustReturn) {
  127803. return;
  127804. }
  127805. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  127806. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  127807. engine.enableEffect(_this._effect);
  127808. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  127809. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  127810. _this._effect.setMatrix("view", scene.getViewMatrix());
  127811. // Alpha test
  127812. if (material && material.needAlphaTesting()) {
  127813. var alphaTexture = material.getAlphaTestTexture();
  127814. if (alphaTexture) {
  127815. _this._effect.setTexture("diffuseSampler", alphaTexture);
  127816. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  127817. }
  127818. }
  127819. // Bones
  127820. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  127821. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  127822. }
  127823. // Velocity
  127824. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  127825. // Draw
  127826. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  127827. }
  127828. // Velocity
  127829. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  127830. };
  127831. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  127832. var index;
  127833. if (depthOnlySubMeshes.length) {
  127834. engine.setColorWrite(false);
  127835. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  127836. renderSubMesh(depthOnlySubMeshes.data[index]);
  127837. }
  127838. engine.setColorWrite(true);
  127839. }
  127840. for (index = 0; index < opaqueSubMeshes.length; index++) {
  127841. renderSubMesh(opaqueSubMeshes.data[index]);
  127842. }
  127843. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  127844. renderSubMesh(alphaTestSubMeshes.data[index]);
  127845. }
  127846. };
  127847. };
  127848. /**
  127849. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127850. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127851. */
  127852. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  127853. /**
  127854. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127855. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127856. */
  127857. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  127858. /** @hidden */
  127859. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  127860. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  127861. };
  127862. return GeometryBufferRenderer;
  127863. }());
  127864. /***/ }),
  127865. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  127866. /*!***********************************************************!*\
  127867. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  127868. \***********************************************************/
  127869. /*! exports provided: GeometryBufferRendererSceneComponent */
  127870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127871. "use strict";
  127872. __webpack_require__.r(__webpack_exports__);
  127873. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  127874. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127875. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  127876. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  127877. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  127878. get: function () {
  127879. this._geometryBufferRenderer;
  127880. },
  127881. set: function (value) {
  127882. if (value && value.isSupported) {
  127883. this._geometryBufferRenderer = value;
  127884. }
  127885. },
  127886. enumerable: true,
  127887. configurable: true
  127888. });
  127889. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  127890. if (ratio === void 0) { ratio = 1; }
  127891. if (this._geometryBufferRenderer) {
  127892. return this._geometryBufferRenderer;
  127893. }
  127894. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  127895. if (!this._geometryBufferRenderer.isSupported) {
  127896. this._geometryBufferRenderer = null;
  127897. }
  127898. return this._geometryBufferRenderer;
  127899. };
  127900. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  127901. if (!this._geometryBufferRenderer) {
  127902. return;
  127903. }
  127904. this._geometryBufferRenderer.dispose();
  127905. this._geometryBufferRenderer = null;
  127906. };
  127907. /**
  127908. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127909. * in several rendering techniques.
  127910. */
  127911. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  127912. /**
  127913. * Creates a new instance of the component for the given scene
  127914. * @param scene Defines the scene to register the component in
  127915. */
  127916. function GeometryBufferRendererSceneComponent(scene) {
  127917. /**
  127918. * The component name helpful to identify the component in the list of scene components.
  127919. */
  127920. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  127921. this.scene = scene;
  127922. }
  127923. /**
  127924. * Registers the component in a given scene
  127925. */
  127926. GeometryBufferRendererSceneComponent.prototype.register = function () {
  127927. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  127928. };
  127929. /**
  127930. * Rebuilds the elements related to this component in case of
  127931. * context lost for instance.
  127932. */
  127933. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  127934. // Nothing to do for this component
  127935. };
  127936. /**
  127937. * Disposes the component and the associated ressources
  127938. */
  127939. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  127940. // Nothing to do for this component
  127941. };
  127942. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  127943. if (this.scene._geometryBufferRenderer) {
  127944. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  127945. }
  127946. };
  127947. return GeometryBufferRendererSceneComponent;
  127948. }());
  127949. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  127950. // Register the G Buffer component to the scene.
  127951. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  127952. if (!component) {
  127953. component = new GeometryBufferRendererSceneComponent(scene);
  127954. scene._addComponent(component);
  127955. }
  127956. };
  127957. /***/ }),
  127958. /***/ "./Rendering/index.ts":
  127959. /*!****************************!*\
  127960. !*** ./Rendering/index.ts ***!
  127961. \****************************/
  127962. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  127963. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127964. "use strict";
  127965. __webpack_require__.r(__webpack_exports__);
  127966. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  127967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  127968. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  127969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  127970. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  127971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  127972. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  127973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  127974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  127975. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  127976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  127977. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  127978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  127979. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  127980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  127981. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  127982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  127983. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  127984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  127985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  127986. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  127987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  127988. /***/ }),
  127989. /***/ "./Rendering/outlineRenderer.ts":
  127990. /*!**************************************!*\
  127991. !*** ./Rendering/outlineRenderer.ts ***!
  127992. \**************************************/
  127993. /*! exports provided: OutlineRenderer */
  127994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127995. "use strict";
  127996. __webpack_require__.r(__webpack_exports__);
  127997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  127998. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127999. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  128000. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  128001. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  128002. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  128003. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  128004. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  128005. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  128006. /**
  128007. * Gets the outline renderer associated with the scene
  128008. * @returns a OutlineRenderer
  128009. */
  128010. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  128011. if (!this._outlineRenderer) {
  128012. this._outlineRenderer = new OutlineRenderer(this);
  128013. }
  128014. return this._outlineRenderer;
  128015. };
  128016. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  128017. get: function () {
  128018. return this._renderOutline;
  128019. },
  128020. set: function (value) {
  128021. if (value) {
  128022. // Lazy Load the component.
  128023. this.getScene().getOutlineRenderer();
  128024. }
  128025. this._renderOutline = value;
  128026. },
  128027. enumerable: true,
  128028. configurable: true
  128029. });
  128030. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  128031. get: function () {
  128032. return this._renderOverlay;
  128033. },
  128034. set: function (value) {
  128035. if (value) {
  128036. // Lazy Load the component.
  128037. this.getScene().getOutlineRenderer();
  128038. }
  128039. this._renderOverlay = value;
  128040. },
  128041. enumerable: true,
  128042. configurable: true
  128043. });
  128044. /**
  128045. * This class is responsible to draw bothe outline/overlay of meshes.
  128046. * It should not be used directly but through the available method on mesh.
  128047. */
  128048. var OutlineRenderer = /** @class */ (function () {
  128049. /**
  128050. * Instantiates a new outline renderer. (There could be only one per scene).
  128051. * @param scene Defines the scene it belongs to
  128052. */
  128053. function OutlineRenderer(scene) {
  128054. /**
  128055. * The name of the component. Each component must have a unique name.
  128056. */
  128057. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  128058. /**
  128059. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128060. */
  128061. this.zOffset = 1;
  128062. this.scene = scene;
  128063. this._engine = scene.getEngine();
  128064. this.scene._addComponent(this);
  128065. }
  128066. /**
  128067. * Register the component to one instance of a scene.
  128068. */
  128069. OutlineRenderer.prototype.register = function () {
  128070. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  128071. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  128072. };
  128073. /**
  128074. * Rebuilds the elements related to this component in case of
  128075. * context lost for instance.
  128076. */
  128077. OutlineRenderer.prototype.rebuild = function () {
  128078. // Nothing to do here.
  128079. };
  128080. /**
  128081. * Disposes the component and the associated ressources.
  128082. */
  128083. OutlineRenderer.prototype.dispose = function () {
  128084. // Nothing to do here.
  128085. };
  128086. /**
  128087. * Renders the outline in the canvas.
  128088. * @param subMesh Defines the sumesh to render
  128089. * @param batch Defines the batch of meshes in case of instances
  128090. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128091. */
  128092. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  128093. var _this = this;
  128094. if (useOverlay === void 0) { useOverlay = false; }
  128095. var scene = this.scene;
  128096. var engine = scene.getEngine();
  128097. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  128098. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  128099. return;
  128100. }
  128101. var mesh = subMesh.getRenderingMesh();
  128102. var material = subMesh.getMaterial();
  128103. if (!material || !scene.activeCamera) {
  128104. return;
  128105. }
  128106. engine.enableEffect(this._effect);
  128107. // Logarithmic depth
  128108. if (material.useLogarithmicDepth) {
  128109. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  128110. }
  128111. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  128112. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  128113. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  128114. // Bones
  128115. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  128116. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  128117. }
  128118. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  128119. // Alpha test
  128120. if (material && material.needAlphaTesting()) {
  128121. var alphaTexture = material.getAlphaTestTexture();
  128122. if (alphaTexture) {
  128123. this._effect.setTexture("diffuseSampler", alphaTexture);
  128124. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  128125. }
  128126. }
  128127. engine.setZOffset(-this.zOffset);
  128128. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  128129. engine.setZOffset(0);
  128130. };
  128131. /**
  128132. * Returns whether or not the outline renderer is ready for a given submesh.
  128133. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128134. * @param subMesh Defines the submesh to check readyness for
  128135. * @param useInstances Defines wheter wee are trying to render instances or not
  128136. * @returns true if ready otherwise false
  128137. */
  128138. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  128139. var defines = [];
  128140. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  128141. var mesh = subMesh.getMesh();
  128142. var material = subMesh.getMaterial();
  128143. if (material) {
  128144. // Alpha test
  128145. if (material.needAlphaTesting()) {
  128146. defines.push("#define ALPHATEST");
  128147. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  128148. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  128149. defines.push("#define UV1");
  128150. }
  128151. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  128152. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  128153. defines.push("#define UV2");
  128154. }
  128155. }
  128156. //Logarithmic depth
  128157. if (material.useLogarithmicDepth) {
  128158. defines.push("#define LOGARITHMICDEPTH");
  128159. }
  128160. }
  128161. // Bones
  128162. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  128163. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  128164. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  128165. if (mesh.numBoneInfluencers > 4) {
  128166. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  128167. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  128168. }
  128169. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  128170. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  128171. }
  128172. else {
  128173. defines.push("#define NUM_BONE_INFLUENCERS 0");
  128174. }
  128175. // Instances
  128176. if (useInstances) {
  128177. defines.push("#define INSTANCES");
  128178. attribs.push("world0");
  128179. attribs.push("world1");
  128180. attribs.push("world2");
  128181. attribs.push("world3");
  128182. }
  128183. // Get correct effect
  128184. var join = defines.join("\n");
  128185. if (this._cachedDefines !== join) {
  128186. this._cachedDefines = join;
  128187. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  128188. }
  128189. return this._effect.isReady();
  128190. };
  128191. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  128192. // Outline - step 1
  128193. this._savedDepthWrite = this._engine.getDepthWrite();
  128194. if (mesh.renderOutline) {
  128195. var material = subMesh.getMaterial();
  128196. if (material && material.needAlphaBlending) {
  128197. this._engine.cacheStencilState();
  128198. // Draw only to stencil buffer for the original mesh
  128199. // The resulting stencil buffer will be used so the outline is not visible inside the mesh when the mesh is transparent
  128200. this._engine.setDepthWrite(false);
  128201. this._engine.setColorWrite(false);
  128202. this._engine.setStencilBuffer(true);
  128203. this._engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].REPLACE);
  128204. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALWAYS);
  128205. this._engine.setStencilMask(OutlineRenderer._StencilReference);
  128206. this._engine.setStencilFunctionReference(OutlineRenderer._StencilReference);
  128207. this.render(subMesh, batch, /* This sets offset to 0 */ true);
  128208. this._engine.setColorWrite(true);
  128209. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].NOTEQUAL);
  128210. }
  128211. // Draw the outline using the above stencil if needed to avoid drawing within the mesh
  128212. this._engine.setDepthWrite(false);
  128213. this.render(subMesh, batch);
  128214. this._engine.setDepthWrite(this._savedDepthWrite);
  128215. if (material && material.needAlphaBlending) {
  128216. this._engine.restoreStencilState();
  128217. }
  128218. }
  128219. };
  128220. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  128221. // Outline - step 2
  128222. if (mesh.renderOutline && this._savedDepthWrite) {
  128223. this._engine.setDepthWrite(true);
  128224. this._engine.setColorWrite(false);
  128225. this.render(subMesh, batch);
  128226. this._engine.setColorWrite(true);
  128227. }
  128228. // Overlay
  128229. if (mesh.renderOverlay) {
  128230. var currentMode = this._engine.getAlphaMode();
  128231. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  128232. this.render(subMesh, batch, true);
  128233. this._engine.setAlphaMode(currentMode);
  128234. }
  128235. };
  128236. /**
  128237. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128238. */
  128239. OutlineRenderer._StencilReference = 0x04;
  128240. return OutlineRenderer;
  128241. }());
  128242. /***/ }),
  128243. /***/ "./Rendering/renderingGroup.ts":
  128244. /*!*************************************!*\
  128245. !*** ./Rendering/renderingGroup.ts ***!
  128246. \*************************************/
  128247. /*! exports provided: RenderingGroup */
  128248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128249. "use strict";
  128250. __webpack_require__.r(__webpack_exports__);
  128251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  128252. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  128253. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  128254. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  128255. /**
  128256. * This represents the object necessary to create a rendering group.
  128257. * This is exclusively used and created by the rendering manager.
  128258. * To modify the behavior, you use the available helpers in your scene or meshes.
  128259. * @hidden
  128260. */
  128261. var RenderingGroup = /** @class */ (function () {
  128262. /**
  128263. * Creates a new rendering group.
  128264. * @param index The rendering group index
  128265. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  128266. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  128267. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  128268. */
  128269. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  128270. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  128271. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  128272. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  128273. this.index = index;
  128274. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  128275. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  128276. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  128277. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  128278. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  128279. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  128280. /** @hidden */
  128281. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  128282. this._scene = scene;
  128283. this.opaqueSortCompareFn = opaqueSortCompareFn;
  128284. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  128285. this.transparentSortCompareFn = transparentSortCompareFn;
  128286. }
  128287. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  128288. /**
  128289. * Set the opaque sort comparison function.
  128290. * If null the sub meshes will be render in the order they were created
  128291. */
  128292. set: function (value) {
  128293. this._opaqueSortCompareFn = value;
  128294. if (value) {
  128295. this._renderOpaque = this.renderOpaqueSorted;
  128296. }
  128297. else {
  128298. this._renderOpaque = RenderingGroup.renderUnsorted;
  128299. }
  128300. },
  128301. enumerable: true,
  128302. configurable: true
  128303. });
  128304. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  128305. /**
  128306. * Set the alpha test sort comparison function.
  128307. * If null the sub meshes will be render in the order they were created
  128308. */
  128309. set: function (value) {
  128310. this._alphaTestSortCompareFn = value;
  128311. if (value) {
  128312. this._renderAlphaTest = this.renderAlphaTestSorted;
  128313. }
  128314. else {
  128315. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  128316. }
  128317. },
  128318. enumerable: true,
  128319. configurable: true
  128320. });
  128321. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  128322. /**
  128323. * Set the transparent sort comparison function.
  128324. * If null the sub meshes will be render in the order they were created
  128325. */
  128326. set: function (value) {
  128327. if (value) {
  128328. this._transparentSortCompareFn = value;
  128329. }
  128330. else {
  128331. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  128332. }
  128333. this._renderTransparent = this.renderTransparentSorted;
  128334. },
  128335. enumerable: true,
  128336. configurable: true
  128337. });
  128338. /**
  128339. * Render all the sub meshes contained in the group.
  128340. * @param customRenderFunction Used to override the default render behaviour of the group.
  128341. * @returns true if rendered some submeshes.
  128342. */
  128343. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  128344. if (customRenderFunction) {
  128345. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  128346. return;
  128347. }
  128348. var engine = this._scene.getEngine();
  128349. // Depth only
  128350. if (this._depthOnlySubMeshes.length !== 0) {
  128351. engine.setColorWrite(false);
  128352. this._renderAlphaTest(this._depthOnlySubMeshes);
  128353. engine.setColorWrite(true);
  128354. }
  128355. // Opaque
  128356. if (this._opaqueSubMeshes.length !== 0) {
  128357. this._renderOpaque(this._opaqueSubMeshes);
  128358. }
  128359. // Alpha test
  128360. if (this._alphaTestSubMeshes.length !== 0) {
  128361. this._renderAlphaTest(this._alphaTestSubMeshes);
  128362. }
  128363. var stencilState = engine.getStencilBuffer();
  128364. engine.setStencilBuffer(false);
  128365. // Sprites
  128366. if (renderSprites) {
  128367. this._renderSprites();
  128368. }
  128369. // Particles
  128370. if (renderParticles) {
  128371. this._renderParticles(activeMeshes);
  128372. }
  128373. if (this.onBeforeTransparentRendering) {
  128374. this.onBeforeTransparentRendering();
  128375. }
  128376. // Transparent
  128377. if (this._transparentSubMeshes.length !== 0) {
  128378. this._renderTransparent(this._transparentSubMeshes);
  128379. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  128380. }
  128381. // Set back stencil to false in case it changes before the edge renderer.
  128382. engine.setStencilBuffer(false);
  128383. // Edges
  128384. if (this._edgesRenderers.length) {
  128385. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  128386. this._edgesRenderers.data[edgesRendererIndex].render();
  128387. }
  128388. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  128389. }
  128390. // Restore Stencil state.
  128391. engine.setStencilBuffer(stencilState);
  128392. };
  128393. /**
  128394. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  128395. * @param subMeshes The submeshes to render
  128396. */
  128397. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  128398. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  128399. };
  128400. /**
  128401. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  128402. * @param subMeshes The submeshes to render
  128403. */
  128404. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  128405. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  128406. };
  128407. /**
  128408. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  128409. * @param subMeshes The submeshes to render
  128410. */
  128411. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  128412. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  128413. };
  128414. /**
  128415. * Renders the submeshes in a specified order.
  128416. * @param subMeshes The submeshes to sort before render
  128417. * @param sortCompareFn The comparison function use to sort
  128418. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  128419. * @param transparent Specifies to activate blending if true
  128420. */
  128421. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  128422. var subIndex = 0;
  128423. var subMesh;
  128424. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  128425. for (; subIndex < subMeshes.length; subIndex++) {
  128426. subMesh = subMeshes.data[subIndex];
  128427. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  128428. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  128429. }
  128430. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  128431. if (sortCompareFn) {
  128432. sortedArray.sort(sortCompareFn);
  128433. }
  128434. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  128435. subMesh = sortedArray[subIndex];
  128436. if (transparent) {
  128437. var material = subMesh.getMaterial();
  128438. if (material && material.needDepthPrePass) {
  128439. var engine = material.getScene().getEngine();
  128440. engine.setColorWrite(false);
  128441. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  128442. subMesh.render(false);
  128443. engine.setColorWrite(true);
  128444. }
  128445. }
  128446. subMesh.render(transparent);
  128447. }
  128448. };
  128449. /**
  128450. * Renders the submeshes in the order they were dispatched (no sort applied).
  128451. * @param subMeshes The submeshes to render
  128452. */
  128453. RenderingGroup.renderUnsorted = function (subMeshes) {
  128454. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  128455. var submesh = subMeshes.data[subIndex];
  128456. submesh.render(false);
  128457. }
  128458. };
  128459. /**
  128460. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  128461. * are rendered back to front if in the same alpha index.
  128462. *
  128463. * @param a The first submesh
  128464. * @param b The second submesh
  128465. * @returns The result of the comparison
  128466. */
  128467. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  128468. // Alpha index first
  128469. if (a._alphaIndex > b._alphaIndex) {
  128470. return 1;
  128471. }
  128472. if (a._alphaIndex < b._alphaIndex) {
  128473. return -1;
  128474. }
  128475. // Then distance to camera
  128476. return RenderingGroup.backToFrontSortCompare(a, b);
  128477. };
  128478. /**
  128479. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  128480. * are rendered back to front.
  128481. *
  128482. * @param a The first submesh
  128483. * @param b The second submesh
  128484. * @returns The result of the comparison
  128485. */
  128486. RenderingGroup.backToFrontSortCompare = function (a, b) {
  128487. // Then distance to camera
  128488. if (a._distanceToCamera < b._distanceToCamera) {
  128489. return 1;
  128490. }
  128491. if (a._distanceToCamera > b._distanceToCamera) {
  128492. return -1;
  128493. }
  128494. return 0;
  128495. };
  128496. /**
  128497. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  128498. * are rendered front to back (prevent overdraw).
  128499. *
  128500. * @param a The first submesh
  128501. * @param b The second submesh
  128502. * @returns The result of the comparison
  128503. */
  128504. RenderingGroup.frontToBackSortCompare = function (a, b) {
  128505. // Then distance to camera
  128506. if (a._distanceToCamera < b._distanceToCamera) {
  128507. return -1;
  128508. }
  128509. if (a._distanceToCamera > b._distanceToCamera) {
  128510. return 1;
  128511. }
  128512. return 0;
  128513. };
  128514. /**
  128515. * Resets the different lists of submeshes to prepare a new frame.
  128516. */
  128517. RenderingGroup.prototype.prepare = function () {
  128518. this._opaqueSubMeshes.reset();
  128519. this._transparentSubMeshes.reset();
  128520. this._alphaTestSubMeshes.reset();
  128521. this._depthOnlySubMeshes.reset();
  128522. this._particleSystems.reset();
  128523. this._spriteManagers.reset();
  128524. this._edgesRenderers.reset();
  128525. };
  128526. RenderingGroup.prototype.dispose = function () {
  128527. this._opaqueSubMeshes.dispose();
  128528. this._transparentSubMeshes.dispose();
  128529. this._alphaTestSubMeshes.dispose();
  128530. this._depthOnlySubMeshes.dispose();
  128531. this._particleSystems.dispose();
  128532. this._spriteManagers.dispose();
  128533. this._edgesRenderers.dispose();
  128534. };
  128535. /**
  128536. * Inserts the submesh in its correct queue depending on its material.
  128537. * @param subMesh The submesh to dispatch
  128538. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  128539. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  128540. */
  128541. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  128542. // Get mesh and materials if not provided
  128543. if (mesh === undefined) {
  128544. mesh = subMesh.getMesh();
  128545. }
  128546. if (material === undefined) {
  128547. material = subMesh.getMaterial();
  128548. }
  128549. if (material === null || material === undefined) {
  128550. return;
  128551. }
  128552. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  128553. this._transparentSubMeshes.push(subMesh);
  128554. }
  128555. else if (material.needAlphaTesting()) { // Alpha test
  128556. if (material.needDepthPrePass) {
  128557. this._depthOnlySubMeshes.push(subMesh);
  128558. }
  128559. this._alphaTestSubMeshes.push(subMesh);
  128560. }
  128561. else {
  128562. if (material.needDepthPrePass) {
  128563. this._depthOnlySubMeshes.push(subMesh);
  128564. }
  128565. this._opaqueSubMeshes.push(subMesh); // Opaque
  128566. }
  128567. mesh._renderingGroup = this;
  128568. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  128569. this._edgesRenderers.push(mesh._edgesRenderer);
  128570. }
  128571. };
  128572. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  128573. this._spriteManagers.push(spriteManager);
  128574. };
  128575. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  128576. this._particleSystems.push(particleSystem);
  128577. };
  128578. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  128579. if (this._particleSystems.length === 0) {
  128580. return;
  128581. }
  128582. // Particles
  128583. var activeCamera = this._scene.activeCamera;
  128584. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  128585. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  128586. var particleSystem = this._particleSystems.data[particleIndex];
  128587. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  128588. continue;
  128589. }
  128590. var emitter = particleSystem.emitter;
  128591. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  128592. this._scene._activeParticles.addCount(particleSystem.render(), false);
  128593. }
  128594. }
  128595. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  128596. };
  128597. RenderingGroup.prototype._renderSprites = function () {
  128598. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  128599. return;
  128600. }
  128601. // Sprites
  128602. var activeCamera = this._scene.activeCamera;
  128603. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  128604. for (var id = 0; id < this._spriteManagers.length; id++) {
  128605. var spriteManager = this._spriteManagers.data[id];
  128606. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  128607. spriteManager.render();
  128608. }
  128609. }
  128610. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  128611. };
  128612. return RenderingGroup;
  128613. }());
  128614. /***/ }),
  128615. /***/ "./Rendering/renderingManager.ts":
  128616. /*!***************************************!*\
  128617. !*** ./Rendering/renderingManager.ts ***!
  128618. \***************************************/
  128619. /*! exports provided: RenderingGroupInfo, RenderingManager */
  128620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128621. "use strict";
  128622. __webpack_require__.r(__webpack_exports__);
  128623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  128624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  128625. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  128626. /**
  128627. * This class is used by the onRenderingGroupObservable
  128628. */
  128629. var RenderingGroupInfo = /** @class */ (function () {
  128630. function RenderingGroupInfo() {
  128631. }
  128632. return RenderingGroupInfo;
  128633. }());
  128634. /**
  128635. * This is the manager responsible of all the rendering for meshes sprites and particles.
  128636. * It is enable to manage the different groups as well as the different necessary sort functions.
  128637. * This should not be used directly aside of the few static configurations
  128638. */
  128639. var RenderingManager = /** @class */ (function () {
  128640. /**
  128641. * Instantiates a new rendering group for a particular scene
  128642. * @param scene Defines the scene the groups belongs to
  128643. */
  128644. function RenderingManager(scene) {
  128645. /**
  128646. * @hidden
  128647. */
  128648. this._useSceneAutoClearSetup = false;
  128649. this._renderingGroups = new Array();
  128650. this._autoClearDepthStencil = {};
  128651. this._customOpaqueSortCompareFn = {};
  128652. this._customAlphaTestSortCompareFn = {};
  128653. this._customTransparentSortCompareFn = {};
  128654. this._renderingGroupInfo = new RenderingGroupInfo();
  128655. this._scene = scene;
  128656. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  128657. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  128658. }
  128659. }
  128660. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  128661. if (depth === void 0) { depth = true; }
  128662. if (stencil === void 0) { stencil = true; }
  128663. if (this._depthStencilBufferAlreadyCleaned) {
  128664. return;
  128665. }
  128666. this._scene.getEngine().clear(null, false, depth, stencil);
  128667. this._depthStencilBufferAlreadyCleaned = true;
  128668. };
  128669. /**
  128670. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  128671. * @hidden
  128672. */
  128673. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  128674. // Update the observable context (not null as it only goes away on dispose)
  128675. var info = this._renderingGroupInfo;
  128676. info.scene = this._scene;
  128677. info.camera = this._scene.activeCamera;
  128678. // Dispatch sprites
  128679. if (this._scene.spriteManagers && renderSprites) {
  128680. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  128681. var manager = this._scene.spriteManagers[index];
  128682. this.dispatchSprites(manager);
  128683. }
  128684. }
  128685. // Render
  128686. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  128687. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  128688. var renderingGroup = this._renderingGroups[index];
  128689. if (!renderingGroup) {
  128690. continue;
  128691. }
  128692. var renderingGroupMask = Math.pow(2, index);
  128693. info.renderingGroupId = index;
  128694. // Before Observable
  128695. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  128696. // Clear depth/stencil if needed
  128697. if (RenderingManager.AUTOCLEAR) {
  128698. var autoClear = this._useSceneAutoClearSetup ?
  128699. this._scene.getAutoClearDepthStencilSetup(index) :
  128700. this._autoClearDepthStencil[index];
  128701. if (autoClear && autoClear.autoClear) {
  128702. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  128703. }
  128704. }
  128705. // Render
  128706. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  128707. var step = _a[_i];
  128708. step.action(index);
  128709. }
  128710. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  128711. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  128712. var step = _c[_b];
  128713. step.action(index);
  128714. }
  128715. // After Observable
  128716. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  128717. }
  128718. };
  128719. /**
  128720. * Resets the different information of the group to prepare a new frame
  128721. * @hidden
  128722. */
  128723. RenderingManager.prototype.reset = function () {
  128724. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  128725. var renderingGroup = this._renderingGroups[index];
  128726. if (renderingGroup) {
  128727. renderingGroup.prepare();
  128728. }
  128729. }
  128730. };
  128731. /**
  128732. * Dispose and release the group and its associated resources.
  128733. * @hidden
  128734. */
  128735. RenderingManager.prototype.dispose = function () {
  128736. this.freeRenderingGroups();
  128737. this._renderingGroups.length = 0;
  128738. this._renderingGroupInfo = null;
  128739. };
  128740. /**
  128741. * Clear the info related to rendering groups preventing retention points during dispose.
  128742. */
  128743. RenderingManager.prototype.freeRenderingGroups = function () {
  128744. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  128745. var renderingGroup = this._renderingGroups[index];
  128746. if (renderingGroup) {
  128747. renderingGroup.dispose();
  128748. }
  128749. }
  128750. };
  128751. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  128752. if (this._renderingGroups[renderingGroupId] === undefined) {
  128753. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  128754. }
  128755. };
  128756. /**
  128757. * Add a sprite manager to the rendering manager in order to render it this frame.
  128758. * @param spriteManager Define the sprite manager to render
  128759. */
  128760. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  128761. var renderingGroupId = spriteManager.renderingGroupId || 0;
  128762. this._prepareRenderingGroup(renderingGroupId);
  128763. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  128764. };
  128765. /**
  128766. * Add a particle system to the rendering manager in order to render it this frame.
  128767. * @param particleSystem Define the particle system to render
  128768. */
  128769. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  128770. var renderingGroupId = particleSystem.renderingGroupId || 0;
  128771. this._prepareRenderingGroup(renderingGroupId);
  128772. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  128773. };
  128774. /**
  128775. * Add a submesh to the manager in order to render it this frame
  128776. * @param subMesh The submesh to dispatch
  128777. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  128778. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  128779. */
  128780. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  128781. if (mesh === undefined) {
  128782. mesh = subMesh.getMesh();
  128783. }
  128784. var renderingGroupId = mesh.renderingGroupId || 0;
  128785. this._prepareRenderingGroup(renderingGroupId);
  128786. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  128787. };
  128788. /**
  128789. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  128790. * This allowed control for front to back rendering or reversly depending of the special needs.
  128791. *
  128792. * @param renderingGroupId The rendering group id corresponding to its index
  128793. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  128794. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  128795. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  128796. */
  128797. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  128798. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  128799. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  128800. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  128801. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  128802. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  128803. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  128804. if (this._renderingGroups[renderingGroupId]) {
  128805. var group = this._renderingGroups[renderingGroupId];
  128806. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  128807. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  128808. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  128809. }
  128810. };
  128811. /**
  128812. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  128813. *
  128814. * @param renderingGroupId The rendering group id corresponding to its index
  128815. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128816. * @param depth Automatically clears depth between groups if true and autoClear is true.
  128817. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  128818. */
  128819. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  128820. if (depth === void 0) { depth = true; }
  128821. if (stencil === void 0) { stencil = true; }
  128822. this._autoClearDepthStencil[renderingGroupId] = {
  128823. autoClear: autoClearDepthStencil,
  128824. depth: depth,
  128825. stencil: stencil
  128826. };
  128827. };
  128828. /**
  128829. * Gets the current auto clear configuration for one rendering group of the rendering
  128830. * manager.
  128831. * @param index the rendering group index to get the information for
  128832. * @returns The auto clear setup for the requested rendering group
  128833. */
  128834. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  128835. return this._autoClearDepthStencil[index];
  128836. };
  128837. /**
  128838. * The max id used for rendering groups (not included)
  128839. */
  128840. RenderingManager.MAX_RENDERINGGROUPS = 4;
  128841. /**
  128842. * The min id used for rendering groups (included)
  128843. */
  128844. RenderingManager.MIN_RENDERINGGROUPS = 0;
  128845. /**
  128846. * Used to globally prevent autoclearing scenes.
  128847. */
  128848. RenderingManager.AUTOCLEAR = true;
  128849. return RenderingManager;
  128850. }());
  128851. /***/ }),
  128852. /***/ "./Rendering/utilityLayerRenderer.ts":
  128853. /*!*******************************************!*\
  128854. !*** ./Rendering/utilityLayerRenderer.ts ***!
  128855. \*******************************************/
  128856. /*! exports provided: UtilityLayerRenderer */
  128857. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128858. "use strict";
  128859. __webpack_require__.r(__webpack_exports__);
  128860. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  128861. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  128862. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  128863. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  128864. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  128865. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  128866. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  128867. /**
  128868. * Renders a layer on top of an existing scene
  128869. */
  128870. var UtilityLayerRenderer = /** @class */ (function () {
  128871. /**
  128872. * Instantiates a UtilityLayerRenderer
  128873. * @param originalScene the original scene that will be rendered on top of
  128874. * @param handleEvents boolean indicating if the utility layer should handle events
  128875. */
  128876. function UtilityLayerRenderer(
  128877. /** the original scene that will be rendered on top of */
  128878. originalScene, handleEvents) {
  128879. if (handleEvents === void 0) { handleEvents = true; }
  128880. var _this = this;
  128881. this.originalScene = originalScene;
  128882. this._pointerCaptures = {};
  128883. this._lastPointerEvents = {};
  128884. this._sharedGizmoLight = null;
  128885. /**
  128886. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128887. */
  128888. this.pickUtilitySceneFirst = true;
  128889. /**
  128890. * If the utility layer should automatically be rendered on top of existing scene
  128891. */
  128892. this.shouldRender = true;
  128893. /**
  128894. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128895. */
  128896. this.onlyCheckPointerDownEvents = true;
  128897. /**
  128898. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128899. */
  128900. this.processAllEvents = false;
  128901. /**
  128902. * Observable raised when the pointer move from the utility layer scene to the main scene
  128903. */
  128904. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  128905. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  128906. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  128907. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  128908. this.utilityLayerScene._allowPostProcessClearColor = false;
  128909. originalScene.getEngine().scenes.pop();
  128910. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  128911. this.utilityLayerScene.detachControl();
  128912. if (handleEvents) {
  128913. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  128914. if (!_this.utilityLayerScene.activeCamera) {
  128915. return;
  128916. }
  128917. if (!_this.processAllEvents) {
  128918. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  128919. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  128920. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  128921. return;
  128922. }
  128923. }
  128924. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  128925. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  128926. var pointerEvent = (prePointerInfo.event);
  128927. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  128928. _this._pointerCaptures[pointerEvent.pointerId] = false;
  128929. return;
  128930. }
  128931. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  128932. if (!prePointerInfo.ray && utilityScenePick) {
  128933. prePointerInfo.ray = utilityScenePick.ray;
  128934. }
  128935. // always fire the prepointer oversvable
  128936. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  128937. // allow every non pointer down event to flow to the utility layer
  128938. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  128939. if (!prePointerInfo.skipOnPointerObservable) {
  128940. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  128941. }
  128942. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  128943. _this._pointerCaptures[pointerEvent.pointerId] = false;
  128944. }
  128945. return;
  128946. }
  128947. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  128948. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  128949. if (utilityScenePick && utilityScenePick.hit) {
  128950. if (!prePointerInfo.skipOnPointerObservable) {
  128951. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  128952. }
  128953. prePointerInfo.skipOnPointerObservable = true;
  128954. }
  128955. }
  128956. else {
  128957. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  128958. var pointerEvent_1 = (prePointerInfo.event);
  128959. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  128960. if (originalScenePick && utilityScenePick) {
  128961. // No pick in utility scene
  128962. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  128963. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  128964. // We touched an utility mesh present in the main scene
  128965. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  128966. prePointerInfo.skipOnPointerObservable = true;
  128967. }
  128968. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  128969. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  128970. }
  128971. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  128972. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  128973. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  128974. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  128975. }
  128976. }
  128977. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  128978. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  128979. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  128980. // If a previous utility layer set this, do not unset this
  128981. if (!prePointerInfo.skipOnPointerObservable) {
  128982. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  128983. }
  128984. }
  128985. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  128986. // We have a pick in both scenes but main is closer than utility
  128987. // We touched an utility mesh present in the main scene
  128988. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  128989. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  128990. prePointerInfo.skipOnPointerObservable = true;
  128991. }
  128992. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  128993. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  128994. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  128995. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  128996. }
  128997. }
  128998. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  128999. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  129000. }
  129001. }
  129002. }
  129003. });
  129004. // As a newly added utility layer will be rendered over the screen last, it's pointer events should be processed first
  129005. if (this._originalPointerObserver) {
  129006. originalScene.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver);
  129007. }
  129008. }
  129009. // Render directly on top of existing scene without clearing
  129010. this.utilityLayerScene.autoClear = false;
  129011. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  129012. if (_this.shouldRender) {
  129013. _this.render();
  129014. }
  129015. });
  129016. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  129017. _this.dispose();
  129018. });
  129019. this._updateCamera();
  129020. }
  129021. /**
  129022. * @hidden
  129023. * Light which used by gizmos to get light shading
  129024. */
  129025. UtilityLayerRenderer.prototype._getSharedGizmoLight = function () {
  129026. if (!this._sharedGizmoLight) {
  129027. 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);
  129028. this._sharedGizmoLight.intensity = 2;
  129029. this._sharedGizmoLight.groundColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].Gray();
  129030. }
  129031. return this._sharedGizmoLight;
  129032. };
  129033. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  129034. /**
  129035. * 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)
  129036. */
  129037. get: function () {
  129038. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  129039. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  129040. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  129041. UtilityLayerRenderer._DefaultUtilityLayer = null;
  129042. });
  129043. }
  129044. return UtilityLayerRenderer._DefaultUtilityLayer;
  129045. },
  129046. enumerable: true,
  129047. configurable: true
  129048. });
  129049. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  129050. /**
  129051. * 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)
  129052. */
  129053. get: function () {
  129054. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  129055. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  129056. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  129057. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  129058. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  129059. });
  129060. }
  129061. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  129062. },
  129063. enumerable: true,
  129064. configurable: true
  129065. });
  129066. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  129067. if (!prePointerInfo.skipOnPointerObservable) {
  129068. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  129069. this._lastPointerEvents[pointerEvent.pointerId] = true;
  129070. }
  129071. };
  129072. /**
  129073. * Renders the utility layers scene on top of the original scene
  129074. */
  129075. UtilityLayerRenderer.prototype.render = function () {
  129076. this._updateCamera();
  129077. if (this.utilityLayerScene.activeCamera) {
  129078. // Set the camera's scene to utility layers scene
  129079. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  129080. var camera = this.utilityLayerScene.activeCamera;
  129081. camera._scene = this.utilityLayerScene;
  129082. if (camera.leftCamera) {
  129083. camera.leftCamera._scene = this.utilityLayerScene;
  129084. }
  129085. if (camera.rightCamera) {
  129086. camera.rightCamera._scene = this.utilityLayerScene;
  129087. }
  129088. this.utilityLayerScene.render(false);
  129089. // Reset camera's scene back to original
  129090. camera._scene = oldScene;
  129091. if (camera.leftCamera) {
  129092. camera.leftCamera._scene = oldScene;
  129093. }
  129094. if (camera.rightCamera) {
  129095. camera.rightCamera._scene = oldScene;
  129096. }
  129097. }
  129098. };
  129099. /**
  129100. * Disposes of the renderer
  129101. */
  129102. UtilityLayerRenderer.prototype.dispose = function () {
  129103. this.onPointerOutObservable.clear();
  129104. if (this._afterRenderObserver) {
  129105. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  129106. }
  129107. if (this._sceneDisposeObserver) {
  129108. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  129109. }
  129110. if (this._originalPointerObserver) {
  129111. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  129112. }
  129113. this.utilityLayerScene.dispose();
  129114. };
  129115. UtilityLayerRenderer.prototype._updateCamera = function () {
  129116. if (this.originalScene.activeCameras.length > 1) {
  129117. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  129118. }
  129119. else {
  129120. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  129121. }
  129122. };
  129123. UtilityLayerRenderer._DefaultUtilityLayer = null;
  129124. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  129125. return UtilityLayerRenderer;
  129126. }());
  129127. /***/ }),
  129128. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  129129. /*!*****************************************************************!*\
  129130. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  129131. \*****************************************************************/
  129132. /*! exports provided: backgroundFragmentDeclaration */
  129133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129134. "use strict";
  129135. __webpack_require__.r(__webpack_exports__);
  129136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  129137. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129138. var name = 'backgroundFragmentDeclaration';
  129139. 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";
  129140. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129141. /** @hidden */
  129142. var backgroundFragmentDeclaration = { name: name, shader: shader };
  129143. /***/ }),
  129144. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  129145. /*!************************************************************!*\
  129146. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  129147. \************************************************************/
  129148. /*! exports provided: backgroundUboDeclaration */
  129149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129150. "use strict";
  129151. __webpack_require__.r(__webpack_exports__);
  129152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  129153. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129154. var name = 'backgroundUboDeclaration';
  129155. 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};";
  129156. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129157. /** @hidden */
  129158. var backgroundUboDeclaration = { name: name, shader: shader };
  129159. /***/ }),
  129160. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  129161. /*!***************************************************************!*\
  129162. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  129163. \***************************************************************/
  129164. /*! exports provided: backgroundVertexDeclaration */
  129165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129166. "use strict";
  129167. __webpack_require__.r(__webpack_exports__);
  129168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  129169. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129170. var name = 'backgroundVertexDeclaration';
  129171. 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";
  129172. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129173. /** @hidden */
  129174. var backgroundVertexDeclaration = { name: name, shader: shader };
  129175. /***/ }),
  129176. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  129177. /*!****************************************************!*\
  129178. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  129179. \****************************************************/
  129180. /*! exports provided: bonesDeclaration */
  129181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129182. "use strict";
  129183. __webpack_require__.r(__webpack_exports__);
  129184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  129185. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129186. var name = 'bonesDeclaration';
  129187. 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";
  129188. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129189. /** @hidden */
  129190. var bonesDeclaration = { name: name, shader: shader };
  129191. /***/ }),
  129192. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  129193. /*!***********************************************!*\
  129194. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  129195. \***********************************************/
  129196. /*! exports provided: bonesVertex */
  129197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129198. "use strict";
  129199. __webpack_require__.r(__webpack_exports__);
  129200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  129201. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129202. var name = 'bonesVertex';
  129203. 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";
  129204. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129205. /** @hidden */
  129206. var bonesVertex = { name: name, shader: shader };
  129207. /***/ }),
  129208. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  129209. /*!************************************************!*\
  129210. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  129211. \************************************************/
  129212. /*! exports provided: bumpFragment */
  129213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129214. "use strict";
  129215. __webpack_require__.r(__webpack_exports__);
  129216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  129217. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129218. var name = 'bumpFragment';
  129219. 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";
  129220. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129221. /** @hidden */
  129222. var bumpFragment = { name: name, shader: shader };
  129223. /***/ }),
  129224. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  129225. /*!*********************************************************!*\
  129226. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  129227. \*********************************************************/
  129228. /*! exports provided: bumpFragmentFunctions */
  129229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129230. "use strict";
  129231. __webpack_require__.r(__webpack_exports__);
  129232. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  129233. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129234. var name = 'bumpFragmentFunctions';
  129235. 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";
  129236. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129237. /** @hidden */
  129238. var bumpFragmentFunctions = { name: name, shader: shader };
  129239. /***/ }),
  129240. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  129241. /*!**********************************************!*\
  129242. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  129243. \**********************************************/
  129244. /*! exports provided: bumpVertex */
  129245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129246. "use strict";
  129247. __webpack_require__.r(__webpack_exports__);
  129248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  129249. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129250. var name = 'bumpVertex';
  129251. 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";
  129252. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129253. /** @hidden */
  129254. var bumpVertex = { name: name, shader: shader };
  129255. /***/ }),
  129256. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  129257. /*!*********************************************************!*\
  129258. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  129259. \*********************************************************/
  129260. /*! exports provided: bumpVertexDeclaration */
  129261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129262. "use strict";
  129263. __webpack_require__.r(__webpack_exports__);
  129264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  129265. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129266. var name = 'bumpVertexDeclaration';
  129267. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  129268. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129269. /** @hidden */
  129270. var bumpVertexDeclaration = { name: name, shader: shader };
  129271. /***/ }),
  129272. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  129273. /*!*****************************************************!*\
  129274. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  129275. \*****************************************************/
  129276. /*! exports provided: clipPlaneFragment */
  129277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129278. "use strict";
  129279. __webpack_require__.r(__webpack_exports__);
  129280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  129281. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129282. var name = 'clipPlaneFragment';
  129283. 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";
  129284. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129285. /** @hidden */
  129286. var clipPlaneFragment = { name: name, shader: shader };
  129287. /***/ }),
  129288. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  129289. /*!****************************************************************!*\
  129290. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  129291. \****************************************************************/
  129292. /*! exports provided: clipPlaneFragmentDeclaration */
  129293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129294. "use strict";
  129295. __webpack_require__.r(__webpack_exports__);
  129296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  129297. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129298. var name = 'clipPlaneFragmentDeclaration';
  129299. 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";
  129300. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129301. /** @hidden */
  129302. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  129303. /***/ }),
  129304. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  129305. /*!*****************************************************************!*\
  129306. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  129307. \*****************************************************************/
  129308. /*! exports provided: clipPlaneFragmentDeclaration2 */
  129309. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129310. "use strict";
  129311. __webpack_require__.r(__webpack_exports__);
  129312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  129313. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129314. var name = 'clipPlaneFragmentDeclaration2';
  129315. 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";
  129316. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129317. /** @hidden */
  129318. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  129319. /***/ }),
  129320. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  129321. /*!***************************************************!*\
  129322. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  129323. \***************************************************/
  129324. /*! exports provided: clipPlaneVertex */
  129325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129326. "use strict";
  129327. __webpack_require__.r(__webpack_exports__);
  129328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  129329. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129330. var name = 'clipPlaneVertex';
  129331. 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";
  129332. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129333. /** @hidden */
  129334. var clipPlaneVertex = { name: name, shader: shader };
  129335. /***/ }),
  129336. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  129337. /*!**************************************************************!*\
  129338. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  129339. \**************************************************************/
  129340. /*! exports provided: clipPlaneVertexDeclaration */
  129341. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129342. "use strict";
  129343. __webpack_require__.r(__webpack_exports__);
  129344. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  129345. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129346. var name = 'clipPlaneVertexDeclaration';
  129347. 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";
  129348. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129349. /** @hidden */
  129350. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  129351. /***/ }),
  129352. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  129353. /*!***************************************************************!*\
  129354. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  129355. \***************************************************************/
  129356. /*! exports provided: clipPlaneVertexDeclaration2 */
  129357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129358. "use strict";
  129359. __webpack_require__.r(__webpack_exports__);
  129360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  129361. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129362. var name = 'clipPlaneVertexDeclaration2';
  129363. 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";
  129364. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129365. /** @hidden */
  129366. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  129367. /***/ }),
  129368. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  129369. /*!**************************************************************!*\
  129370. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  129371. \**************************************************************/
  129372. /*! exports provided: defaultFragmentDeclaration */
  129373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129374. "use strict";
  129375. __webpack_require__.r(__webpack_exports__);
  129376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  129377. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129378. var name = 'defaultFragmentDeclaration';
  129379. 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";
  129380. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129381. /** @hidden */
  129382. var defaultFragmentDeclaration = { name: name, shader: shader };
  129383. /***/ }),
  129384. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  129385. /*!*********************************************************!*\
  129386. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  129387. \*********************************************************/
  129388. /*! exports provided: defaultUboDeclaration */
  129389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129390. "use strict";
  129391. __webpack_require__.r(__webpack_exports__);
  129392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  129393. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129394. var name = 'defaultUboDeclaration';
  129395. 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";
  129396. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129397. /** @hidden */
  129398. var defaultUboDeclaration = { name: name, shader: shader };
  129399. /***/ }),
  129400. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  129401. /*!************************************************************!*\
  129402. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  129403. \************************************************************/
  129404. /*! exports provided: defaultVertexDeclaration */
  129405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129406. "use strict";
  129407. __webpack_require__.r(__webpack_exports__);
  129408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  129409. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129410. var name = 'defaultVertexDeclaration';
  129411. 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";
  129412. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129413. /** @hidden */
  129414. var defaultVertexDeclaration = { name: name, shader: shader };
  129415. /***/ }),
  129416. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  129417. /*!************************************************!*\
  129418. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  129419. \************************************************/
  129420. /*! exports provided: depthPrePass */
  129421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129422. "use strict";
  129423. __webpack_require__.r(__webpack_exports__);
  129424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  129425. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129426. var name = 'depthPrePass';
  129427. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  129428. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129429. /** @hidden */
  129430. var depthPrePass = { name: name, shader: shader };
  129431. /***/ }),
  129432. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  129433. /*!***********************************************!*\
  129434. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  129435. \***********************************************/
  129436. /*! exports provided: fogFragment */
  129437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129438. "use strict";
  129439. __webpack_require__.r(__webpack_exports__);
  129440. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  129441. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129442. var name = 'fogFragment';
  129443. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  129444. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129445. /** @hidden */
  129446. var fogFragment = { name: name, shader: shader };
  129447. /***/ }),
  129448. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  129449. /*!**********************************************************!*\
  129450. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  129451. \**********************************************************/
  129452. /*! exports provided: fogFragmentDeclaration */
  129453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129454. "use strict";
  129455. __webpack_require__.r(__webpack_exports__);
  129456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  129457. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129458. var name = 'fogFragmentDeclaration';
  129459. 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";
  129460. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129461. /** @hidden */
  129462. var fogFragmentDeclaration = { name: name, shader: shader };
  129463. /***/ }),
  129464. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  129465. /*!*********************************************!*\
  129466. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  129467. \*********************************************/
  129468. /*! exports provided: fogVertex */
  129469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129470. "use strict";
  129471. __webpack_require__.r(__webpack_exports__);
  129472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  129473. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129474. var name = 'fogVertex';
  129475. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  129476. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129477. /** @hidden */
  129478. var fogVertex = { name: name, shader: shader };
  129479. /***/ }),
  129480. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  129481. /*!********************************************************!*\
  129482. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  129483. \********************************************************/
  129484. /*! exports provided: fogVertexDeclaration */
  129485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129486. "use strict";
  129487. __webpack_require__.r(__webpack_exports__);
  129488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  129489. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129490. var name = 'fogVertexDeclaration';
  129491. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  129492. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129493. /** @hidden */
  129494. var fogVertexDeclaration = { name: name, shader: shader };
  129495. /***/ }),
  129496. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  129497. /*!***************************************************!*\
  129498. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  129499. \***************************************************/
  129500. /*! exports provided: fresnelFunction */
  129501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129502. "use strict";
  129503. __webpack_require__.r(__webpack_exports__);
  129504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  129505. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129506. var name = 'fresnelFunction';
  129507. 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";
  129508. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129509. /** @hidden */
  129510. var fresnelFunction = { name: name, shader: shader };
  129511. /***/ }),
  129512. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  129513. /*!******************************************************!*\
  129514. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  129515. \******************************************************/
  129516. /*! exports provided: harmonicsFunctions */
  129517. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129518. "use strict";
  129519. __webpack_require__.r(__webpack_exports__);
  129520. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  129521. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129522. var name = 'harmonicsFunctions';
  129523. 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";
  129524. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129525. /** @hidden */
  129526. var harmonicsFunctions = { name: name, shader: shader };
  129527. /***/ }),
  129528. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  129529. /*!***************************************************!*\
  129530. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  129531. \***************************************************/
  129532. /*! exports provided: helperFunctions */
  129533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129534. "use strict";
  129535. __webpack_require__.r(__webpack_exports__);
  129536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  129537. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129538. var name = 'helperFunctions';
  129539. 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}";
  129540. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129541. /** @hidden */
  129542. var helperFunctions = { name: name, shader: shader };
  129543. /***/ }),
  129544. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  129545. /*!**************************************************************!*\
  129546. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  129547. \**************************************************************/
  129548. /*! exports provided: imageProcessingDeclaration */
  129549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129550. "use strict";
  129551. __webpack_require__.r(__webpack_exports__);
  129552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  129553. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129554. var name = 'imageProcessingDeclaration';
  129555. 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";
  129556. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129557. /** @hidden */
  129558. var imageProcessingDeclaration = { name: name, shader: shader };
  129559. /***/ }),
  129560. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  129561. /*!************************************************************!*\
  129562. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  129563. \************************************************************/
  129564. /*! exports provided: imageProcessingFunctions */
  129565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129566. "use strict";
  129567. __webpack_require__.r(__webpack_exports__);
  129568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  129569. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129570. var name = 'imageProcessingFunctions';
  129571. 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}";
  129572. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129573. /** @hidden */
  129574. var imageProcessingFunctions = { name: name, shader: shader };
  129575. /***/ }),
  129576. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  129577. /*!********************************************************!*\
  129578. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  129579. \********************************************************/
  129580. /*! exports provided: instancesDeclaration */
  129581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129582. "use strict";
  129583. __webpack_require__.r(__webpack_exports__);
  129584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  129585. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129586. var name = 'instancesDeclaration';
  129587. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  129588. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129589. /** @hidden */
  129590. var instancesDeclaration = { name: name, shader: shader };
  129591. /***/ }),
  129592. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  129593. /*!***************************************************!*\
  129594. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  129595. \***************************************************/
  129596. /*! exports provided: instancesVertex */
  129597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129598. "use strict";
  129599. __webpack_require__.r(__webpack_exports__);
  129600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  129601. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129602. var name = 'instancesVertex';
  129603. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  129604. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129605. /** @hidden */
  129606. var instancesVertex = { name: name, shader: shader };
  129607. /***/ }),
  129608. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  129609. /*!******************************************************!*\
  129610. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  129611. \******************************************************/
  129612. /*! exports provided: kernelBlurFragment */
  129613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129614. "use strict";
  129615. __webpack_require__.r(__webpack_exports__);
  129616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  129617. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129618. var name = 'kernelBlurFragment';
  129619. 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";
  129620. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129621. /** @hidden */
  129622. var kernelBlurFragment = { name: name, shader: shader };
  129623. /***/ }),
  129624. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  129625. /*!*******************************************************!*\
  129626. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  129627. \*******************************************************/
  129628. /*! exports provided: kernelBlurFragment2 */
  129629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129630. "use strict";
  129631. __webpack_require__.r(__webpack_exports__);
  129632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  129633. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129634. var name = 'kernelBlurFragment2';
  129635. 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";
  129636. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129637. /** @hidden */
  129638. var kernelBlurFragment2 = { name: name, shader: shader };
  129639. /***/ }),
  129640. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  129641. /*!****************************************************************!*\
  129642. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  129643. \****************************************************************/
  129644. /*! exports provided: kernelBlurVaryingDeclaration */
  129645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129646. "use strict";
  129647. __webpack_require__.r(__webpack_exports__);
  129648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  129649. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129650. var name = 'kernelBlurVaryingDeclaration';
  129651. var shader = "varying vec2 sampleCoord{X};";
  129652. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129653. /** @hidden */
  129654. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  129655. /***/ }),
  129656. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  129657. /*!****************************************************!*\
  129658. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  129659. \****************************************************/
  129660. /*! exports provided: kernelBlurVertex */
  129661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129662. "use strict";
  129663. __webpack_require__.r(__webpack_exports__);
  129664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  129665. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129666. var name = 'kernelBlurVertex';
  129667. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  129668. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129669. /** @hidden */
  129670. var kernelBlurVertex = { name: name, shader: shader };
  129671. /***/ }),
  129672. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  129673. /*!*************************************************!*\
  129674. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  129675. \*************************************************/
  129676. /*! exports provided: lightFragment */
  129677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129678. "use strict";
  129679. __webpack_require__.r(__webpack_exports__);
  129680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  129681. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129682. var name = 'lightFragment';
  129683. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\n\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#elif defined(SS_TRANSLUCENCY)\ninfo.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,transmittance);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicTangent,anisotropicBitangent,anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\n\npreInfo.roughness=sheenIntensity;\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef CLEARCOAT\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearCoatRoughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearCoatNormalW,clearCoatAARoughnessFactors.x,clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatLightingAbsorption(clearCoatNdotVRefract,preInfo.L,clearCoatNormalW,clearCoatColor,clearCoatThickness,clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\n\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif";
  129684. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129685. /** @hidden */
  129686. var lightFragment = { name: name, shader: shader };
  129687. /***/ }),
  129688. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  129689. /*!************************************************************!*\
  129690. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  129691. \************************************************************/
  129692. /*! exports provided: lightFragmentDeclaration */
  129693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129694. "use strict";
  129695. __webpack_require__.r(__webpack_exports__);
  129696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  129697. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129698. var name = 'lightFragmentDeclaration';
  129699. 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";
  129700. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129701. /** @hidden */
  129702. var lightFragmentDeclaration = { name: name, shader: shader };
  129703. /***/ }),
  129704. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  129705. /*!*******************************************************!*\
  129706. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  129707. \*******************************************************/
  129708. /*! exports provided: lightUboDeclaration */
  129709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129710. "use strict";
  129711. __webpack_require__.r(__webpack_exports__);
  129712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  129713. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129714. var name = 'lightUboDeclaration';
  129715. 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";
  129716. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129717. /** @hidden */
  129718. var lightUboDeclaration = { name: name, shader: shader };
  129719. /***/ }),
  129720. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  129721. /*!***********************************************************!*\
  129722. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  129723. \***********************************************************/
  129724. /*! exports provided: lightsFragmentFunctions */
  129725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129726. "use strict";
  129727. __webpack_require__.r(__webpack_exports__);
  129728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  129729. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129730. var name = 'lightsFragmentFunctions';
  129731. 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}";
  129732. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129733. /** @hidden */
  129734. var lightsFragmentFunctions = { name: name, shader: shader };
  129735. /***/ }),
  129736. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  129737. /*!*******************************************************!*\
  129738. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  129739. \*******************************************************/
  129740. /*! exports provided: logDepthDeclaration */
  129741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129742. "use strict";
  129743. __webpack_require__.r(__webpack_exports__);
  129744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  129745. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129746. var name = 'logDepthDeclaration';
  129747. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  129748. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129749. /** @hidden */
  129750. var logDepthDeclaration = { name: name, shader: shader };
  129751. /***/ }),
  129752. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  129753. /*!****************************************************!*\
  129754. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  129755. \****************************************************/
  129756. /*! exports provided: logDepthFragment */
  129757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129758. "use strict";
  129759. __webpack_require__.r(__webpack_exports__);
  129760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  129761. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129762. var name = 'logDepthFragment';
  129763. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  129764. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129765. /** @hidden */
  129766. var logDepthFragment = { name: name, shader: shader };
  129767. /***/ }),
  129768. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  129769. /*!**************************************************!*\
  129770. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  129771. \**************************************************/
  129772. /*! exports provided: logDepthVertex */
  129773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129774. "use strict";
  129775. __webpack_require__.r(__webpack_exports__);
  129776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  129777. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129778. var name = 'logDepthVertex';
  129779. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  129780. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129781. /** @hidden */
  129782. var logDepthVertex = { name: name, shader: shader };
  129783. /***/ }),
  129784. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  129785. /*!******************************************************!*\
  129786. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  129787. \******************************************************/
  129788. /*! exports provided: morphTargetsVertex */
  129789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129790. "use strict";
  129791. __webpack_require__.r(__webpack_exports__);
  129792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  129793. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129794. var name = 'morphTargetsVertex';
  129795. 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";
  129796. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129797. /** @hidden */
  129798. var morphTargetsVertex = { name: name, shader: shader };
  129799. /***/ }),
  129800. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  129801. /*!*****************************************************************!*\
  129802. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  129803. \*****************************************************************/
  129804. /*! exports provided: morphTargetsVertexDeclaration */
  129805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129806. "use strict";
  129807. __webpack_require__.r(__webpack_exports__);
  129808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  129809. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129810. var name = 'morphTargetsVertexDeclaration';
  129811. 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";
  129812. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129813. /** @hidden */
  129814. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  129815. /***/ }),
  129816. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  129817. /*!***********************************************************************!*\
  129818. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  129819. \***********************************************************************/
  129820. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  129821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129822. "use strict";
  129823. __webpack_require__.r(__webpack_exports__);
  129824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  129825. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129826. var name = 'morphTargetsVertexGlobalDeclaration';
  129827. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  129828. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129829. /** @hidden */
  129830. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  129831. /***/ }),
  129832. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  129833. /*!**********************************************************!*\
  129834. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  129835. \**********************************************************/
  129836. /*! exports provided: mrtFragmentDeclaration */
  129837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129838. "use strict";
  129839. __webpack_require__.r(__webpack_exports__);
  129840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  129841. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129842. var name = 'mrtFragmentDeclaration';
  129843. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  129844. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129845. /** @hidden */
  129846. var mrtFragmentDeclaration = { name: name, shader: shader };
  129847. /***/ }),
  129848. /***/ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts":
  129849. /*!****************************************************!*\
  129850. !*** ./Shaders/ShadersInclude/pbrBRDFFunctions.ts ***!
  129851. \****************************************************/
  129852. /*! exports provided: pbrBRDFFunctions */
  129853. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129854. "use strict";
  129855. __webpack_require__.r(__webpack_exports__);
  129856. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrBRDFFunctions", function() { return pbrBRDFFunctions; });
  129857. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129858. var name = 'pbrBRDFFunctions';
  129859. var shader = "\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n\n\n\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness,sampler2D brdfSampler) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec4 brdfLookup=texture2D(brdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(REFLECTION)\n\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\n\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\n\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n\n\n\n\n#ifdef BRDF_V_HEIGHT_CORRELATED\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n#endif\n#ifdef SHEEN\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n#endif\n\n\n\n\n\n\n\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n#ifdef SS_TRANSLUCENCY\n\n\nvec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {\nvec3 S=1./maxEps(diffusionDistance);\nvec3 temp=exp((-0.333333333*thickness)*S);\nreturn tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);\n}\n\n\nfloat computeWrappedDiffuseNdotL(float NdotL,float w) {\nfloat t=1.0+w;\nfloat invt2=1.0/square(t);\nreturn saturate((NdotL+w)*invt2);\n}\n#endif\n";
  129860. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129861. /** @hidden */
  129862. var pbrBRDFFunctions = { name: name, shader: shader };
  129863. /***/ }),
  129864. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  129865. /*!********************************************!*\
  129866. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  129867. \********************************************/
  129868. /*! exports provided: pbrDebug */
  129869. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129870. "use strict";
  129871. __webpack_require__.r(__webpack_exports__);
  129872. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  129873. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129874. var name = 'pbrDebug';
  129875. var shader = "#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w<vDebugMode.x) {\nreturn;\n}\n\n#if DEBUGMODE == 1\ngl_FragColor.rgb=vPositionW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 2 && defined(NORMAL)\ngl_FragColor.rgb=vNormalW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 3 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 4 && (defined(BUMP) || defined(PARALLAX) || defined(ANISOTROPIC))\n\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 5\n\ngl_FragColor.rgb=normalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 6 && defined(MAINUV1)\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\n#elif DEBUGMODE == 7 && defined(MAINUV2)\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\n#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 10 && defined(CLEARCOAT)\n\ngl_FragColor.rgb=clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 12 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicTangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 13 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicBitangent;\n#define DEBUGMODE_NORMALIZE\n\n#elif DEBUGMODE == 20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE == 21 && defined(AMBIENT)\ngl_FragColor.rgb=ambientOcclusionColorMap.rgb;\n#elif DEBUGMODE == 22 && defined(OPACITY)\ngl_FragColor.rgb=opacityMap.rgb;\n#elif DEBUGMODE == 23 && defined(EMISSIVE)\ngl_FragColor.rgb=emissiveColorTex.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 24 && defined(LIGHTMAP)\ngl_FragColor.rgb=lightmapColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=clearCoatMapData.rgb;\n#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearCoatTintMapData.rgb;\n#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\ngl_FragColor.rgb=sheenMapData.rgb;\n#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\ngl_FragColor.rgb=anisotropyMapData.rgb;\n#elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)\ngl_FragColor.rgb=thicknessMap.rgb;\n\n#elif DEBUGMODE == 40 && defined(SS_REFRACTION)\n\ngl_FragColor.rgb=environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 41 && defined(REFLECTION)\ngl_FragColor.rgb=environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=environmentClearCoatRadiance;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 53 && defined(SHEEN)\ngl_FragColor.rgb=sheenBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 54 && defined(REFLECTION)\ngl_FragColor.rgb=environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 61\ngl_FragColor.rgb=specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 62\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 65 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 66 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatRoughness);\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatNdotV);\n#elif DEBUGMODE == 68 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)\ngl_FragColor.rgb=transmittance;\n#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_REFRACTION)\ngl_FragColor.rgb=refractionTransmittance;\n\n#elif DEBUGMODE == 70 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 71 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 72 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 73 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 74 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 75 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 76 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 77\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#endif";
  129876. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129877. /** @hidden */
  129878. var pbrDebug = { name: name, shader: shader };
  129879. /***/ }),
  129880. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts":
  129881. /*!*********************************************************************!*\
  129882. !*** ./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts ***!
  129883. \*********************************************************************/
  129884. /*! exports provided: pbrDirectLightingFalloffFunctions */
  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__, "pbrDirectLightingFalloffFunctions", function() { return pbrDirectLightingFalloffFunctions; });
  129889. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129890. var name = 'pbrDirectLightingFalloffFunctions';
  129891. 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}";
  129892. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129893. /** @hidden */
  129894. var pbrDirectLightingFalloffFunctions = { name: name, shader: shader };
  129895. /***/ }),
  129896. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts":
  129897. /*!**************************************************************!*\
  129898. !*** ./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts ***!
  129899. \**************************************************************/
  129900. /*! exports provided: pbrDirectLightingFunctions */
  129901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129902. "use strict";
  129903. __webpack_require__.r(__webpack_exports__);
  129904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFunctions", function() { return pbrDirectLightingFunctions; });
  129905. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129906. var name = 'pbrDirectLightingFunctions';
  129907. var shader = "#define CLEARCOATREFLECTANCE90 1.0\n\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\n\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SS_TRANSLUCENCY\nvec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {\nfloat NdotL=absEps(info.NdotLUnclamped);\n\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\n\nfloat trAdapt=step(0.,info.NdotLUnclamped);\nvec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);\nfloat diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;\n}\n#endif\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat visibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat visibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat visibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*visibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n\nvec3 fresnel=reflectance0;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\nvec3 sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";
  129908. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129909. /** @hidden */
  129910. var pbrDirectLightingFunctions = { name: name, shader: shader };
  129911. /***/ }),
  129912. /***/ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts":
  129913. /*!*******************************************************************!*\
  129914. !*** ./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts ***!
  129915. \*******************************************************************/
  129916. /*! exports provided: pbrDirectLightingSetupFunctions */
  129917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129918. "use strict";
  129919. __webpack_require__.r(__webpack_exports__);
  129920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingSetupFunctions", function() { return pbrDirectLightingSetupFunctions; });
  129921. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129922. var name = 'pbrDirectLightingSetupFunctions';
  129923. var shader = "\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotLUnclamped;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\nresult.NdotLUnclamped=result.NdotL;\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";
  129924. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129925. /** @hidden */
  129926. var pbrDirectLightingSetupFunctions = { name: name, shader: shader };
  129927. /***/ }),
  129928. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  129929. /*!**********************************************************!*\
  129930. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  129931. \**********************************************************/
  129932. /*! exports provided: pbrFragmentDeclaration */
  129933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129934. "use strict";
  129935. __webpack_require__.r(__webpack_exports__);
  129936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  129937. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129938. var name = 'pbrFragmentDeclaration';
  129939. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n#endif";
  129940. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129941. /** @hidden */
  129942. var pbrFragmentDeclaration = { name: name, shader: shader };
  129943. /***/ }),
  129944. /***/ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts":
  129945. /*!***************************************************************!*\
  129946. !*** ./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts ***!
  129947. \***************************************************************/
  129948. /*! exports provided: pbrFragmentExtraDeclaration */
  129949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129950. "use strict";
  129951. __webpack_require__.r(__webpack_exports__);
  129952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentExtraDeclaration", function() { return pbrFragmentExtraDeclaration; });
  129953. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129954. var name = 'pbrFragmentExtraDeclaration';
  129955. 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";
  129956. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129957. /** @hidden */
  129958. var pbrFragmentExtraDeclaration = { name: name, shader: shader };
  129959. /***/ }),
  129960. /***/ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts":
  129961. /*!******************************************************************!*\
  129962. !*** ./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts ***!
  129963. \******************************************************************/
  129964. /*! exports provided: pbrFragmentSamplersDeclaration */
  129965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129966. "use strict";
  129967. __webpack_require__.r(__webpack_exports__);
  129968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentSamplersDeclaration", function() { return pbrFragmentSamplersDeclaration; });
  129969. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129970. var name = 'pbrFragmentSamplersDeclaration';
  129971. var shader = "#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\n#ifdef SS_REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\n#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1\n#define vThicknessUV vMainUV1\n#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2\n#define vThicknessUV vMainUV2\n#else\nvarying vec2 vThicknessUV;\n#endif\nuniform sampler2D thicknessSampler;\n#endif\n#endif";
  129972. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129973. /** @hidden */
  129974. var pbrFragmentSamplersDeclaration = { name: name, shader: shader };
  129975. /***/ }),
  129976. /***/ "./Shaders/ShadersInclude/pbrHelperFunctions.ts":
  129977. /*!******************************************************!*\
  129978. !*** ./Shaders/ShadersInclude/pbrHelperFunctions.ts ***!
  129979. \******************************************************/
  129980. /*! exports provided: pbrHelperFunctions */
  129981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129982. "use strict";
  129983. __webpack_require__.r(__webpack_exports__);
  129984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrHelperFunctions", function() { return pbrHelperFunctions; });
  129985. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129986. var name = 'pbrHelperFunctions';
  129987. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\n\n\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n\n\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\n\n\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\n\n\n\nvec3 cocaLambert(vec3 alpha,float distance) {\nreturn exp(-alpha*distance);\n}\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n\n\n\n\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif";
  129988. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129989. /** @hidden */
  129990. var pbrHelperFunctions = { name: name, shader: shader };
  129991. /***/ }),
  129992. /***/ "./Shaders/ShadersInclude/pbrIBLFunctions.ts":
  129993. /*!***************************************************!*\
  129994. !*** ./Shaders/ShadersInclude/pbrIBLFunctions.ts ***!
  129995. \***************************************************/
  129996. /*! exports provided: pbrIBLFunctions */
  129997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129998. "use strict";
  129999. __webpack_require__.r(__webpack_exports__);
  130000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrIBLFunctions", function() { return pbrIBLFunctions; });
  130001. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  130002. var name = 'pbrIBLFunctions';
  130003. var shader = "#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,normal));\nreturn square(temp);\n}\n#endif\n\n\n\n\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif";
  130004. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  130005. /** @hidden */
  130006. var pbrIBLFunctions = { name: name, shader: shader };
  130007. /***/ }),
  130008. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  130009. /*!*****************************************************!*\
  130010. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  130011. \*****************************************************/
  130012. /*! exports provided: pbrUboDeclaration */
  130013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130014. "use strict";
  130015. __webpack_require__.r(__webpack_exports__);
  130016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  130017. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  130018. var name = 'pbrUboDeclaration';
  130019. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float pointSize;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";
  130020. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  130021. /** @hidden */
  130022. var pbrUboDeclaration = { name: name, shader: shader };
  130023. /***/ }),
  130024. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  130025. /*!********************************************************!*\
  130026. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  130027. \********************************************************/
  130028. /*! exports provided: pbrVertexDeclaration */
  130029. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130030. "use strict";
  130031. __webpack_require__.r(__webpack_exports__);
  130032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  130033. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  130034. var name = 'pbrVertexDeclaration';
  130035. var shader = "uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\n#endif\n\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;;\n#endif\n#endif\n";
  130036. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  130037. /** @hidden */
  130038. var pbrVertexDeclaration = { name: name, shader: shader };
  130039. /***/ }),
  130040. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  130041. /*!****************************************************!*\
  130042. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  130043. \****************************************************/
  130044. /*! exports provided: pointCloudVertex */
  130045. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130046. "use strict";
  130047. __webpack_require__.r(__webpack_exports__);
  130048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  130049. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  130050. var name = 'pointCloudVertex';
  130051. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  130052. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  130053. /** @hidden */
  130054. var pointCloudVertex = { name: name, shader: shader };
  130055. /***/ }),
  130056. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  130057. /*!******************************************************!*\
  130058. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  130059. \******************************************************/
  130060. /*! exports provided: reflectionFunction */
  130061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130062. "use strict";
  130063. __webpack_require__.r(__webpack_exports__);
  130064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  130065. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  130066. var name = 'reflectionFunction';
  130067. 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}";
  130068. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  130069. /** @hidden */
  130070. var reflectionFunction = { name: name, shader: shader };
  130071. /***/ }),
  130072. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  130073. /*!************************************************************!*\
  130074. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  130075. \************************************************************/
  130076. /*! exports provided: shadowsFragmentFunctions */
  130077. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130078. "use strict";
  130079. __webpack_require__.r(__webpack_exports__);
  130080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  130081. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  130082. var name = 'shadowsFragmentFunctions';
  130083. 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";
  130084. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  130085. /** @hidden */
  130086. var shadowsFragmentFunctions = { name: name, shader: shader };
  130087. /***/ }),
  130088. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  130089. /*!*************************************************!*\
  130090. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  130091. \*************************************************/
  130092. /*! exports provided: shadowsVertex */
  130093. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130094. "use strict";
  130095. __webpack_require__.r(__webpack_exports__);
  130096. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  130097. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  130098. var name = 'shadowsVertex';
  130099. 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";
  130100. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  130101. /** @hidden */
  130102. var shadowsVertex = { name: name, shader: shader };
  130103. /***/ }),
  130104. /***/ "./Shaders/anaglyph.fragment.ts":
  130105. /*!**************************************!*\
  130106. !*** ./Shaders/anaglyph.fragment.ts ***!
  130107. \**************************************/
  130108. /*! exports provided: anaglyphPixelShader */
  130109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130110. "use strict";
  130111. __webpack_require__.r(__webpack_exports__);
  130112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  130113. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130114. var name = 'anaglyphPixelShader';
  130115. 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}";
  130116. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130117. /** @hidden */
  130118. var anaglyphPixelShader = { name: name, shader: shader };
  130119. /***/ }),
  130120. /***/ "./Shaders/background.fragment.ts":
  130121. /*!****************************************!*\
  130122. !*** ./Shaders/background.fragment.ts ***!
  130123. \****************************************/
  130124. /*! exports provided: backgroundPixelShader */
  130125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130126. "use strict";
  130127. __webpack_require__.r(__webpack_exports__);
  130128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  130129. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130130. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  130131. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  130132. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  130133. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130134. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130135. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130136. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130137. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  130138. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  130139. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130140. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  130141. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  130142. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130143. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  130144. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  130145. var name = 'backgroundPixelShader';
  130146. 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";
  130147. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130148. /** @hidden */
  130149. var backgroundPixelShader = { name: name, shader: shader };
  130150. /***/ }),
  130151. /***/ "./Shaders/background.vertex.ts":
  130152. /*!**************************************!*\
  130153. !*** ./Shaders/background.vertex.ts ***!
  130154. \**************************************/
  130155. /*! exports provided: backgroundVertexShader */
  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__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  130160. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130161. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  130162. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  130163. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130164. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130165. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130166. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  130167. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  130168. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130169. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130170. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130171. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130172. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130173. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  130174. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  130175. var name = 'backgroundVertexShader';
  130176. 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";
  130177. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130178. /** @hidden */
  130179. var backgroundVertexShader = { name: name, shader: shader };
  130180. /***/ }),
  130181. /***/ "./Shaders/blackAndWhite.fragment.ts":
  130182. /*!*******************************************!*\
  130183. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  130184. \*******************************************/
  130185. /*! exports provided: blackAndWhitePixelShader */
  130186. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130187. "use strict";
  130188. __webpack_require__.r(__webpack_exports__);
  130189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  130190. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130191. var name = 'blackAndWhitePixelShader';
  130192. 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}";
  130193. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130194. /** @hidden */
  130195. var blackAndWhitePixelShader = { name: name, shader: shader };
  130196. /***/ }),
  130197. /***/ "./Shaders/bloomMerge.fragment.ts":
  130198. /*!****************************************!*\
  130199. !*** ./Shaders/bloomMerge.fragment.ts ***!
  130200. \****************************************/
  130201. /*! exports provided: bloomMergePixelShader */
  130202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130203. "use strict";
  130204. __webpack_require__.r(__webpack_exports__);
  130205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  130206. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130207. var name = 'bloomMergePixelShader';
  130208. 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";
  130209. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130210. /** @hidden */
  130211. var bloomMergePixelShader = { name: name, shader: shader };
  130212. /***/ }),
  130213. /***/ "./Shaders/chromaticAberration.fragment.ts":
  130214. /*!*************************************************!*\
  130215. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  130216. \*************************************************/
  130217. /*! exports provided: chromaticAberrationPixelShader */
  130218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130219. "use strict";
  130220. __webpack_require__.r(__webpack_exports__);
  130221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  130222. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130223. var name = 'chromaticAberrationPixelShader';
  130224. 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}";
  130225. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130226. /** @hidden */
  130227. var chromaticAberrationPixelShader = { name: name, shader: shader };
  130228. /***/ }),
  130229. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  130230. /*!***********************************************!*\
  130231. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  130232. \***********************************************/
  130233. /*! exports provided: circleOfConfusionPixelShader */
  130234. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130235. "use strict";
  130236. __webpack_require__.r(__webpack_exports__);
  130237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  130238. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130239. var name = 'circleOfConfusionPixelShader';
  130240. 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";
  130241. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130242. /** @hidden */
  130243. var circleOfConfusionPixelShader = { name: name, shader: shader };
  130244. /***/ }),
  130245. /***/ "./Shaders/color.fragment.ts":
  130246. /*!***********************************!*\
  130247. !*** ./Shaders/color.fragment.ts ***!
  130248. \***********************************/
  130249. /*! exports provided: colorPixelShader */
  130250. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130251. "use strict";
  130252. __webpack_require__.r(__webpack_exports__);
  130253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  130254. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130255. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  130256. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130257. var name = 'colorPixelShader';
  130258. 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}";
  130259. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130260. /** @hidden */
  130261. var colorPixelShader = { name: name, shader: shader };
  130262. /***/ }),
  130263. /***/ "./Shaders/color.vertex.ts":
  130264. /*!*********************************!*\
  130265. !*** ./Shaders/color.vertex.ts ***!
  130266. \*********************************/
  130267. /*! exports provided: colorVertexShader */
  130268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130269. "use strict";
  130270. __webpack_require__.r(__webpack_exports__);
  130271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  130272. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130273. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130274. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  130275. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130276. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130277. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130278. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130279. var name = 'colorVertexShader';
  130280. 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}";
  130281. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130282. /** @hidden */
  130283. var colorVertexShader = { name: name, shader: shader };
  130284. /***/ }),
  130285. /***/ "./Shaders/colorCorrection.fragment.ts":
  130286. /*!*********************************************!*\
  130287. !*** ./Shaders/colorCorrection.fragment.ts ***!
  130288. \*********************************************/
  130289. /*! exports provided: colorCorrectionPixelShader */
  130290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130291. "use strict";
  130292. __webpack_require__.r(__webpack_exports__);
  130293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  130294. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130295. var name = 'colorCorrectionPixelShader';
  130296. 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}";
  130297. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130298. /** @hidden */
  130299. var colorCorrectionPixelShader = { name: name, shader: shader };
  130300. /***/ }),
  130301. /***/ "./Shaders/convolution.fragment.ts":
  130302. /*!*****************************************!*\
  130303. !*** ./Shaders/convolution.fragment.ts ***!
  130304. \*****************************************/
  130305. /*! exports provided: convolutionPixelShader */
  130306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130307. "use strict";
  130308. __webpack_require__.r(__webpack_exports__);
  130309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  130310. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130311. var name = 'convolutionPixelShader';
  130312. 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}";
  130313. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130314. /** @hidden */
  130315. var convolutionPixelShader = { name: name, shader: shader };
  130316. /***/ }),
  130317. /***/ "./Shaders/default.fragment.ts":
  130318. /*!*************************************!*\
  130319. !*** ./Shaders/default.fragment.ts ***!
  130320. \*************************************/
  130321. /*! exports provided: defaultPixelShader */
  130322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130323. "use strict";
  130324. __webpack_require__.r(__webpack_exports__);
  130325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  130326. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130327. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  130328. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  130329. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130330. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130331. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130332. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  130333. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  130334. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  130335. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  130336. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130337. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130338. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  130339. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  130340. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130341. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  130342. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130343. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  130344. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  130345. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  130346. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  130347. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  130348. var name = 'defaultPixelShader';
  130349. 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";
  130350. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130351. /** @hidden */
  130352. var defaultPixelShader = { name: name, shader: shader };
  130353. /***/ }),
  130354. /***/ "./Shaders/default.vertex.ts":
  130355. /*!***********************************!*\
  130356. !*** ./Shaders/default.vertex.ts ***!
  130357. \***********************************/
  130358. /*! exports provided: defaultVertexShader */
  130359. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130360. "use strict";
  130361. __webpack_require__.r(__webpack_exports__);
  130362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  130363. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130364. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  130365. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  130366. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130367. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130368. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130369. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  130370. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  130371. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  130372. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130373. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130374. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130375. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130376. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130377. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130378. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130379. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130380. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  130381. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130382. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  130383. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  130384. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  130385. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  130386. var name = 'defaultVertexShader';
  130387. 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";
  130388. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130389. /** @hidden */
  130390. var defaultVertexShader = { name: name, shader: shader };
  130391. /***/ }),
  130392. /***/ "./Shaders/depth.fragment.ts":
  130393. /*!***********************************!*\
  130394. !*** ./Shaders/depth.fragment.ts ***!
  130395. \***********************************/
  130396. /*! exports provided: depthPixelShader */
  130397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130398. "use strict";
  130399. __webpack_require__.r(__webpack_exports__);
  130400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  130401. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130402. var name = 'depthPixelShader';
  130403. 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}";
  130404. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130405. /** @hidden */
  130406. var depthPixelShader = { name: name, shader: shader };
  130407. /***/ }),
  130408. /***/ "./Shaders/depth.vertex.ts":
  130409. /*!*********************************!*\
  130410. !*** ./Shaders/depth.vertex.ts ***!
  130411. \*********************************/
  130412. /*! exports provided: depthVertexShader */
  130413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130414. "use strict";
  130415. __webpack_require__.r(__webpack_exports__);
  130416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  130417. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130418. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130419. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130420. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130421. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130422. var name = 'depthVertexShader';
  130423. 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}";
  130424. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130425. /** @hidden */
  130426. var depthVertexShader = { name: name, shader: shader };
  130427. /***/ }),
  130428. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  130429. /*!******************************************!*\
  130430. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  130431. \******************************************/
  130432. /*! exports provided: depthBoxBlurPixelShader */
  130433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130434. "use strict";
  130435. __webpack_require__.r(__webpack_exports__);
  130436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  130437. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130438. var name = 'depthBoxBlurPixelShader';
  130439. 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}";
  130440. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130441. /** @hidden */
  130442. var depthBoxBlurPixelShader = { name: name, shader: shader };
  130443. /***/ }),
  130444. /***/ "./Shaders/depthOfField.fragment.ts":
  130445. /*!******************************************!*\
  130446. !*** ./Shaders/depthOfField.fragment.ts ***!
  130447. \******************************************/
  130448. /*! exports provided: depthOfFieldPixelShader */
  130449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130450. "use strict";
  130451. __webpack_require__.r(__webpack_exports__);
  130452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  130453. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130454. var name = 'depthOfFieldPixelShader';
  130455. 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";
  130456. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130457. /** @hidden */
  130458. var depthOfFieldPixelShader = { name: name, shader: shader };
  130459. /***/ }),
  130460. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  130461. /*!***********************************************!*\
  130462. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  130463. \***********************************************/
  130464. /*! exports provided: depthOfFieldMergePixelShader */
  130465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130466. "use strict";
  130467. __webpack_require__.r(__webpack_exports__);
  130468. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  130469. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130470. var name = 'depthOfFieldMergePixelShader';
  130471. 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";
  130472. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130473. /** @hidden */
  130474. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  130475. /***/ }),
  130476. /***/ "./Shaders/displayPass.fragment.ts":
  130477. /*!*****************************************!*\
  130478. !*** ./Shaders/displayPass.fragment.ts ***!
  130479. \*****************************************/
  130480. /*! exports provided: displayPassPixelShader */
  130481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130482. "use strict";
  130483. __webpack_require__.r(__webpack_exports__);
  130484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  130485. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130486. var name = 'displayPassPixelShader';
  130487. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  130488. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130489. /** @hidden */
  130490. var displayPassPixelShader = { name: name, shader: shader };
  130491. /***/ }),
  130492. /***/ "./Shaders/extractHighlights.fragment.ts":
  130493. /*!***********************************************!*\
  130494. !*** ./Shaders/extractHighlights.fragment.ts ***!
  130495. \***********************************************/
  130496. /*! exports provided: extractHighlightsPixelShader */
  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__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  130501. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130502. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130503. var name = 'extractHighlightsPixelShader';
  130504. 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}";
  130505. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130506. /** @hidden */
  130507. var extractHighlightsPixelShader = { name: name, shader: shader };
  130508. /***/ }),
  130509. /***/ "./Shaders/filter.fragment.ts":
  130510. /*!************************************!*\
  130511. !*** ./Shaders/filter.fragment.ts ***!
  130512. \************************************/
  130513. /*! exports provided: filterPixelShader */
  130514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130515. "use strict";
  130516. __webpack_require__.r(__webpack_exports__);
  130517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  130518. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130519. var name = 'filterPixelShader';
  130520. 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}";
  130521. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130522. /** @hidden */
  130523. var filterPixelShader = { name: name, shader: shader };
  130524. /***/ }),
  130525. /***/ "./Shaders/fxaa.fragment.ts":
  130526. /*!**********************************!*\
  130527. !*** ./Shaders/fxaa.fragment.ts ***!
  130528. \**********************************/
  130529. /*! exports provided: fxaaPixelShader */
  130530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130531. "use strict";
  130532. __webpack_require__.r(__webpack_exports__);
  130533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  130534. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130535. var name = 'fxaaPixelShader';
  130536. 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}";
  130537. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130538. /** @hidden */
  130539. var fxaaPixelShader = { name: name, shader: shader };
  130540. /***/ }),
  130541. /***/ "./Shaders/fxaa.vertex.ts":
  130542. /*!********************************!*\
  130543. !*** ./Shaders/fxaa.vertex.ts ***!
  130544. \********************************/
  130545. /*! exports provided: fxaaVertexShader */
  130546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130547. "use strict";
  130548. __webpack_require__.r(__webpack_exports__);
  130549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  130550. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130551. var name = 'fxaaVertexShader';
  130552. 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}";
  130553. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130554. /** @hidden */
  130555. var fxaaVertexShader = { name: name, shader: shader };
  130556. /***/ }),
  130557. /***/ "./Shaders/geometry.fragment.ts":
  130558. /*!**************************************!*\
  130559. !*** ./Shaders/geometry.fragment.ts ***!
  130560. \**************************************/
  130561. /*! exports provided: geometryPixelShader */
  130562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130563. "use strict";
  130564. __webpack_require__.r(__webpack_exports__);
  130565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  130566. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130567. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  130568. var name = 'geometryPixelShader';
  130569. 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}";
  130570. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130571. /** @hidden */
  130572. var geometryPixelShader = { name: name, shader: shader };
  130573. /***/ }),
  130574. /***/ "./Shaders/geometry.vertex.ts":
  130575. /*!************************************!*\
  130576. !*** ./Shaders/geometry.vertex.ts ***!
  130577. \************************************/
  130578. /*! exports provided: geometryVertexShader */
  130579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130580. "use strict";
  130581. __webpack_require__.r(__webpack_exports__);
  130582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  130583. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130584. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130585. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130586. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130587. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130588. var name = 'geometryVertexShader';
  130589. 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}";
  130590. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130591. /** @hidden */
  130592. var geometryVertexShader = { name: name, shader: shader };
  130593. /***/ }),
  130594. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  130595. /*!*************************************************!*\
  130596. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  130597. \*************************************************/
  130598. /*! exports provided: glowBlurPostProcessPixelShader */
  130599. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130600. "use strict";
  130601. __webpack_require__.r(__webpack_exports__);
  130602. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  130603. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130604. var name = 'glowBlurPostProcessPixelShader';
  130605. 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}";
  130606. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130607. /** @hidden */
  130608. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  130609. /***/ }),
  130610. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  130611. /*!***********************************************!*\
  130612. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  130613. \***********************************************/
  130614. /*! exports provided: glowMapGenerationPixelShader */
  130615. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130616. "use strict";
  130617. __webpack_require__.r(__webpack_exports__);
  130618. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  130619. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130620. var name = 'glowMapGenerationPixelShader';
  130621. 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}";
  130622. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130623. /** @hidden */
  130624. var glowMapGenerationPixelShader = { name: name, shader: shader };
  130625. /***/ }),
  130626. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  130627. /*!*********************************************!*\
  130628. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  130629. \*********************************************/
  130630. /*! exports provided: glowMapGenerationVertexShader */
  130631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130632. "use strict";
  130633. __webpack_require__.r(__webpack_exports__);
  130634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  130635. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130636. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130637. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130638. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130639. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130640. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130641. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130642. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130643. var name = 'glowMapGenerationVertexShader';
  130644. 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}";
  130645. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130646. /** @hidden */
  130647. var glowMapGenerationVertexShader = { name: name, shader: shader };
  130648. /***/ }),
  130649. /***/ "./Shaders/glowMapMerge.fragment.ts":
  130650. /*!******************************************!*\
  130651. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  130652. \******************************************/
  130653. /*! exports provided: glowMapMergePixelShader */
  130654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130655. "use strict";
  130656. __webpack_require__.r(__webpack_exports__);
  130657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  130658. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130659. var name = 'glowMapMergePixelShader';
  130660. 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}";
  130661. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130662. /** @hidden */
  130663. var glowMapMergePixelShader = { name: name, shader: shader };
  130664. /***/ }),
  130665. /***/ "./Shaders/glowMapMerge.vertex.ts":
  130666. /*!****************************************!*\
  130667. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  130668. \****************************************/
  130669. /*! exports provided: glowMapMergeVertexShader */
  130670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130671. "use strict";
  130672. __webpack_require__.r(__webpack_exports__);
  130673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  130674. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130675. var name = 'glowMapMergeVertexShader';
  130676. 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}";
  130677. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130678. /** @hidden */
  130679. var glowMapMergeVertexShader = { name: name, shader: shader };
  130680. /***/ }),
  130681. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  130682. /*!************************************************!*\
  130683. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  130684. \************************************************/
  130685. /*! exports provided: gpuRenderParticlesPixelShader */
  130686. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130687. "use strict";
  130688. __webpack_require__.r(__webpack_exports__);
  130689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  130690. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130691. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  130692. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130693. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130694. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130695. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130696. var name = 'gpuRenderParticlesPixelShader';
  130697. 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";
  130698. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130699. /** @hidden */
  130700. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  130701. /***/ }),
  130702. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  130703. /*!**********************************************!*\
  130704. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  130705. \**********************************************/
  130706. /*! exports provided: gpuRenderParticlesVertexShader */
  130707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130708. "use strict";
  130709. __webpack_require__.r(__webpack_exports__);
  130710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  130711. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130712. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  130713. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130714. var name = 'gpuRenderParticlesVertexShader';
  130715. 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}";
  130716. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130717. /** @hidden */
  130718. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  130719. /***/ }),
  130720. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  130721. /*!************************************************!*\
  130722. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  130723. \************************************************/
  130724. /*! exports provided: gpuUpdateParticlesPixelShader */
  130725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130726. "use strict";
  130727. __webpack_require__.r(__webpack_exports__);
  130728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  130729. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130730. var name = 'gpuUpdateParticlesPixelShader';
  130731. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  130732. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130733. /** @hidden */
  130734. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  130735. /***/ }),
  130736. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  130737. /*!**********************************************!*\
  130738. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  130739. \**********************************************/
  130740. /*! exports provided: gpuUpdateParticlesVertexShader */
  130741. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130742. "use strict";
  130743. __webpack_require__.r(__webpack_exports__);
  130744. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  130745. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130746. var name = 'gpuUpdateParticlesVertexShader';
  130747. 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}";
  130748. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130749. /** @hidden */
  130750. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  130751. /***/ }),
  130752. /***/ "./Shaders/grain.fragment.ts":
  130753. /*!***********************************!*\
  130754. !*** ./Shaders/grain.fragment.ts ***!
  130755. \***********************************/
  130756. /*! exports provided: grainPixelShader */
  130757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130758. "use strict";
  130759. __webpack_require__.r(__webpack_exports__);
  130760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  130761. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130762. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130763. var name = 'grainPixelShader';
  130764. 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}";
  130765. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130766. /** @hidden */
  130767. var grainPixelShader = { name: name, shader: shader };
  130768. /***/ }),
  130769. /***/ "./Shaders/highlights.fragment.ts":
  130770. /*!****************************************!*\
  130771. !*** ./Shaders/highlights.fragment.ts ***!
  130772. \****************************************/
  130773. /*! exports provided: highlightsPixelShader */
  130774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130775. "use strict";
  130776. __webpack_require__.r(__webpack_exports__);
  130777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  130778. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130779. var name = 'highlightsPixelShader';
  130780. 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}";
  130781. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130782. /** @hidden */
  130783. var highlightsPixelShader = { name: name, shader: shader };
  130784. /***/ }),
  130785. /***/ "./Shaders/imageProcessing.fragment.ts":
  130786. /*!*********************************************!*\
  130787. !*** ./Shaders/imageProcessing.fragment.ts ***!
  130788. \*********************************************/
  130789. /*! exports provided: imageProcessingPixelShader */
  130790. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130791. "use strict";
  130792. __webpack_require__.r(__webpack_exports__);
  130793. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  130794. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130795. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130796. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130797. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130798. var name = 'imageProcessingPixelShader';
  130799. 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}";
  130800. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130801. /** @hidden */
  130802. var imageProcessingPixelShader = { name: name, shader: shader };
  130803. /***/ }),
  130804. /***/ "./Shaders/kernelBlur.fragment.ts":
  130805. /*!****************************************!*\
  130806. !*** ./Shaders/kernelBlur.fragment.ts ***!
  130807. \****************************************/
  130808. /*! exports provided: kernelBlurPixelShader */
  130809. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130810. "use strict";
  130811. __webpack_require__.r(__webpack_exports__);
  130812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  130813. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130814. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  130815. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  130816. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  130817. var name = 'kernelBlurPixelShader';
  130818. 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}";
  130819. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130820. /** @hidden */
  130821. var kernelBlurPixelShader = { name: name, shader: shader };
  130822. /***/ }),
  130823. /***/ "./Shaders/kernelBlur.vertex.ts":
  130824. /*!**************************************!*\
  130825. !*** ./Shaders/kernelBlur.vertex.ts ***!
  130826. \**************************************/
  130827. /*! exports provided: kernelBlurVertexShader */
  130828. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130829. "use strict";
  130830. __webpack_require__.r(__webpack_exports__);
  130831. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  130832. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130833. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  130834. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  130835. var name = 'kernelBlurVertexShader';
  130836. 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}";
  130837. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130838. /** @hidden */
  130839. var kernelBlurVertexShader = { name: name, shader: shader };
  130840. /***/ }),
  130841. /***/ "./Shaders/layer.fragment.ts":
  130842. /*!***********************************!*\
  130843. !*** ./Shaders/layer.fragment.ts ***!
  130844. \***********************************/
  130845. /*! exports provided: layerPixelShader */
  130846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130847. "use strict";
  130848. __webpack_require__.r(__webpack_exports__);
  130849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  130850. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130851. var name = 'layerPixelShader';
  130852. 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}";
  130853. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130854. /** @hidden */
  130855. var layerPixelShader = { name: name, shader: shader };
  130856. /***/ }),
  130857. /***/ "./Shaders/layer.vertex.ts":
  130858. /*!*********************************!*\
  130859. !*** ./Shaders/layer.vertex.ts ***!
  130860. \*********************************/
  130861. /*! exports provided: layerVertexShader */
  130862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130863. "use strict";
  130864. __webpack_require__.r(__webpack_exports__);
  130865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  130866. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130867. var name = 'layerVertexShader';
  130868. 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}";
  130869. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130870. /** @hidden */
  130871. var layerVertexShader = { name: name, shader: shader };
  130872. /***/ }),
  130873. /***/ "./Shaders/lensFlare.fragment.ts":
  130874. /*!***************************************!*\
  130875. !*** ./Shaders/lensFlare.fragment.ts ***!
  130876. \***************************************/
  130877. /*! exports provided: lensFlarePixelShader */
  130878. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130879. "use strict";
  130880. __webpack_require__.r(__webpack_exports__);
  130881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  130882. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130883. var name = 'lensFlarePixelShader';
  130884. 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}";
  130885. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130886. /** @hidden */
  130887. var lensFlarePixelShader = { name: name, shader: shader };
  130888. /***/ }),
  130889. /***/ "./Shaders/lensFlare.vertex.ts":
  130890. /*!*************************************!*\
  130891. !*** ./Shaders/lensFlare.vertex.ts ***!
  130892. \*************************************/
  130893. /*! exports provided: lensFlareVertexShader */
  130894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130895. "use strict";
  130896. __webpack_require__.r(__webpack_exports__);
  130897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  130898. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130899. var name = 'lensFlareVertexShader';
  130900. 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}";
  130901. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130902. /** @hidden */
  130903. var lensFlareVertexShader = { name: name, shader: shader };
  130904. /***/ }),
  130905. /***/ "./Shaders/lensHighlights.fragment.ts":
  130906. /*!********************************************!*\
  130907. !*** ./Shaders/lensHighlights.fragment.ts ***!
  130908. \********************************************/
  130909. /*! exports provided: lensHighlightsPixelShader */
  130910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130911. "use strict";
  130912. __webpack_require__.r(__webpack_exports__);
  130913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  130914. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130915. var name = 'lensHighlightsPixelShader';
  130916. 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}";
  130917. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130918. /** @hidden */
  130919. var lensHighlightsPixelShader = { name: name, shader: shader };
  130920. /***/ }),
  130921. /***/ "./Shaders/line.fragment.ts":
  130922. /*!**********************************!*\
  130923. !*** ./Shaders/line.fragment.ts ***!
  130924. \**********************************/
  130925. /*! exports provided: linePixelShader */
  130926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130927. "use strict";
  130928. __webpack_require__.r(__webpack_exports__);
  130929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  130930. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130931. var name = 'linePixelShader';
  130932. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  130933. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130934. /** @hidden */
  130935. var linePixelShader = { name: name, shader: shader };
  130936. /***/ }),
  130937. /***/ "./Shaders/line.vertex.ts":
  130938. /*!********************************!*\
  130939. !*** ./Shaders/line.vertex.ts ***!
  130940. \********************************/
  130941. /*! exports provided: lineVertexShader */
  130942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130943. "use strict";
  130944. __webpack_require__.r(__webpack_exports__);
  130945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  130946. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130947. var name = 'lineVertexShader';
  130948. 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}";
  130949. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130950. /** @hidden */
  130951. var lineVertexShader = { name: name, shader: shader };
  130952. /***/ }),
  130953. /***/ "./Shaders/motionBlur.fragment.ts":
  130954. /*!****************************************!*\
  130955. !*** ./Shaders/motionBlur.fragment.ts ***!
  130956. \****************************************/
  130957. /*! exports provided: motionBlurPixelShader */
  130958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130959. "use strict";
  130960. __webpack_require__.r(__webpack_exports__);
  130961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  130962. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130963. var name = 'motionBlurPixelShader';
  130964. 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";
  130965. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130966. /** @hidden */
  130967. var motionBlurPixelShader = { name: name, shader: shader };
  130968. /***/ }),
  130969. /***/ "./Shaders/noise.fragment.ts":
  130970. /*!***********************************!*\
  130971. !*** ./Shaders/noise.fragment.ts ***!
  130972. \***********************************/
  130973. /*! exports provided: noisePixelShader */
  130974. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130975. "use strict";
  130976. __webpack_require__.r(__webpack_exports__);
  130977. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  130978. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130979. var name = 'noisePixelShader';
  130980. 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";
  130981. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130982. /** @hidden */
  130983. var noisePixelShader = { name: name, shader: shader };
  130984. /***/ }),
  130985. /***/ "./Shaders/outline.fragment.ts":
  130986. /*!*************************************!*\
  130987. !*** ./Shaders/outline.fragment.ts ***!
  130988. \*************************************/
  130989. /*! exports provided: outlinePixelShader */
  130990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130991. "use strict";
  130992. __webpack_require__.r(__webpack_exports__);
  130993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  130994. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130995. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130996. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  130997. var name = 'outlinePixelShader';
  130998. 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}";
  130999. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131000. /** @hidden */
  131001. var outlinePixelShader = { name: name, shader: shader };
  131002. /***/ }),
  131003. /***/ "./Shaders/outline.vertex.ts":
  131004. /*!***********************************!*\
  131005. !*** ./Shaders/outline.vertex.ts ***!
  131006. \***********************************/
  131007. /*! exports provided: outlineVertexShader */
  131008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131009. "use strict";
  131010. __webpack_require__.r(__webpack_exports__);
  131011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  131012. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131013. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  131014. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  131015. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  131016. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  131017. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  131018. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  131019. var name = 'outlineVertexShader';
  131020. 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";
  131021. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131022. /** @hidden */
  131023. var outlineVertexShader = { name: name, shader: shader };
  131024. /***/ }),
  131025. /***/ "./Shaders/particles.fragment.ts":
  131026. /*!***************************************!*\
  131027. !*** ./Shaders/particles.fragment.ts ***!
  131028. \***************************************/
  131029. /*! exports provided: particlesPixelShader */
  131030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131031. "use strict";
  131032. __webpack_require__.r(__webpack_exports__);
  131033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  131034. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131035. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  131036. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  131037. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  131038. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  131039. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  131040. var name = 'particlesPixelShader';
  131041. 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}";
  131042. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131043. /** @hidden */
  131044. var particlesPixelShader = { name: name, shader: shader };
  131045. /***/ }),
  131046. /***/ "./Shaders/particles.vertex.ts":
  131047. /*!*************************************!*\
  131048. !*** ./Shaders/particles.vertex.ts ***!
  131049. \*************************************/
  131050. /*! exports provided: particlesVertexShader */
  131051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131052. "use strict";
  131053. __webpack_require__.r(__webpack_exports__);
  131054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  131055. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131056. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  131057. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  131058. var name = 'particlesVertexShader';
  131059. 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}";
  131060. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131061. /** @hidden */
  131062. var particlesVertexShader = { name: name, shader: shader };
  131063. /***/ }),
  131064. /***/ "./Shaders/pass.fragment.ts":
  131065. /*!**********************************!*\
  131066. !*** ./Shaders/pass.fragment.ts ***!
  131067. \**********************************/
  131068. /*! exports provided: passPixelShader */
  131069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131070. "use strict";
  131071. __webpack_require__.r(__webpack_exports__);
  131072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  131073. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131074. var name = 'passPixelShader';
  131075. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  131076. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131077. /** @hidden */
  131078. var passPixelShader = { name: name, shader: shader };
  131079. /***/ }),
  131080. /***/ "./Shaders/passCube.fragment.ts":
  131081. /*!**************************************!*\
  131082. !*** ./Shaders/passCube.fragment.ts ***!
  131083. \**************************************/
  131084. /*! exports provided: passCubePixelShader */
  131085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131086. "use strict";
  131087. __webpack_require__.r(__webpack_exports__);
  131088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  131089. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131090. var name = 'passCubePixelShader';
  131091. 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}";
  131092. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131093. /** @hidden */
  131094. var passCubePixelShader = { name: name, shader: shader };
  131095. /***/ }),
  131096. /***/ "./Shaders/pbr.fragment.ts":
  131097. /*!*********************************!*\
  131098. !*** ./Shaders/pbr.fragment.ts ***!
  131099. \*********************************/
  131100. /*! exports provided: pbrPixelShader */
  131101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131102. "use strict";
  131103. __webpack_require__.r(__webpack_exports__);
  131104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  131105. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131106. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  131107. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  131108. /* harmony import */ var _ShadersInclude_pbrFragmentExtraDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentExtraDeclaration */ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts");
  131109. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  131110. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  131111. /* harmony import */ var _ShadersInclude_pbrFragmentSamplersDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentSamplersDeclaration */ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts");
  131112. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  131113. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  131114. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  131115. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  131116. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  131117. /* harmony import */ var _ShadersInclude_pbrHelperFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrHelperFunctions */ "./Shaders/ShadersInclude/pbrHelperFunctions.ts");
  131118. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  131119. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  131120. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  131121. /* harmony import */ var _ShadersInclude_pbrDirectLightingSetupFunctions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingSetupFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts");
  131122. /* harmony import */ var _ShadersInclude_pbrDirectLightingFalloffFunctions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFalloffFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts");
  131123. /* harmony import */ var _ShadersInclude_pbrBRDFFunctions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/pbrBRDFFunctions */ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts");
  131124. /* harmony import */ var _ShadersInclude_pbrDirectLightingFunctions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts");
  131125. /* harmony import */ var _ShadersInclude_pbrIBLFunctions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/pbrIBLFunctions */ "./Shaders/ShadersInclude/pbrIBLFunctions.ts");
  131126. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  131127. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  131128. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  131129. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  131130. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  131131. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  131132. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  131133. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  131134. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  131135. var name = 'pbrPixelShader';
  131136. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#include<__decl__pbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<pbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n\n#include<helperFunctions>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<bumpFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#ifdef CLEARCOAT\n\nvec3 clearCoatNormalW=normalW;\n#endif\n#include<bumpFragment>\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n#ifdef REFLECTANCE\n\n\n\n\n\nsurfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\n\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=saturate(microSurface);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\n\nfloat NdotV=absEps(NdotVUnclamped);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\n\nalphaG+=AARoughnessFactors.y;\n#endif\n#ifdef ANISOTROPIC\nfloat anisotropy=vAnisotropy.b;\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\n#ifdef ANISOTROPIC_TEXTURE\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\nanisotropy*=anisotropyMapData.b;\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\n#endif\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\nvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\nvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\nvec3 anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\n#endif\n\n#ifdef SS_REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef SS_REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef SS_REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef SS_LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef SS_RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef SS_GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\n#ifdef SHEEN\nfloat sheenIntensity=vSheenColor.a;\n#ifdef SHEEN_TEXTURE\nvec4 sheenMapData=texture2D(sheenSampler,vSheenUV+uvOffset)*vSheenInfos.y;\nsheenIntensity*=sheenMapData.a;\n#endif\n#ifdef SHEEN_LINKWITHALBEDO\nfloat sheenFactor=pow5(1.0-sheenIntensity);\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\nfloat sheenRoughness=sheenIntensity;\n\nsurfaceAlbedo.rgb*=sheenFactor;\n#else\nvec3 sheenColor=vSheenColor.rgb;\n#ifdef SHEEN_TEXTURE\nsheenColor.rgb*=toLinearSpace(sheenMapData.rgb);\n#endif\nfloat sheenRoughness=roughness;\n\nsheenIntensity*=(1.-reflectance);\n\nsheenColor*=sheenIntensity;\n#endif\n\n#if defined(REFLECTION)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\n\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\n\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG,NdotVUnclamped);\n#else\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nsheenReflectionLOD=sheenReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nenvironmentSheenRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,sheenReflectionLOD);\n#else\nfloat lodSheenReflectionNormalized=saturate(sheenReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodSheenReflectionNormalizedDoubled=lodSheenReflectionNormalized*2.0;\nvec4 environmentSheenMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodSheenReflectionNormalizedDoubled<1.0){\nenvironmentSheenRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSheenMid,\nlodSheenReflectionNormalizedDoubled\n);\n}else{\nenvironmentSheenRadiance=mix(\nenvironmentSheenMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodSheenReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentSheenRadiance.rgb=fromRGBD(environmentSheenRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentSheenRadiance.rgb=toLinearSpace(environmentSheenRadiance.rgb);\n#endif\n\nenvironmentSheenRadiance.rgb*=vReflectionInfos.x;\nenvironmentSheenRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#ifdef CLEARCOAT\n\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\nclearCoatIntensity*=clearCoatMapData.x;\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\nclearCoatThickness*=clearCoatTintMapData.a;\n#endif\nclearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\n#endif\n\n\n\n\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\nspecularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset).xyz*2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBN,vClearCoatBumpUV+uvOffset,clearCoatBumpSampler,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\n#endif\n\nvec2 clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\n\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\n\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\n\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\n\nclearCoatAlphaG+=clearCoatAARoughnessFactors.y;\n#endif\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nclearCoatReflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\n#else\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\n#endif\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG,clearCoatNdotVUnclamped);\n#else\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nclearCoatReflectionLOD=clearCoatReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nfloat requestedClearCoatReflectionLOD=clearCoatReflectionLOD;\nenvironmentClearCoatRadiance=sampleReflectionLod(reflectionSampler,clearCoatReflectionCoords,requestedClearCoatReflectionLOD);\n#else\nfloat lodClearCoatReflectionNormalized=saturate(clearCoatReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodClearCoatReflectionNormalizedDoubled=lodClearCoatReflectionNormalized*2.0;\nvec4 environmentClearCoatMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodClearCoatReflectionNormalizedDoubled<1.0){\nenvironmentClearCoatRadiance=mix(\nsampleReflection(reflectionSamplerHigh,clearCoatReflectionCoords),\nenvironmentClearCoatMid,\nlodClearCoatReflectionNormalizedDoubled\n);\n}else{\nenvironmentClearCoatRadiance=mix(\nenvironmentClearCoatMid,\nsampleReflection(reflectionSamplerLow,clearCoatReflectionCoords),\nlodClearCoatReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentClearCoatRadiance.rgb=fromRGBD(environmentClearCoatRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentClearCoatRadiance.rgb=toLinearSpace(environmentClearCoatRadiance.rgb);\n#endif\n#ifdef CLEARCOAT_TINT\n\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\n\nfloat clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\nvec3 absorption=vec3(0.);\n#endif\n\nenvironmentClearCoatRadiance.rgb*=vReflectionInfos.x;\nenvironmentClearCoatRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#if defined(ENVIRONMENTBRDF)\n\nvec3 environmentBrdf=getBRDFLookup(NdotV,roughness,environmentBrdfSampler);\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nfloat refractionIntensity=vSubSurfaceIntensity.x;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nrefractionIntensity*=(1.0-alpha);\n\nalpha=1.0;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nfloat translucencyIntensity=vSubSurfaceIntensity.y;\n#endif\n#ifdef SS_SCATTERING\nfloat scatteringIntensity=vSubSurfaceIntensity.z;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);\nfloat thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;\n#ifdef SS_MASK_FROM_THICKNESS_TEXTURE\n#ifdef SS_REFRACTION\nrefractionIntensity*=thicknessMap.g;\n#endif\n#ifdef SS_TRANSLUCENCY\ntranslucencyIntensity*=thicknessMap.b;\n#endif\n#ifdef SS_SCATTERING\nscatteringIntensity*=thicknessMap.a;\n#endif\n#endif\n#else\nfloat thickness=vThicknessParam.y;\n#endif\n#ifdef SS_TRANSLUCENCY\nthickness=maxEps(thickness);\nvec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);\ntransmittance*=translucencyIntensity;\n#endif\n#endif\n\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef SHEEN\nvec3 sheenBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\n\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(specularEnvironmentR0,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#if defined(SHEEN) && defined(REFLECTION)\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\nsheenEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nsheenEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#endif\n\n#ifdef CLEARCOAT\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness,environmentBrdfSampler);\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\n\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatAbsorption(clearCoatNdotVRefract,clearCoatNdotVRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#ifdef REFLECTION\nenvironmentIrradiance*=absorption;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=absorption;\n#endif\nspecularEnvironmentReflectance*=absorption;\n#endif\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\nfloat conservationFactor=(1.-fresnelIBLClearCoat);\n#ifdef REFLECTION\nenvironmentIrradiance*=conservationFactor;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\nspecularEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\n\n#ifdef SS_REFRACTION\nvec3 refractionTransmittance=vec3(refractionIntensity);\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\n\n\n\n\n\nrefractionTransmittance*=cocaLambert(volumeAlbedo,thickness);\n#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)\n\nfloat maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);\nvec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);\n\nenvironmentRefraction.rgb*=volumeAlbedo;\n#else\n\n#endif\n\nsurfaceAlbedo*=(1.-refractionIntensity);\n\nenvironmentIrradiance*=(1.-refractionIntensity);\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);\n\nrefractionTransmittance*=1.0-specularEnvironmentReflectance;\n#endif\n\n#if defined(REFLECTION) && defined(USESPHERICALFROMREFLECTIONMAP) && defined(SS_TRANSLUCENCY)\n#if defined(USESPHERICALINVERTEX)\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#endif\nvec3 refractionIrradiance=environmentIrradianceJones(-irradianceVector);\nrefractionIrradiance*=transmittance;\n#endif\n\n\n\n#ifndef METALLICWORKFLOW\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(SS_TRANSLUCENCY)\nfinalIrradiance+=refractionIrradiance;\n#endif\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef SS_REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractionTransmittance;\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\n\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=energyConservationFactor;\n#endif\n\n#ifdef REFLECTION\nvec3 finalClearCoatRadiance=environmentClearCoatRadiance.rgb;\nfinalClearCoatRadiance*=clearCoatEnvironmentReflectance;\n\nvec3 finalClearCoatRadianceScaled=finalClearCoatRadiance*vLightingIntensity.z;\n#endif\n#ifdef SS_REFRACTION\nfinalRefraction*=(conservationFactor*conservationFactor);\n#ifdef CLEARCOAT_TINT\nfinalRefraction*=absorption;\n#endif\n#endif\n#endif\n\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n\n\n\n\n\n#ifdef REFLECTION\nvec3 finalSheenRadiance=environmentSheenRadiance.rgb;\nfinalSheenRadiance*=sheenEnvironmentReflectance;\n\nvec3 finalSheenRadianceScaled=finalSheenRadiance*vLightingIntensity.z;\n#endif\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\n#endif\n#endif\n#endif\n\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalAmbient=vAmbientColor;\nfinalAmbient*=surfaceAlbedo.rgb;\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nfinalAmbient*ambientOcclusionColor +\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef CLEARCOAT\n\n\nfinalClearCoatScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#ifdef CLEARCOAT\n\n\nfinalClearCoatRadianceScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenRadianceScaled +\n#endif\n#endif\n#ifdef SS_REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\nfinalColor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=finalColor;\n#include<pbrDebug>\n}\n";
  131137. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131138. /** @hidden */
  131139. var pbrPixelShader = { name: name, shader: shader };
  131140. /***/ }),
  131141. /***/ "./Shaders/pbr.vertex.ts":
  131142. /*!*******************************!*\
  131143. !*** ./Shaders/pbr.vertex.ts ***!
  131144. \*******************************/
  131145. /*! exports provided: pbrVertexShader */
  131146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131147. "use strict";
  131148. __webpack_require__.r(__webpack_exports__);
  131149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  131150. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131151. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  131152. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  131153. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  131154. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  131155. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  131156. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  131157. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  131158. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  131159. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  131160. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  131161. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  131162. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  131163. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  131164. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  131165. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  131166. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  131167. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  131168. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  131169. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  131170. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  131171. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  131172. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  131173. var name = 'pbrVertexShader';
  131174. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n#define CUSTOM_VERTEX_BEGIN\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatTintUV;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nvarying vec2 vSheenUV;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nvarying vec2 vAnisotropyUV;\n#endif\n#endif\n#ifdef SUBSURFACE\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\nvarying vec2 vThicknessUV;\n#endif\n#endif\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(positionUpdated,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#endif\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nif (vClearCoatInfos.x == 0.)\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nif (vClearCoatBumpInfos.x == 0.)\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nif (vClearCoatTintInfos.x == 0.)\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nif (vSheenInfos.x == 0.)\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nif (vAnisotropyInfos.x == 0.)\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SUBSURFACE\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\nif (vThicknessInfos.x == 0.)\n{\nvThicknessUV=vec2(thicknessMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvThicknessUV=vec2(thicknessMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}";
  131175. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131176. /** @hidden */
  131177. var pbrVertexShader = { name: name, shader: shader };
  131178. /***/ }),
  131179. /***/ "./Shaders/postprocess.vertex.ts":
  131180. /*!***************************************!*\
  131181. !*** ./Shaders/postprocess.vertex.ts ***!
  131182. \***************************************/
  131183. /*! exports provided: postprocessVertexShader */
  131184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131185. "use strict";
  131186. __webpack_require__.r(__webpack_exports__);
  131187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  131188. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131189. var name = 'postprocessVertexShader';
  131190. 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}";
  131191. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131192. /** @hidden */
  131193. var postprocessVertexShader = { name: name, shader: shader };
  131194. /***/ }),
  131195. /***/ "./Shaders/procedural.vertex.ts":
  131196. /*!**************************************!*\
  131197. !*** ./Shaders/procedural.vertex.ts ***!
  131198. \**************************************/
  131199. /*! exports provided: proceduralVertexShader */
  131200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131201. "use strict";
  131202. __webpack_require__.r(__webpack_exports__);
  131203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  131204. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131205. var name = 'proceduralVertexShader';
  131206. 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}";
  131207. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131208. /** @hidden */
  131209. var proceduralVertexShader = { name: name, shader: shader };
  131210. /***/ }),
  131211. /***/ "./Shaders/refraction.fragment.ts":
  131212. /*!****************************************!*\
  131213. !*** ./Shaders/refraction.fragment.ts ***!
  131214. \****************************************/
  131215. /*! exports provided: refractionPixelShader */
  131216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131217. "use strict";
  131218. __webpack_require__.r(__webpack_exports__);
  131219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  131220. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131221. var name = 'refractionPixelShader';
  131222. 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}";
  131223. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131224. /** @hidden */
  131225. var refractionPixelShader = { name: name, shader: shader };
  131226. /***/ }),
  131227. /***/ "./Shaders/rgbdDecode.fragment.ts":
  131228. /*!****************************************!*\
  131229. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  131230. \****************************************/
  131231. /*! exports provided: rgbdDecodePixelShader */
  131232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131233. "use strict";
  131234. __webpack_require__.r(__webpack_exports__);
  131235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  131236. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131237. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  131238. var name = 'rgbdDecodePixelShader';
  131239. 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}";
  131240. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131241. /** @hidden */
  131242. var rgbdDecodePixelShader = { name: name, shader: shader };
  131243. /***/ }),
  131244. /***/ "./Shaders/rgbdEncode.fragment.ts":
  131245. /*!****************************************!*\
  131246. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  131247. \****************************************/
  131248. /*! exports provided: rgbdEncodePixelShader */
  131249. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131250. "use strict";
  131251. __webpack_require__.r(__webpack_exports__);
  131252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  131253. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131254. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  131255. var name = 'rgbdEncodePixelShader';
  131256. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  131257. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131258. /** @hidden */
  131259. var rgbdEncodePixelShader = { name: name, shader: shader };
  131260. /***/ }),
  131261. /***/ "./Shaders/shadowMap.fragment.ts":
  131262. /*!***************************************!*\
  131263. !*** ./Shaders/shadowMap.fragment.ts ***!
  131264. \***************************************/
  131265. /*! exports provided: shadowMapPixelShader */
  131266. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131267. "use strict";
  131268. __webpack_require__.r(__webpack_exports__);
  131269. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  131270. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131271. var name = 'shadowMapPixelShader';
  131272. 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}";
  131273. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131274. /** @hidden */
  131275. var shadowMapPixelShader = { name: name, shader: shader };
  131276. /***/ }),
  131277. /***/ "./Shaders/shadowMap.vertex.ts":
  131278. /*!*************************************!*\
  131279. !*** ./Shaders/shadowMap.vertex.ts ***!
  131280. \*************************************/
  131281. /*! exports provided: shadowMapVertexShader */
  131282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131283. "use strict";
  131284. __webpack_require__.r(__webpack_exports__);
  131285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  131286. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131287. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  131288. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  131289. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  131290. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  131291. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  131292. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  131293. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  131294. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  131295. var name = 'shadowMapVertexShader';
  131296. 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}";
  131297. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131298. /** @hidden */
  131299. var shadowMapVertexShader = { name: name, shader: shader };
  131300. /***/ }),
  131301. /***/ "./Shaders/sharpen.fragment.ts":
  131302. /*!*************************************!*\
  131303. !*** ./Shaders/sharpen.fragment.ts ***!
  131304. \*************************************/
  131305. /*! exports provided: sharpenPixelShader */
  131306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131307. "use strict";
  131308. __webpack_require__.r(__webpack_exports__);
  131309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  131310. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131311. var name = 'sharpenPixelShader';
  131312. 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}";
  131313. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131314. /** @hidden */
  131315. var sharpenPixelShader = { name: name, shader: shader };
  131316. /***/ }),
  131317. /***/ "./Shaders/sprites.fragment.ts":
  131318. /*!*************************************!*\
  131319. !*** ./Shaders/sprites.fragment.ts ***!
  131320. \*************************************/
  131321. /*! exports provided: spritesPixelShader */
  131322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131323. "use strict";
  131324. __webpack_require__.r(__webpack_exports__);
  131325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  131326. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131327. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  131328. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  131329. var name = 'spritesPixelShader';
  131330. 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}";
  131331. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131332. /** @hidden */
  131333. var spritesPixelShader = { name: name, shader: shader };
  131334. /***/ }),
  131335. /***/ "./Shaders/sprites.vertex.ts":
  131336. /*!***********************************!*\
  131337. !*** ./Shaders/sprites.vertex.ts ***!
  131338. \***********************************/
  131339. /*! exports provided: spritesVertexShader */
  131340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131341. "use strict";
  131342. __webpack_require__.r(__webpack_exports__);
  131343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  131344. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131345. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  131346. var name = 'spritesVertexShader';
  131347. 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}";
  131348. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131349. /** @hidden */
  131350. var spritesVertexShader = { name: name, shader: shader };
  131351. /***/ }),
  131352. /***/ "./Shaders/ssao.fragment.ts":
  131353. /*!**********************************!*\
  131354. !*** ./Shaders/ssao.fragment.ts ***!
  131355. \**********************************/
  131356. /*! exports provided: ssaoPixelShader */
  131357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131358. "use strict";
  131359. __webpack_require__.r(__webpack_exports__);
  131360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  131361. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131362. var name = 'ssaoPixelShader';
  131363. 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";
  131364. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131365. /** @hidden */
  131366. var ssaoPixelShader = { name: name, shader: shader };
  131367. /***/ }),
  131368. /***/ "./Shaders/ssao2.fragment.ts":
  131369. /*!***********************************!*\
  131370. !*** ./Shaders/ssao2.fragment.ts ***!
  131371. \***********************************/
  131372. /*! exports provided: ssao2PixelShader */
  131373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131374. "use strict";
  131375. __webpack_require__.r(__webpack_exports__);
  131376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  131377. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131378. var name = 'ssao2PixelShader';
  131379. 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";
  131380. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131381. /** @hidden */
  131382. var ssao2PixelShader = { name: name, shader: shader };
  131383. /***/ }),
  131384. /***/ "./Shaders/ssaoCombine.fragment.ts":
  131385. /*!*****************************************!*\
  131386. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  131387. \*****************************************/
  131388. /*! exports provided: ssaoCombinePixelShader */
  131389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131390. "use strict";
  131391. __webpack_require__.r(__webpack_exports__);
  131392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  131393. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131394. var name = 'ssaoCombinePixelShader';
  131395. 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";
  131396. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131397. /** @hidden */
  131398. var ssaoCombinePixelShader = { name: name, shader: shader };
  131399. /***/ }),
  131400. /***/ "./Shaders/standard.fragment.ts":
  131401. /*!**************************************!*\
  131402. !*** ./Shaders/standard.fragment.ts ***!
  131403. \**************************************/
  131404. /*! exports provided: standardPixelShader */
  131405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131406. "use strict";
  131407. __webpack_require__.r(__webpack_exports__);
  131408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  131409. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131410. var name = 'standardPixelShader';
  131411. 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";
  131412. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131413. /** @hidden */
  131414. var standardPixelShader = { name: name, shader: shader };
  131415. /***/ }),
  131416. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  131417. /*!***************************************************!*\
  131418. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  131419. \***************************************************/
  131420. /*! exports provided: stereoscopicInterlacePixelShader */
  131421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131422. "use strict";
  131423. __webpack_require__.r(__webpack_exports__);
  131424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  131425. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131426. var name = 'stereoscopicInterlacePixelShader';
  131427. 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}";
  131428. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131429. /** @hidden */
  131430. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  131431. /***/ }),
  131432. /***/ "./Shaders/tonemap.fragment.ts":
  131433. /*!*************************************!*\
  131434. !*** ./Shaders/tonemap.fragment.ts ***!
  131435. \*************************************/
  131436. /*! exports provided: tonemapPixelShader */
  131437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131438. "use strict";
  131439. __webpack_require__.r(__webpack_exports__);
  131440. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  131441. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131442. var name = 'tonemapPixelShader';
  131443. 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}";
  131444. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131445. /** @hidden */
  131446. var tonemapPixelShader = { name: name, shader: shader };
  131447. /***/ }),
  131448. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  131449. /*!*******************************************************!*\
  131450. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  131451. \*******************************************************/
  131452. /*! exports provided: volumetricLightScatteringPixelShader */
  131453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131454. "use strict";
  131455. __webpack_require__.r(__webpack_exports__);
  131456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  131457. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131458. var name = 'volumetricLightScatteringPixelShader';
  131459. 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";
  131460. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131461. /** @hidden */
  131462. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  131463. /***/ }),
  131464. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  131465. /*!***********************************************************!*\
  131466. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  131467. \***********************************************************/
  131468. /*! exports provided: volumetricLightScatteringPassPixelShader */
  131469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131470. "use strict";
  131471. __webpack_require__.r(__webpack_exports__);
  131472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  131473. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131474. var name = 'volumetricLightScatteringPassPixelShader';
  131475. 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";
  131476. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131477. /** @hidden */
  131478. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  131479. /***/ }),
  131480. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  131481. /*!****************************************************!*\
  131482. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  131483. \****************************************************/
  131484. /*! exports provided: vrDistortionCorrectionPixelShader */
  131485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131486. "use strict";
  131487. __webpack_require__.r(__webpack_exports__);
  131488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  131489. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131490. var name = 'vrDistortionCorrectionPixelShader';
  131491. 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}";
  131492. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131493. /** @hidden */
  131494. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  131495. /***/ }),
  131496. /***/ "./Shaders/vrMultiviewToSingleview.fragment.ts":
  131497. /*!*****************************************************!*\
  131498. !*** ./Shaders/vrMultiviewToSingleview.fragment.ts ***!
  131499. \*****************************************************/
  131500. /*! exports provided: vrMultiviewToSingleviewPixelShader */
  131501. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131502. "use strict";
  131503. __webpack_require__.r(__webpack_exports__);
  131504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrMultiviewToSingleviewPixelShader", function() { return vrMultiviewToSingleviewPixelShader; });
  131505. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131506. var name = 'vrMultiviewToSingleviewPixelShader';
  131507. 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}";
  131508. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131509. /** @hidden */
  131510. var vrMultiviewToSingleviewPixelShader = { name: name, shader: shader };
  131511. /***/ }),
  131512. /***/ "./Sprites/index.ts":
  131513. /*!**************************!*\
  131514. !*** ./Sprites/index.ts ***!
  131515. \**************************/
  131516. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  131517. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131518. "use strict";
  131519. __webpack_require__.r(__webpack_exports__);
  131520. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  131521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  131522. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  131523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  131524. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  131525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  131526. /***/ }),
  131527. /***/ "./Sprites/sprite.ts":
  131528. /*!***************************!*\
  131529. !*** ./Sprites/sprite.ts ***!
  131530. \***************************/
  131531. /*! exports provided: Sprite */
  131532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131533. "use strict";
  131534. __webpack_require__.r(__webpack_exports__);
  131535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  131536. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  131537. /**
  131538. * Class used to represent a sprite
  131539. * @see http://doc.babylonjs.com/babylon101/sprites
  131540. */
  131541. var Sprite = /** @class */ (function () {
  131542. /**
  131543. * Creates a new Sprite
  131544. * @param name defines the name
  131545. * @param manager defines the manager
  131546. */
  131547. function Sprite(
  131548. /** defines the name */
  131549. name, manager) {
  131550. this.name = name;
  131551. /** Gets or sets the main color */
  131552. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  131553. /** Gets or sets the width */
  131554. this.width = 1.0;
  131555. /** Gets or sets the height */
  131556. this.height = 1.0;
  131557. /** Gets or sets rotation angle */
  131558. this.angle = 0;
  131559. /** Gets or sets the cell index in the sprite sheet */
  131560. this.cellIndex = 0;
  131561. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  131562. this.invertU = 0;
  131563. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  131564. this.invertV = 0;
  131565. /** Gets the list of attached animations */
  131566. this.animations = new Array();
  131567. /** Gets or sets a boolean indicating if the sprite can be picked */
  131568. this.isPickable = false;
  131569. this._animationStarted = false;
  131570. this._loopAnimation = false;
  131571. this._fromIndex = 0;
  131572. this._toIndex = 0;
  131573. this._delay = 0;
  131574. this._direction = 1;
  131575. this._time = 0;
  131576. /**
  131577. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  131578. */
  131579. this.isVisible = true;
  131580. this._manager = manager;
  131581. this._manager.sprites.push(this);
  131582. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  131583. }
  131584. Object.defineProperty(Sprite.prototype, "size", {
  131585. /**
  131586. * Gets or sets the sprite size
  131587. */
  131588. get: function () {
  131589. return this.width;
  131590. },
  131591. set: function (value) {
  131592. this.width = value;
  131593. this.height = value;
  131594. },
  131595. enumerable: true,
  131596. configurable: true
  131597. });
  131598. /**
  131599. * Starts an animation
  131600. * @param from defines the initial key
  131601. * @param to defines the end key
  131602. * @param loop defines if the animation must loop
  131603. * @param delay defines the start delay (in ms)
  131604. * @param onAnimationEnd defines a callback to call when animation ends
  131605. */
  131606. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  131607. this._fromIndex = from;
  131608. this._toIndex = to;
  131609. this._loopAnimation = loop;
  131610. this._delay = delay;
  131611. this._animationStarted = true;
  131612. this._direction = from < to ? 1 : -1;
  131613. this.cellIndex = from;
  131614. this._time = 0;
  131615. this._onAnimationEnd = onAnimationEnd;
  131616. };
  131617. /** Stops current animation (if any) */
  131618. Sprite.prototype.stopAnimation = function () {
  131619. this._animationStarted = false;
  131620. };
  131621. /** @hidden */
  131622. Sprite.prototype._animate = function (deltaTime) {
  131623. if (!this._animationStarted) {
  131624. return;
  131625. }
  131626. this._time += deltaTime;
  131627. if (this._time > this._delay) {
  131628. this._time = this._time % this._delay;
  131629. this.cellIndex += this._direction;
  131630. if (this.cellIndex > this._toIndex) {
  131631. if (this._loopAnimation) {
  131632. this.cellIndex = this._fromIndex;
  131633. }
  131634. else {
  131635. this.cellIndex = this._toIndex;
  131636. this._animationStarted = false;
  131637. if (this._onAnimationEnd) {
  131638. this._onAnimationEnd();
  131639. }
  131640. if (this.disposeWhenFinishedAnimating) {
  131641. this.dispose();
  131642. }
  131643. }
  131644. }
  131645. }
  131646. };
  131647. /** Release associated resources */
  131648. Sprite.prototype.dispose = function () {
  131649. for (var i = 0; i < this._manager.sprites.length; i++) {
  131650. if (this._manager.sprites[i] == this) {
  131651. this._manager.sprites.splice(i, 1);
  131652. }
  131653. }
  131654. };
  131655. return Sprite;
  131656. }());
  131657. /***/ }),
  131658. /***/ "./Sprites/spriteManager.ts":
  131659. /*!**********************************!*\
  131660. !*** ./Sprites/spriteManager.ts ***!
  131661. \**********************************/
  131662. /*! exports provided: SpriteManager */
  131663. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131664. "use strict";
  131665. __webpack_require__.r(__webpack_exports__);
  131666. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  131667. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  131668. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  131669. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  131670. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  131671. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  131672. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  131673. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  131674. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  131675. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  131676. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  131677. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  131678. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  131679. /**
  131680. * Class used to manage multiple sprites on the same spritesheet
  131681. * @see http://doc.babylonjs.com/babylon101/sprites
  131682. */
  131683. var SpriteManager = /** @class */ (function () {
  131684. /**
  131685. * Creates a new sprite manager
  131686. * @param name defines the manager's name
  131687. * @param imgUrl defines the sprite sheet url
  131688. * @param capacity defines the maximum allowed number of sprites
  131689. * @param cellSize defines the size of a sprite cell
  131690. * @param scene defines the hosting scene
  131691. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  131692. * @param samplingMode defines the smapling mode to use with spritesheet
  131693. */
  131694. function SpriteManager(
  131695. /** defines the manager's name */
  131696. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  131697. if (epsilon === void 0) { epsilon = 0.01; }
  131698. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  131699. this.name = name;
  131700. /** Gets the list of sprites */
  131701. this.sprites = new Array();
  131702. /** Gets or sets the rendering group id (0 by default) */
  131703. this.renderingGroupId = 0;
  131704. /** Gets or sets camera layer mask */
  131705. this.layerMask = 0x0FFFFFFF;
  131706. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  131707. this.fogEnabled = true;
  131708. /** Gets or sets a boolean indicating if the sprites are pickable */
  131709. this.isPickable = false;
  131710. /**
  131711. * An event triggered when the manager is disposed.
  131712. */
  131713. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  131714. this._vertexBuffers = {};
  131715. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  131716. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  131717. }
  131718. this._capacity = capacity;
  131719. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  131720. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  131721. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  131722. if (cellSize.width && cellSize.height) {
  131723. this.cellWidth = cellSize.width;
  131724. this.cellHeight = cellSize.height;
  131725. }
  131726. else if (cellSize !== undefined) {
  131727. this.cellWidth = cellSize;
  131728. this.cellHeight = cellSize;
  131729. }
  131730. else {
  131731. return;
  131732. }
  131733. this._epsilon = epsilon;
  131734. this._scene = scene;
  131735. this._scene.spriteManagers.push(this);
  131736. var indices = [];
  131737. var index = 0;
  131738. for (var count = 0; count < capacity; count++) {
  131739. indices.push(index);
  131740. indices.push(index + 1);
  131741. indices.push(index + 2);
  131742. indices.push(index);
  131743. indices.push(index + 2);
  131744. indices.push(index + 3);
  131745. index += 4;
  131746. }
  131747. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  131748. // VBO
  131749. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  131750. this._vertexData = new Float32Array(capacity * 16 * 4);
  131751. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  131752. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  131753. var options = this._buffer.createVertexBuffer("options", 4, 4);
  131754. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  131755. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  131756. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  131757. this._vertexBuffers["options"] = options;
  131758. this._vertexBuffers["cellInfo"] = cellInfo;
  131759. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  131760. // Effects
  131761. 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"], "");
  131762. 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");
  131763. }
  131764. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  131765. /**
  131766. * Callback called when the manager is disposed
  131767. */
  131768. set: function (callback) {
  131769. if (this._onDisposeObserver) {
  131770. this.onDisposeObservable.remove(this._onDisposeObserver);
  131771. }
  131772. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  131773. },
  131774. enumerable: true,
  131775. configurable: true
  131776. });
  131777. Object.defineProperty(SpriteManager.prototype, "texture", {
  131778. /**
  131779. * Gets or sets the spritesheet texture
  131780. */
  131781. get: function () {
  131782. return this._spriteTexture;
  131783. },
  131784. set: function (value) {
  131785. this._spriteTexture = value;
  131786. },
  131787. enumerable: true,
  131788. configurable: true
  131789. });
  131790. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  131791. var arrayOffset = index * 16;
  131792. if (offsetX === 0) {
  131793. offsetX = this._epsilon;
  131794. }
  131795. else if (offsetX === 1) {
  131796. offsetX = 1 - this._epsilon;
  131797. }
  131798. if (offsetY === 0) {
  131799. offsetY = this._epsilon;
  131800. }
  131801. else if (offsetY === 1) {
  131802. offsetY = 1 - this._epsilon;
  131803. }
  131804. this._vertexData[arrayOffset] = sprite.position.x;
  131805. this._vertexData[arrayOffset + 1] = sprite.position.y;
  131806. this._vertexData[arrayOffset + 2] = sprite.position.z;
  131807. this._vertexData[arrayOffset + 3] = sprite.angle;
  131808. this._vertexData[arrayOffset + 4] = sprite.width;
  131809. this._vertexData[arrayOffset + 5] = sprite.height;
  131810. this._vertexData[arrayOffset + 6] = offsetX;
  131811. this._vertexData[arrayOffset + 7] = offsetY;
  131812. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  131813. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  131814. var offset = (sprite.cellIndex / rowSize) >> 0;
  131815. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  131816. this._vertexData[arrayOffset + 11] = offset;
  131817. // Color
  131818. this._vertexData[arrayOffset + 12] = sprite.color.r;
  131819. this._vertexData[arrayOffset + 13] = sprite.color.g;
  131820. this._vertexData[arrayOffset + 14] = sprite.color.b;
  131821. this._vertexData[arrayOffset + 15] = sprite.color.a;
  131822. };
  131823. /**
  131824. * Intersects the sprites with a ray
  131825. * @param ray defines the ray to intersect with
  131826. * @param camera defines the current active camera
  131827. * @param predicate defines a predicate used to select candidate sprites
  131828. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  131829. * @returns null if no hit or a PickingInfo
  131830. */
  131831. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  131832. var count = Math.min(this._capacity, this.sprites.length);
  131833. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131834. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131835. var distance = Number.MAX_VALUE;
  131836. var currentSprite = null;
  131837. var pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131838. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131839. var cameraView = camera.getViewMatrix();
  131840. for (var index = 0; index < count; index++) {
  131841. var sprite = this.sprites[index];
  131842. if (!sprite) {
  131843. continue;
  131844. }
  131845. if (predicate) {
  131846. if (!predicate(sprite)) {
  131847. continue;
  131848. }
  131849. }
  131850. else if (!sprite.isPickable) {
  131851. continue;
  131852. }
  131853. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  131854. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  131855. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  131856. if (ray.intersectsBoxMinMax(min, max)) {
  131857. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  131858. if (distance > currentDistance) {
  131859. distance = currentDistance;
  131860. currentSprite = sprite;
  131861. if (fastCheck) {
  131862. break;
  131863. }
  131864. }
  131865. }
  131866. }
  131867. if (currentSprite) {
  131868. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  131869. cameraView.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  131870. result.hit = true;
  131871. result.pickedSprite = currentSprite;
  131872. result.distance = distance;
  131873. // Get picked point
  131874. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  131875. direction.copyFrom(ray.direction);
  131876. direction.normalize();
  131877. direction.scaleInPlace(distance);
  131878. ray.origin.addToRef(direction, pickedPoint);
  131879. result.pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(pickedPoint, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  131880. return result;
  131881. }
  131882. return null;
  131883. };
  131884. /**
  131885. * Render all child sprites
  131886. */
  131887. SpriteManager.prototype.render = function () {
  131888. // Check
  131889. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  131890. || !this._spriteTexture.isReady() || !this.sprites.length) {
  131891. return;
  131892. }
  131893. var engine = this._scene.getEngine();
  131894. var baseSize = this._spriteTexture.getBaseSize();
  131895. // Sprites
  131896. var deltaTime = engine.getDeltaTime();
  131897. var max = Math.min(this._capacity, this.sprites.length);
  131898. var rowSize = baseSize.width / this.cellWidth;
  131899. var offset = 0;
  131900. var noSprite = true;
  131901. for (var index = 0; index < max; index++) {
  131902. var sprite = this.sprites[index];
  131903. if (!sprite || !sprite.isVisible) {
  131904. continue;
  131905. }
  131906. noSprite = false;
  131907. sprite._animate(deltaTime);
  131908. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  131909. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  131910. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  131911. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  131912. }
  131913. if (noSprite) {
  131914. return;
  131915. }
  131916. this._buffer.update(this._vertexData);
  131917. // Render
  131918. var effect = this._effectBase;
  131919. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  131920. effect = this._effectFog;
  131921. }
  131922. engine.enableEffect(effect);
  131923. var viewMatrix = this._scene.getViewMatrix();
  131924. effect.setTexture("diffuseSampler", this._spriteTexture);
  131925. effect.setMatrix("view", viewMatrix);
  131926. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  131927. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  131928. // Fog
  131929. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  131930. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  131931. effect.setColor3("vFogColor", this._scene.fogColor);
  131932. }
  131933. // VBOs
  131934. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  131935. // Draw order
  131936. engine.setDepthFunctionToLessOrEqual();
  131937. effect.setBool("alphaTest", true);
  131938. engine.setColorWrite(false);
  131939. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  131940. engine.setColorWrite(true);
  131941. effect.setBool("alphaTest", false);
  131942. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  131943. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  131944. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  131945. };
  131946. /**
  131947. * Release associated resources
  131948. */
  131949. SpriteManager.prototype.dispose = function () {
  131950. if (this._buffer) {
  131951. this._buffer.dispose();
  131952. this._buffer = null;
  131953. }
  131954. if (this._indexBuffer) {
  131955. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  131956. this._indexBuffer = null;
  131957. }
  131958. if (this._spriteTexture) {
  131959. this._spriteTexture.dispose();
  131960. this._spriteTexture = null;
  131961. }
  131962. // Remove from scene
  131963. var index = this._scene.spriteManagers.indexOf(this);
  131964. this._scene.spriteManagers.splice(index, 1);
  131965. // Callback
  131966. this.onDisposeObservable.notifyObservers(this);
  131967. this.onDisposeObservable.clear();
  131968. };
  131969. return SpriteManager;
  131970. }());
  131971. /***/ }),
  131972. /***/ "./Sprites/spriteSceneComponent.ts":
  131973. /*!*****************************************!*\
  131974. !*** ./Sprites/spriteSceneComponent.ts ***!
  131975. \*****************************************/
  131976. /*! exports provided: SpriteSceneComponent */
  131977. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131978. "use strict";
  131979. __webpack_require__.r(__webpack_exports__);
  131980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  131981. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  131982. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  131983. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  131984. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  131985. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  131986. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  131987. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  131988. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  131989. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  131990. return null;
  131991. }
  131992. var pickingInfo = null;
  131993. if (!camera) {
  131994. if (!this.activeCamera) {
  131995. return null;
  131996. }
  131997. camera = this.activeCamera;
  131998. }
  131999. if (this.spriteManagers.length > 0) {
  132000. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  132001. var spriteManager = this.spriteManagers[spriteIndex];
  132002. if (!spriteManager.isPickable) {
  132003. continue;
  132004. }
  132005. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  132006. if (!result || !result.hit) {
  132007. continue;
  132008. }
  132009. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  132010. continue;
  132011. }
  132012. pickingInfo = result;
  132013. if (fastCheck) {
  132014. break;
  132015. }
  132016. }
  132017. }
  132018. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  132019. };
  132020. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  132021. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  132022. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  132023. };
  132024. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  132025. if (!this._tempSpritePickingRay) {
  132026. return null;
  132027. }
  132028. if (!camera) {
  132029. if (!this.activeCamera) {
  132030. return null;
  132031. }
  132032. camera = this.activeCamera;
  132033. }
  132034. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  132035. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  132036. };
  132037. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  132038. if (this._pointerOverSprite === sprite) {
  132039. return;
  132040. }
  132041. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  132042. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  132043. }
  132044. this._pointerOverSprite = sprite;
  132045. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  132046. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  132047. }
  132048. };
  132049. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  132050. return this._pointerOverSprite;
  132051. };
  132052. /**
  132053. * Defines the sprite scene component responsible to manage sprites
  132054. * in a given scene.
  132055. */
  132056. var SpriteSceneComponent = /** @class */ (function () {
  132057. /**
  132058. * Creates a new instance of the component for the given scene
  132059. * @param scene Defines the scene to register the component in
  132060. */
  132061. function SpriteSceneComponent(scene) {
  132062. /**
  132063. * The component name helpfull to identify the component in the list of scene components.
  132064. */
  132065. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  132066. this.scene = scene;
  132067. this.scene.spriteManagers = new Array();
  132068. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  132069. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  132070. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  132071. this._spritePredicate = function (sprite) {
  132072. if (!sprite.actionManager) {
  132073. return false;
  132074. }
  132075. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  132076. };
  132077. }
  132078. /**
  132079. * Registers the component in a given scene
  132080. */
  132081. SpriteSceneComponent.prototype.register = function () {
  132082. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  132083. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  132084. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  132085. };
  132086. /**
  132087. * Rebuilds the elements related to this component in case of
  132088. * context lost for instance.
  132089. */
  132090. SpriteSceneComponent.prototype.rebuild = function () {
  132091. /** Nothing to do for sprites */
  132092. };
  132093. /**
  132094. * Disposes the component and the associated ressources.
  132095. */
  132096. SpriteSceneComponent.prototype.dispose = function () {
  132097. this.scene.onBeforeSpritesRenderingObservable.clear();
  132098. this.scene.onAfterSpritesRenderingObservable.clear();
  132099. var spriteManagers = this.scene.spriteManagers;
  132100. while (spriteManagers.length) {
  132101. spriteManagers[0].dispose();
  132102. }
  132103. };
  132104. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  132105. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  132106. if (result) {
  132107. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  132108. }
  132109. return result;
  132110. };
  132111. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  132112. var scene = this.scene;
  132113. if (isMeshPicked) {
  132114. scene.setPointerOverSprite(null);
  132115. }
  132116. else {
  132117. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  132118. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  132119. scene.setPointerOverSprite(pickResult.pickedSprite);
  132120. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  132121. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  132122. }
  132123. else {
  132124. canvas.style.cursor = scene.hoverCursor;
  132125. }
  132126. }
  132127. else {
  132128. scene.setPointerOverSprite(null);
  132129. }
  132130. }
  132131. return pickResult;
  132132. };
  132133. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  132134. var scene = this.scene;
  132135. scene._pickedDownSprite = null;
  132136. if (scene.spriteManagers.length > 0) {
  132137. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  132138. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  132139. if (pickResult.pickedSprite.actionManager) {
  132140. scene._pickedDownSprite = pickResult.pickedSprite;
  132141. switch (evt.button) {
  132142. case 0:
  132143. 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));
  132144. break;
  132145. case 1:
  132146. 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));
  132147. break;
  132148. case 2:
  132149. 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));
  132150. break;
  132151. }
  132152. if (pickResult.pickedSprite.actionManager) {
  132153. 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));
  132154. }
  132155. }
  132156. }
  132157. }
  132158. return pickResult;
  132159. };
  132160. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  132161. var scene = this.scene;
  132162. if (scene.spriteManagers.length > 0) {
  132163. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  132164. if (spritePickResult) {
  132165. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  132166. if (spritePickResult.pickedSprite.actionManager) {
  132167. 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));
  132168. if (spritePickResult.pickedSprite.actionManager) {
  132169. if (!this.scene._isPointerSwiping()) {
  132170. 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));
  132171. }
  132172. }
  132173. }
  132174. }
  132175. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  132176. 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));
  132177. }
  132178. }
  132179. }
  132180. return pickResult;
  132181. };
  132182. return SpriteSceneComponent;
  132183. }());
  132184. /***/ }),
  132185. /***/ "./States/alphaCullingState.ts":
  132186. /*!*************************************!*\
  132187. !*** ./States/alphaCullingState.ts ***!
  132188. \*************************************/
  132189. /*! exports provided: _AlphaState */
  132190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132191. "use strict";
  132192. __webpack_require__.r(__webpack_exports__);
  132193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  132194. /**
  132195. * @hidden
  132196. **/
  132197. var _AlphaState = /** @class */ (function () {
  132198. /**
  132199. * Initializes the state.
  132200. */
  132201. function _AlphaState() {
  132202. this._isAlphaBlendDirty = false;
  132203. this._isBlendFunctionParametersDirty = false;
  132204. this._isBlendEquationParametersDirty = false;
  132205. this._isBlendConstantsDirty = false;
  132206. this._alphaBlend = false;
  132207. this._blendFunctionParameters = new Array(4);
  132208. this._blendEquationParameters = new Array(2);
  132209. this._blendConstants = new Array(4);
  132210. this.reset();
  132211. }
  132212. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  132213. get: function () {
  132214. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  132215. },
  132216. enumerable: true,
  132217. configurable: true
  132218. });
  132219. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  132220. get: function () {
  132221. return this._alphaBlend;
  132222. },
  132223. set: function (value) {
  132224. if (this._alphaBlend === value) {
  132225. return;
  132226. }
  132227. this._alphaBlend = value;
  132228. this._isAlphaBlendDirty = true;
  132229. },
  132230. enumerable: true,
  132231. configurable: true
  132232. });
  132233. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  132234. if (this._blendConstants[0] === r &&
  132235. this._blendConstants[1] === g &&
  132236. this._blendConstants[2] === b &&
  132237. this._blendConstants[3] === a) {
  132238. return;
  132239. }
  132240. this._blendConstants[0] = r;
  132241. this._blendConstants[1] = g;
  132242. this._blendConstants[2] = b;
  132243. this._blendConstants[3] = a;
  132244. this._isBlendConstantsDirty = true;
  132245. };
  132246. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  132247. if (this._blendFunctionParameters[0] === value0 &&
  132248. this._blendFunctionParameters[1] === value1 &&
  132249. this._blendFunctionParameters[2] === value2 &&
  132250. this._blendFunctionParameters[3] === value3) {
  132251. return;
  132252. }
  132253. this._blendFunctionParameters[0] = value0;
  132254. this._blendFunctionParameters[1] = value1;
  132255. this._blendFunctionParameters[2] = value2;
  132256. this._blendFunctionParameters[3] = value3;
  132257. this._isBlendFunctionParametersDirty = true;
  132258. };
  132259. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  132260. if (this._blendEquationParameters[0] === rgb &&
  132261. this._blendEquationParameters[1] === alpha) {
  132262. return;
  132263. }
  132264. this._blendEquationParameters[0] = rgb;
  132265. this._blendEquationParameters[1] = alpha;
  132266. this._isBlendEquationParametersDirty = true;
  132267. };
  132268. _AlphaState.prototype.reset = function () {
  132269. this._alphaBlend = false;
  132270. this._blendFunctionParameters[0] = null;
  132271. this._blendFunctionParameters[1] = null;
  132272. this._blendFunctionParameters[2] = null;
  132273. this._blendFunctionParameters[3] = null;
  132274. this._blendEquationParameters[0] = null;
  132275. this._blendEquationParameters[1] = null;
  132276. this._blendConstants[0] = null;
  132277. this._blendConstants[1] = null;
  132278. this._blendConstants[2] = null;
  132279. this._blendConstants[3] = null;
  132280. this._isAlphaBlendDirty = true;
  132281. this._isBlendFunctionParametersDirty = false;
  132282. this._isBlendEquationParametersDirty = false;
  132283. this._isBlendConstantsDirty = false;
  132284. };
  132285. _AlphaState.prototype.apply = function (gl) {
  132286. if (!this.isDirty) {
  132287. return;
  132288. }
  132289. // Alpha blend
  132290. if (this._isAlphaBlendDirty) {
  132291. if (this._alphaBlend) {
  132292. gl.enable(gl.BLEND);
  132293. }
  132294. else {
  132295. gl.disable(gl.BLEND);
  132296. }
  132297. this._isAlphaBlendDirty = false;
  132298. }
  132299. // Alpha function
  132300. if (this._isBlendFunctionParametersDirty) {
  132301. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  132302. this._isBlendFunctionParametersDirty = false;
  132303. }
  132304. // Alpha equation
  132305. if (this._isBlendEquationParametersDirty) {
  132306. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  132307. this._isBlendEquationParametersDirty = false;
  132308. }
  132309. // Constants
  132310. if (this._isBlendConstantsDirty) {
  132311. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  132312. this._isBlendConstantsDirty = false;
  132313. }
  132314. };
  132315. return _AlphaState;
  132316. }());
  132317. /***/ }),
  132318. /***/ "./States/depthCullingState.ts":
  132319. /*!*************************************!*\
  132320. !*** ./States/depthCullingState.ts ***!
  132321. \*************************************/
  132322. /*! exports provided: _DepthCullingState */
  132323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132324. "use strict";
  132325. __webpack_require__.r(__webpack_exports__);
  132326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  132327. /**
  132328. * @hidden
  132329. **/
  132330. var _DepthCullingState = /** @class */ (function () {
  132331. /**
  132332. * Initializes the state.
  132333. */
  132334. function _DepthCullingState() {
  132335. this._isDepthTestDirty = false;
  132336. this._isDepthMaskDirty = false;
  132337. this._isDepthFuncDirty = false;
  132338. this._isCullFaceDirty = false;
  132339. this._isCullDirty = false;
  132340. this._isZOffsetDirty = false;
  132341. this._isFrontFaceDirty = false;
  132342. this.reset();
  132343. }
  132344. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  132345. get: function () {
  132346. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  132347. },
  132348. enumerable: true,
  132349. configurable: true
  132350. });
  132351. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  132352. get: function () {
  132353. return this._zOffset;
  132354. },
  132355. set: function (value) {
  132356. if (this._zOffset === value) {
  132357. return;
  132358. }
  132359. this._zOffset = value;
  132360. this._isZOffsetDirty = true;
  132361. },
  132362. enumerable: true,
  132363. configurable: true
  132364. });
  132365. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  132366. get: function () {
  132367. return this._cullFace;
  132368. },
  132369. set: function (value) {
  132370. if (this._cullFace === value) {
  132371. return;
  132372. }
  132373. this._cullFace = value;
  132374. this._isCullFaceDirty = true;
  132375. },
  132376. enumerable: true,
  132377. configurable: true
  132378. });
  132379. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  132380. get: function () {
  132381. return this._cull;
  132382. },
  132383. set: function (value) {
  132384. if (this._cull === value) {
  132385. return;
  132386. }
  132387. this._cull = value;
  132388. this._isCullDirty = true;
  132389. },
  132390. enumerable: true,
  132391. configurable: true
  132392. });
  132393. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  132394. get: function () {
  132395. return this._depthFunc;
  132396. },
  132397. set: function (value) {
  132398. if (this._depthFunc === value) {
  132399. return;
  132400. }
  132401. this._depthFunc = value;
  132402. this._isDepthFuncDirty = true;
  132403. },
  132404. enumerable: true,
  132405. configurable: true
  132406. });
  132407. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  132408. get: function () {
  132409. return this._depthMask;
  132410. },
  132411. set: function (value) {
  132412. if (this._depthMask === value) {
  132413. return;
  132414. }
  132415. this._depthMask = value;
  132416. this._isDepthMaskDirty = true;
  132417. },
  132418. enumerable: true,
  132419. configurable: true
  132420. });
  132421. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  132422. get: function () {
  132423. return this._depthTest;
  132424. },
  132425. set: function (value) {
  132426. if (this._depthTest === value) {
  132427. return;
  132428. }
  132429. this._depthTest = value;
  132430. this._isDepthTestDirty = true;
  132431. },
  132432. enumerable: true,
  132433. configurable: true
  132434. });
  132435. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  132436. get: function () {
  132437. return this._frontFace;
  132438. },
  132439. set: function (value) {
  132440. if (this._frontFace === value) {
  132441. return;
  132442. }
  132443. this._frontFace = value;
  132444. this._isFrontFaceDirty = true;
  132445. },
  132446. enumerable: true,
  132447. configurable: true
  132448. });
  132449. _DepthCullingState.prototype.reset = function () {
  132450. this._depthMask = true;
  132451. this._depthTest = true;
  132452. this._depthFunc = null;
  132453. this._cullFace = null;
  132454. this._cull = null;
  132455. this._zOffset = 0;
  132456. this._frontFace = null;
  132457. this._isDepthTestDirty = true;
  132458. this._isDepthMaskDirty = true;
  132459. this._isDepthFuncDirty = false;
  132460. this._isCullFaceDirty = false;
  132461. this._isCullDirty = false;
  132462. this._isZOffsetDirty = false;
  132463. this._isFrontFaceDirty = false;
  132464. };
  132465. _DepthCullingState.prototype.apply = function (gl) {
  132466. if (!this.isDirty) {
  132467. return;
  132468. }
  132469. // Cull
  132470. if (this._isCullDirty) {
  132471. if (this.cull) {
  132472. gl.enable(gl.CULL_FACE);
  132473. }
  132474. else {
  132475. gl.disable(gl.CULL_FACE);
  132476. }
  132477. this._isCullDirty = false;
  132478. }
  132479. // Cull face
  132480. if (this._isCullFaceDirty) {
  132481. gl.cullFace(this.cullFace);
  132482. this._isCullFaceDirty = false;
  132483. }
  132484. // Depth mask
  132485. if (this._isDepthMaskDirty) {
  132486. gl.depthMask(this.depthMask);
  132487. this._isDepthMaskDirty = false;
  132488. }
  132489. // Depth test
  132490. if (this._isDepthTestDirty) {
  132491. if (this.depthTest) {
  132492. gl.enable(gl.DEPTH_TEST);
  132493. }
  132494. else {
  132495. gl.disable(gl.DEPTH_TEST);
  132496. }
  132497. this._isDepthTestDirty = false;
  132498. }
  132499. // Depth func
  132500. if (this._isDepthFuncDirty) {
  132501. gl.depthFunc(this.depthFunc);
  132502. this._isDepthFuncDirty = false;
  132503. }
  132504. // zOffset
  132505. if (this._isZOffsetDirty) {
  132506. if (this.zOffset) {
  132507. gl.enable(gl.POLYGON_OFFSET_FILL);
  132508. gl.polygonOffset(this.zOffset, 0);
  132509. }
  132510. else {
  132511. gl.disable(gl.POLYGON_OFFSET_FILL);
  132512. }
  132513. this._isZOffsetDirty = false;
  132514. }
  132515. // Front face
  132516. if (this._isFrontFaceDirty) {
  132517. gl.frontFace(this.frontFace);
  132518. this._isFrontFaceDirty = false;
  132519. }
  132520. };
  132521. return _DepthCullingState;
  132522. }());
  132523. /***/ }),
  132524. /***/ "./States/index.ts":
  132525. /*!*************************!*\
  132526. !*** ./States/index.ts ***!
  132527. \*************************/
  132528. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  132529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132530. "use strict";
  132531. __webpack_require__.r(__webpack_exports__);
  132532. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  132533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  132534. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  132535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  132536. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  132537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  132538. /***/ }),
  132539. /***/ "./States/stencilState.ts":
  132540. /*!********************************!*\
  132541. !*** ./States/stencilState.ts ***!
  132542. \********************************/
  132543. /*! exports provided: _StencilState */
  132544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132545. "use strict";
  132546. __webpack_require__.r(__webpack_exports__);
  132547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  132548. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  132549. /**
  132550. * @hidden
  132551. **/
  132552. var _StencilState = /** @class */ (function () {
  132553. function _StencilState() {
  132554. this._isStencilTestDirty = false;
  132555. this._isStencilMaskDirty = false;
  132556. this._isStencilFuncDirty = false;
  132557. this._isStencilOpDirty = false;
  132558. this.reset();
  132559. }
  132560. Object.defineProperty(_StencilState.prototype, "isDirty", {
  132561. get: function () {
  132562. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  132563. },
  132564. enumerable: true,
  132565. configurable: true
  132566. });
  132567. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  132568. get: function () {
  132569. return this._stencilFunc;
  132570. },
  132571. set: function (value) {
  132572. if (this._stencilFunc === value) {
  132573. return;
  132574. }
  132575. this._stencilFunc = value;
  132576. this._isStencilFuncDirty = true;
  132577. },
  132578. enumerable: true,
  132579. configurable: true
  132580. });
  132581. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  132582. get: function () {
  132583. return this._stencilFuncRef;
  132584. },
  132585. set: function (value) {
  132586. if (this._stencilFuncRef === value) {
  132587. return;
  132588. }
  132589. this._stencilFuncRef = value;
  132590. this._isStencilFuncDirty = true;
  132591. },
  132592. enumerable: true,
  132593. configurable: true
  132594. });
  132595. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  132596. get: function () {
  132597. return this._stencilFuncMask;
  132598. },
  132599. set: function (value) {
  132600. if (this._stencilFuncMask === value) {
  132601. return;
  132602. }
  132603. this._stencilFuncMask = value;
  132604. this._isStencilFuncDirty = true;
  132605. },
  132606. enumerable: true,
  132607. configurable: true
  132608. });
  132609. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  132610. get: function () {
  132611. return this._stencilOpStencilFail;
  132612. },
  132613. set: function (value) {
  132614. if (this._stencilOpStencilFail === value) {
  132615. return;
  132616. }
  132617. this._stencilOpStencilFail = value;
  132618. this._isStencilOpDirty = true;
  132619. },
  132620. enumerable: true,
  132621. configurable: true
  132622. });
  132623. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  132624. get: function () {
  132625. return this._stencilOpDepthFail;
  132626. },
  132627. set: function (value) {
  132628. if (this._stencilOpDepthFail === value) {
  132629. return;
  132630. }
  132631. this._stencilOpDepthFail = value;
  132632. this._isStencilOpDirty = true;
  132633. },
  132634. enumerable: true,
  132635. configurable: true
  132636. });
  132637. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  132638. get: function () {
  132639. return this._stencilOpStencilDepthPass;
  132640. },
  132641. set: function (value) {
  132642. if (this._stencilOpStencilDepthPass === value) {
  132643. return;
  132644. }
  132645. this._stencilOpStencilDepthPass = value;
  132646. this._isStencilOpDirty = true;
  132647. },
  132648. enumerable: true,
  132649. configurable: true
  132650. });
  132651. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  132652. get: function () {
  132653. return this._stencilMask;
  132654. },
  132655. set: function (value) {
  132656. if (this._stencilMask === value) {
  132657. return;
  132658. }
  132659. this._stencilMask = value;
  132660. this._isStencilMaskDirty = true;
  132661. },
  132662. enumerable: true,
  132663. configurable: true
  132664. });
  132665. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  132666. get: function () {
  132667. return this._stencilTest;
  132668. },
  132669. set: function (value) {
  132670. if (this._stencilTest === value) {
  132671. return;
  132672. }
  132673. this._stencilTest = value;
  132674. this._isStencilTestDirty = true;
  132675. },
  132676. enumerable: true,
  132677. configurable: true
  132678. });
  132679. _StencilState.prototype.reset = function () {
  132680. this._stencilTest = false;
  132681. this._stencilMask = 0xFF;
  132682. this._stencilFunc = _StencilState.ALWAYS;
  132683. this._stencilFuncRef = 1;
  132684. this._stencilFuncMask = 0xFF;
  132685. this._stencilOpStencilFail = _StencilState.KEEP;
  132686. this._stencilOpDepthFail = _StencilState.KEEP;
  132687. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  132688. this._isStencilTestDirty = true;
  132689. this._isStencilMaskDirty = true;
  132690. this._isStencilFuncDirty = true;
  132691. this._isStencilOpDirty = true;
  132692. };
  132693. _StencilState.prototype.apply = function (gl) {
  132694. if (!this.isDirty) {
  132695. return;
  132696. }
  132697. // Stencil test
  132698. if (this._isStencilTestDirty) {
  132699. if (this.stencilTest) {
  132700. gl.enable(gl.STENCIL_TEST);
  132701. }
  132702. else {
  132703. gl.disable(gl.STENCIL_TEST);
  132704. }
  132705. this._isStencilTestDirty = false;
  132706. }
  132707. // Stencil mask
  132708. if (this._isStencilMaskDirty) {
  132709. gl.stencilMask(this.stencilMask);
  132710. this._isStencilMaskDirty = false;
  132711. }
  132712. // Stencil func
  132713. if (this._isStencilFuncDirty) {
  132714. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  132715. this._isStencilFuncDirty = false;
  132716. }
  132717. // Stencil op
  132718. if (this._isStencilOpDirty) {
  132719. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  132720. this._isStencilOpDirty = false;
  132721. }
  132722. };
  132723. /** 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 */
  132724. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  132725. /** Passed to stencilOperation to specify that stencil value must be kept */
  132726. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  132727. /** Passed to stencilOperation to specify that stencil value must be replaced */
  132728. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  132729. return _StencilState;
  132730. }());
  132731. /***/ }),
  132732. /***/ "./abstractScene.ts":
  132733. /*!**************************!*\
  132734. !*** ./abstractScene.ts ***!
  132735. \**************************/
  132736. /*! exports provided: AbstractScene */
  132737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132738. "use strict";
  132739. __webpack_require__.r(__webpack_exports__);
  132740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  132741. /**
  132742. * Base class of the scene acting as a container for the different elements composing a scene.
  132743. * This class is dynamically extended by the different components of the scene increasing
  132744. * flexibility and reducing coupling
  132745. */
  132746. var AbstractScene = /** @class */ (function () {
  132747. function AbstractScene() {
  132748. /**
  132749. * Gets the list of root nodes (ie. nodes with no parent)
  132750. */
  132751. this.rootNodes = new Array();
  132752. /** All of the cameras added to this scene
  132753. * @see http://doc.babylonjs.com/babylon101/cameras
  132754. */
  132755. this.cameras = new Array();
  132756. /**
  132757. * All of the lights added to this scene
  132758. * @see http://doc.babylonjs.com/babylon101/lights
  132759. */
  132760. this.lights = new Array();
  132761. /**
  132762. * All of the (abstract) meshes added to this scene
  132763. */
  132764. this.meshes = new Array();
  132765. /**
  132766. * The list of skeletons added to the scene
  132767. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  132768. */
  132769. this.skeletons = new Array();
  132770. /**
  132771. * All of the particle systems added to this scene
  132772. * @see http://doc.babylonjs.com/babylon101/particles
  132773. */
  132774. this.particleSystems = new Array();
  132775. /**
  132776. * Gets a list of Animations associated with the scene
  132777. */
  132778. this.animations = [];
  132779. /**
  132780. * All of the animation groups added to this scene
  132781. * @see http://doc.babylonjs.com/how_to/group
  132782. */
  132783. this.animationGroups = new Array();
  132784. /**
  132785. * All of the multi-materials added to this scene
  132786. * @see http://doc.babylonjs.com/how_to/multi_materials
  132787. */
  132788. this.multiMaterials = new Array();
  132789. /**
  132790. * All of the materials added to this scene
  132791. * In the context of a Scene, it is not supposed to be modified manually.
  132792. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  132793. * Note also that the order of the Material wihin the array is not significant and might change.
  132794. * @see http://doc.babylonjs.com/babylon101/materials
  132795. */
  132796. this.materials = new Array();
  132797. /**
  132798. * The list of morph target managers added to the scene
  132799. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  132800. */
  132801. this.morphTargetManagers = new Array();
  132802. /**
  132803. * The list of geometries used in the scene.
  132804. */
  132805. this.geometries = new Array();
  132806. /**
  132807. * All of the tranform nodes added to this scene
  132808. * In the context of a Scene, it is not supposed to be modified manually.
  132809. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  132810. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  132811. * @see http://doc.babylonjs.com/how_to/transformnode
  132812. */
  132813. this.transformNodes = new Array();
  132814. /**
  132815. * ActionManagers available on the scene.
  132816. */
  132817. this.actionManagers = new Array();
  132818. /**
  132819. * Textures to keep.
  132820. */
  132821. this.textures = new Array();
  132822. /**
  132823. * Environment texture for the scene
  132824. */
  132825. this.environmentTexture = null;
  132826. }
  132827. /**
  132828. * Adds a parser in the list of available ones
  132829. * @param name Defines the name of the parser
  132830. * @param parser Defines the parser to add
  132831. */
  132832. AbstractScene.AddParser = function (name, parser) {
  132833. this._BabylonFileParsers[name] = parser;
  132834. };
  132835. /**
  132836. * Gets a general parser from the list of avaialble ones
  132837. * @param name Defines the name of the parser
  132838. * @returns the requested parser or null
  132839. */
  132840. AbstractScene.GetParser = function (name) {
  132841. if (this._BabylonFileParsers[name]) {
  132842. return this._BabylonFileParsers[name];
  132843. }
  132844. return null;
  132845. };
  132846. /**
  132847. * Adds n individual parser in the list of available ones
  132848. * @param name Defines the name of the parser
  132849. * @param parser Defines the parser to add
  132850. */
  132851. AbstractScene.AddIndividualParser = function (name, parser) {
  132852. this._IndividualBabylonFileParsers[name] = parser;
  132853. };
  132854. /**
  132855. * Gets an individual parser from the list of avaialble ones
  132856. * @param name Defines the name of the parser
  132857. * @returns the requested parser or null
  132858. */
  132859. AbstractScene.GetIndividualParser = function (name) {
  132860. if (this._IndividualBabylonFileParsers[name]) {
  132861. return this._IndividualBabylonFileParsers[name];
  132862. }
  132863. return null;
  132864. };
  132865. /**
  132866. * Parser json data and populate both a scene and its associated container object
  132867. * @param jsonData Defines the data to parse
  132868. * @param scene Defines the scene to parse the data for
  132869. * @param container Defines the container attached to the parsing sequence
  132870. * @param rootUrl Defines the root url of the data
  132871. */
  132872. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  132873. for (var parserName in this._BabylonFileParsers) {
  132874. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  132875. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  132876. }
  132877. }
  132878. };
  132879. /**
  132880. * Stores the list of available parsers in the application.
  132881. */
  132882. AbstractScene._BabylonFileParsers = {};
  132883. /**
  132884. * Stores the list of available individual parsers in the application.
  132885. */
  132886. AbstractScene._IndividualBabylonFileParsers = {};
  132887. return AbstractScene;
  132888. }());
  132889. /***/ }),
  132890. /***/ "./assetContainer.ts":
  132891. /*!***************************!*\
  132892. !*** ./assetContainer.ts ***!
  132893. \***************************/
  132894. /*! exports provided: KeepAssets, AssetContainer */
  132895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132896. "use strict";
  132897. __webpack_require__.r(__webpack_exports__);
  132898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  132899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  132900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132901. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  132902. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  132903. /**
  132904. * Set of assets to keep when moving a scene into an asset container.
  132905. */
  132906. var KeepAssets = /** @class */ (function (_super) {
  132907. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  132908. function KeepAssets() {
  132909. return _super !== null && _super.apply(this, arguments) || this;
  132910. }
  132911. return KeepAssets;
  132912. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  132913. /**
  132914. * Container with a set of assets that can be added or removed from a scene.
  132915. */
  132916. var AssetContainer = /** @class */ (function (_super) {
  132917. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  132918. /**
  132919. * Instantiates an AssetContainer.
  132920. * @param scene The scene the AssetContainer belongs to.
  132921. */
  132922. function AssetContainer(scene) {
  132923. var _this = _super.call(this) || this;
  132924. _this.scene = scene;
  132925. _this["sounds"] = [];
  132926. _this["effectLayers"] = [];
  132927. _this["layers"] = [];
  132928. _this["lensFlareSystems"] = [];
  132929. _this["proceduralTextures"] = [];
  132930. _this["reflectionProbes"] = [];
  132931. return _this;
  132932. }
  132933. /**
  132934. * Adds all the assets from the container to the scene.
  132935. */
  132936. AssetContainer.prototype.addAllToScene = function () {
  132937. var _this = this;
  132938. this.cameras.forEach(function (o) {
  132939. _this.scene.addCamera(o);
  132940. });
  132941. this.lights.forEach(function (o) {
  132942. _this.scene.addLight(o);
  132943. });
  132944. this.meshes.forEach(function (o) {
  132945. _this.scene.addMesh(o);
  132946. });
  132947. this.skeletons.forEach(function (o) {
  132948. _this.scene.addSkeleton(o);
  132949. });
  132950. this.animations.forEach(function (o) {
  132951. _this.scene.addAnimation(o);
  132952. });
  132953. this.animationGroups.forEach(function (o) {
  132954. _this.scene.addAnimationGroup(o);
  132955. });
  132956. this.multiMaterials.forEach(function (o) {
  132957. _this.scene.addMultiMaterial(o);
  132958. });
  132959. this.materials.forEach(function (o) {
  132960. _this.scene.addMaterial(o);
  132961. });
  132962. this.morphTargetManagers.forEach(function (o) {
  132963. _this.scene.addMorphTargetManager(o);
  132964. });
  132965. this.geometries.forEach(function (o) {
  132966. _this.scene.addGeometry(o);
  132967. });
  132968. this.transformNodes.forEach(function (o) {
  132969. _this.scene.addTransformNode(o);
  132970. });
  132971. this.actionManagers.forEach(function (o) {
  132972. _this.scene.addActionManager(o);
  132973. });
  132974. this.textures.forEach(function (o) {
  132975. _this.scene.addTexture(o);
  132976. });
  132977. this.reflectionProbes.forEach(function (o) {
  132978. _this.scene.addReflectionProbe(o);
  132979. });
  132980. if (this.environmentTexture) {
  132981. this.scene.environmentTexture = this.environmentTexture;
  132982. }
  132983. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  132984. var component = _a[_i];
  132985. component.addFromContainer(this);
  132986. }
  132987. };
  132988. /**
  132989. * Removes all the assets in the container from the scene
  132990. */
  132991. AssetContainer.prototype.removeAllFromScene = function () {
  132992. var _this = this;
  132993. this.cameras.forEach(function (o) {
  132994. _this.scene.removeCamera(o);
  132995. });
  132996. this.lights.forEach(function (o) {
  132997. _this.scene.removeLight(o);
  132998. });
  132999. this.meshes.forEach(function (o) {
  133000. _this.scene.removeMesh(o);
  133001. });
  133002. this.skeletons.forEach(function (o) {
  133003. _this.scene.removeSkeleton(o);
  133004. });
  133005. this.animations.forEach(function (o) {
  133006. _this.scene.removeAnimation(o);
  133007. });
  133008. this.animationGroups.forEach(function (o) {
  133009. _this.scene.removeAnimationGroup(o);
  133010. });
  133011. this.multiMaterials.forEach(function (o) {
  133012. _this.scene.removeMultiMaterial(o);
  133013. });
  133014. this.materials.forEach(function (o) {
  133015. _this.scene.removeMaterial(o);
  133016. });
  133017. this.morphTargetManagers.forEach(function (o) {
  133018. _this.scene.removeMorphTargetManager(o);
  133019. });
  133020. this.geometries.forEach(function (o) {
  133021. _this.scene.removeGeometry(o);
  133022. });
  133023. this.transformNodes.forEach(function (o) {
  133024. _this.scene.removeTransformNode(o);
  133025. });
  133026. this.actionManagers.forEach(function (o) {
  133027. _this.scene.removeActionManager(o);
  133028. });
  133029. this.textures.forEach(function (o) {
  133030. _this.scene.removeTexture(o);
  133031. });
  133032. this.reflectionProbes.forEach(function (o) {
  133033. _this.scene.removeReflectionProbe(o);
  133034. });
  133035. if (this.environmentTexture === this.scene.environmentTexture) {
  133036. this.scene.environmentTexture = null;
  133037. }
  133038. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  133039. var component = _a[_i];
  133040. component.removeFromContainer(this);
  133041. }
  133042. };
  133043. /**
  133044. * Disposes all the assets in the container
  133045. */
  133046. AssetContainer.prototype.dispose = function () {
  133047. this.cameras.forEach(function (o) {
  133048. o.dispose();
  133049. });
  133050. this.cameras = [];
  133051. this.lights.forEach(function (o) {
  133052. o.dispose();
  133053. });
  133054. this.lights = [];
  133055. this.meshes.forEach(function (o) {
  133056. o.dispose();
  133057. });
  133058. this.meshes = [];
  133059. this.skeletons.forEach(function (o) {
  133060. o.dispose();
  133061. });
  133062. this.skeletons = [];
  133063. this.animationGroups.forEach(function (o) {
  133064. o.dispose();
  133065. });
  133066. this.animationGroups = [];
  133067. this.multiMaterials.forEach(function (o) {
  133068. o.dispose();
  133069. });
  133070. this.multiMaterials = [];
  133071. this.materials.forEach(function (o) {
  133072. o.dispose();
  133073. });
  133074. this.materials = [];
  133075. this.geometries.forEach(function (o) {
  133076. o.dispose();
  133077. });
  133078. this.geometries = [];
  133079. this.transformNodes.forEach(function (o) {
  133080. o.dispose();
  133081. });
  133082. this.transformNodes = [];
  133083. this.actionManagers.forEach(function (o) {
  133084. o.dispose();
  133085. });
  133086. this.actionManagers = [];
  133087. this.textures.forEach(function (o) {
  133088. o.dispose();
  133089. });
  133090. this.textures = [];
  133091. this.reflectionProbes.forEach(function (o) {
  133092. o.dispose();
  133093. });
  133094. this.reflectionProbes = [];
  133095. if (this.environmentTexture) {
  133096. this.environmentTexture.dispose();
  133097. this.environmentTexture = null;
  133098. }
  133099. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  133100. var component = _a[_i];
  133101. component.removeFromContainer(this, true);
  133102. }
  133103. };
  133104. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  133105. if (!sourceAssets) {
  133106. return;
  133107. }
  133108. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  133109. var asset = sourceAssets_1[_i];
  133110. var move = true;
  133111. if (keepAssets) {
  133112. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  133113. var keepAsset = keepAssets_1[_a];
  133114. if (asset === keepAsset) {
  133115. move = false;
  133116. break;
  133117. }
  133118. }
  133119. }
  133120. if (move) {
  133121. targetAssets.push(asset);
  133122. }
  133123. }
  133124. };
  133125. /**
  133126. * Removes all the assets contained in the scene and adds them to the container.
  133127. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  133128. */
  133129. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  133130. if (keepAssets === undefined) {
  133131. keepAssets = new KeepAssets();
  133132. }
  133133. for (var key in this) {
  133134. if (this.hasOwnProperty(key)) {
  133135. this[key] = this[key] || [];
  133136. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  133137. }
  133138. }
  133139. this.removeAllFromScene();
  133140. };
  133141. /**
  133142. * 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.
  133143. * @returns the root mesh
  133144. */
  133145. AssetContainer.prototype.createRootMesh = function () {
  133146. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  133147. this.meshes.forEach(function (m) {
  133148. if (!m.parent) {
  133149. rootMesh.addChild(m);
  133150. }
  133151. });
  133152. this.meshes.unshift(rootMesh);
  133153. return rootMesh;
  133154. };
  133155. return AssetContainer;
  133156. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  133157. /***/ }),
  133158. /***/ "./index.ts":
  133159. /*!******************!*\
  133160. !*** ./index.ts ***!
  133161. \******************/
  133162. /*! 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, _IAnimationState, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, AutoRotationBehavior, BouncingBehavior, FramingBehavior, PointerDragBehavior, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, 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, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, _KTXTextureLoader, MultiRenderTarget, 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, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  133163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133164. "use strict";
  133165. __webpack_require__.r(__webpack_exports__);
  133166. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  133167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  133168. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  133169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  133170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  133171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  133172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  133173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  133174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  133175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  133176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  133177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  133178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  133179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  133180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  133181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  133182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  133183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  133184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  133185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  133186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  133187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  133188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  133189. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  133190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  133191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IAnimationState", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["_IAnimationState"]; });
  133192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  133193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  133194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  133195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  133196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  133197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  133198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  133199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  133200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  133201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  133202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  133203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  133204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  133205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  133206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  133207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  133208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  133209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  133210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  133211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  133212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  133213. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  133214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  133215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  133216. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  133217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  133218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  133219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  133220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  133221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  133222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  133223. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  133224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  133225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  133226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  133227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  133228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  133229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  133230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  133231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  133232. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  133233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  133234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  133235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  133236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  133237. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  133238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  133239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  133240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  133241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  133242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  133243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  133244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  133245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  133246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  133247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  133248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  133249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  133250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  133251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  133252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  133253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  133254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  133255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  133256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  133257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  133258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  133259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  133260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  133261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  133262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  133263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  133264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  133265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  133266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  133267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  133268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  133269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  133270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  133271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  133272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  133273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  133274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  133275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  133276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  133277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  133278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  133279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  133280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  133281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  133282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  133283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  133284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  133285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  133286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  133287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  133288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  133289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  133290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  133291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  133292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  133293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  133294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  133295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  133296. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  133297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  133298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  133299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  133300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  133301. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  133302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  133303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  133304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  133305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  133306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  133307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  133308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  133309. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  133310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  133311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  133312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  133313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  133314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  133315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  133316. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  133317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  133318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  133319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  133320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  133321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  133322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  133323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  133324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  133325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  133326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  133327. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  133328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  133329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  133330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  133331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  133332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  133333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  133334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  133335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  133336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  133337. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  133338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  133339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  133340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  133341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  133342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  133343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  133344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  133345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  133346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  133347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  133348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  133349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  133350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  133351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  133352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  133353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  133354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  133355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  133356. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  133357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  133358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  133359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  133360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  133361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  133362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  133363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  133364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  133365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  133366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  133367. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  133368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  133369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  133370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  133371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  133372. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  133373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  133374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  133375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  133376. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  133377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  133378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  133379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  133380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  133381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  133382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  133383. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  133384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  133385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  133386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  133387. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  133388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  133389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  133390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  133391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  133392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  133393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  133394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  133395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  133396. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  133397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  133398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  133399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  133400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  133401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  133402. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  133403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  133404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  133405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  133406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  133407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  133408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  133409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  133410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  133411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  133412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  133413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  133414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  133415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  133416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  133417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  133418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  133419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  133420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EquiRectangularCubeTexture"]; });
  133421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  133422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  133423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  133424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  133425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  133426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  133427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  133428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  133429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  133430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterialDefines"]; });
  133431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  133432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  133433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  133434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  133435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  133436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  133437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  133438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  133439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  133440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  133441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  133442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  133443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  133444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  133445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  133446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  133447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  133448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  133449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  133450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  133451. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  133452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  133453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  133454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  133455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  133456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  133457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  133458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  133459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  133460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  133461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  133462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  133463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  133464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  133465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  133466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  133467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  133468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  133469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  133470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  133471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  133472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  133473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  133474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  133475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  133476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  133477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  133478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  133479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  133480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  133481. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  133482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  133483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  133484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  133485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  133486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  133487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  133488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  133489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  133490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  133491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  133492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  133493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  133494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  133495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  133496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  133497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  133498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  133499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  133500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  133501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  133502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  133503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  133504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  133505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  133506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  133507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  133508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  133509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  133510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  133511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  133512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  133513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  133514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  133515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["HemisphereBuilder"]; });
  133516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  133517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  133518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  133519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  133520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  133521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  133522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  133523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  133524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  133525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  133526. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  133527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  133528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  133529. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  133530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  133531. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  133532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  133533. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  133534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  133535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  133536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  133537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  133538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  133539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  133540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  133541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  133542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  133543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  133544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  133545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  133546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  133547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  133548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  133549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  133550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  133551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  133552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  133553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  133554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  133555. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  133556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  133557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  133558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  133559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEventOptions"]; });
  133560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEventOptions"]; });
  133561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEventOptions"]; });
  133562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  133563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  133564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  133565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  133566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  133567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  133568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  133569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  133570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  133571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  133572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  133573. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  133574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  133575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  133576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  133577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  133578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  133579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  133580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  133581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  133582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  133583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  133584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  133585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  133586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  133587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  133588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  133589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  133590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  133591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  133592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  133593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  133594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  133595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  133596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  133597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  133598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  133599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  133600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  133601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  133602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  133603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  133604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  133605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  133606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  133607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRMultiviewToSingleviewPostProcess"]; });
  133608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  133609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  133610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  133611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  133612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  133613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  133614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  133615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  133616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  133617. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  133618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  133619. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  133620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  133621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  133622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  133623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  133624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  133625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  133626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  133627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  133628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  133629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  133630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  133631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  133632. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  133633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  133634. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  133635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  133636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  133637. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  133638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  133639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  133640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  133641. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  133642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  133643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  133644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  133645. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  133646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  133647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  133648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  133649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  133650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  133651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  133652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  133653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  133654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  133655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  133656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  133657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EquiRectangularCubeTextureAssetTask"]; });
  133658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  133659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  133660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  133661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  133662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  133663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  133664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  133665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  133666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  133667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  133668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  133669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  133670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  133671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  133672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMatrix"]; });
  133673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  133674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  133675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  133676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  133677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshExploder"]; });
  133678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  133679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  133680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  133681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  133682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  133683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  133684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  133685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  133686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  133687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  133688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  133689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  133690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  133691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  133692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  133693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  133694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  133695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  133696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  133697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  133698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  133699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  133700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  133701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  133702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  133703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  133704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  133705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  133706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  133707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  133708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  133709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  133710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  133711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  133712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  133713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  133714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  133715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  133716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  133717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  133718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  133719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  133720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  133721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  133722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  133723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  133724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  133725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  133726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WebRequest"]; });
  133727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["InspectableType"]; });
  133728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  133729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  133730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  133731. /***/ }),
  133732. /***/ "./node.ts":
  133733. /*!*****************!*\
  133734. !*** ./node.ts ***!
  133735. \*****************/
  133736. /*! exports provided: Node */
  133737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133738. "use strict";
  133739. __webpack_require__.r(__webpack_exports__);
  133740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  133741. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  133742. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  133743. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  133744. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  133745. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  133746. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  133747. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  133748. /**
  133749. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  133750. */
  133751. var Node = /** @class */ (function () {
  133752. /**
  133753. * Creates a new Node
  133754. * @param name the name and id to be given to this node
  133755. * @param scene the scene this node will be added to
  133756. * @param addToRootNodes the node will be added to scene.rootNodes
  133757. */
  133758. function Node(name, scene, addToRootNodes) {
  133759. if (scene === void 0) { scene = null; }
  133760. if (addToRootNodes === void 0) { addToRootNodes = true; }
  133761. /**
  133762. * Gets or sets a string used to store user defined state for the node
  133763. */
  133764. this.state = "";
  133765. /**
  133766. * Gets or sets an object used to store user defined information for the node
  133767. */
  133768. this.metadata = null;
  133769. /**
  133770. * For internal use only. Please do not use.
  133771. */
  133772. this.reservedDataStore = null;
  133773. /**
  133774. * Gets or sets a boolean used to define if the node must be serialized
  133775. */
  133776. this.doNotSerialize = false;
  133777. /** @hidden */
  133778. this._isDisposed = false;
  133779. /**
  133780. * Gets a list of Animations associated with the node
  133781. */
  133782. this.animations = new Array();
  133783. this._ranges = {};
  133784. /**
  133785. * Callback raised when the node is ready to be used
  133786. */
  133787. this.onReady = null;
  133788. this._isEnabled = true;
  133789. this._isParentEnabled = true;
  133790. this._isReady = true;
  133791. /** @hidden */
  133792. this._currentRenderId = -1;
  133793. this._parentUpdateId = -1;
  133794. /** @hidden */
  133795. this._childUpdateId = -1;
  133796. /** @hidden */
  133797. this._waitingParentId = null;
  133798. /** @hidden */
  133799. this._cache = {};
  133800. this._parentNode = null;
  133801. this._children = null;
  133802. /** @hidden */
  133803. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  133804. /** @hidden */
  133805. this._worldMatrixDeterminant = 0;
  133806. /** @hidden */
  133807. this._worldMatrixDeterminantIsDirty = true;
  133808. /** @hidden */
  133809. this._sceneRootNodesIndex = -1;
  133810. this._animationPropertiesOverride = null;
  133811. /** @hidden */
  133812. this._isNode = true;
  133813. /**
  133814. * An event triggered when the mesh is disposed
  133815. */
  133816. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133817. this._onDisposeObserver = null;
  133818. // Behaviors
  133819. this._behaviors = new Array();
  133820. this.name = name;
  133821. this.id = name;
  133822. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  133823. this.uniqueId = this._scene.getUniqueId();
  133824. this._initCache();
  133825. if (addToRootNodes) {
  133826. this.addToSceneRootNodes();
  133827. }
  133828. }
  133829. /**
  133830. * Add a new node constructor
  133831. * @param type defines the type name of the node to construct
  133832. * @param constructorFunc defines the constructor function
  133833. */
  133834. Node.AddNodeConstructor = function (type, constructorFunc) {
  133835. this._NodeConstructors[type] = constructorFunc;
  133836. };
  133837. /**
  133838. * Returns a node constructor based on type name
  133839. * @param type defines the type name
  133840. * @param name defines the new node name
  133841. * @param scene defines the hosting scene
  133842. * @param options defines optional options to transmit to constructors
  133843. * @returns the new constructor or null
  133844. */
  133845. Node.Construct = function (type, name, scene, options) {
  133846. var constructorFunc = this._NodeConstructors[type];
  133847. if (!constructorFunc) {
  133848. return null;
  133849. }
  133850. return constructorFunc(name, scene, options);
  133851. };
  133852. /**
  133853. * Gets a boolean indicating if the node has been disposed
  133854. * @returns true if the node was disposed
  133855. */
  133856. Node.prototype.isDisposed = function () {
  133857. return this._isDisposed;
  133858. };
  133859. Object.defineProperty(Node.prototype, "parent", {
  133860. get: function () {
  133861. return this._parentNode;
  133862. },
  133863. /**
  133864. * Gets or sets the parent of the node (without keeping the current position in the scene)
  133865. * @see https://doc.babylonjs.com/how_to/parenting
  133866. */
  133867. set: function (parent) {
  133868. if (this._parentNode === parent) {
  133869. return;
  133870. }
  133871. var previousParentNode = this._parentNode;
  133872. // Remove self from list of children of parent
  133873. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  133874. var index = this._parentNode._children.indexOf(this);
  133875. if (index !== -1) {
  133876. this._parentNode._children.splice(index, 1);
  133877. }
  133878. if (!parent && !this._isDisposed) {
  133879. this.addToSceneRootNodes();
  133880. }
  133881. }
  133882. // Store new parent
  133883. this._parentNode = parent;
  133884. // Add as child to new parent
  133885. if (this._parentNode) {
  133886. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  133887. this._parentNode._children = new Array();
  133888. }
  133889. this._parentNode._children.push(this);
  133890. if (!previousParentNode) {
  133891. this.removeFromSceneRootNodes();
  133892. }
  133893. }
  133894. // Enabled state
  133895. this._syncParentEnabledState();
  133896. },
  133897. enumerable: true,
  133898. configurable: true
  133899. });
  133900. Node.prototype.addToSceneRootNodes = function () {
  133901. if (this._sceneRootNodesIndex === -1) {
  133902. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  133903. this._scene.rootNodes.push(this);
  133904. }
  133905. };
  133906. Node.prototype.removeFromSceneRootNodes = function () {
  133907. if (this._sceneRootNodesIndex !== -1) {
  133908. var rootNodes = this._scene.rootNodes;
  133909. var lastIdx = rootNodes.length - 1;
  133910. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  133911. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  133912. this._scene.rootNodes.pop();
  133913. this._sceneRootNodesIndex = -1;
  133914. }
  133915. };
  133916. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  133917. /**
  133918. * Gets or sets the animation properties override
  133919. */
  133920. get: function () {
  133921. if (!this._animationPropertiesOverride) {
  133922. return this._scene.animationPropertiesOverride;
  133923. }
  133924. return this._animationPropertiesOverride;
  133925. },
  133926. set: function (value) {
  133927. this._animationPropertiesOverride = value;
  133928. },
  133929. enumerable: true,
  133930. configurable: true
  133931. });
  133932. /**
  133933. * Gets a string idenfifying the name of the class
  133934. * @returns "Node" string
  133935. */
  133936. Node.prototype.getClassName = function () {
  133937. return "Node";
  133938. };
  133939. Object.defineProperty(Node.prototype, "onDispose", {
  133940. /**
  133941. * Sets a callback that will be raised when the node will be disposed
  133942. */
  133943. set: function (callback) {
  133944. if (this._onDisposeObserver) {
  133945. this.onDisposeObservable.remove(this._onDisposeObserver);
  133946. }
  133947. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  133948. },
  133949. enumerable: true,
  133950. configurable: true
  133951. });
  133952. /**
  133953. * Gets the scene of the node
  133954. * @returns a scene
  133955. */
  133956. Node.prototype.getScene = function () {
  133957. return this._scene;
  133958. };
  133959. /**
  133960. * Gets the engine of the node
  133961. * @returns a Engine
  133962. */
  133963. Node.prototype.getEngine = function () {
  133964. return this._scene.getEngine();
  133965. };
  133966. /**
  133967. * Attach a behavior to the node
  133968. * @see http://doc.babylonjs.com/features/behaviour
  133969. * @param behavior defines the behavior to attach
  133970. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  133971. * @returns the current Node
  133972. */
  133973. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  133974. var _this = this;
  133975. if (attachImmediately === void 0) { attachImmediately = false; }
  133976. var index = this._behaviors.indexOf(behavior);
  133977. if (index !== -1) {
  133978. return this;
  133979. }
  133980. behavior.init();
  133981. if (this._scene.isLoading && !attachImmediately) {
  133982. // We defer the attach when the scene will be loaded
  133983. this._scene.onDataLoadedObservable.addOnce(function () {
  133984. behavior.attach(_this);
  133985. });
  133986. }
  133987. else {
  133988. behavior.attach(this);
  133989. }
  133990. this._behaviors.push(behavior);
  133991. return this;
  133992. };
  133993. /**
  133994. * Remove an attached behavior
  133995. * @see http://doc.babylonjs.com/features/behaviour
  133996. * @param behavior defines the behavior to attach
  133997. * @returns the current Node
  133998. */
  133999. Node.prototype.removeBehavior = function (behavior) {
  134000. var index = this._behaviors.indexOf(behavior);
  134001. if (index === -1) {
  134002. return this;
  134003. }
  134004. this._behaviors[index].detach();
  134005. this._behaviors.splice(index, 1);
  134006. return this;
  134007. };
  134008. Object.defineProperty(Node.prototype, "behaviors", {
  134009. /**
  134010. * Gets the list of attached behaviors
  134011. * @see http://doc.babylonjs.com/features/behaviour
  134012. */
  134013. get: function () {
  134014. return this._behaviors;
  134015. },
  134016. enumerable: true,
  134017. configurable: true
  134018. });
  134019. /**
  134020. * Gets an attached behavior by name
  134021. * @param name defines the name of the behavior to look for
  134022. * @see http://doc.babylonjs.com/features/behaviour
  134023. * @returns null if behavior was not found else the requested behavior
  134024. */
  134025. Node.prototype.getBehaviorByName = function (name) {
  134026. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  134027. var behavior = _a[_i];
  134028. if (behavior.name === name) {
  134029. return behavior;
  134030. }
  134031. }
  134032. return null;
  134033. };
  134034. /**
  134035. * Returns the latest update of the World matrix
  134036. * @returns a Matrix
  134037. */
  134038. Node.prototype.getWorldMatrix = function () {
  134039. if (this._currentRenderId !== this._scene.getRenderId()) {
  134040. this.computeWorldMatrix();
  134041. }
  134042. return this._worldMatrix;
  134043. };
  134044. /** @hidden */
  134045. Node.prototype._getWorldMatrixDeterminant = function () {
  134046. if (this._worldMatrixDeterminantIsDirty) {
  134047. this._worldMatrixDeterminantIsDirty = false;
  134048. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  134049. }
  134050. return this._worldMatrixDeterminant;
  134051. };
  134052. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  134053. /**
  134054. * Returns directly the latest state of the mesh World matrix.
  134055. * A Matrix is returned.
  134056. */
  134057. get: function () {
  134058. return this._worldMatrix;
  134059. },
  134060. enumerable: true,
  134061. configurable: true
  134062. });
  134063. // override it in derived class if you add new variables to the cache
  134064. // and call the parent class method
  134065. /** @hidden */
  134066. Node.prototype._initCache = function () {
  134067. this._cache = {};
  134068. this._cache.parent = undefined;
  134069. };
  134070. /** @hidden */
  134071. Node.prototype.updateCache = function (force) {
  134072. if (!force && this.isSynchronized()) {
  134073. return;
  134074. }
  134075. this._cache.parent = this.parent;
  134076. this._updateCache();
  134077. };
  134078. /** @hidden */
  134079. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  134080. if (initialCall === void 0) { initialCall = true; }
  134081. if (!this.parent) {
  134082. return null;
  134083. }
  134084. return this.parent._getActionManagerForTrigger(trigger, false);
  134085. };
  134086. // override it in derived class if you add new variables to the cache
  134087. // and call the parent class method if !ignoreParentClass
  134088. /** @hidden */
  134089. Node.prototype._updateCache = function (ignoreParentClass) {
  134090. };
  134091. // override it in derived class if you add new variables to the cache
  134092. /** @hidden */
  134093. Node.prototype._isSynchronized = function () {
  134094. return true;
  134095. };
  134096. /** @hidden */
  134097. Node.prototype._markSyncedWithParent = function () {
  134098. if (this._parentNode) {
  134099. this._parentUpdateId = this._parentNode._childUpdateId;
  134100. }
  134101. };
  134102. /** @hidden */
  134103. Node.prototype.isSynchronizedWithParent = function () {
  134104. if (!this._parentNode) {
  134105. return true;
  134106. }
  134107. if (this._parentUpdateId !== this._parentNode._childUpdateId) {
  134108. return false;
  134109. }
  134110. return this._parentNode.isSynchronized();
  134111. };
  134112. /** @hidden */
  134113. Node.prototype.isSynchronized = function () {
  134114. if (this._cache.parent != this._parentNode) {
  134115. this._cache.parent = this._parentNode;
  134116. return false;
  134117. }
  134118. if (this._parentNode && !this.isSynchronizedWithParent()) {
  134119. return false;
  134120. }
  134121. return this._isSynchronized();
  134122. };
  134123. /**
  134124. * Is this node ready to be used/rendered
  134125. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  134126. * @return true if the node is ready
  134127. */
  134128. Node.prototype.isReady = function (completeCheck) {
  134129. if (completeCheck === void 0) { completeCheck = false; }
  134130. return this._isReady;
  134131. };
  134132. /**
  134133. * Is this node enabled?
  134134. * 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
  134135. * @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
  134136. * @return whether this node (and its parent) is enabled
  134137. */
  134138. Node.prototype.isEnabled = function (checkAncestors) {
  134139. if (checkAncestors === void 0) { checkAncestors = true; }
  134140. if (checkAncestors === false) {
  134141. return this._isEnabled;
  134142. }
  134143. if (!this._isEnabled) {
  134144. return false;
  134145. }
  134146. return this._isParentEnabled;
  134147. };
  134148. /** @hidden */
  134149. Node.prototype._syncParentEnabledState = function () {
  134150. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  134151. if (this._children) {
  134152. this._children.forEach(function (c) {
  134153. c._syncParentEnabledState(); // Force children to update accordingly
  134154. });
  134155. }
  134156. };
  134157. /**
  134158. * Set the enabled state of this node
  134159. * @param value defines the new enabled state
  134160. */
  134161. Node.prototype.setEnabled = function (value) {
  134162. this._isEnabled = value;
  134163. this._syncParentEnabledState();
  134164. };
  134165. /**
  134166. * Is this node a descendant of the given node?
  134167. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  134168. * @param ancestor defines the parent node to inspect
  134169. * @returns a boolean indicating if this node is a descendant of the given node
  134170. */
  134171. Node.prototype.isDescendantOf = function (ancestor) {
  134172. if (this.parent) {
  134173. if (this.parent === ancestor) {
  134174. return true;
  134175. }
  134176. return this.parent.isDescendantOf(ancestor);
  134177. }
  134178. return false;
  134179. };
  134180. /** @hidden */
  134181. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  134182. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  134183. if (!this._children) {
  134184. return;
  134185. }
  134186. for (var index = 0; index < this._children.length; index++) {
  134187. var item = this._children[index];
  134188. if (!predicate || predicate(item)) {
  134189. results.push(item);
  134190. }
  134191. if (!directDescendantsOnly) {
  134192. item._getDescendants(results, false, predicate);
  134193. }
  134194. }
  134195. };
  134196. /**
  134197. * Will return all nodes that have this node as ascendant
  134198. * @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
  134199. * @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
  134200. * @return all children nodes of all types
  134201. */
  134202. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  134203. var results = new Array();
  134204. this._getDescendants(results, directDescendantsOnly, predicate);
  134205. return results;
  134206. };
  134207. /**
  134208. * Get all child-meshes of this node
  134209. * @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)
  134210. * @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
  134211. * @returns an array of AbstractMesh
  134212. */
  134213. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  134214. var results = [];
  134215. this._getDescendants(results, directDescendantsOnly, function (node) {
  134216. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  134217. });
  134218. return results;
  134219. };
  134220. /**
  134221. * Get all direct children of this node
  134222. * @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
  134223. * @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)
  134224. * @returns an array of Node
  134225. */
  134226. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  134227. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  134228. return this.getDescendants(directDescendantsOnly, predicate);
  134229. };
  134230. /** @hidden */
  134231. Node.prototype._setReady = function (state) {
  134232. if (state === this._isReady) {
  134233. return;
  134234. }
  134235. if (!state) {
  134236. this._isReady = false;
  134237. return;
  134238. }
  134239. if (this.onReady) {
  134240. this.onReady(this);
  134241. }
  134242. this._isReady = true;
  134243. };
  134244. /**
  134245. * Get an animation by name
  134246. * @param name defines the name of the animation to look for
  134247. * @returns null if not found else the requested animation
  134248. */
  134249. Node.prototype.getAnimationByName = function (name) {
  134250. for (var i = 0; i < this.animations.length; i++) {
  134251. var animation = this.animations[i];
  134252. if (animation.name === name) {
  134253. return animation;
  134254. }
  134255. }
  134256. return null;
  134257. };
  134258. /**
  134259. * Creates an animation range for this node
  134260. * @param name defines the name of the range
  134261. * @param from defines the starting key
  134262. * @param to defines the end key
  134263. */
  134264. Node.prototype.createAnimationRange = function (name, from, to) {
  134265. // check name not already in use
  134266. if (!this._ranges[name]) {
  134267. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  134268. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  134269. if (this.animations[i]) {
  134270. this.animations[i].createRange(name, from, to);
  134271. }
  134272. }
  134273. }
  134274. };
  134275. /**
  134276. * Delete a specific animation range
  134277. * @param name defines the name of the range to delete
  134278. * @param deleteFrames defines if animation frames from the range must be deleted as well
  134279. */
  134280. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  134281. if (deleteFrames === void 0) { deleteFrames = true; }
  134282. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  134283. if (this.animations[i]) {
  134284. this.animations[i].deleteRange(name, deleteFrames);
  134285. }
  134286. }
  134287. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  134288. };
  134289. /**
  134290. * Get an animation range by name
  134291. * @param name defines the name of the animation range to look for
  134292. * @returns null if not found else the requested animation range
  134293. */
  134294. Node.prototype.getAnimationRange = function (name) {
  134295. return this._ranges[name];
  134296. };
  134297. /**
  134298. * Gets the list of all animation ranges defined on this node
  134299. * @returns an array
  134300. */
  134301. Node.prototype.getAnimationRanges = function () {
  134302. var animationRanges = [];
  134303. var name;
  134304. for (name in this._ranges) {
  134305. animationRanges.push(this._ranges[name]);
  134306. }
  134307. return animationRanges;
  134308. };
  134309. /**
  134310. * Will start the animation sequence
  134311. * @param name defines the range frames for animation sequence
  134312. * @param loop defines if the animation should loop (false by default)
  134313. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  134314. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  134315. * @returns the object created for this animation. If range does not exist, it will return null
  134316. */
  134317. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  134318. var range = this.getAnimationRange(name);
  134319. if (!range) {
  134320. return null;
  134321. }
  134322. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  134323. };
  134324. /**
  134325. * Serialize animation ranges into a JSON compatible object
  134326. * @returns serialization object
  134327. */
  134328. Node.prototype.serializeAnimationRanges = function () {
  134329. var serializationRanges = [];
  134330. for (var name in this._ranges) {
  134331. var localRange = this._ranges[name];
  134332. if (!localRange) {
  134333. continue;
  134334. }
  134335. var range = {};
  134336. range.name = name;
  134337. range.from = localRange.from;
  134338. range.to = localRange.to;
  134339. serializationRanges.push(range);
  134340. }
  134341. return serializationRanges;
  134342. };
  134343. /**
  134344. * Computes the world matrix of the node
  134345. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  134346. * @returns the world matrix
  134347. */
  134348. Node.prototype.computeWorldMatrix = function (force) {
  134349. if (!this._worldMatrix) {
  134350. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  134351. }
  134352. return this._worldMatrix;
  134353. };
  134354. /**
  134355. * Releases resources associated with this node.
  134356. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134357. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134358. */
  134359. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  134360. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  134361. this._isDisposed = true;
  134362. if (!doNotRecurse) {
  134363. var nodes = this.getDescendants(true);
  134364. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  134365. var node = nodes_1[_i];
  134366. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  134367. }
  134368. }
  134369. if (!this.parent) {
  134370. this.removeFromSceneRootNodes();
  134371. }
  134372. else {
  134373. this.parent = null;
  134374. }
  134375. // Callback
  134376. this.onDisposeObservable.notifyObservers(this);
  134377. this.onDisposeObservable.clear();
  134378. // Behaviors
  134379. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  134380. var behavior = _b[_a];
  134381. behavior.detach();
  134382. }
  134383. this._behaviors = [];
  134384. };
  134385. /**
  134386. * Parse animation range data from a serialization object and store them into a given node
  134387. * @param node defines where to store the animation ranges
  134388. * @param parsedNode defines the serialization object to read data from
  134389. * @param scene defines the hosting scene
  134390. */
  134391. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  134392. if (parsedNode.ranges) {
  134393. for (var index = 0; index < parsedNode.ranges.length; index++) {
  134394. var data = parsedNode.ranges[index];
  134395. node.createAnimationRange(data.name, data.from, data.to);
  134396. }
  134397. }
  134398. };
  134399. /**
  134400. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  134401. * @param includeDescendants Include bounding info from descendants as well (true by default)
  134402. * @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
  134403. * @returns the new bounding vectors
  134404. */
  134405. Node.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  134406. if (includeDescendants === void 0) { includeDescendants = true; }
  134407. if (predicate === void 0) { predicate = null; }
  134408. // Ensures that all world matrix will be recomputed.
  134409. this.getScene().incrementRenderId();
  134410. this.computeWorldMatrix(true);
  134411. var min;
  134412. var max;
  134413. var thisAbstractMesh = this;
  134414. if (thisAbstractMesh.getBoundingInfo && thisAbstractMesh.subMeshes) {
  134415. // If this is an abstract mesh get its bounding info
  134416. var boundingInfo = thisAbstractMesh.getBoundingInfo();
  134417. min = boundingInfo.boundingBox.minimumWorld;
  134418. max = boundingInfo.boundingBox.maximumWorld;
  134419. }
  134420. else {
  134421. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  134422. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  134423. }
  134424. if (includeDescendants) {
  134425. var descendants = this.getDescendants(false);
  134426. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  134427. var descendant = descendants_1[_i];
  134428. var childMesh = descendant;
  134429. childMesh.computeWorldMatrix(true);
  134430. // Filters meshes based on custom predicate function.
  134431. if (predicate && !predicate(childMesh)) {
  134432. continue;
  134433. }
  134434. //make sure we have the needed params to get mix and max
  134435. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  134436. continue;
  134437. }
  134438. var childBoundingInfo = childMesh.getBoundingInfo();
  134439. var boundingBox = childBoundingInfo.boundingBox;
  134440. var minBox = boundingBox.minimumWorld;
  134441. var maxBox = boundingBox.maximumWorld;
  134442. _Misc_tools__WEBPACK_IMPORTED_MODULE_6__["Tools"].CheckExtends(minBox, min, max);
  134443. _Misc_tools__WEBPACK_IMPORTED_MODULE_6__["Tools"].CheckExtends(maxBox, min, max);
  134444. }
  134445. }
  134446. return {
  134447. min: min,
  134448. max: max
  134449. };
  134450. };
  134451. /** @hidden */
  134452. Node._AnimationRangeFactory = function (name, from, to) {
  134453. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  134454. };
  134455. Node._NodeConstructors = {};
  134456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134458. ], Node.prototype, "name", void 0);
  134459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134461. ], Node.prototype, "id", void 0);
  134462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134464. ], Node.prototype, "uniqueId", void 0);
  134465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134467. ], Node.prototype, "state", void 0);
  134468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134470. ], Node.prototype, "metadata", void 0);
  134471. return Node;
  134472. }());
  134473. /***/ }),
  134474. /***/ "./scene.ts":
  134475. /*!******************!*\
  134476. !*** ./scene.ts ***!
  134477. \******************/
  134478. /*! exports provided: Scene */
  134479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134480. "use strict";
  134481. __webpack_require__.r(__webpack_exports__);
  134482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  134483. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  134484. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  134485. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  134486. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  134487. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  134488. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  134489. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  134490. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  134491. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/transformNode */ "./Meshes/transformNode.ts");
  134492. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  134493. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  134494. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  134495. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  134496. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  134497. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  134498. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  134499. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  134500. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  134501. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  134502. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  134503. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  134504. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  134505. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  134506. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  134507. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  134508. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  134509. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  134510. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  134511. /** @hidden */
  134512. var ClickInfo = /** @class */ (function () {
  134513. function ClickInfo() {
  134514. this._singleClick = false;
  134515. this._doubleClick = false;
  134516. this._hasSwiped = false;
  134517. this._ignore = false;
  134518. }
  134519. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  134520. get: function () {
  134521. return this._singleClick;
  134522. },
  134523. set: function (b) {
  134524. this._singleClick = b;
  134525. },
  134526. enumerable: true,
  134527. configurable: true
  134528. });
  134529. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  134530. get: function () {
  134531. return this._doubleClick;
  134532. },
  134533. set: function (b) {
  134534. this._doubleClick = b;
  134535. },
  134536. enumerable: true,
  134537. configurable: true
  134538. });
  134539. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  134540. get: function () {
  134541. return this._hasSwiped;
  134542. },
  134543. set: function (b) {
  134544. this._hasSwiped = b;
  134545. },
  134546. enumerable: true,
  134547. configurable: true
  134548. });
  134549. Object.defineProperty(ClickInfo.prototype, "ignore", {
  134550. get: function () {
  134551. return this._ignore;
  134552. },
  134553. set: function (b) {
  134554. this._ignore = b;
  134555. },
  134556. enumerable: true,
  134557. configurable: true
  134558. });
  134559. return ClickInfo;
  134560. }());
  134561. /**
  134562. * Represents a scene to be rendered by the engine.
  134563. * @see http://doc.babylonjs.com/features/scene
  134564. */
  134565. var Scene = /** @class */ (function (_super) {
  134566. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  134567. /**
  134568. * Creates a new Scene
  134569. * @param engine defines the engine to use to render this scene
  134570. * @param options defines the scene options
  134571. */
  134572. function Scene(engine, options) {
  134573. var _this = _super.call(this) || this;
  134574. // Members
  134575. /** @hidden */
  134576. _this._isScene = true;
  134577. /**
  134578. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  134579. */
  134580. _this.autoClear = true;
  134581. /**
  134582. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  134583. */
  134584. _this.autoClearDepthAndStencil = true;
  134585. /**
  134586. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  134587. */
  134588. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  134589. /**
  134590. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  134591. */
  134592. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  134593. _this._forceWireframe = false;
  134594. _this._forcePointsCloud = false;
  134595. /**
  134596. * Gets or sets a boolean indicating if animations are enabled
  134597. */
  134598. _this.animationsEnabled = true;
  134599. _this._animationPropertiesOverride = null;
  134600. /**
  134601. * Gets or sets a boolean indicating if a constant deltatime has to be used
  134602. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  134603. */
  134604. _this.useConstantAnimationDeltaTime = false;
  134605. /**
  134606. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  134607. * Please note that it requires to run a ray cast through the scene on every frame
  134608. */
  134609. _this.constantlyUpdateMeshUnderPointer = false;
  134610. /**
  134611. * Defines the HTML cursor to use when hovering over interactive elements
  134612. */
  134613. _this.hoverCursor = "pointer";
  134614. /**
  134615. * Defines the HTML default cursor to use (empty by default)
  134616. */
  134617. _this.defaultCursor = "";
  134618. /**
  134619. * This is used to call preventDefault() on pointer down
  134620. * in order to block unwanted artifacts like system double clicks
  134621. */
  134622. _this.preventDefaultOnPointerDown = true;
  134623. /**
  134624. * This is used to call preventDefault() on pointer up
  134625. * in order to block unwanted artifacts like system double clicks
  134626. */
  134627. _this.preventDefaultOnPointerUp = true;
  134628. // Metadata
  134629. /**
  134630. * Gets or sets user defined metadata
  134631. */
  134632. _this.metadata = null;
  134633. /**
  134634. * For internal use only. Please do not use.
  134635. */
  134636. _this.reservedDataStore = null;
  134637. /**
  134638. * Use this array to add regular expressions used to disable offline support for specific urls
  134639. */
  134640. _this.disableOfflineSupportExceptionRules = new Array();
  134641. /**
  134642. * An event triggered when the scene is disposed.
  134643. */
  134644. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134645. _this._onDisposeObserver = null;
  134646. /**
  134647. * An event triggered before rendering the scene (right after animations and physics)
  134648. */
  134649. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134650. _this._onBeforeRenderObserver = null;
  134651. /**
  134652. * An event triggered after rendering the scene
  134653. */
  134654. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134655. _this._onAfterRenderObserver = null;
  134656. /**
  134657. * An event triggered before animating the scene
  134658. */
  134659. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134660. /**
  134661. * An event triggered after animations processing
  134662. */
  134663. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134664. /**
  134665. * An event triggered before draw calls are ready to be sent
  134666. */
  134667. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134668. /**
  134669. * An event triggered after draw calls have been sent
  134670. */
  134671. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134672. /**
  134673. * An event triggered when the scene is ready
  134674. */
  134675. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134676. /**
  134677. * An event triggered before rendering a camera
  134678. */
  134679. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134680. _this._onBeforeCameraRenderObserver = null;
  134681. /**
  134682. * An event triggered after rendering a camera
  134683. */
  134684. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134685. _this._onAfterCameraRenderObserver = null;
  134686. /**
  134687. * An event triggered when active meshes evaluation is about to start
  134688. */
  134689. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134690. /**
  134691. * An event triggered when active meshes evaluation is done
  134692. */
  134693. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134694. /**
  134695. * An event triggered when particles rendering is about to start
  134696. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  134697. */
  134698. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134699. /**
  134700. * An event triggered when particles rendering is done
  134701. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  134702. */
  134703. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134704. /**
  134705. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  134706. */
  134707. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134708. /**
  134709. * An event triggered when a camera is created
  134710. */
  134711. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134712. /**
  134713. * An event triggered when a camera is removed
  134714. */
  134715. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134716. /**
  134717. * An event triggered when a light is created
  134718. */
  134719. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134720. /**
  134721. * An event triggered when a light is removed
  134722. */
  134723. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134724. /**
  134725. * An event triggered when a geometry is created
  134726. */
  134727. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134728. /**
  134729. * An event triggered when a geometry is removed
  134730. */
  134731. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134732. /**
  134733. * An event triggered when a transform node is created
  134734. */
  134735. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134736. /**
  134737. * An event triggered when a transform node is removed
  134738. */
  134739. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134740. /**
  134741. * An event triggered when a mesh is created
  134742. */
  134743. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134744. /**
  134745. * An event triggered when a mesh is removed
  134746. */
  134747. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134748. /**
  134749. * An event triggered when a skeleton is created
  134750. */
  134751. _this.onNewSkeletonAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134752. /**
  134753. * An event triggered when a skeleton is removed
  134754. */
  134755. _this.onSkeletonRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134756. /**
  134757. * An event triggered when a material is created
  134758. */
  134759. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134760. /**
  134761. * An event triggered when a material is removed
  134762. */
  134763. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134764. /**
  134765. * An event triggered when a texture is created
  134766. */
  134767. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134768. /**
  134769. * An event triggered when a texture is removed
  134770. */
  134771. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134772. /**
  134773. * An event triggered when render targets are about to be rendered
  134774. * Can happen multiple times per frame.
  134775. */
  134776. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134777. /**
  134778. * An event triggered when render targets were rendered.
  134779. * Can happen multiple times per frame.
  134780. */
  134781. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134782. /**
  134783. * An event triggered before calculating deterministic simulation step
  134784. */
  134785. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134786. /**
  134787. * An event triggered after calculating deterministic simulation step
  134788. */
  134789. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134790. /**
  134791. * An event triggered when the activeCamera property is updated
  134792. */
  134793. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134794. /**
  134795. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  134796. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  134797. * 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)
  134798. */
  134799. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134800. /**
  134801. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  134802. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  134803. * 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)
  134804. */
  134805. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134806. /**
  134807. * This Observable will when a mesh has been imported into the scene.
  134808. */
  134809. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134810. // Animations
  134811. /** @hidden */
  134812. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  134813. /**
  134814. * 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).
  134815. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  134816. */
  134817. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134818. /**
  134819. * Observable event triggered each time an input event is received from the rendering canvas
  134820. */
  134821. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134822. _this._meshPickProceed = false;
  134823. _this._currentPickResult = null;
  134824. _this._previousPickResult = null;
  134825. _this._totalPointersPressed = 0;
  134826. _this._doubleClickOccured = false;
  134827. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  134828. _this.cameraToUseForPointers = null;
  134829. _this._pointerX = 0;
  134830. _this._pointerY = 0;
  134831. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  134832. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  134833. _this._startingPointerTime = 0;
  134834. _this._previousStartingPointerTime = 0;
  134835. _this._pointerCaptures = {};
  134836. // Deterministic lockstep
  134837. _this._timeAccumulator = 0;
  134838. _this._currentStepId = 0;
  134839. _this._currentInternalStep = 0;
  134840. // Keyboard
  134841. /**
  134842. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  134843. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  134844. */
  134845. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134846. /**
  134847. * Observable event triggered each time an keyboard event is received from the hosting window
  134848. */
  134849. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134850. // Coordinates system
  134851. _this._useRightHandedSystem = false;
  134852. // Fog
  134853. _this._fogEnabled = true;
  134854. _this._fogMode = Scene.FOGMODE_NONE;
  134855. /**
  134856. * Gets or sets the fog color to use
  134857. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134858. * (Default is Color3(0.2, 0.2, 0.3))
  134859. */
  134860. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  134861. /**
  134862. * Gets or sets the fog density to use
  134863. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134864. * (Default is 0.1)
  134865. */
  134866. _this.fogDensity = 0.1;
  134867. /**
  134868. * Gets or sets the fog start distance to use
  134869. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134870. * (Default is 0)
  134871. */
  134872. _this.fogStart = 0;
  134873. /**
  134874. * Gets or sets the fog end distance to use
  134875. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134876. * (Default is 1000)
  134877. */
  134878. _this.fogEnd = 1000.0;
  134879. // Lights
  134880. _this._shadowsEnabled = true;
  134881. _this._lightsEnabled = true;
  134882. /** All of the active cameras added to this scene. */
  134883. _this.activeCameras = new Array();
  134884. // Textures
  134885. _this._texturesEnabled = true;
  134886. // Particles
  134887. /**
  134888. * Gets or sets a boolean indicating if particles are enabled on this scene
  134889. */
  134890. _this.particlesEnabled = true;
  134891. // Sprites
  134892. /**
  134893. * Gets or sets a boolean indicating if sprites are enabled on this scene
  134894. */
  134895. _this.spritesEnabled = true;
  134896. // Skeletons
  134897. _this._skeletonsEnabled = true;
  134898. // Lens flares
  134899. /**
  134900. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  134901. */
  134902. _this.lensFlaresEnabled = true;
  134903. // Collisions
  134904. /**
  134905. * Gets or sets a boolean indicating if collisions are enabled on this scene
  134906. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  134907. */
  134908. _this.collisionsEnabled = true;
  134909. /**
  134910. * Defines the gravity applied to this scene (used only for collisions)
  134911. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  134912. */
  134913. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  134914. // Postprocesses
  134915. /**
  134916. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  134917. */
  134918. _this.postProcessesEnabled = true;
  134919. /**
  134920. * The list of postprocesses added to the scene
  134921. */
  134922. _this.postProcesses = new Array();
  134923. // Customs render targets
  134924. /**
  134925. * Gets or sets a boolean indicating if render targets are enabled on this scene
  134926. */
  134927. _this.renderTargetsEnabled = true;
  134928. /**
  134929. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  134930. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  134931. */
  134932. _this.dumpNextRenderTargets = false;
  134933. /**
  134934. * The list of user defined render targets added to the scene
  134935. */
  134936. _this.customRenderTargets = new Array();
  134937. /**
  134938. * Gets the list of meshes imported to the scene through SceneLoader
  134939. */
  134940. _this.importedMeshesFiles = new Array();
  134941. // Probes
  134942. /**
  134943. * Gets or sets a boolean indicating if probes are enabled on this scene
  134944. */
  134945. _this.probesEnabled = true;
  134946. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  134947. // Procedural textures
  134948. /**
  134949. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  134950. */
  134951. _this.proceduralTexturesEnabled = true;
  134952. // Performance counters
  134953. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134954. /** @hidden */
  134955. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134956. /** @hidden */
  134957. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134958. /** @hidden */
  134959. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134960. /** @hidden */
  134961. _this._animationTime = 0;
  134962. /**
  134963. * Gets or sets a general scale for animation speed
  134964. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  134965. */
  134966. _this.animationTimeScale = 1;
  134967. _this._renderId = 0;
  134968. _this._frameId = 0;
  134969. _this._executeWhenReadyTimeoutId = -1;
  134970. _this._intermediateRendering = false;
  134971. _this._viewUpdateFlag = -1;
  134972. _this._projectionUpdateFlag = -1;
  134973. /** @hidden */
  134974. _this._toBeDisposed = new Array(256);
  134975. _this._activeRequests = new Array();
  134976. /** @hidden */
  134977. _this._pendingData = new Array();
  134978. _this._isDisposed = false;
  134979. /**
  134980. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  134981. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  134982. */
  134983. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  134984. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  134985. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  134986. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  134987. /** @hidden */
  134988. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  134989. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  134990. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  134991. /** @hidden */
  134992. _this._activeAnimatables = new Array();
  134993. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  134994. _this._wheelEventName = "";
  134995. /**
  134996. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  134997. * This is useful if there are more lights that the maximum simulteanous authorized
  134998. */
  134999. _this.requireLightSorting = false;
  135000. /**
  135001. * @hidden
  135002. * Backing store of defined scene components.
  135003. */
  135004. _this._components = [];
  135005. /**
  135006. * @hidden
  135007. * Backing store of defined scene components.
  135008. */
  135009. _this._serializableComponents = [];
  135010. /**
  135011. * List of components to register on the next registration step.
  135012. */
  135013. _this._transientComponents = [];
  135014. /**
  135015. * @hidden
  135016. * Defines the actions happening before camera updates.
  135017. */
  135018. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135019. /**
  135020. * @hidden
  135021. * Defines the actions happening before clear the canvas.
  135022. */
  135023. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135024. /**
  135025. * @hidden
  135026. * Defines the actions when collecting render targets for the frame.
  135027. */
  135028. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135029. /**
  135030. * @hidden
  135031. * Defines the actions happening for one camera in the frame.
  135032. */
  135033. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135034. /**
  135035. * @hidden
  135036. * Defines the actions happening during the per mesh ready checks.
  135037. */
  135038. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135039. /**
  135040. * @hidden
  135041. * Defines the actions happening before evaluate active mesh checks.
  135042. */
  135043. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135044. /**
  135045. * @hidden
  135046. * Defines the actions happening during the evaluate sub mesh checks.
  135047. */
  135048. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135049. /**
  135050. * @hidden
  135051. * Defines the actions happening during the active mesh stage.
  135052. */
  135053. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135054. /**
  135055. * @hidden
  135056. * Defines the actions happening during the per camera render target step.
  135057. */
  135058. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135059. /**
  135060. * @hidden
  135061. * Defines the actions happening just before the active camera is drawing.
  135062. */
  135063. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135064. /**
  135065. * @hidden
  135066. * Defines the actions happening just before a render target is drawing.
  135067. */
  135068. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135069. /**
  135070. * @hidden
  135071. * Defines the actions happening just before a rendering group is drawing.
  135072. */
  135073. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135074. /**
  135075. * @hidden
  135076. * Defines the actions happening just before a mesh is drawing.
  135077. */
  135078. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135079. /**
  135080. * @hidden
  135081. * Defines the actions happening just after a mesh has been drawn.
  135082. */
  135083. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135084. /**
  135085. * @hidden
  135086. * Defines the actions happening just after a rendering group has been drawn.
  135087. */
  135088. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135089. /**
  135090. * @hidden
  135091. * Defines the actions happening just after the active camera has been drawn.
  135092. */
  135093. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135094. /**
  135095. * @hidden
  135096. * Defines the actions happening just after a render target has been drawn.
  135097. */
  135098. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135099. /**
  135100. * @hidden
  135101. * Defines the actions happening just after rendering all cameras and computing intersections.
  135102. */
  135103. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135104. /**
  135105. * @hidden
  135106. * Defines the actions happening when a pointer move event happens.
  135107. */
  135108. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135109. /**
  135110. * @hidden
  135111. * Defines the actions happening when a pointer down event happens.
  135112. */
  135113. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135114. /**
  135115. * @hidden
  135116. * Defines the actions happening when a pointer up event happens.
  135117. */
  135118. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  135119. /**
  135120. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  135121. */
  135122. _this.geometriesByUniqueId = null;
  135123. _this._defaultMeshCandidates = {
  135124. data: [],
  135125. length: 0
  135126. };
  135127. _this._defaultSubMeshCandidates = {
  135128. data: [],
  135129. length: 0
  135130. };
  135131. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  135132. _this._activeMeshesFrozen = false;
  135133. /** @hidden */
  135134. _this._allowPostProcessClearColor = true;
  135135. /**
  135136. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  135137. */
  135138. _this.getDeterministicFrameTime = function () {
  135139. return 1000.0 / 60.0; // frame time in ms
  135140. };
  135141. _this._blockMaterialDirtyMechanism = false;
  135142. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_25__["EngineStore"].LastCreatedEngine;
  135143. _this._engine.scenes.push(_this);
  135144. _this._uid = null;
  135145. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_20__["RenderingManager"](_this);
  135146. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_19__["PostProcessManager"]) {
  135147. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_19__["PostProcessManager"](_this);
  135148. }
  135149. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_23__["DomManagement"].IsWindowObjectExist()) {
  135150. _this.attachControl();
  135151. }
  135152. // Uniform Buffer
  135153. _this._createUbo();
  135154. // Default Image processing definition
  135155. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  135156. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]();
  135157. }
  135158. _this.setDefaultCandidateProviders();
  135159. if (options && options.useGeometryUniqueIdsMap === true) {
  135160. _this.geometriesByUniqueId = {};
  135161. }
  135162. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  135163. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  135164. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  135165. return _this;
  135166. }
  135167. /**
  135168. * Factory used to create the default material.
  135169. * @param name The name of the material to create
  135170. * @param scene The scene to create the material for
  135171. * @returns The default material
  135172. */
  135173. Scene.DefaultMaterialFactory = function (scene) {
  135174. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("StandardMaterial");
  135175. };
  135176. /**
  135177. * Factory used to create the a collision coordinator.
  135178. * @returns The collision coordinator
  135179. */
  135180. Scene.CollisionCoordinatorFactory = function () {
  135181. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  135182. };
  135183. Object.defineProperty(Scene.prototype, "environmentTexture", {
  135184. /**
  135185. * Texture used in all pbr material as the reflection texture.
  135186. * As in the majority of the scene they are the same (exception for multi room and so on),
  135187. * this is easier to reference from here than from all the materials.
  135188. */
  135189. get: function () {
  135190. return this._environmentTexture;
  135191. },
  135192. /**
  135193. * Texture used in all pbr material as the reflection texture.
  135194. * As in the majority of the scene they are the same (exception for multi room and so on),
  135195. * this is easier to set here than in all the materials.
  135196. */
  135197. set: function (value) {
  135198. if (this._environmentTexture === value) {
  135199. return;
  135200. }
  135201. this._environmentTexture = value;
  135202. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  135203. },
  135204. enumerable: true,
  135205. configurable: true
  135206. });
  135207. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  135208. /**
  135209. * Default image processing configuration used either in the rendering
  135210. * Forward main pass or through the imageProcessingPostProcess if present.
  135211. * As in the majority of the scene they are the same (exception for multi camera),
  135212. * this is easier to reference from here than from all the materials and post process.
  135213. *
  135214. * No setter as we it is a shared configuration, you can set the values instead.
  135215. */
  135216. get: function () {
  135217. return this._imageProcessingConfiguration;
  135218. },
  135219. enumerable: true,
  135220. configurable: true
  135221. });
  135222. Object.defineProperty(Scene.prototype, "forceWireframe", {
  135223. get: function () {
  135224. return this._forceWireframe;
  135225. },
  135226. /**
  135227. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  135228. */
  135229. set: function (value) {
  135230. if (this._forceWireframe === value) {
  135231. return;
  135232. }
  135233. this._forceWireframe = value;
  135234. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  135235. },
  135236. enumerable: true,
  135237. configurable: true
  135238. });
  135239. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  135240. get: function () {
  135241. return this._forcePointsCloud;
  135242. },
  135243. /**
  135244. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  135245. */
  135246. set: function (value) {
  135247. if (this._forcePointsCloud === value) {
  135248. return;
  135249. }
  135250. this._forcePointsCloud = value;
  135251. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  135252. },
  135253. enumerable: true,
  135254. configurable: true
  135255. });
  135256. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  135257. /**
  135258. * Gets or sets the animation properties override
  135259. */
  135260. get: function () {
  135261. return this._animationPropertiesOverride;
  135262. },
  135263. set: function (value) {
  135264. this._animationPropertiesOverride = value;
  135265. },
  135266. enumerable: true,
  135267. configurable: true
  135268. });
  135269. Object.defineProperty(Scene.prototype, "onDispose", {
  135270. /** Sets a function to be executed when this scene is disposed. */
  135271. set: function (callback) {
  135272. if (this._onDisposeObserver) {
  135273. this.onDisposeObservable.remove(this._onDisposeObserver);
  135274. }
  135275. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  135276. },
  135277. enumerable: true,
  135278. configurable: true
  135279. });
  135280. Object.defineProperty(Scene.prototype, "beforeRender", {
  135281. /** Sets a function to be executed before rendering this scene */
  135282. set: function (callback) {
  135283. if (this._onBeforeRenderObserver) {
  135284. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  135285. }
  135286. if (callback) {
  135287. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  135288. }
  135289. },
  135290. enumerable: true,
  135291. configurable: true
  135292. });
  135293. Object.defineProperty(Scene.prototype, "afterRender", {
  135294. /** Sets a function to be executed after rendering this scene */
  135295. set: function (callback) {
  135296. if (this._onAfterRenderObserver) {
  135297. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  135298. }
  135299. if (callback) {
  135300. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  135301. }
  135302. },
  135303. enumerable: true,
  135304. configurable: true
  135305. });
  135306. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  135307. /** Sets a function to be executed before rendering a camera*/
  135308. set: function (callback) {
  135309. if (this._onBeforeCameraRenderObserver) {
  135310. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  135311. }
  135312. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  135313. },
  135314. enumerable: true,
  135315. configurable: true
  135316. });
  135317. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  135318. /** Sets a function to be executed after rendering a camera*/
  135319. set: function (callback) {
  135320. if (this._onAfterCameraRenderObserver) {
  135321. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  135322. }
  135323. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  135324. },
  135325. enumerable: true,
  135326. configurable: true
  135327. });
  135328. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  135329. /**
  135330. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  135331. */
  135332. get: function () {
  135333. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  135334. },
  135335. enumerable: true,
  135336. configurable: true
  135337. });
  135338. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  135339. get: function () {
  135340. return this._useRightHandedSystem;
  135341. },
  135342. /**
  135343. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  135344. */
  135345. set: function (value) {
  135346. if (this._useRightHandedSystem === value) {
  135347. return;
  135348. }
  135349. this._useRightHandedSystem = value;
  135350. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  135351. },
  135352. enumerable: true,
  135353. configurable: true
  135354. });
  135355. /**
  135356. * Sets the step Id used by deterministic lock step
  135357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135358. * @param newStepId defines the step Id
  135359. */
  135360. Scene.prototype.setStepId = function (newStepId) {
  135361. this._currentStepId = newStepId;
  135362. };
  135363. /**
  135364. * Gets the step Id used by deterministic lock step
  135365. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135366. * @returns the step Id
  135367. */
  135368. Scene.prototype.getStepId = function () {
  135369. return this._currentStepId;
  135370. };
  135371. /**
  135372. * Gets the internal step used by deterministic lock step
  135373. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  135374. * @returns the internal step
  135375. */
  135376. Scene.prototype.getInternalStep = function () {
  135377. return this._currentInternalStep;
  135378. };
  135379. Object.defineProperty(Scene.prototype, "fogEnabled", {
  135380. get: function () {
  135381. return this._fogEnabled;
  135382. },
  135383. /**
  135384. * Gets or sets a boolean indicating if fog is enabled on this scene
  135385. * @see http://doc.babylonjs.com/babylon101/environment#fog
  135386. * (Default is true)
  135387. */
  135388. set: function (value) {
  135389. if (this._fogEnabled === value) {
  135390. return;
  135391. }
  135392. this._fogEnabled = value;
  135393. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  135394. },
  135395. enumerable: true,
  135396. configurable: true
  135397. });
  135398. Object.defineProperty(Scene.prototype, "fogMode", {
  135399. get: function () {
  135400. return this._fogMode;
  135401. },
  135402. /**
  135403. * Gets or sets the fog mode to use
  135404. * @see http://doc.babylonjs.com/babylon101/environment#fog
  135405. * | mode | value |
  135406. * | --- | --- |
  135407. * | FOGMODE_NONE | 0 |
  135408. * | FOGMODE_EXP | 1 |
  135409. * | FOGMODE_EXP2 | 2 |
  135410. * | FOGMODE_LINEAR | 3 |
  135411. */
  135412. set: function (value) {
  135413. if (this._fogMode === value) {
  135414. return;
  135415. }
  135416. this._fogMode = value;
  135417. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  135418. },
  135419. enumerable: true,
  135420. configurable: true
  135421. });
  135422. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  135423. get: function () {
  135424. return this._shadowsEnabled;
  135425. },
  135426. /**
  135427. * Gets or sets a boolean indicating if shadows are enabled on this scene
  135428. */
  135429. set: function (value) {
  135430. if (this._shadowsEnabled === value) {
  135431. return;
  135432. }
  135433. this._shadowsEnabled = value;
  135434. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_LightDirtyFlag);
  135435. },
  135436. enumerable: true,
  135437. configurable: true
  135438. });
  135439. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  135440. get: function () {
  135441. return this._lightsEnabled;
  135442. },
  135443. /**
  135444. * Gets or sets a boolean indicating if lights are enabled on this scene
  135445. */
  135446. set: function (value) {
  135447. if (this._lightsEnabled === value) {
  135448. return;
  135449. }
  135450. this._lightsEnabled = value;
  135451. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_LightDirtyFlag);
  135452. },
  135453. enumerable: true,
  135454. configurable: true
  135455. });
  135456. Object.defineProperty(Scene.prototype, "activeCamera", {
  135457. /** Gets or sets the current active camera */
  135458. get: function () {
  135459. return this._activeCamera;
  135460. },
  135461. set: function (value) {
  135462. if (value === this._activeCamera) {
  135463. return;
  135464. }
  135465. this._activeCamera = value;
  135466. this.onActiveCameraChanged.notifyObservers(this);
  135467. },
  135468. enumerable: true,
  135469. configurable: true
  135470. });
  135471. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  135472. /** The default material used on meshes when no material is affected */
  135473. get: function () {
  135474. if (!this._defaultMaterial) {
  135475. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  135476. }
  135477. return this._defaultMaterial;
  135478. },
  135479. /** The default material used on meshes when no material is affected */
  135480. set: function (value) {
  135481. this._defaultMaterial = value;
  135482. },
  135483. enumerable: true,
  135484. configurable: true
  135485. });
  135486. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  135487. get: function () {
  135488. return this._texturesEnabled;
  135489. },
  135490. /**
  135491. * Gets or sets a boolean indicating if textures are enabled on this scene
  135492. */
  135493. set: function (value) {
  135494. if (this._texturesEnabled === value) {
  135495. return;
  135496. }
  135497. this._texturesEnabled = value;
  135498. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  135499. },
  135500. enumerable: true,
  135501. configurable: true
  135502. });
  135503. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  135504. get: function () {
  135505. return this._skeletonsEnabled;
  135506. },
  135507. /**
  135508. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  135509. */
  135510. set: function (value) {
  135511. if (this._skeletonsEnabled === value) {
  135512. return;
  135513. }
  135514. this._skeletonsEnabled = value;
  135515. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_AttributesDirtyFlag);
  135516. },
  135517. enumerable: true,
  135518. configurable: true
  135519. });
  135520. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  135521. /** @hidden */
  135522. get: function () {
  135523. if (!this._collisionCoordinator) {
  135524. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  135525. this._collisionCoordinator.init(this);
  135526. }
  135527. return this._collisionCoordinator;
  135528. },
  135529. enumerable: true,
  135530. configurable: true
  135531. });
  135532. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  135533. /**
  135534. * Gets the list of frustum planes (built from the active camera)
  135535. */
  135536. get: function () {
  135537. return this._frustumPlanes;
  135538. },
  135539. enumerable: true,
  135540. configurable: true
  135541. });
  135542. /**
  135543. * Registers the transient components if needed.
  135544. */
  135545. Scene.prototype._registerTransientComponents = function () {
  135546. // Register components that have been associated lately to the scene.
  135547. if (this._transientComponents.length > 0) {
  135548. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  135549. var component = _a[_i];
  135550. component.register();
  135551. }
  135552. this._transientComponents = [];
  135553. }
  135554. };
  135555. /**
  135556. * @hidden
  135557. * Add a component to the scene.
  135558. * Note that the ccomponent could be registered on th next frame if this is called after
  135559. * the register component stage.
  135560. * @param component Defines the component to add to the scene
  135561. */
  135562. Scene.prototype._addComponent = function (component) {
  135563. this._components.push(component);
  135564. this._transientComponents.push(component);
  135565. var serializableComponent = component;
  135566. if (serializableComponent.addFromContainer) {
  135567. this._serializableComponents.push(serializableComponent);
  135568. }
  135569. };
  135570. /**
  135571. * @hidden
  135572. * Gets a component from the scene.
  135573. * @param name defines the name of the component to retrieve
  135574. * @returns the component or null if not present
  135575. */
  135576. Scene.prototype._getComponent = function (name) {
  135577. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  135578. var component = _a[_i];
  135579. if (component.name === name) {
  135580. return component;
  135581. }
  135582. }
  135583. return null;
  135584. };
  135585. /**
  135586. * Gets a string idenfifying the name of the class
  135587. * @returns "Scene" string
  135588. */
  135589. Scene.prototype.getClassName = function () {
  135590. return "Scene";
  135591. };
  135592. /**
  135593. * @hidden
  135594. */
  135595. Scene.prototype._getDefaultMeshCandidates = function () {
  135596. this._defaultMeshCandidates.data = this.meshes;
  135597. this._defaultMeshCandidates.length = this.meshes.length;
  135598. return this._defaultMeshCandidates;
  135599. };
  135600. /**
  135601. * @hidden
  135602. */
  135603. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  135604. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  135605. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  135606. return this._defaultSubMeshCandidates;
  135607. };
  135608. /**
  135609. * Sets the default candidate providers for the scene.
  135610. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  135611. * and getCollidingSubMeshCandidates to their default function
  135612. */
  135613. Scene.prototype.setDefaultCandidateProviders = function () {
  135614. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  135615. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  135616. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  135617. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  135618. };
  135619. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  135620. /**
  135621. * Gets the mesh that is currently under the pointer
  135622. */
  135623. get: function () {
  135624. return this._pointerOverMesh;
  135625. },
  135626. enumerable: true,
  135627. configurable: true
  135628. });
  135629. Object.defineProperty(Scene.prototype, "pointerX", {
  135630. /**
  135631. * Gets or sets the current on-screen X position of the pointer
  135632. */
  135633. get: function () {
  135634. return this._pointerX;
  135635. },
  135636. set: function (value) {
  135637. this._pointerX = value;
  135638. },
  135639. enumerable: true,
  135640. configurable: true
  135641. });
  135642. Object.defineProperty(Scene.prototype, "pointerY", {
  135643. /**
  135644. * Gets or sets the current on-screen Y position of the pointer
  135645. */
  135646. get: function () {
  135647. return this._pointerY;
  135648. },
  135649. set: function (value) {
  135650. this._pointerY = value;
  135651. },
  135652. enumerable: true,
  135653. configurable: true
  135654. });
  135655. /**
  135656. * Gets the cached material (ie. the latest rendered one)
  135657. * @returns the cached material
  135658. */
  135659. Scene.prototype.getCachedMaterial = function () {
  135660. return this._cachedMaterial;
  135661. };
  135662. /**
  135663. * Gets the cached effect (ie. the latest rendered one)
  135664. * @returns the cached effect
  135665. */
  135666. Scene.prototype.getCachedEffect = function () {
  135667. return this._cachedEffect;
  135668. };
  135669. /**
  135670. * Gets the cached visibility state (ie. the latest rendered one)
  135671. * @returns the cached visibility state
  135672. */
  135673. Scene.prototype.getCachedVisibility = function () {
  135674. return this._cachedVisibility;
  135675. };
  135676. /**
  135677. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  135678. * @param material defines the current material
  135679. * @param effect defines the current effect
  135680. * @param visibility defines the current visibility state
  135681. * @returns true if one parameter is not cached
  135682. */
  135683. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  135684. if (visibility === void 0) { visibility = 1; }
  135685. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  135686. };
  135687. /**
  135688. * Gets the engine associated with the scene
  135689. * @returns an Engine
  135690. */
  135691. Scene.prototype.getEngine = function () {
  135692. return this._engine;
  135693. };
  135694. /**
  135695. * Gets the total number of vertices rendered per frame
  135696. * @returns the total number of vertices rendered per frame
  135697. */
  135698. Scene.prototype.getTotalVertices = function () {
  135699. return this._totalVertices.current;
  135700. };
  135701. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  135702. /**
  135703. * Gets the performance counter for total vertices
  135704. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135705. */
  135706. get: function () {
  135707. return this._totalVertices;
  135708. },
  135709. enumerable: true,
  135710. configurable: true
  135711. });
  135712. /**
  135713. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  135714. * @returns the total number of active indices rendered per frame
  135715. */
  135716. Scene.prototype.getActiveIndices = function () {
  135717. return this._activeIndices.current;
  135718. };
  135719. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  135720. /**
  135721. * Gets the performance counter for active indices
  135722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135723. */
  135724. get: function () {
  135725. return this._activeIndices;
  135726. },
  135727. enumerable: true,
  135728. configurable: true
  135729. });
  135730. /**
  135731. * Gets the total number of active particles rendered per frame
  135732. * @returns the total number of active particles rendered per frame
  135733. */
  135734. Scene.prototype.getActiveParticles = function () {
  135735. return this._activeParticles.current;
  135736. };
  135737. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  135738. /**
  135739. * Gets the performance counter for active particles
  135740. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135741. */
  135742. get: function () {
  135743. return this._activeParticles;
  135744. },
  135745. enumerable: true,
  135746. configurable: true
  135747. });
  135748. /**
  135749. * Gets the total number of active bones rendered per frame
  135750. * @returns the total number of active bones rendered per frame
  135751. */
  135752. Scene.prototype.getActiveBones = function () {
  135753. return this._activeBones.current;
  135754. };
  135755. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  135756. /**
  135757. * Gets the performance counter for active bones
  135758. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135759. */
  135760. get: function () {
  135761. return this._activeBones;
  135762. },
  135763. enumerable: true,
  135764. configurable: true
  135765. });
  135766. /**
  135767. * Gets the array of active meshes
  135768. * @returns an array of AbstractMesh
  135769. */
  135770. Scene.prototype.getActiveMeshes = function () {
  135771. return this._activeMeshes;
  135772. };
  135773. /**
  135774. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  135775. * @returns a number
  135776. */
  135777. Scene.prototype.getAnimationRatio = function () {
  135778. return this._animationRatio !== undefined ? this._animationRatio : 1;
  135779. };
  135780. /**
  135781. * Gets an unique Id for the current render phase
  135782. * @returns a number
  135783. */
  135784. Scene.prototype.getRenderId = function () {
  135785. return this._renderId;
  135786. };
  135787. /**
  135788. * Gets an unique Id for the current frame
  135789. * @returns a number
  135790. */
  135791. Scene.prototype.getFrameId = function () {
  135792. return this._frameId;
  135793. };
  135794. /** Call this function if you want to manually increment the render Id*/
  135795. Scene.prototype.incrementRenderId = function () {
  135796. this._renderId++;
  135797. };
  135798. Scene.prototype._updatePointerPosition = function (evt) {
  135799. var canvasRect = this._engine.getRenderingCanvasClientRect();
  135800. if (!canvasRect) {
  135801. return;
  135802. }
  135803. this._pointerX = evt.clientX - canvasRect.left;
  135804. this._pointerY = evt.clientY - canvasRect.top;
  135805. this._unTranslatedPointerX = this._pointerX;
  135806. this._unTranslatedPointerY = this._pointerY;
  135807. };
  135808. Scene.prototype._createUbo = function () {
  135809. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__["UniformBuffer"](this._engine, undefined, true);
  135810. this._sceneUbo.addUniform("viewProjection", 16);
  135811. this._sceneUbo.addUniform("view", 16);
  135812. };
  135813. // Pointers handling
  135814. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  135815. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  135816. if (!pointerInfo.pickInfo.ray) {
  135817. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  135818. }
  135819. }
  135820. };
  135821. /**
  135822. * Use this method to simulate a pointer move on a mesh
  135823. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  135824. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  135825. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  135826. * @returns the current scene
  135827. */
  135828. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  135829. var evt = new PointerEvent("pointermove", pointerEventInit);
  135830. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERMOVE)) {
  135831. return this;
  135832. }
  135833. return this._processPointerMove(pickResult, evt);
  135834. };
  135835. Scene.prototype._processPointerMove = function (pickResult, evt) {
  135836. var canvas = this._engine.getRenderingCanvas();
  135837. if (!canvas) {
  135838. return this;
  135839. }
  135840. // Restore pointer
  135841. canvas.style.cursor = this.defaultCursor;
  135842. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  135843. if (isMeshPicked) {
  135844. this.setPointerOverMesh(pickResult.pickedMesh);
  135845. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  135846. if (this._pointerOverMesh.actionManager.hoverCursor) {
  135847. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  135848. }
  135849. else {
  135850. canvas.style.cursor = this.hoverCursor;
  135851. }
  135852. }
  135853. }
  135854. else {
  135855. this.setPointerOverMesh(null);
  135856. }
  135857. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  135858. var step = _a[_i];
  135859. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  135860. }
  135861. if (pickResult) {
  135862. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERMOVE;
  135863. if (this.onPointerMove) {
  135864. this.onPointerMove(evt, pickResult, type);
  135865. }
  135866. if (this.onPointerObservable.hasObservers()) {
  135867. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135868. this._setRayOnPointerInfo(pi);
  135869. this.onPointerObservable.notifyObservers(pi, type);
  135870. }
  135871. }
  135872. return this;
  135873. };
  135874. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  135875. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  135876. if (pickResult) {
  135877. pi.ray = pickResult.ray;
  135878. }
  135879. this.onPrePointerObservable.notifyObservers(pi, type);
  135880. if (pi.skipOnPointerObservable) {
  135881. return true;
  135882. }
  135883. else {
  135884. return false;
  135885. }
  135886. };
  135887. /**
  135888. * Use this method to simulate a pointer down on a mesh
  135889. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  135890. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  135891. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  135892. * @returns the current scene
  135893. */
  135894. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  135895. var evt = new PointerEvent("pointerdown", pointerEventInit);
  135896. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOWN)) {
  135897. return this;
  135898. }
  135899. return this._processPointerDown(pickResult, evt);
  135900. };
  135901. Scene.prototype._processPointerDown = function (pickResult, evt) {
  135902. var _this = this;
  135903. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  135904. this._pickedDownMesh = pickResult.pickedMesh;
  135905. var actionManager = pickResult.pickedMesh.actionManager;
  135906. if (actionManager) {
  135907. if (actionManager.hasPickTriggers) {
  135908. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135909. switch (evt.button) {
  135910. case 0:
  135911. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135912. break;
  135913. case 1:
  135914. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135915. break;
  135916. case 2:
  135917. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135918. break;
  135919. }
  135920. }
  135921. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger)) {
  135922. window.setTimeout(function () {
  135923. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  135924. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  135925. if (_this._totalPointersPressed !== 0 &&
  135926. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  135927. !_this._isPointerSwiping()) {
  135928. _this._startingPointerTime = 0;
  135929. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135930. }
  135931. }
  135932. }, Scene.LongPressDelay);
  135933. }
  135934. }
  135935. }
  135936. else {
  135937. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  135938. var step = _a[_i];
  135939. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  135940. }
  135941. }
  135942. if (pickResult) {
  135943. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOWN;
  135944. if (this.onPointerDown) {
  135945. this.onPointerDown(evt, pickResult, type);
  135946. }
  135947. if (this.onPointerObservable.hasObservers()) {
  135948. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135949. this._setRayOnPointerInfo(pi);
  135950. this.onPointerObservable.notifyObservers(pi, type);
  135951. }
  135952. }
  135953. return this;
  135954. };
  135955. /**
  135956. * Use this method to simulate a pointer up on a mesh
  135957. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  135958. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  135959. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  135960. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  135961. * @returns the current scene
  135962. */
  135963. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  135964. var evt = new PointerEvent("pointerup", pointerEventInit);
  135965. var clickInfo = new ClickInfo();
  135966. if (doubleTap) {
  135967. clickInfo.doubleClick = true;
  135968. }
  135969. else {
  135970. clickInfo.singleClick = true;
  135971. }
  135972. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERUP)) {
  135973. return this;
  135974. }
  135975. return this._processPointerUp(pickResult, evt, clickInfo);
  135976. };
  135977. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  135978. if (pickResult && pickResult && pickResult.pickedMesh) {
  135979. this._pickedUpMesh = pickResult.pickedMesh;
  135980. if (this._pickedDownMesh === this._pickedUpMesh) {
  135981. if (this.onPointerPick) {
  135982. this.onPointerPick(evt, pickResult);
  135983. }
  135984. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  135985. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERPICK;
  135986. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type_1, evt, pickResult);
  135987. this._setRayOnPointerInfo(pi);
  135988. this.onPointerObservable.notifyObservers(pi, type_1);
  135989. }
  135990. }
  135991. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  135992. if (actionManager && !clickInfo.ignore) {
  135993. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135994. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  135995. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135996. }
  135997. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  135998. if (clickInfo.doubleClick && doubleClickActionManager) {
  135999. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  136000. }
  136001. }
  136002. }
  136003. else {
  136004. if (!clickInfo.ignore) {
  136005. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  136006. var step = _a[_i];
  136007. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  136008. }
  136009. }
  136010. }
  136011. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  136012. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickOutTrigger);
  136013. if (pickedDownActionManager) {
  136014. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  136015. }
  136016. }
  136017. var type = 0;
  136018. if (this.onPointerObservable.hasObservers()) {
  136019. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  136020. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)) {
  136021. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP;
  136022. }
  136023. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP)) {
  136024. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP;
  136025. }
  136026. if (type) {
  136027. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  136028. this._setRayOnPointerInfo(pi);
  136029. this.onPointerObservable.notifyObservers(pi, type);
  136030. }
  136031. }
  136032. if (!clickInfo.ignore) {
  136033. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERUP;
  136034. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  136035. this._setRayOnPointerInfo(pi);
  136036. this.onPointerObservable.notifyObservers(pi, type);
  136037. }
  136038. }
  136039. if (this.onPointerUp && !clickInfo.ignore) {
  136040. this.onPointerUp(evt, pickResult, type);
  136041. }
  136042. return this;
  136043. };
  136044. /**
  136045. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  136046. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  136047. * @returns true if the pointer was captured
  136048. */
  136049. Scene.prototype.isPointerCaptured = function (pointerId) {
  136050. if (pointerId === void 0) { pointerId = 0; }
  136051. return this._pointerCaptures[pointerId];
  136052. };
  136053. /** @hidden */
  136054. Scene.prototype._isPointerSwiping = function () {
  136055. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  136056. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  136057. };
  136058. /**
  136059. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  136060. * @param attachUp defines if you want to attach events to pointerup
  136061. * @param attachDown defines if you want to attach events to pointerdown
  136062. * @param attachMove defines if you want to attach events to pointermove
  136063. */
  136064. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  136065. var _this = this;
  136066. if (attachUp === void 0) { attachUp = true; }
  136067. if (attachDown === void 0) { attachDown = true; }
  136068. if (attachMove === void 0) { attachMove = true; }
  136069. this._initActionManager = function (act, clickInfo) {
  136070. if (!_this._meshPickProceed) {
  136071. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  136072. _this._currentPickResult = pickResult;
  136073. if (pickResult) {
  136074. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh._getActionManagerForTrigger() : null;
  136075. }
  136076. _this._meshPickProceed = true;
  136077. }
  136078. return act;
  136079. };
  136080. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  136081. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  136082. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  136083. btn !== _this._previousButtonPressed) {
  136084. _this._doubleClickOccured = false;
  136085. clickInfo.singleClick = true;
  136086. clickInfo.ignore = false;
  136087. cb(clickInfo, _this._currentPickResult);
  136088. }
  136089. };
  136090. this._initClickEvent = function (obs1, obs2, evt, cb) {
  136091. var clickInfo = new ClickInfo();
  136092. _this._currentPickResult = null;
  136093. var act = null;
  136094. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERPICK)
  136095. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)
  136096. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP);
  136097. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"]) {
  136098. act = _this._initActionManager(act, clickInfo);
  136099. if (act) {
  136100. checkPicking = act.hasPickTriggers;
  136101. }
  136102. }
  136103. var needToIgnoreNext = false;
  136104. if (checkPicking) {
  136105. var btn = evt.button;
  136106. clickInfo.hasSwiped = _this._isPointerSwiping();
  136107. if (!clickInfo.hasSwiped) {
  136108. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  136109. if (!checkSingleClickImmediately) {
  136110. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP) &&
  136111. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP);
  136112. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger)) {
  136113. act = _this._initActionManager(act, clickInfo);
  136114. if (act) {
  136115. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  136116. }
  136117. }
  136118. }
  136119. if (checkSingleClickImmediately) {
  136120. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  136121. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  136122. btn !== _this._previousButtonPressed) {
  136123. clickInfo.singleClick = true;
  136124. cb(clickInfo, _this._currentPickResult);
  136125. needToIgnoreNext = true;
  136126. }
  136127. }
  136128. // at least one double click is required to be check and exclusive double click is enabled
  136129. else {
  136130. // wait that no double click has been raised during the double click delay
  136131. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  136132. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  136133. }
  136134. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP) ||
  136135. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP);
  136136. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger)) {
  136137. act = _this._initActionManager(act, clickInfo);
  136138. if (act) {
  136139. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  136140. }
  136141. }
  136142. if (checkDoubleClick) {
  136143. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  136144. if (btn === _this._previousButtonPressed &&
  136145. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  136146. !_this._doubleClickOccured) {
  136147. // pointer has not moved for 2 clicks, it's a double click
  136148. if (!clickInfo.hasSwiped &&
  136149. !_this._isPointerSwiping()) {
  136150. _this._previousStartingPointerTime = 0;
  136151. _this._doubleClickOccured = true;
  136152. clickInfo.doubleClick = true;
  136153. clickInfo.ignore = false;
  136154. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  136155. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  136156. }
  136157. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  136158. cb(clickInfo, _this._currentPickResult);
  136159. }
  136160. // if the two successive clicks are too far, it's just two simple clicks
  136161. else {
  136162. _this._doubleClickOccured = false;
  136163. _this._previousStartingPointerTime = _this._startingPointerTime;
  136164. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  136165. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  136166. _this._previousButtonPressed = btn;
  136167. if (Scene.ExclusiveDoubleClickMode) {
  136168. if (_this._previousDelayedSimpleClickTimeout) {
  136169. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  136170. }
  136171. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  136172. cb(clickInfo, _this._previousPickResult);
  136173. }
  136174. else {
  136175. cb(clickInfo, _this._currentPickResult);
  136176. }
  136177. }
  136178. needToIgnoreNext = true;
  136179. }
  136180. // just the first click of the double has been raised
  136181. else {
  136182. _this._doubleClickOccured = false;
  136183. _this._previousStartingPointerTime = _this._startingPointerTime;
  136184. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  136185. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  136186. _this._previousButtonPressed = btn;
  136187. }
  136188. }
  136189. }
  136190. }
  136191. if (!needToIgnoreNext) {
  136192. cb(clickInfo, _this._currentPickResult);
  136193. }
  136194. };
  136195. this._onPointerMove = function (evt) {
  136196. _this._updatePointerPosition(evt);
  136197. // PreObservable support
  136198. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERMOVE)) {
  136199. return;
  136200. }
  136201. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  136202. return;
  136203. }
  136204. if (!_this.pointerMovePredicate) {
  136205. _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)); };
  136206. }
  136207. // Meshes
  136208. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  136209. _this._processPointerMove(pickResult, evt);
  136210. };
  136211. this._onPointerDown = function (evt) {
  136212. _this._totalPointersPressed++;
  136213. _this._pickedDownMesh = null;
  136214. _this._meshPickProceed = false;
  136215. _this._updatePointerPosition(evt);
  136216. if (_this.preventDefaultOnPointerDown && canvas) {
  136217. evt.preventDefault();
  136218. canvas.focus();
  136219. }
  136220. _this._startingPointerPosition.x = _this._pointerX;
  136221. _this._startingPointerPosition.y = _this._pointerY;
  136222. _this._startingPointerTime = Date.now();
  136223. // PreObservable support
  136224. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOWN)) {
  136225. return;
  136226. }
  136227. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  136228. return;
  136229. }
  136230. _this._pointerCaptures[evt.pointerId] = true;
  136231. if (!_this.pointerDownPredicate) {
  136232. _this.pointerDownPredicate = function (mesh) {
  136233. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  136234. };
  136235. }
  136236. // Meshes
  136237. _this._pickedDownMesh = null;
  136238. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  136239. _this._processPointerDown(pickResult, evt);
  136240. };
  136241. this._onPointerUp = function (evt) {
  136242. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  136243. return; // So we need to test it the pointer down was pressed before.
  136244. }
  136245. _this._totalPointersPressed--;
  136246. _this._pickedUpMesh = null;
  136247. _this._meshPickProceed = false;
  136248. _this._updatePointerPosition(evt);
  136249. if (_this.preventDefaultOnPointerUp && canvas) {
  136250. evt.preventDefault();
  136251. canvas.focus();
  136252. }
  136253. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  136254. // PreObservable support
  136255. if (_this.onPrePointerObservable.hasObservers()) {
  136256. if (!clickInfo.ignore) {
  136257. if (!clickInfo.hasSwiped) {
  136258. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)) {
  136259. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)) {
  136260. return;
  136261. }
  136262. }
  136263. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP)) {
  136264. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP)) {
  136265. return;
  136266. }
  136267. }
  136268. }
  136269. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERUP)) {
  136270. return;
  136271. }
  136272. }
  136273. }
  136274. if (!_this._pointerCaptures[evt.pointerId]) {
  136275. return;
  136276. }
  136277. _this._pointerCaptures[evt.pointerId] = false;
  136278. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  136279. return;
  136280. }
  136281. if (!_this.pointerUpPredicate) {
  136282. _this.pointerUpPredicate = function (mesh) {
  136283. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  136284. };
  136285. }
  136286. // Meshes
  136287. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  136288. _this._initActionManager(null, clickInfo);
  136289. }
  136290. if (!pickResult) {
  136291. pickResult = _this._currentPickResult;
  136292. }
  136293. _this._processPointerUp(pickResult, evt, clickInfo);
  136294. _this._previousPickResult = _this._currentPickResult;
  136295. });
  136296. };
  136297. this._onKeyDown = function (evt) {
  136298. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardEventTypes"].KEYDOWN;
  136299. if (_this.onPreKeyboardObservable.hasObservers()) {
  136300. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfoPre"](type, evt);
  136301. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  136302. if (pi.skipOnPointerObservable) {
  136303. return;
  136304. }
  136305. }
  136306. if (_this.onKeyboardObservable.hasObservers()) {
  136307. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfo"](type, evt);
  136308. _this.onKeyboardObservable.notifyObservers(pi, type);
  136309. }
  136310. if (_this.actionManager) {
  136311. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNewFromScene(_this, evt));
  136312. }
  136313. };
  136314. this._onKeyUp = function (evt) {
  136315. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardEventTypes"].KEYUP;
  136316. if (_this.onPreKeyboardObservable.hasObservers()) {
  136317. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfoPre"](type, evt);
  136318. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  136319. if (pi.skipOnPointerObservable) {
  136320. return;
  136321. }
  136322. }
  136323. if (_this.onKeyboardObservable.hasObservers()) {
  136324. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfo"](type, evt);
  136325. _this.onKeyboardObservable.notifyObservers(pi, type);
  136326. }
  136327. if (_this.actionManager) {
  136328. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNewFromScene(_this, evt));
  136329. }
  136330. };
  136331. var engine = this.getEngine();
  136332. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  136333. if (!canvas) {
  136334. return;
  136335. }
  136336. canvas.addEventListener("keydown", _this._onKeyDown, false);
  136337. canvas.addEventListener("keyup", _this._onKeyUp, false);
  136338. });
  136339. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  136340. if (!canvas) {
  136341. return;
  136342. }
  136343. canvas.removeEventListener("keydown", _this._onKeyDown);
  136344. canvas.removeEventListener("keyup", _this._onKeyUp);
  136345. });
  136346. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  136347. var canvas = this._engine.getRenderingCanvas();
  136348. if (!canvas) {
  136349. return;
  136350. }
  136351. if (attachMove) {
  136352. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  136353. // Wheel
  136354. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  136355. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  136356. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  136357. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  136358. }
  136359. if (attachDown) {
  136360. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  136361. }
  136362. if (attachUp) {
  136363. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  136364. }
  136365. canvas.tabIndex = 1;
  136366. };
  136367. /** Detaches all event handlers*/
  136368. Scene.prototype.detachControl = function () {
  136369. var engine = this.getEngine();
  136370. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  136371. var canvas = engine.getRenderingCanvas();
  136372. if (!canvas) {
  136373. return;
  136374. }
  136375. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  136376. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  136377. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  136378. if (this._onCanvasBlurObserver) {
  136379. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  136380. }
  136381. if (this._onCanvasFocusObserver) {
  136382. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  136383. }
  136384. // Wheel
  136385. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  136386. // Keyboard
  136387. canvas.removeEventListener("keydown", this._onKeyDown);
  136388. canvas.removeEventListener("keyup", this._onKeyUp);
  136389. // Cursor
  136390. canvas.style.cursor = this.defaultCursor;
  136391. };
  136392. /**
  136393. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  136394. * Delay loaded resources are not taking in account
  136395. * @return true if all required resources are ready
  136396. */
  136397. Scene.prototype.isReady = function () {
  136398. if (this._isDisposed) {
  136399. return false;
  136400. }
  136401. var index;
  136402. var engine = this.getEngine();
  136403. // Effects
  136404. if (!engine.areAllEffectsReady()) {
  136405. return false;
  136406. }
  136407. // Pending data
  136408. if (this._pendingData.length > 0) {
  136409. return false;
  136410. }
  136411. // Meshes
  136412. for (index = 0; index < this.meshes.length; index++) {
  136413. var mesh = this.meshes[index];
  136414. if (!mesh.isEnabled()) {
  136415. continue;
  136416. }
  136417. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  136418. continue;
  136419. }
  136420. if (!mesh.isReady(true)) {
  136421. return false;
  136422. }
  136423. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  136424. // Is Ready For Mesh
  136425. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  136426. var step = _a[_i];
  136427. if (!step.action(mesh, hardwareInstancedRendering)) {
  136428. return false;
  136429. }
  136430. }
  136431. }
  136432. // Geometries
  136433. for (index = 0; index < this.geometries.length; index++) {
  136434. var geometry = this.geometries[index];
  136435. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].DELAYLOADSTATE_LOADING) {
  136436. return false;
  136437. }
  136438. }
  136439. // Post-processes
  136440. if (this.activeCameras && this.activeCameras.length > 0) {
  136441. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  136442. var camera = _c[_b];
  136443. if (!camera.isReady(true)) {
  136444. return false;
  136445. }
  136446. }
  136447. }
  136448. else if (this.activeCamera) {
  136449. if (!this.activeCamera.isReady(true)) {
  136450. return false;
  136451. }
  136452. }
  136453. // Particles
  136454. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  136455. var particleSystem = _e[_d];
  136456. if (!particleSystem.isReady()) {
  136457. return false;
  136458. }
  136459. }
  136460. return true;
  136461. };
  136462. /** Resets all cached information relative to material (including effect and visibility) */
  136463. Scene.prototype.resetCachedMaterial = function () {
  136464. this._cachedMaterial = null;
  136465. this._cachedEffect = null;
  136466. this._cachedVisibility = null;
  136467. };
  136468. /**
  136469. * Registers a function to be called before every frame render
  136470. * @param func defines the function to register
  136471. */
  136472. Scene.prototype.registerBeforeRender = function (func) {
  136473. this.onBeforeRenderObservable.add(func);
  136474. };
  136475. /**
  136476. * Unregisters a function called before every frame render
  136477. * @param func defines the function to unregister
  136478. */
  136479. Scene.prototype.unregisterBeforeRender = function (func) {
  136480. this.onBeforeRenderObservable.removeCallback(func);
  136481. };
  136482. /**
  136483. * Registers a function to be called after every frame render
  136484. * @param func defines the function to register
  136485. */
  136486. Scene.prototype.registerAfterRender = function (func) {
  136487. this.onAfterRenderObservable.add(func);
  136488. };
  136489. /**
  136490. * Unregisters a function called after every frame render
  136491. * @param func defines the function to unregister
  136492. */
  136493. Scene.prototype.unregisterAfterRender = function (func) {
  136494. this.onAfterRenderObservable.removeCallback(func);
  136495. };
  136496. Scene.prototype._executeOnceBeforeRender = function (func) {
  136497. var _this = this;
  136498. var execFunc = function () {
  136499. func();
  136500. setTimeout(function () {
  136501. _this.unregisterBeforeRender(execFunc);
  136502. });
  136503. };
  136504. this.registerBeforeRender(execFunc);
  136505. };
  136506. /**
  136507. * The provided function will run before render once and will be disposed afterwards.
  136508. * A timeout delay can be provided so that the function will be executed in N ms.
  136509. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  136510. * @param func The function to be executed.
  136511. * @param timeout optional delay in ms
  136512. */
  136513. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  136514. var _this = this;
  136515. if (timeout !== undefined) {
  136516. setTimeout(function () {
  136517. _this._executeOnceBeforeRender(func);
  136518. }, timeout);
  136519. }
  136520. else {
  136521. this._executeOnceBeforeRender(func);
  136522. }
  136523. };
  136524. /** @hidden */
  136525. Scene.prototype._addPendingData = function (data) {
  136526. this._pendingData.push(data);
  136527. };
  136528. /** @hidden */
  136529. Scene.prototype._removePendingData = function (data) {
  136530. var wasLoading = this.isLoading;
  136531. var index = this._pendingData.indexOf(data);
  136532. if (index !== -1) {
  136533. this._pendingData.splice(index, 1);
  136534. }
  136535. if (wasLoading && !this.isLoading) {
  136536. this.onDataLoadedObservable.notifyObservers(this);
  136537. }
  136538. };
  136539. /**
  136540. * Returns the number of items waiting to be loaded
  136541. * @returns the number of items waiting to be loaded
  136542. */
  136543. Scene.prototype.getWaitingItemsCount = function () {
  136544. return this._pendingData.length;
  136545. };
  136546. Object.defineProperty(Scene.prototype, "isLoading", {
  136547. /**
  136548. * Returns a boolean indicating if the scene is still loading data
  136549. */
  136550. get: function () {
  136551. return this._pendingData.length > 0;
  136552. },
  136553. enumerable: true,
  136554. configurable: true
  136555. });
  136556. /**
  136557. * Registers a function to be executed when the scene is ready
  136558. * @param {Function} func - the function to be executed
  136559. */
  136560. Scene.prototype.executeWhenReady = function (func) {
  136561. var _this = this;
  136562. this.onReadyObservable.add(func);
  136563. if (this._executeWhenReadyTimeoutId !== -1) {
  136564. return;
  136565. }
  136566. this._executeWhenReadyTimeoutId = setTimeout(function () {
  136567. _this._checkIsReady();
  136568. }, 150);
  136569. };
  136570. /**
  136571. * Returns a promise that resolves when the scene is ready
  136572. * @returns A promise that resolves when the scene is ready
  136573. */
  136574. Scene.prototype.whenReadyAsync = function () {
  136575. var _this = this;
  136576. return new Promise(function (resolve) {
  136577. _this.executeWhenReady(function () {
  136578. resolve();
  136579. });
  136580. });
  136581. };
  136582. /** @hidden */
  136583. Scene.prototype._checkIsReady = function () {
  136584. var _this = this;
  136585. this._registerTransientComponents();
  136586. if (this.isReady()) {
  136587. this.onReadyObservable.notifyObservers(this);
  136588. this.onReadyObservable.clear();
  136589. this._executeWhenReadyTimeoutId = -1;
  136590. return;
  136591. }
  136592. this._executeWhenReadyTimeoutId = setTimeout(function () {
  136593. _this._checkIsReady();
  136594. }, 150);
  136595. };
  136596. Object.defineProperty(Scene.prototype, "animatables", {
  136597. /**
  136598. * Gets all animatable attached to the scene
  136599. */
  136600. get: function () {
  136601. return this._activeAnimatables;
  136602. },
  136603. enumerable: true,
  136604. configurable: true
  136605. });
  136606. /**
  136607. * Resets the last animation time frame.
  136608. * Useful to override when animations start running when loading a scene for the first time.
  136609. */
  136610. Scene.prototype.resetLastAnimationTimeFrame = function () {
  136611. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  136612. };
  136613. // Matrix
  136614. /**
  136615. * Gets the current view matrix
  136616. * @returns a Matrix
  136617. */
  136618. Scene.prototype.getViewMatrix = function () {
  136619. return this._viewMatrix;
  136620. };
  136621. /**
  136622. * Gets the current projection matrix
  136623. * @returns a Matrix
  136624. */
  136625. Scene.prototype.getProjectionMatrix = function () {
  136626. return this._projectionMatrix;
  136627. };
  136628. /**
  136629. * Gets the current transform matrix
  136630. * @returns a Matrix made of View * Projection
  136631. */
  136632. Scene.prototype.getTransformMatrix = function () {
  136633. return this._transformMatrix;
  136634. };
  136635. /**
  136636. * Sets the current transform matrix
  136637. * @param viewL defines the View matrix to use
  136638. * @param projectionL defines the Projection matrix to use
  136639. * @param viewR defines the right View matrix to use (if provided)
  136640. * @param projectionR defines the right Projection matrix to use (if provided)
  136641. */
  136642. Scene.prototype.setTransformMatrix = function (viewL, projectionL, viewR, projectionR) {
  136643. if (this._viewUpdateFlag === viewL.updateFlag && this._projectionUpdateFlag === projectionL.updateFlag) {
  136644. return;
  136645. }
  136646. this._viewUpdateFlag = viewL.updateFlag;
  136647. this._projectionUpdateFlag = projectionL.updateFlag;
  136648. this._viewMatrix = viewL;
  136649. this._projectionMatrix = projectionL;
  136650. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  136651. // Update frustum
  136652. if (!this._frustumPlanes) {
  136653. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  136654. }
  136655. else {
  136656. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  136657. }
  136658. if (this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo) {
  136659. this._updateMultiviewUbo(viewR, projectionR);
  136660. }
  136661. else if (this._sceneUbo.useUbo) {
  136662. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  136663. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  136664. this._sceneUbo.update();
  136665. }
  136666. };
  136667. /**
  136668. * Gets the uniform buffer used to store scene data
  136669. * @returns a UniformBuffer
  136670. */
  136671. Scene.prototype.getSceneUniformBuffer = function () {
  136672. return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo;
  136673. };
  136674. /**
  136675. * Gets an unique (relatively to the current scene) Id
  136676. * @returns an unique number for the scene
  136677. */
  136678. Scene.prototype.getUniqueId = function () {
  136679. var result = Scene._uniqueIdCounter;
  136680. Scene._uniqueIdCounter++;
  136681. return result;
  136682. };
  136683. /**
  136684. * Add a mesh to the list of scene's meshes
  136685. * @param newMesh defines the mesh to add
  136686. * @param recursive if all child meshes should also be added to the scene
  136687. */
  136688. Scene.prototype.addMesh = function (newMesh, recursive) {
  136689. var _this = this;
  136690. if (recursive === void 0) { recursive = false; }
  136691. this.meshes.push(newMesh);
  136692. newMesh._resyncLightSources();
  136693. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  136694. if (recursive) {
  136695. newMesh.getChildMeshes().forEach(function (m) {
  136696. _this.addMesh(m);
  136697. });
  136698. }
  136699. };
  136700. /**
  136701. * Remove a mesh for the list of scene's meshes
  136702. * @param toRemove defines the mesh to remove
  136703. * @param recursive if all child meshes should also be removed from the scene
  136704. * @returns the index where the mesh was in the mesh list
  136705. */
  136706. Scene.prototype.removeMesh = function (toRemove, recursive) {
  136707. var _this = this;
  136708. if (recursive === void 0) { recursive = false; }
  136709. var index = this.meshes.indexOf(toRemove);
  136710. if (index !== -1) {
  136711. // Remove from the scene if mesh found
  136712. this.meshes[index] = this.meshes[this.meshes.length - 1];
  136713. this.meshes.pop();
  136714. }
  136715. this.onMeshRemovedObservable.notifyObservers(toRemove);
  136716. if (recursive) {
  136717. toRemove.getChildMeshes().forEach(function (m) {
  136718. _this.removeMesh(m);
  136719. });
  136720. }
  136721. return index;
  136722. };
  136723. /**
  136724. * Add a transform node to the list of scene's transform nodes
  136725. * @param newTransformNode defines the transform node to add
  136726. */
  136727. Scene.prototype.addTransformNode = function (newTransformNode) {
  136728. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  136729. this.transformNodes.push(newTransformNode);
  136730. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  136731. };
  136732. /**
  136733. * Remove a transform node for the list of scene's transform nodes
  136734. * @param toRemove defines the transform node to remove
  136735. * @returns the index where the transform node was in the transform node list
  136736. */
  136737. Scene.prototype.removeTransformNode = function (toRemove) {
  136738. var index = toRemove._indexInSceneTransformNodesArray;
  136739. if (index !== -1) {
  136740. if (index !== this.transformNodes.length - 1) {
  136741. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  136742. this.transformNodes[index] = lastNode;
  136743. lastNode._indexInSceneTransformNodesArray = index;
  136744. }
  136745. toRemove._indexInSceneTransformNodesArray = -1;
  136746. this.transformNodes.pop();
  136747. }
  136748. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  136749. return index;
  136750. };
  136751. /**
  136752. * Remove a skeleton for the list of scene's skeletons
  136753. * @param toRemove defines the skeleton to remove
  136754. * @returns the index where the skeleton was in the skeleton list
  136755. */
  136756. Scene.prototype.removeSkeleton = function (toRemove) {
  136757. var index = this.skeletons.indexOf(toRemove);
  136758. if (index !== -1) {
  136759. // Remove from the scene if found
  136760. this.skeletons.splice(index, 1);
  136761. this.onSkeletonRemovedObservable.notifyObservers(toRemove);
  136762. }
  136763. return index;
  136764. };
  136765. /**
  136766. * Remove a morph target for the list of scene's morph targets
  136767. * @param toRemove defines the morph target to remove
  136768. * @returns the index where the morph target was in the morph target list
  136769. */
  136770. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  136771. var index = this.morphTargetManagers.indexOf(toRemove);
  136772. if (index !== -1) {
  136773. // Remove from the scene if found
  136774. this.morphTargetManagers.splice(index, 1);
  136775. }
  136776. return index;
  136777. };
  136778. /**
  136779. * Remove a light for the list of scene's lights
  136780. * @param toRemove defines the light to remove
  136781. * @returns the index where the light was in the light list
  136782. */
  136783. Scene.prototype.removeLight = function (toRemove) {
  136784. var index = this.lights.indexOf(toRemove);
  136785. if (index !== -1) {
  136786. // Remove from meshes
  136787. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  136788. var mesh = _a[_i];
  136789. mesh._removeLightSource(toRemove);
  136790. }
  136791. // Remove from the scene if mesh found
  136792. this.lights.splice(index, 1);
  136793. this.sortLightsByPriority();
  136794. }
  136795. this.onLightRemovedObservable.notifyObservers(toRemove);
  136796. return index;
  136797. };
  136798. /**
  136799. * Remove a camera for the list of scene's cameras
  136800. * @param toRemove defines the camera to remove
  136801. * @returns the index where the camera was in the camera list
  136802. */
  136803. Scene.prototype.removeCamera = function (toRemove) {
  136804. var index = this.cameras.indexOf(toRemove);
  136805. if (index !== -1) {
  136806. // Remove from the scene if mesh found
  136807. this.cameras.splice(index, 1);
  136808. }
  136809. // Remove from activeCameras
  136810. var index2 = this.activeCameras.indexOf(toRemove);
  136811. if (index2 !== -1) {
  136812. // Remove from the scene if mesh found
  136813. this.activeCameras.splice(index2, 1);
  136814. }
  136815. // Reset the activeCamera
  136816. if (this.activeCamera === toRemove) {
  136817. if (this.cameras.length > 0) {
  136818. this.activeCamera = this.cameras[0];
  136819. }
  136820. else {
  136821. this.activeCamera = null;
  136822. }
  136823. }
  136824. this.onCameraRemovedObservable.notifyObservers(toRemove);
  136825. return index;
  136826. };
  136827. /**
  136828. * Remove a particle system for the list of scene's particle systems
  136829. * @param toRemove defines the particle system to remove
  136830. * @returns the index where the particle system was in the particle system list
  136831. */
  136832. Scene.prototype.removeParticleSystem = function (toRemove) {
  136833. var index = this.particleSystems.indexOf(toRemove);
  136834. if (index !== -1) {
  136835. this.particleSystems.splice(index, 1);
  136836. }
  136837. return index;
  136838. };
  136839. /**
  136840. * Remove a animation for the list of scene's animations
  136841. * @param toRemove defines the animation to remove
  136842. * @returns the index where the animation was in the animation list
  136843. */
  136844. Scene.prototype.removeAnimation = function (toRemove) {
  136845. var index = this.animations.indexOf(toRemove);
  136846. if (index !== -1) {
  136847. this.animations.splice(index, 1);
  136848. }
  136849. return index;
  136850. };
  136851. /**
  136852. * Removes the given animation group from this scene.
  136853. * @param toRemove The animation group to remove
  136854. * @returns The index of the removed animation group
  136855. */
  136856. Scene.prototype.removeAnimationGroup = function (toRemove) {
  136857. var index = this.animationGroups.indexOf(toRemove);
  136858. if (index !== -1) {
  136859. this.animationGroups.splice(index, 1);
  136860. }
  136861. return index;
  136862. };
  136863. /**
  136864. * Removes the given multi-material from this scene.
  136865. * @param toRemove The multi-material to remove
  136866. * @returns The index of the removed multi-material
  136867. */
  136868. Scene.prototype.removeMultiMaterial = function (toRemove) {
  136869. var index = this.multiMaterials.indexOf(toRemove);
  136870. if (index !== -1) {
  136871. this.multiMaterials.splice(index, 1);
  136872. }
  136873. return index;
  136874. };
  136875. /**
  136876. * Removes the given material from this scene.
  136877. * @param toRemove The material to remove
  136878. * @returns The index of the removed material
  136879. */
  136880. Scene.prototype.removeMaterial = function (toRemove) {
  136881. var index = toRemove._indexInSceneMaterialArray;
  136882. if (index !== -1 && index < this.materials.length) {
  136883. if (index !== this.materials.length - 1) {
  136884. var lastMaterial = this.materials[this.materials.length - 1];
  136885. this.materials[index] = lastMaterial;
  136886. lastMaterial._indexInSceneMaterialArray = index;
  136887. }
  136888. toRemove._indexInSceneMaterialArray = -1;
  136889. this.materials.pop();
  136890. }
  136891. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  136892. return index;
  136893. };
  136894. /**
  136895. * Removes the given action manager from this scene.
  136896. * @param toRemove The action manager to remove
  136897. * @returns The index of the removed action manager
  136898. */
  136899. Scene.prototype.removeActionManager = function (toRemove) {
  136900. var index = this.actionManagers.indexOf(toRemove);
  136901. if (index !== -1) {
  136902. this.actionManagers.splice(index, 1);
  136903. }
  136904. return index;
  136905. };
  136906. /**
  136907. * Removes the given texture from this scene.
  136908. * @param toRemove The texture to remove
  136909. * @returns The index of the removed texture
  136910. */
  136911. Scene.prototype.removeTexture = function (toRemove) {
  136912. var index = this.textures.indexOf(toRemove);
  136913. if (index !== -1) {
  136914. this.textures.splice(index, 1);
  136915. }
  136916. this.onTextureRemovedObservable.notifyObservers(toRemove);
  136917. return index;
  136918. };
  136919. /**
  136920. * Adds the given light to this scene
  136921. * @param newLight The light to add
  136922. */
  136923. Scene.prototype.addLight = function (newLight) {
  136924. this.lights.push(newLight);
  136925. this.sortLightsByPriority();
  136926. // Add light to all meshes (To support if the light is removed and then readded)
  136927. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  136928. var mesh = _a[_i];
  136929. if (mesh._lightSources.indexOf(newLight) === -1) {
  136930. mesh._lightSources.push(newLight);
  136931. mesh._resyncLightSources();
  136932. }
  136933. }
  136934. this.onNewLightAddedObservable.notifyObservers(newLight);
  136935. };
  136936. /**
  136937. * Sorts the list list based on light priorities
  136938. */
  136939. Scene.prototype.sortLightsByPriority = function () {
  136940. if (this.requireLightSorting) {
  136941. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_14__["Light"].CompareLightsPriority);
  136942. }
  136943. };
  136944. /**
  136945. * Adds the given camera to this scene
  136946. * @param newCamera The camera to add
  136947. */
  136948. Scene.prototype.addCamera = function (newCamera) {
  136949. this.cameras.push(newCamera);
  136950. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  136951. };
  136952. /**
  136953. * Adds the given skeleton to this scene
  136954. * @param newSkeleton The skeleton to add
  136955. */
  136956. Scene.prototype.addSkeleton = function (newSkeleton) {
  136957. this.skeletons.push(newSkeleton);
  136958. this.onNewSkeletonAddedObservable.notifyObservers(newSkeleton);
  136959. };
  136960. /**
  136961. * Adds the given particle system to this scene
  136962. * @param newParticleSystem The particle system to add
  136963. */
  136964. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  136965. this.particleSystems.push(newParticleSystem);
  136966. };
  136967. /**
  136968. * Adds the given animation to this scene
  136969. * @param newAnimation The animation to add
  136970. */
  136971. Scene.prototype.addAnimation = function (newAnimation) {
  136972. this.animations.push(newAnimation);
  136973. };
  136974. /**
  136975. * Adds the given animation group to this scene.
  136976. * @param newAnimationGroup The animation group to add
  136977. */
  136978. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  136979. this.animationGroups.push(newAnimationGroup);
  136980. };
  136981. /**
  136982. * Adds the given multi-material to this scene
  136983. * @param newMultiMaterial The multi-material to add
  136984. */
  136985. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  136986. this.multiMaterials.push(newMultiMaterial);
  136987. };
  136988. /**
  136989. * Adds the given material to this scene
  136990. * @param newMaterial The material to add
  136991. */
  136992. Scene.prototype.addMaterial = function (newMaterial) {
  136993. newMaterial._indexInSceneMaterialArray = this.materials.length;
  136994. this.materials.push(newMaterial);
  136995. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  136996. };
  136997. /**
  136998. * Adds the given morph target to this scene
  136999. * @param newMorphTargetManager The morph target to add
  137000. */
  137001. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  137002. this.morphTargetManagers.push(newMorphTargetManager);
  137003. };
  137004. /**
  137005. * Adds the given geometry to this scene
  137006. * @param newGeometry The geometry to add
  137007. */
  137008. Scene.prototype.addGeometry = function (newGeometry) {
  137009. if (this.geometriesByUniqueId) {
  137010. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  137011. }
  137012. this.geometries.push(newGeometry);
  137013. };
  137014. /**
  137015. * Adds the given action manager to this scene
  137016. * @param newActionManager The action manager to add
  137017. */
  137018. Scene.prototype.addActionManager = function (newActionManager) {
  137019. this.actionManagers.push(newActionManager);
  137020. };
  137021. /**
  137022. * Adds the given texture to this scene.
  137023. * @param newTexture The texture to add
  137024. */
  137025. Scene.prototype.addTexture = function (newTexture) {
  137026. this.textures.push(newTexture);
  137027. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  137028. };
  137029. /**
  137030. * Switch active camera
  137031. * @param newCamera defines the new active camera
  137032. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  137033. */
  137034. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  137035. if (attachControl === void 0) { attachControl = true; }
  137036. var canvas = this._engine.getRenderingCanvas();
  137037. if (!canvas) {
  137038. return;
  137039. }
  137040. if (this.activeCamera) {
  137041. this.activeCamera.detachControl(canvas);
  137042. }
  137043. this.activeCamera = newCamera;
  137044. if (attachControl) {
  137045. newCamera.attachControl(canvas);
  137046. }
  137047. };
  137048. /**
  137049. * sets the active camera of the scene using its ID
  137050. * @param id defines the camera's ID
  137051. * @return the new active camera or null if none found.
  137052. */
  137053. Scene.prototype.setActiveCameraByID = function (id) {
  137054. var camera = this.getCameraByID(id);
  137055. if (camera) {
  137056. this.activeCamera = camera;
  137057. return camera;
  137058. }
  137059. return null;
  137060. };
  137061. /**
  137062. * sets the active camera of the scene using its name
  137063. * @param name defines the camera's name
  137064. * @returns the new active camera or null if none found.
  137065. */
  137066. Scene.prototype.setActiveCameraByName = function (name) {
  137067. var camera = this.getCameraByName(name);
  137068. if (camera) {
  137069. this.activeCamera = camera;
  137070. return camera;
  137071. }
  137072. return null;
  137073. };
  137074. /**
  137075. * get an animation group using its name
  137076. * @param name defines the material's name
  137077. * @return the animation group or null if none found.
  137078. */
  137079. Scene.prototype.getAnimationGroupByName = function (name) {
  137080. for (var index = 0; index < this.animationGroups.length; index++) {
  137081. if (this.animationGroups[index].name === name) {
  137082. return this.animationGroups[index];
  137083. }
  137084. }
  137085. return null;
  137086. };
  137087. /**
  137088. * Get a material using its unique id
  137089. * @param uniqueId defines the material's unique id
  137090. * @return the material or null if none found.
  137091. */
  137092. Scene.prototype.getMaterialByUniqueID = function (uniqueId) {
  137093. for (var index = 0; index < this.materials.length; index++) {
  137094. if (this.materials[index].uniqueId === uniqueId) {
  137095. return this.materials[index];
  137096. }
  137097. }
  137098. return null;
  137099. };
  137100. /**
  137101. * get a material using its id
  137102. * @param id defines the material's ID
  137103. * @return the material or null if none found.
  137104. */
  137105. Scene.prototype.getMaterialByID = function (id) {
  137106. for (var index = 0; index < this.materials.length; index++) {
  137107. if (this.materials[index].id === id) {
  137108. return this.materials[index];
  137109. }
  137110. }
  137111. return null;
  137112. };
  137113. /**
  137114. * Gets a material using its name
  137115. * @param name defines the material's name
  137116. * @return the material or null if none found.
  137117. */
  137118. Scene.prototype.getMaterialByName = function (name) {
  137119. for (var index = 0; index < this.materials.length; index++) {
  137120. if (this.materials[index].name === name) {
  137121. return this.materials[index];
  137122. }
  137123. }
  137124. return null;
  137125. };
  137126. /**
  137127. * Gets a camera using its id
  137128. * @param id defines the id to look for
  137129. * @returns the camera or null if not found
  137130. */
  137131. Scene.prototype.getCameraByID = function (id) {
  137132. for (var index = 0; index < this.cameras.length; index++) {
  137133. if (this.cameras[index].id === id) {
  137134. return this.cameras[index];
  137135. }
  137136. }
  137137. return null;
  137138. };
  137139. /**
  137140. * Gets a camera using its unique id
  137141. * @param uniqueId defines the unique id to look for
  137142. * @returns the camera or null if not found
  137143. */
  137144. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  137145. for (var index = 0; index < this.cameras.length; index++) {
  137146. if (this.cameras[index].uniqueId === uniqueId) {
  137147. return this.cameras[index];
  137148. }
  137149. }
  137150. return null;
  137151. };
  137152. /**
  137153. * Gets a camera using its name
  137154. * @param name defines the camera's name
  137155. * @return the camera or null if none found.
  137156. */
  137157. Scene.prototype.getCameraByName = function (name) {
  137158. for (var index = 0; index < this.cameras.length; index++) {
  137159. if (this.cameras[index].name === name) {
  137160. return this.cameras[index];
  137161. }
  137162. }
  137163. return null;
  137164. };
  137165. /**
  137166. * Gets a bone using its id
  137167. * @param id defines the bone's id
  137168. * @return the bone or null if not found
  137169. */
  137170. Scene.prototype.getBoneByID = function (id) {
  137171. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  137172. var skeleton = this.skeletons[skeletonIndex];
  137173. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  137174. if (skeleton.bones[boneIndex].id === id) {
  137175. return skeleton.bones[boneIndex];
  137176. }
  137177. }
  137178. }
  137179. return null;
  137180. };
  137181. /**
  137182. * Gets a bone using its id
  137183. * @param name defines the bone's name
  137184. * @return the bone or null if not found
  137185. */
  137186. Scene.prototype.getBoneByName = function (name) {
  137187. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  137188. var skeleton = this.skeletons[skeletonIndex];
  137189. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  137190. if (skeleton.bones[boneIndex].name === name) {
  137191. return skeleton.bones[boneIndex];
  137192. }
  137193. }
  137194. }
  137195. return null;
  137196. };
  137197. /**
  137198. * Gets a light node using its name
  137199. * @param name defines the the light's name
  137200. * @return the light or null if none found.
  137201. */
  137202. Scene.prototype.getLightByName = function (name) {
  137203. for (var index = 0; index < this.lights.length; index++) {
  137204. if (this.lights[index].name === name) {
  137205. return this.lights[index];
  137206. }
  137207. }
  137208. return null;
  137209. };
  137210. /**
  137211. * Gets a light node using its id
  137212. * @param id defines the light's id
  137213. * @return the light or null if none found.
  137214. */
  137215. Scene.prototype.getLightByID = function (id) {
  137216. for (var index = 0; index < this.lights.length; index++) {
  137217. if (this.lights[index].id === id) {
  137218. return this.lights[index];
  137219. }
  137220. }
  137221. return null;
  137222. };
  137223. /**
  137224. * Gets a light node using its scene-generated unique ID
  137225. * @param uniqueId defines the light's unique id
  137226. * @return the light or null if none found.
  137227. */
  137228. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  137229. for (var index = 0; index < this.lights.length; index++) {
  137230. if (this.lights[index].uniqueId === uniqueId) {
  137231. return this.lights[index];
  137232. }
  137233. }
  137234. return null;
  137235. };
  137236. /**
  137237. * Gets a particle system by id
  137238. * @param id defines the particle system id
  137239. * @return the corresponding system or null if none found
  137240. */
  137241. Scene.prototype.getParticleSystemByID = function (id) {
  137242. for (var index = 0; index < this.particleSystems.length; index++) {
  137243. if (this.particleSystems[index].id === id) {
  137244. return this.particleSystems[index];
  137245. }
  137246. }
  137247. return null;
  137248. };
  137249. /**
  137250. * Gets a geometry using its ID
  137251. * @param id defines the geometry's id
  137252. * @return the geometry or null if none found.
  137253. */
  137254. Scene.prototype.getGeometryByID = function (id) {
  137255. for (var index = 0; index < this.geometries.length; index++) {
  137256. if (this.geometries[index].id === id) {
  137257. return this.geometries[index];
  137258. }
  137259. }
  137260. return null;
  137261. };
  137262. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  137263. if (this.geometriesByUniqueId) {
  137264. var index_1 = this.geometriesByUniqueId[uniqueId];
  137265. if (index_1 !== undefined) {
  137266. return this.geometries[index_1];
  137267. }
  137268. }
  137269. else {
  137270. for (var index = 0; index < this.geometries.length; index++) {
  137271. if (this.geometries[index].uniqueId === uniqueId) {
  137272. return this.geometries[index];
  137273. }
  137274. }
  137275. }
  137276. return null;
  137277. };
  137278. /**
  137279. * Add a new geometry to this scene
  137280. * @param geometry defines the geometry to be added to the scene.
  137281. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  137282. * @return a boolean defining if the geometry was added or not
  137283. */
  137284. Scene.prototype.pushGeometry = function (geometry, force) {
  137285. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  137286. return false;
  137287. }
  137288. this.addGeometry(geometry);
  137289. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  137290. return true;
  137291. };
  137292. /**
  137293. * Removes an existing geometry
  137294. * @param geometry defines the geometry to be removed from the scene
  137295. * @return a boolean defining if the geometry was removed or not
  137296. */
  137297. Scene.prototype.removeGeometry = function (geometry) {
  137298. var index;
  137299. if (this.geometriesByUniqueId) {
  137300. index = this.geometriesByUniqueId[geometry.uniqueId];
  137301. if (index === undefined) {
  137302. return false;
  137303. }
  137304. }
  137305. else {
  137306. index = this.geometries.indexOf(geometry);
  137307. if (index < 0) {
  137308. return false;
  137309. }
  137310. }
  137311. if (index !== this.geometries.length - 1) {
  137312. var lastGeometry = this.geometries[this.geometries.length - 1];
  137313. this.geometries[index] = lastGeometry;
  137314. if (this.geometriesByUniqueId) {
  137315. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  137316. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  137317. }
  137318. }
  137319. this.geometries.pop();
  137320. this.onGeometryRemovedObservable.notifyObservers(geometry);
  137321. return true;
  137322. };
  137323. /**
  137324. * Gets the list of geometries attached to the scene
  137325. * @returns an array of Geometry
  137326. */
  137327. Scene.prototype.getGeometries = function () {
  137328. return this.geometries;
  137329. };
  137330. /**
  137331. * Gets the first added mesh found of a given ID
  137332. * @param id defines the id to search for
  137333. * @return the mesh found or null if not found at all
  137334. */
  137335. Scene.prototype.getMeshByID = function (id) {
  137336. for (var index = 0; index < this.meshes.length; index++) {
  137337. if (this.meshes[index].id === id) {
  137338. return this.meshes[index];
  137339. }
  137340. }
  137341. return null;
  137342. };
  137343. /**
  137344. * Gets a list of meshes using their id
  137345. * @param id defines the id to search for
  137346. * @returns a list of meshes
  137347. */
  137348. Scene.prototype.getMeshesByID = function (id) {
  137349. return this.meshes.filter(function (m) {
  137350. return m.id === id;
  137351. });
  137352. };
  137353. /**
  137354. * Gets the first added transform node found of a given ID
  137355. * @param id defines the id to search for
  137356. * @return the found transform node or null if not found at all.
  137357. */
  137358. Scene.prototype.getTransformNodeByID = function (id) {
  137359. for (var index = 0; index < this.transformNodes.length; index++) {
  137360. if (this.transformNodes[index].id === id) {
  137361. return this.transformNodes[index];
  137362. }
  137363. }
  137364. return null;
  137365. };
  137366. /**
  137367. * Gets a transform node with its auto-generated unique id
  137368. * @param uniqueId efines the unique id to search for
  137369. * @return the found transform node or null if not found at all.
  137370. */
  137371. Scene.prototype.getTransformNodeByUniqueID = function (uniqueId) {
  137372. for (var index = 0; index < this.transformNodes.length; index++) {
  137373. if (this.transformNodes[index].uniqueId === uniqueId) {
  137374. return this.transformNodes[index];
  137375. }
  137376. }
  137377. return null;
  137378. };
  137379. /**
  137380. * Gets a list of transform nodes using their id
  137381. * @param id defines the id to search for
  137382. * @returns a list of transform nodes
  137383. */
  137384. Scene.prototype.getTransformNodesByID = function (id) {
  137385. return this.transformNodes.filter(function (m) {
  137386. return m.id === id;
  137387. });
  137388. };
  137389. /**
  137390. * Gets a mesh with its auto-generated unique id
  137391. * @param uniqueId defines the unique id to search for
  137392. * @return the found mesh or null if not found at all.
  137393. */
  137394. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  137395. for (var index = 0; index < this.meshes.length; index++) {
  137396. if (this.meshes[index].uniqueId === uniqueId) {
  137397. return this.meshes[index];
  137398. }
  137399. }
  137400. return null;
  137401. };
  137402. /**
  137403. * Gets a the last added mesh using a given id
  137404. * @param id defines the id to search for
  137405. * @return the found mesh or null if not found at all.
  137406. */
  137407. Scene.prototype.getLastMeshByID = function (id) {
  137408. for (var index = this.meshes.length - 1; index >= 0; index--) {
  137409. if (this.meshes[index].id === id) {
  137410. return this.meshes[index];
  137411. }
  137412. }
  137413. return null;
  137414. };
  137415. /**
  137416. * Gets a the last added node (Mesh, Camera, Light) using a given id
  137417. * @param id defines the id to search for
  137418. * @return the found node or null if not found at all
  137419. */
  137420. Scene.prototype.getLastEntryByID = function (id) {
  137421. var index;
  137422. for (index = this.meshes.length - 1; index >= 0; index--) {
  137423. if (this.meshes[index].id === id) {
  137424. return this.meshes[index];
  137425. }
  137426. }
  137427. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  137428. if (this.transformNodes[index].id === id) {
  137429. return this.transformNodes[index];
  137430. }
  137431. }
  137432. for (index = this.cameras.length - 1; index >= 0; index--) {
  137433. if (this.cameras[index].id === id) {
  137434. return this.cameras[index];
  137435. }
  137436. }
  137437. for (index = this.lights.length - 1; index >= 0; index--) {
  137438. if (this.lights[index].id === id) {
  137439. return this.lights[index];
  137440. }
  137441. }
  137442. return null;
  137443. };
  137444. /**
  137445. * Gets a node (Mesh, Camera, Light) using a given id
  137446. * @param id defines the id to search for
  137447. * @return the found node or null if not found at all
  137448. */
  137449. Scene.prototype.getNodeByID = function (id) {
  137450. var mesh = this.getMeshByID(id);
  137451. if (mesh) {
  137452. return mesh;
  137453. }
  137454. var transformNode = this.getTransformNodeByID(id);
  137455. if (transformNode) {
  137456. return transformNode;
  137457. }
  137458. var light = this.getLightByID(id);
  137459. if (light) {
  137460. return light;
  137461. }
  137462. var camera = this.getCameraByID(id);
  137463. if (camera) {
  137464. return camera;
  137465. }
  137466. var bone = this.getBoneByID(id);
  137467. if (bone) {
  137468. return bone;
  137469. }
  137470. return null;
  137471. };
  137472. /**
  137473. * Gets a node (Mesh, Camera, Light) using a given name
  137474. * @param name defines the name to search for
  137475. * @return the found node or null if not found at all.
  137476. */
  137477. Scene.prototype.getNodeByName = function (name) {
  137478. var mesh = this.getMeshByName(name);
  137479. if (mesh) {
  137480. return mesh;
  137481. }
  137482. var transformNode = this.getTransformNodeByName(name);
  137483. if (transformNode) {
  137484. return transformNode;
  137485. }
  137486. var light = this.getLightByName(name);
  137487. if (light) {
  137488. return light;
  137489. }
  137490. var camera = this.getCameraByName(name);
  137491. if (camera) {
  137492. return camera;
  137493. }
  137494. var bone = this.getBoneByName(name);
  137495. if (bone) {
  137496. return bone;
  137497. }
  137498. return null;
  137499. };
  137500. /**
  137501. * Gets a mesh using a given name
  137502. * @param name defines the name to search for
  137503. * @return the found mesh or null if not found at all.
  137504. */
  137505. Scene.prototype.getMeshByName = function (name) {
  137506. for (var index = 0; index < this.meshes.length; index++) {
  137507. if (this.meshes[index].name === name) {
  137508. return this.meshes[index];
  137509. }
  137510. }
  137511. return null;
  137512. };
  137513. /**
  137514. * Gets a transform node using a given name
  137515. * @param name defines the name to search for
  137516. * @return the found transform node or null if not found at all.
  137517. */
  137518. Scene.prototype.getTransformNodeByName = function (name) {
  137519. for (var index = 0; index < this.transformNodes.length; index++) {
  137520. if (this.transformNodes[index].name === name) {
  137521. return this.transformNodes[index];
  137522. }
  137523. }
  137524. return null;
  137525. };
  137526. /**
  137527. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  137528. * @param id defines the id to search for
  137529. * @return the found skeleton or null if not found at all.
  137530. */
  137531. Scene.prototype.getLastSkeletonByID = function (id) {
  137532. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  137533. if (this.skeletons[index].id === id) {
  137534. return this.skeletons[index];
  137535. }
  137536. }
  137537. return null;
  137538. };
  137539. /**
  137540. * Gets a skeleton using a given auto generated unique id
  137541. * @param uniqueId defines the unique id to search for
  137542. * @return the found skeleton or null if not found at all.
  137543. */
  137544. Scene.prototype.getSkeletonByUniqueId = function (uniqueId) {
  137545. for (var index = 0; index < this.skeletons.length; index++) {
  137546. if (this.skeletons[index].uniqueId === uniqueId) {
  137547. return this.skeletons[index];
  137548. }
  137549. }
  137550. return null;
  137551. };
  137552. /**
  137553. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  137554. * @param id defines the id to search for
  137555. * @return the found skeleton or null if not found at all.
  137556. */
  137557. Scene.prototype.getSkeletonById = function (id) {
  137558. for (var index = 0; index < this.skeletons.length; index++) {
  137559. if (this.skeletons[index].id === id) {
  137560. return this.skeletons[index];
  137561. }
  137562. }
  137563. return null;
  137564. };
  137565. /**
  137566. * Gets a skeleton using a given name
  137567. * @param name defines the name to search for
  137568. * @return the found skeleton or null if not found at all.
  137569. */
  137570. Scene.prototype.getSkeletonByName = function (name) {
  137571. for (var index = 0; index < this.skeletons.length; index++) {
  137572. if (this.skeletons[index].name === name) {
  137573. return this.skeletons[index];
  137574. }
  137575. }
  137576. return null;
  137577. };
  137578. /**
  137579. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  137580. * @param id defines the id to search for
  137581. * @return the found morph target manager or null if not found at all.
  137582. */
  137583. Scene.prototype.getMorphTargetManagerById = function (id) {
  137584. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  137585. if (this.morphTargetManagers[index].uniqueId === id) {
  137586. return this.morphTargetManagers[index];
  137587. }
  137588. }
  137589. return null;
  137590. };
  137591. /**
  137592. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  137593. * @param id defines the id to search for
  137594. * @return the found morph target or null if not found at all.
  137595. */
  137596. Scene.prototype.getMorphTargetById = function (id) {
  137597. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  137598. var morphTargetManager = this.morphTargetManagers[managerIndex];
  137599. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  137600. var target = morphTargetManager.getTarget(index);
  137601. if (target.id === id) {
  137602. return target;
  137603. }
  137604. }
  137605. }
  137606. return null;
  137607. };
  137608. /**
  137609. * Gets a boolean indicating if the given mesh is active
  137610. * @param mesh defines the mesh to look for
  137611. * @returns true if the mesh is in the active list
  137612. */
  137613. Scene.prototype.isActiveMesh = function (mesh) {
  137614. return (this._activeMeshes.indexOf(mesh) !== -1);
  137615. };
  137616. Object.defineProperty(Scene.prototype, "uid", {
  137617. /**
  137618. * Return a unique id as a string which can serve as an identifier for the scene
  137619. */
  137620. get: function () {
  137621. if (!this._uid) {
  137622. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  137623. }
  137624. return this._uid;
  137625. },
  137626. enumerable: true,
  137627. configurable: true
  137628. });
  137629. /**
  137630. * Add an externaly attached data from its key.
  137631. * This method call will fail and return false, if such key already exists.
  137632. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  137633. * @param key the unique key that identifies the data
  137634. * @param data the data object to associate to the key for this Engine instance
  137635. * @return true if no such key were already present and the data was added successfully, false otherwise
  137636. */
  137637. Scene.prototype.addExternalData = function (key, data) {
  137638. if (!this._externalData) {
  137639. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  137640. }
  137641. return this._externalData.add(key, data);
  137642. };
  137643. /**
  137644. * Get an externaly attached data from its key
  137645. * @param key the unique key that identifies the data
  137646. * @return the associated data, if present (can be null), or undefined if not present
  137647. */
  137648. Scene.prototype.getExternalData = function (key) {
  137649. if (!this._externalData) {
  137650. return null;
  137651. }
  137652. return this._externalData.get(key);
  137653. };
  137654. /**
  137655. * Get an externaly attached data from its key, create it using a factory if it's not already present
  137656. * @param key the unique key that identifies the data
  137657. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  137658. * @return the associated data, can be null if the factory returned null.
  137659. */
  137660. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  137661. if (!this._externalData) {
  137662. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  137663. }
  137664. return this._externalData.getOrAddWithFactory(key, factory);
  137665. };
  137666. /**
  137667. * Remove an externaly attached data from the Engine instance
  137668. * @param key the unique key that identifies the data
  137669. * @return true if the data was successfully removed, false if it doesn't exist
  137670. */
  137671. Scene.prototype.removeExternalData = function (key) {
  137672. return this._externalData.remove(key);
  137673. };
  137674. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  137675. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  137676. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  137677. var step = _a[_i];
  137678. step.action(mesh, subMesh);
  137679. }
  137680. var material = subMesh.getMaterial();
  137681. if (material !== null && material !== undefined) {
  137682. // Render targets
  137683. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  137684. if (this._processedMaterials.indexOf(material) === -1) {
  137685. this._processedMaterials.push(material);
  137686. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  137687. }
  137688. }
  137689. // Dispatch
  137690. this._activeIndices.addCount(subMesh.indexCount, false);
  137691. this._renderingManager.dispatch(subMesh, mesh, material);
  137692. }
  137693. }
  137694. };
  137695. /**
  137696. * Clear the processed materials smart array preventing retention point in material dispose.
  137697. */
  137698. Scene.prototype.freeProcessedMaterials = function () {
  137699. this._processedMaterials.dispose();
  137700. };
  137701. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  137702. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  137703. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  137704. * when disposing several meshes in a row or a hierarchy of meshes.
  137705. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  137706. */
  137707. get: function () {
  137708. return this._preventFreeActiveMeshesAndRenderingGroups;
  137709. },
  137710. set: function (value) {
  137711. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  137712. return;
  137713. }
  137714. if (value) {
  137715. this.freeActiveMeshes();
  137716. this.freeRenderingGroups();
  137717. }
  137718. this._preventFreeActiveMeshesAndRenderingGroups = value;
  137719. },
  137720. enumerable: true,
  137721. configurable: true
  137722. });
  137723. /**
  137724. * Clear the active meshes smart array preventing retention point in mesh dispose.
  137725. */
  137726. Scene.prototype.freeActiveMeshes = function () {
  137727. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  137728. return;
  137729. }
  137730. this._activeMeshes.dispose();
  137731. if (this.activeCamera && this.activeCamera._activeMeshes) {
  137732. this.activeCamera._activeMeshes.dispose();
  137733. }
  137734. if (this.activeCameras) {
  137735. for (var i = 0; i < this.activeCameras.length; i++) {
  137736. var activeCamera = this.activeCameras[i];
  137737. if (activeCamera && activeCamera._activeMeshes) {
  137738. activeCamera._activeMeshes.dispose();
  137739. }
  137740. }
  137741. }
  137742. };
  137743. /**
  137744. * Clear the info related to rendering groups preventing retention points during dispose.
  137745. */
  137746. Scene.prototype.freeRenderingGroups = function () {
  137747. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  137748. return;
  137749. }
  137750. if (this._renderingManager) {
  137751. this._renderingManager.freeRenderingGroups();
  137752. }
  137753. if (this.textures) {
  137754. for (var i = 0; i < this.textures.length; i++) {
  137755. var texture = this.textures[i];
  137756. if (texture && texture.renderList) {
  137757. texture.freeRenderingGroups();
  137758. }
  137759. }
  137760. }
  137761. };
  137762. /** @hidden */
  137763. Scene.prototype._isInIntermediateRendering = function () {
  137764. return this._intermediateRendering;
  137765. };
  137766. /**
  137767. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  137768. * @returns the current scene
  137769. */
  137770. Scene.prototype.freezeActiveMeshes = function () {
  137771. if (!this.activeCamera) {
  137772. return this;
  137773. }
  137774. if (!this._frustumPlanes) {
  137775. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  137776. }
  137777. this._evaluateActiveMeshes();
  137778. this._activeMeshesFrozen = true;
  137779. for (var _i = 0, _a = this._activeMeshes.data; _i < _a.length; _i++) {
  137780. var mesh = _a[_i];
  137781. mesh._freeze();
  137782. }
  137783. return this;
  137784. };
  137785. /**
  137786. * Use this function to restart evaluating active meshes on every frame
  137787. * @returns the current scene
  137788. */
  137789. Scene.prototype.unfreezeActiveMeshes = function () {
  137790. for (var _i = 0, _a = this._activeMeshes.data; _i < _a.length; _i++) {
  137791. var mesh = _a[_i];
  137792. mesh._unFreeze();
  137793. }
  137794. this._activeMeshesFrozen = false;
  137795. return this;
  137796. };
  137797. Scene.prototype._evaluateActiveMeshes = function () {
  137798. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  137799. var len_1 = this._activeMeshes.length;
  137800. for (var i = 0; i < len_1; i++) {
  137801. var mesh = this._activeMeshes.data[i];
  137802. mesh.computeWorldMatrix();
  137803. }
  137804. return;
  137805. }
  137806. if (!this.activeCamera) {
  137807. return;
  137808. }
  137809. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  137810. this.activeCamera._activeMeshes.reset();
  137811. this._activeMeshes.reset();
  137812. this._renderingManager.reset();
  137813. this._processedMaterials.reset();
  137814. this._activeParticleSystems.reset();
  137815. this._activeSkeletons.reset();
  137816. this._softwareSkinnedMeshes.reset();
  137817. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  137818. var step = _a[_i];
  137819. step.action();
  137820. }
  137821. // Determine mesh candidates
  137822. var meshes = this.getActiveMeshCandidates();
  137823. // Check each mesh
  137824. var len = meshes.length;
  137825. for (var i = 0; i < len; i++) {
  137826. var mesh = meshes.data[i];
  137827. mesh._isActive = false;
  137828. if (mesh.isBlocked) {
  137829. continue;
  137830. }
  137831. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  137832. if (!mesh.isReady() || !mesh.isEnabled() || mesh.scaling.lengthSquared() === 0) {
  137833. continue;
  137834. }
  137835. mesh.computeWorldMatrix();
  137836. // Intersections
  137837. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  137838. this._meshesForIntersections.pushNoDuplicate(mesh);
  137839. }
  137840. // Switch to current LOD
  137841. var meshLOD = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  137842. if (meshLOD === undefined || meshLOD === null) {
  137843. continue;
  137844. }
  137845. // Compute world matrix if LOD is billboard
  137846. if (meshLOD !== mesh && meshLOD.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__["TransformNode"].BILLBOARDMODE_NONE) {
  137847. meshLOD.computeWorldMatrix();
  137848. }
  137849. mesh._preActivate();
  137850. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  137851. this._activeMeshes.push(mesh);
  137852. this.activeCamera._activeMeshes.push(mesh);
  137853. if (meshLOD !== mesh) {
  137854. meshLOD._activate(this._renderId);
  137855. }
  137856. if (mesh._activate(this._renderId)) {
  137857. mesh._isActive = true;
  137858. this._activeMesh(mesh, meshLOD);
  137859. }
  137860. }
  137861. }
  137862. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  137863. // Particle systems
  137864. if (this.particlesEnabled) {
  137865. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  137866. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  137867. var particleSystem = this.particleSystems[particleIndex];
  137868. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  137869. continue;
  137870. }
  137871. var emitter = particleSystem.emitter;
  137872. if (!emitter.position || emitter.isEnabled()) {
  137873. this._activeParticleSystems.push(particleSystem);
  137874. particleSystem.animate();
  137875. this._renderingManager.dispatchParticles(particleSystem);
  137876. }
  137877. }
  137878. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  137879. }
  137880. };
  137881. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  137882. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  137883. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  137884. mesh.skeleton.prepare();
  137885. }
  137886. if (!mesh.computeBonesUsingShaders) {
  137887. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  137888. }
  137889. }
  137890. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  137891. var step = _a[_i];
  137892. step.action(sourceMesh, mesh);
  137893. }
  137894. if (mesh !== undefined && mesh !== null
  137895. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  137896. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  137897. var len = subMeshes.length;
  137898. for (var i = 0; i < len; i++) {
  137899. var subMesh = subMeshes.data[i];
  137900. this._evaluateSubMesh(subMesh, mesh);
  137901. }
  137902. }
  137903. };
  137904. /**
  137905. * Update the transform matrix to update from the current active camera
  137906. * @param force defines a boolean used to force the update even if cache is up to date
  137907. */
  137908. Scene.prototype.updateTransformMatrix = function (force) {
  137909. if (!this.activeCamera) {
  137910. return;
  137911. }
  137912. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  137913. };
  137914. Scene.prototype._bindFrameBuffer = function () {
  137915. if (this.activeCamera && this.activeCamera._multiviewTexture) {
  137916. this.activeCamera._multiviewTexture._bindFrameBuffer();
  137917. }
  137918. else if (this.activeCamera && this.activeCamera.outputRenderTarget) {
  137919. var useMultiview = this.getEngine().getCaps().multiview && this.activeCamera.outputRenderTarget && this.activeCamera.outputRenderTarget.getViewCount() > 1;
  137920. if (useMultiview) {
  137921. this.activeCamera.outputRenderTarget._bindFrameBuffer();
  137922. }
  137923. else {
  137924. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  137925. if (internalTexture) {
  137926. this.getEngine().bindFramebuffer(internalTexture);
  137927. }
  137928. else {
  137929. _Misc_logger__WEBPACK_IMPORTED_MODULE_24__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  137930. }
  137931. }
  137932. }
  137933. else {
  137934. this.getEngine().restoreDefaultFramebuffer(); // Restore back buffer if needed
  137935. }
  137936. };
  137937. /** @hidden */
  137938. Scene.prototype._renderForCamera = function (camera, rigParent) {
  137939. if (camera && camera._skipRendering) {
  137940. return;
  137941. }
  137942. var engine = this._engine;
  137943. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  137944. this._activeCamera = camera;
  137945. if (!this.activeCamera) {
  137946. throw new Error("Active camera not set");
  137947. }
  137948. // Viewport
  137949. engine.setViewport(this.activeCamera.viewport);
  137950. // Camera
  137951. this.resetCachedMaterial();
  137952. this._renderId++;
  137953. var useMultiview = this.getEngine().getCaps().multiview && camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1;
  137954. if (useMultiview) {
  137955. this.setTransformMatrix(camera._rigCameras[0].getViewMatrix(), camera._rigCameras[0].getProjectionMatrix(), camera._rigCameras[1].getViewMatrix(), camera._rigCameras[1].getProjectionMatrix());
  137956. }
  137957. else {
  137958. this.updateTransformMatrix();
  137959. }
  137960. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  137961. // Meshes
  137962. this._evaluateActiveMeshes();
  137963. // Software skinning
  137964. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  137965. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  137966. mesh.applySkeleton(mesh.skeleton);
  137967. }
  137968. // Render targets
  137969. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  137970. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  137971. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  137972. }
  137973. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  137974. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  137975. }
  137976. // Collects render targets from external components.
  137977. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  137978. var step = _a[_i];
  137979. step.action(this._renderTargets);
  137980. }
  137981. if (this.renderTargetsEnabled) {
  137982. this._intermediateRendering = true;
  137983. var needRebind = false;
  137984. if (this._renderTargets.length > 0) {
  137985. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  137986. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  137987. var renderTarget = this._renderTargets.data[renderIndex];
  137988. if (renderTarget._shouldRender()) {
  137989. this._renderId++;
  137990. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  137991. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  137992. needRebind = true;
  137993. }
  137994. }
  137995. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  137996. this._renderId++;
  137997. }
  137998. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  137999. var step = _c[_b];
  138000. needRebind = needRebind || step.action(this.activeCamera);
  138001. }
  138002. this._intermediateRendering = false;
  138003. // Restore framebuffer after rendering to targets
  138004. if (needRebind) {
  138005. this._bindFrameBuffer();
  138006. }
  138007. }
  138008. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  138009. // Prepare Frame
  138010. if (this.postProcessManager && !camera._multiviewTexture) {
  138011. this.postProcessManager._prepareFrame();
  138012. }
  138013. // Before Camera Draw
  138014. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  138015. var step = _e[_d];
  138016. step.action(this.activeCamera);
  138017. }
  138018. // Render
  138019. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  138020. this._renderingManager.render(null, null, true, true);
  138021. this.onAfterDrawPhaseObservable.notifyObservers(this);
  138022. // After Camera Draw
  138023. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  138024. var step = _g[_f];
  138025. step.action(this.activeCamera);
  138026. }
  138027. // Finalize frame
  138028. if (this.postProcessManager && !camera._multiviewTexture) {
  138029. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  138030. }
  138031. // Reset some special arrays
  138032. this._renderTargets.reset();
  138033. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  138034. };
  138035. Scene.prototype._processSubCameras = function (camera) {
  138036. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE || (camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview)) {
  138037. this._renderForCamera(camera);
  138038. return;
  138039. }
  138040. if (camera._useMultiviewToSingleView) {
  138041. this._renderMultiviewToSingleView(camera);
  138042. }
  138043. else {
  138044. // rig cameras
  138045. for (var index = 0; index < camera._rigCameras.length; index++) {
  138046. this._renderForCamera(camera._rigCameras[index], camera);
  138047. }
  138048. }
  138049. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  138050. this._activeCamera = camera;
  138051. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  138052. };
  138053. Scene.prototype._checkIntersections = function () {
  138054. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  138055. var sourceMesh = this._meshesForIntersections.data[index];
  138056. if (!sourceMesh.actionManager) {
  138057. continue;
  138058. }
  138059. for (var actionIndex = 0; sourceMesh.actionManager && actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  138060. var action = sourceMesh.actionManager.actions[actionIndex];
  138061. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  138062. var parameters = action.getTriggerParameter();
  138063. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameters : parameters.mesh;
  138064. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  138065. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  138066. if (areIntersecting && currentIntersectionInProgress === -1) {
  138067. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  138068. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  138069. sourceMesh._intersectionsInProgress.push(otherMesh);
  138070. }
  138071. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  138072. sourceMesh._intersectionsInProgress.push(otherMesh);
  138073. }
  138074. }
  138075. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  138076. //They intersected, and now they don't.
  138077. //is this trigger an exit trigger? execute an event.
  138078. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  138079. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  138080. }
  138081. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  138082. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  138083. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameter : parameter.mesh;
  138084. return otherMesh === parameterMesh;
  138085. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  138086. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  138087. }
  138088. }
  138089. }
  138090. }
  138091. }
  138092. };
  138093. /** @hidden */
  138094. Scene.prototype._advancePhysicsEngineStep = function (step) {
  138095. // Do nothing. Code will be replaced if physics engine component is referenced
  138096. };
  138097. /** @hidden */
  138098. Scene.prototype._animate = function () {
  138099. // Nothing to do as long as Animatable have not been imported.
  138100. };
  138101. /** Execute all animations (for a frame) */
  138102. Scene.prototype.animate = function () {
  138103. if (this._engine.isDeterministicLockStep()) {
  138104. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  138105. var defaultFPS = (60.0 / 1000.0);
  138106. var defaultFrameTime = this.getDeterministicFrameTime();
  138107. var stepsTaken = 0;
  138108. var maxSubSteps = this._engine.getLockstepMaxSteps();
  138109. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  138110. internalSteps = Math.min(internalSteps, maxSubSteps);
  138111. do {
  138112. this.onBeforeStepObservable.notifyObservers(this);
  138113. // Animations
  138114. this._animationRatio = defaultFrameTime * defaultFPS;
  138115. this._animate();
  138116. this.onAfterAnimationsObservable.notifyObservers(this);
  138117. // Physics
  138118. this._advancePhysicsEngineStep(defaultFrameTime);
  138119. this.onAfterStepObservable.notifyObservers(this);
  138120. this._currentStepId++;
  138121. stepsTaken++;
  138122. deltaTime -= defaultFrameTime;
  138123. } while (deltaTime > 0 && stepsTaken < internalSteps);
  138124. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  138125. }
  138126. else {
  138127. // Animations
  138128. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  138129. this._animationRatio = deltaTime * (60.0 / 1000.0);
  138130. this._animate();
  138131. this.onAfterAnimationsObservable.notifyObservers(this);
  138132. // Physics
  138133. this._advancePhysicsEngineStep(deltaTime);
  138134. }
  138135. };
  138136. /**
  138137. * Render the scene
  138138. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  138139. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  138140. */
  138141. Scene.prototype.render = function (updateCameras, ignoreAnimations) {
  138142. if (updateCameras === void 0) { updateCameras = true; }
  138143. if (ignoreAnimations === void 0) { ignoreAnimations = false; }
  138144. if (this.isDisposed) {
  138145. return;
  138146. }
  138147. this._frameId++;
  138148. // Register components that have been associated lately to the scene.
  138149. this._registerTransientComponents();
  138150. this._activeParticles.fetchNewFrame();
  138151. this._totalVertices.fetchNewFrame();
  138152. this._activeIndices.fetchNewFrame();
  138153. this._activeBones.fetchNewFrame();
  138154. this._meshesForIntersections.reset();
  138155. this.resetCachedMaterial();
  138156. this.onBeforeAnimationsObservable.notifyObservers(this);
  138157. // Actions
  138158. if (this.actionManager) {
  138159. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnEveryFrameTrigger);
  138160. }
  138161. // Animations
  138162. if (!ignoreAnimations) {
  138163. this.animate();
  138164. }
  138165. // Before camera update steps
  138166. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  138167. var step = _a[_i];
  138168. step.action();
  138169. }
  138170. // Update Cameras
  138171. if (updateCameras) {
  138172. if (this.activeCameras.length > 0) {
  138173. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  138174. var camera = this.activeCameras[cameraIndex];
  138175. camera.update();
  138176. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  138177. // rig cameras
  138178. for (var index = 0; index < camera._rigCameras.length; index++) {
  138179. camera._rigCameras[index].update();
  138180. }
  138181. }
  138182. }
  138183. }
  138184. else if (this.activeCamera) {
  138185. this.activeCamera.update();
  138186. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  138187. // rig cameras
  138188. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  138189. this.activeCamera._rigCameras[index].update();
  138190. }
  138191. }
  138192. }
  138193. }
  138194. // Before render
  138195. this.onBeforeRenderObservable.notifyObservers(this);
  138196. // Customs render targets
  138197. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  138198. var engine = this.getEngine();
  138199. var currentActiveCamera = this.activeCamera;
  138200. if (this.renderTargetsEnabled) {
  138201. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  138202. this._intermediateRendering = true;
  138203. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  138204. var renderTarget = this.customRenderTargets[customIndex];
  138205. if (renderTarget._shouldRender()) {
  138206. this._renderId++;
  138207. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  138208. if (!this.activeCamera) {
  138209. throw new Error("Active camera not set");
  138210. }
  138211. // Viewport
  138212. engine.setViewport(this.activeCamera.viewport);
  138213. // Camera
  138214. this.updateTransformMatrix();
  138215. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  138216. }
  138217. }
  138218. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  138219. this._intermediateRendering = false;
  138220. this._renderId++;
  138221. }
  138222. // Restore back buffer
  138223. this.activeCamera = currentActiveCamera;
  138224. this._bindFrameBuffer();
  138225. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  138226. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  138227. var step = _c[_b];
  138228. step.action();
  138229. }
  138230. // Clear
  138231. if (this.autoClearDepthAndStencil || this.autoClear) {
  138232. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  138233. }
  138234. // Collects render targets from external components.
  138235. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  138236. var step = _e[_d];
  138237. step.action(this._renderTargets);
  138238. }
  138239. // Multi-cameras?
  138240. if (this.activeCameras.length > 0) {
  138241. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  138242. if (cameraIndex > 0) {
  138243. this._engine.clear(null, false, true, true);
  138244. }
  138245. this._processSubCameras(this.activeCameras[cameraIndex]);
  138246. }
  138247. }
  138248. else {
  138249. if (!this.activeCamera) {
  138250. throw new Error("No camera defined");
  138251. }
  138252. this._processSubCameras(this.activeCamera);
  138253. }
  138254. // Intersection checks
  138255. this._checkIntersections();
  138256. // Executes the after render stage actions.
  138257. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  138258. var step = _g[_f];
  138259. step.action();
  138260. }
  138261. // After render
  138262. if (this.afterRender) {
  138263. this.afterRender();
  138264. }
  138265. this.onAfterRenderObservable.notifyObservers(this);
  138266. // Cleaning
  138267. if (this._toBeDisposed.length) {
  138268. for (var index = 0; index < this._toBeDisposed.length; index++) {
  138269. var data = this._toBeDisposed[index];
  138270. if (data) {
  138271. data.dispose();
  138272. }
  138273. }
  138274. this._toBeDisposed = [];
  138275. }
  138276. if (this.dumpNextRenderTargets) {
  138277. this.dumpNextRenderTargets = false;
  138278. }
  138279. this._activeBones.addCount(0, true);
  138280. this._activeIndices.addCount(0, true);
  138281. this._activeParticles.addCount(0, true);
  138282. };
  138283. /**
  138284. * Freeze all materials
  138285. * A frozen material will not be updatable but should be faster to render
  138286. */
  138287. Scene.prototype.freezeMaterials = function () {
  138288. for (var i = 0; i < this.materials.length; i++) {
  138289. this.materials[i].freeze();
  138290. }
  138291. };
  138292. /**
  138293. * Unfreeze all materials
  138294. * A frozen material will not be updatable but should be faster to render
  138295. */
  138296. Scene.prototype.unfreezeMaterials = function () {
  138297. for (var i = 0; i < this.materials.length; i++) {
  138298. this.materials[i].unfreeze();
  138299. }
  138300. };
  138301. /**
  138302. * Releases all held ressources
  138303. */
  138304. Scene.prototype.dispose = function () {
  138305. this.beforeRender = null;
  138306. this.afterRender = null;
  138307. this.skeletons = [];
  138308. this.morphTargetManagers = [];
  138309. this._transientComponents = [];
  138310. this._isReadyForMeshStage.clear();
  138311. this._beforeEvaluateActiveMeshStage.clear();
  138312. this._evaluateSubMeshStage.clear();
  138313. this._activeMeshStage.clear();
  138314. this._cameraDrawRenderTargetStage.clear();
  138315. this._beforeCameraDrawStage.clear();
  138316. this._beforeRenderTargetDrawStage.clear();
  138317. this._beforeRenderingGroupDrawStage.clear();
  138318. this._beforeRenderingMeshStage.clear();
  138319. this._afterRenderingMeshStage.clear();
  138320. this._afterRenderingGroupDrawStage.clear();
  138321. this._afterCameraDrawStage.clear();
  138322. this._afterRenderTargetDrawStage.clear();
  138323. this._afterRenderStage.clear();
  138324. this._beforeCameraUpdateStage.clear();
  138325. this._beforeClearStage.clear();
  138326. this._gatherRenderTargetsStage.clear();
  138327. this._gatherActiveCameraRenderTargetsStage.clear();
  138328. this._pointerMoveStage.clear();
  138329. this._pointerDownStage.clear();
  138330. this._pointerUpStage.clear();
  138331. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  138332. var component = _a[_i];
  138333. component.dispose();
  138334. }
  138335. this.importedMeshesFiles = new Array();
  138336. this.stopAllAnimations();
  138337. this.resetCachedMaterial();
  138338. // Smart arrays
  138339. if (this.activeCamera) {
  138340. this.activeCamera._activeMeshes.dispose();
  138341. this.activeCamera = null;
  138342. }
  138343. this._activeMeshes.dispose();
  138344. this._renderingManager.dispose();
  138345. this._processedMaterials.dispose();
  138346. this._activeParticleSystems.dispose();
  138347. this._activeSkeletons.dispose();
  138348. this._softwareSkinnedMeshes.dispose();
  138349. this._renderTargets.dispose();
  138350. this._registeredForLateAnimationBindings.dispose();
  138351. this._meshesForIntersections.dispose();
  138352. this._toBeDisposed = [];
  138353. // Abort active requests
  138354. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  138355. var request = _c[_b];
  138356. request.abort();
  138357. }
  138358. // Events
  138359. this.onDisposeObservable.notifyObservers(this);
  138360. this.onDisposeObservable.clear();
  138361. this.onBeforeRenderObservable.clear();
  138362. this.onAfterRenderObservable.clear();
  138363. this.onBeforeRenderTargetsRenderObservable.clear();
  138364. this.onAfterRenderTargetsRenderObservable.clear();
  138365. this.onAfterStepObservable.clear();
  138366. this.onBeforeStepObservable.clear();
  138367. this.onBeforeActiveMeshesEvaluationObservable.clear();
  138368. this.onAfterActiveMeshesEvaluationObservable.clear();
  138369. this.onBeforeParticlesRenderingObservable.clear();
  138370. this.onAfterParticlesRenderingObservable.clear();
  138371. this.onBeforeDrawPhaseObservable.clear();
  138372. this.onAfterDrawPhaseObservable.clear();
  138373. this.onBeforeAnimationsObservable.clear();
  138374. this.onAfterAnimationsObservable.clear();
  138375. this.onDataLoadedObservable.clear();
  138376. this.onBeforeRenderingGroupObservable.clear();
  138377. this.onAfterRenderingGroupObservable.clear();
  138378. this.onMeshImportedObservable.clear();
  138379. this.onBeforeCameraRenderObservable.clear();
  138380. this.onAfterCameraRenderObservable.clear();
  138381. this.onReadyObservable.clear();
  138382. this.onNewCameraAddedObservable.clear();
  138383. this.onCameraRemovedObservable.clear();
  138384. this.onNewLightAddedObservable.clear();
  138385. this.onLightRemovedObservable.clear();
  138386. this.onNewGeometryAddedObservable.clear();
  138387. this.onGeometryRemovedObservable.clear();
  138388. this.onNewTransformNodeAddedObservable.clear();
  138389. this.onTransformNodeRemovedObservable.clear();
  138390. this.onNewMeshAddedObservable.clear();
  138391. this.onMeshRemovedObservable.clear();
  138392. this.onNewSkeletonAddedObservable.clear();
  138393. this.onSkeletonRemovedObservable.clear();
  138394. this.onNewMaterialAddedObservable.clear();
  138395. this.onMaterialRemovedObservable.clear();
  138396. this.onNewTextureAddedObservable.clear();
  138397. this.onTextureRemovedObservable.clear();
  138398. this.onPrePointerObservable.clear();
  138399. this.onPointerObservable.clear();
  138400. this.onPreKeyboardObservable.clear();
  138401. this.onKeyboardObservable.clear();
  138402. this.onActiveCameraChanged.clear();
  138403. this.detachControl();
  138404. // Detach cameras
  138405. var canvas = this._engine.getRenderingCanvas();
  138406. if (canvas) {
  138407. var index;
  138408. for (index = 0; index < this.cameras.length; index++) {
  138409. this.cameras[index].detachControl(canvas);
  138410. }
  138411. }
  138412. // Release animation groups
  138413. while (this.animationGroups.length) {
  138414. this.animationGroups[0].dispose();
  138415. }
  138416. // Release lights
  138417. while (this.lights.length) {
  138418. this.lights[0].dispose();
  138419. }
  138420. // Release meshes
  138421. while (this.meshes.length) {
  138422. this.meshes[0].dispose(true);
  138423. }
  138424. while (this.transformNodes.length) {
  138425. this.transformNodes[0].dispose(true);
  138426. }
  138427. // Release cameras
  138428. while (this.cameras.length) {
  138429. this.cameras[0].dispose();
  138430. }
  138431. // Release materials
  138432. if (this.defaultMaterial) {
  138433. this.defaultMaterial.dispose();
  138434. }
  138435. while (this.multiMaterials.length) {
  138436. this.multiMaterials[0].dispose();
  138437. }
  138438. while (this.materials.length) {
  138439. this.materials[0].dispose();
  138440. }
  138441. // Release particles
  138442. while (this.particleSystems.length) {
  138443. this.particleSystems[0].dispose();
  138444. }
  138445. // Release postProcesses
  138446. while (this.postProcesses.length) {
  138447. this.postProcesses[0].dispose();
  138448. }
  138449. // Release textures
  138450. while (this.textures.length) {
  138451. this.textures[0].dispose();
  138452. }
  138453. // Release UBO
  138454. this._sceneUbo.dispose();
  138455. if (this._multiviewSceneUbo) {
  138456. this._multiviewSceneUbo.dispose();
  138457. }
  138458. // Post-processes
  138459. this.postProcessManager.dispose();
  138460. // Remove from engine
  138461. index = this._engine.scenes.indexOf(this);
  138462. if (index > -1) {
  138463. this._engine.scenes.splice(index, 1);
  138464. }
  138465. this._engine.wipeCaches(true);
  138466. this._isDisposed = true;
  138467. };
  138468. Object.defineProperty(Scene.prototype, "isDisposed", {
  138469. /**
  138470. * Gets if the scene is already disposed
  138471. */
  138472. get: function () {
  138473. return this._isDisposed;
  138474. },
  138475. enumerable: true,
  138476. configurable: true
  138477. });
  138478. /**
  138479. * Call this function to reduce memory footprint of the scene.
  138480. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  138481. */
  138482. Scene.prototype.clearCachedVertexData = function () {
  138483. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  138484. var mesh = this.meshes[meshIndex];
  138485. var geometry = mesh.geometry;
  138486. if (geometry) {
  138487. geometry._indices = [];
  138488. for (var vbName in geometry._vertexBuffers) {
  138489. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  138490. continue;
  138491. }
  138492. geometry._vertexBuffers[vbName]._buffer._data = null;
  138493. }
  138494. }
  138495. }
  138496. };
  138497. /**
  138498. * This function will remove the local cached buffer data from texture.
  138499. * It will save memory but will prevent the texture from being rebuilt
  138500. */
  138501. Scene.prototype.cleanCachedTextureBuffer = function () {
  138502. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  138503. var baseTexture = _a[_i];
  138504. var buffer = baseTexture._buffer;
  138505. if (buffer) {
  138506. baseTexture._buffer = null;
  138507. }
  138508. }
  138509. };
  138510. /**
  138511. * Get the world extend vectors with an optional filter
  138512. *
  138513. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  138514. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  138515. */
  138516. Scene.prototype.getWorldExtends = function (filterPredicate) {
  138517. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  138518. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  138519. filterPredicate = filterPredicate || (function () { return true; });
  138520. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  138521. mesh.computeWorldMatrix(true);
  138522. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  138523. return;
  138524. }
  138525. var boundingInfo = mesh.getBoundingInfo();
  138526. var minBox = boundingInfo.boundingBox.minimumWorld;
  138527. var maxBox = boundingInfo.boundingBox.maximumWorld;
  138528. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  138529. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  138530. });
  138531. return {
  138532. min: min,
  138533. max: max
  138534. };
  138535. };
  138536. // Picking
  138537. /**
  138538. * Creates a ray that can be used to pick in the scene
  138539. * @param x defines the x coordinate of the origin (on-screen)
  138540. * @param y defines the y coordinate of the origin (on-screen)
  138541. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  138542. * @param camera defines the camera to use for the picking
  138543. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  138544. * @returns a Ray
  138545. */
  138546. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  138547. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  138548. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138549. };
  138550. /**
  138551. * Creates a ray that can be used to pick in the scene
  138552. * @param x defines the x coordinate of the origin (on-screen)
  138553. * @param y defines the y coordinate of the origin (on-screen)
  138554. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  138555. * @param result defines the ray where to store the picking ray
  138556. * @param camera defines the camera to use for the picking
  138557. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  138558. * @returns the current scene
  138559. */
  138560. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  138561. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  138562. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138563. };
  138564. /**
  138565. * Creates a ray that can be used to pick in the scene
  138566. * @param x defines the x coordinate of the origin (on-screen)
  138567. * @param y defines the y coordinate of the origin (on-screen)
  138568. * @param camera defines the camera to use for the picking
  138569. * @returns a Ray
  138570. */
  138571. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  138572. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138573. };
  138574. /**
  138575. * Creates a ray that can be used to pick in the scene
  138576. * @param x defines the x coordinate of the origin (on-screen)
  138577. * @param y defines the y coordinate of the origin (on-screen)
  138578. * @param result defines the ray where to store the picking ray
  138579. * @param camera defines the camera to use for the picking
  138580. * @returns the current scene
  138581. */
  138582. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  138583. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138584. };
  138585. /** Launch a ray to try to pick a mesh in the scene
  138586. * @param x position on screen
  138587. * @param y position on screen
  138588. * @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
  138589. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  138590. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  138591. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138592. * @returns a PickingInfo
  138593. */
  138594. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  138595. // Dummy info if picking as not been imported
  138596. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__["PickingInfo"]();
  138597. pi._pickingUnavailable = true;
  138598. return pi;
  138599. };
  138600. /** Use the given ray to pick a mesh in the scene
  138601. * @param ray The ray to use to pick meshes
  138602. * @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
  138603. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  138604. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138605. * @returns a PickingInfo
  138606. */
  138607. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  138608. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138609. };
  138610. /**
  138611. * Launch a ray to try to pick a mesh in the scene
  138612. * @param x X position on screen
  138613. * @param y Y position on screen
  138614. * @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
  138615. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  138616. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138617. * @returns an array of PickingInfo
  138618. */
  138619. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  138620. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138621. };
  138622. /**
  138623. * Launch a ray to try to pick a mesh in the scene
  138624. * @param ray Ray to use
  138625. * @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
  138626. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138627. * @returns an array of PickingInfo
  138628. */
  138629. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  138630. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138631. };
  138632. /**
  138633. * Force the value of meshUnderPointer
  138634. * @param mesh defines the mesh to use
  138635. */
  138636. Scene.prototype.setPointerOverMesh = function (mesh) {
  138637. if (this._pointerOverMesh === mesh) {
  138638. return;
  138639. }
  138640. var actionManager;
  138641. if (this._pointerOverMesh) {
  138642. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOutTrigger);
  138643. if (actionManager) {
  138644. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(this._pointerOverMesh));
  138645. }
  138646. }
  138647. this._pointerOverMesh = mesh;
  138648. if (this._pointerOverMesh) {
  138649. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOverTrigger);
  138650. if (actionManager) {
  138651. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(this._pointerOverMesh));
  138652. }
  138653. }
  138654. };
  138655. /**
  138656. * Gets the mesh under the pointer
  138657. * @returns a Mesh or null if no mesh is under the pointer
  138658. */
  138659. Scene.prototype.getPointerOverMesh = function () {
  138660. return this._pointerOverMesh;
  138661. };
  138662. // Misc.
  138663. /** @hidden */
  138664. Scene.prototype._rebuildGeometries = function () {
  138665. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  138666. var geometry = _a[_i];
  138667. geometry._rebuild();
  138668. }
  138669. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  138670. var mesh = _c[_b];
  138671. mesh._rebuild();
  138672. }
  138673. if (this.postProcessManager) {
  138674. this.postProcessManager._rebuild();
  138675. }
  138676. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  138677. var component = _e[_d];
  138678. component.rebuild();
  138679. }
  138680. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  138681. var system = _g[_f];
  138682. system.rebuild();
  138683. }
  138684. };
  138685. /** @hidden */
  138686. Scene.prototype._rebuildTextures = function () {
  138687. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  138688. var texture = _a[_i];
  138689. texture._rebuild();
  138690. }
  138691. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  138692. };
  138693. // Tags
  138694. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  138695. if (tagsQuery === undefined) {
  138696. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  138697. return list;
  138698. }
  138699. var listByTags = [];
  138700. forEach = forEach || (function (item) { return; });
  138701. for (var i in list) {
  138702. var item = list[i];
  138703. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  138704. listByTags.push(item);
  138705. forEach(item);
  138706. }
  138707. }
  138708. return listByTags;
  138709. };
  138710. /**
  138711. * Get a list of meshes by tags
  138712. * @param tagsQuery defines the tags query to use
  138713. * @param forEach defines a predicate used to filter results
  138714. * @returns an array of Mesh
  138715. */
  138716. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  138717. return this._getByTags(this.meshes, tagsQuery, forEach);
  138718. };
  138719. /**
  138720. * Get a list of cameras by tags
  138721. * @param tagsQuery defines the tags query to use
  138722. * @param forEach defines a predicate used to filter results
  138723. * @returns an array of Camera
  138724. */
  138725. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  138726. return this._getByTags(this.cameras, tagsQuery, forEach);
  138727. };
  138728. /**
  138729. * Get a list of lights by tags
  138730. * @param tagsQuery defines the tags query to use
  138731. * @param forEach defines a predicate used to filter results
  138732. * @returns an array of Light
  138733. */
  138734. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  138735. return this._getByTags(this.lights, tagsQuery, forEach);
  138736. };
  138737. /**
  138738. * Get a list of materials by tags
  138739. * @param tagsQuery defines the tags query to use
  138740. * @param forEach defines a predicate used to filter results
  138741. * @returns an array of Material
  138742. */
  138743. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  138744. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  138745. };
  138746. /**
  138747. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  138748. * This allowed control for front to back rendering or reversly depending of the special needs.
  138749. *
  138750. * @param renderingGroupId The rendering group id corresponding to its index
  138751. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  138752. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  138753. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  138754. */
  138755. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  138756. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  138757. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  138758. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  138759. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  138760. };
  138761. /**
  138762. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  138763. *
  138764. * @param renderingGroupId The rendering group id corresponding to its index
  138765. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138766. * @param depth Automatically clears depth between groups if true and autoClear is true.
  138767. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  138768. */
  138769. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  138770. if (depth === void 0) { depth = true; }
  138771. if (stencil === void 0) { stencil = true; }
  138772. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  138773. };
  138774. /**
  138775. * Gets the current auto clear configuration for one rendering group of the rendering
  138776. * manager.
  138777. * @param index the rendering group index to get the information for
  138778. * @returns The auto clear setup for the requested rendering group
  138779. */
  138780. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  138781. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  138782. };
  138783. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  138784. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  138785. get: function () {
  138786. return this._blockMaterialDirtyMechanism;
  138787. },
  138788. set: function (value) {
  138789. if (this._blockMaterialDirtyMechanism === value) {
  138790. return;
  138791. }
  138792. this._blockMaterialDirtyMechanism = value;
  138793. if (!value) { // Do a complete update
  138794. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_AllDirtyFlag);
  138795. }
  138796. },
  138797. enumerable: true,
  138798. configurable: true
  138799. });
  138800. /**
  138801. * Will flag all materials as dirty to trigger new shader compilation
  138802. * @param flag defines the flag used to specify which material part must be marked as dirty
  138803. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  138804. */
  138805. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  138806. if (this._blockMaterialDirtyMechanism) {
  138807. return;
  138808. }
  138809. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  138810. var material = _a[_i];
  138811. if (predicate && !predicate(material)) {
  138812. continue;
  138813. }
  138814. material.markAsDirty(flag);
  138815. }
  138816. };
  138817. /** @hidden */
  138818. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  138819. var _this = this;
  138820. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  138821. this._activeRequests.push(request);
  138822. request.onCompleteObservable.add(function (request) {
  138823. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  138824. });
  138825. return request;
  138826. };
  138827. /** @hidden */
  138828. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  138829. var _this = this;
  138830. return new Promise(function (resolve, reject) {
  138831. _this._loadFile(url, function (data) {
  138832. resolve(data);
  138833. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  138834. reject(exception);
  138835. });
  138836. });
  138837. };
  138838. // Statics
  138839. Scene._uniqueIdCounter = 0;
  138840. /** The fog is deactivated */
  138841. Scene.FOGMODE_NONE = 0;
  138842. /** The fog density is following an exponential function */
  138843. Scene.FOGMODE_EXP = 1;
  138844. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  138845. Scene.FOGMODE_EXP2 = 2;
  138846. /** The fog density is following a linear function. */
  138847. Scene.FOGMODE_LINEAR = 3;
  138848. /**
  138849. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  138850. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  138851. */
  138852. Scene.MinDeltaTime = 1.0;
  138853. /**
  138854. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  138855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  138856. */
  138857. Scene.MaxDeltaTime = 1000.0;
  138858. /** The distance in pixel that you have to move to prevent some events */
  138859. Scene.DragMovementThreshold = 10; // in pixels
  138860. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  138861. Scene.LongPressDelay = 500; // in milliseconds
  138862. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  138863. Scene.DoubleClickDelay = 300; // in milliseconds
  138864. /** If you need to check double click without raising a single click at first click, enable this flag */
  138865. Scene.ExclusiveDoubleClickMode = false;
  138866. return Scene;
  138867. }(_abstractScene__WEBPACK_IMPORTED_MODULE_11__["AbstractScene"]));
  138868. /***/ }),
  138869. /***/ "./sceneComponent.ts":
  138870. /*!***************************!*\
  138871. !*** ./sceneComponent.ts ***!
  138872. \***************************/
  138873. /*! exports provided: SceneComponentConstants, Stage */
  138874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138875. "use strict";
  138876. __webpack_require__.r(__webpack_exports__);
  138877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  138878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  138879. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  138880. /**
  138881. * Groups all the scene component constants in one place to ease maintenance.
  138882. * @hidden
  138883. */
  138884. var SceneComponentConstants = /** @class */ (function () {
  138885. function SceneComponentConstants() {
  138886. }
  138887. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  138888. SceneComponentConstants.NAME_LAYER = "Layer";
  138889. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  138890. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  138891. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  138892. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  138893. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  138894. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  138895. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  138896. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  138897. SceneComponentConstants.NAME_SPRITE = "Sprite";
  138898. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  138899. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  138900. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  138901. SceneComponentConstants.NAME_OCTREE = "Octree";
  138902. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  138903. SceneComponentConstants.NAME_AUDIO = "Audio";
  138904. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  138905. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  138906. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  138907. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  138908. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  138909. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  138910. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  138911. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  138912. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  138913. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  138914. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  138915. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  138916. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  138917. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  138918. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  138919. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  138920. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  138921. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  138922. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  138923. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  138924. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  138925. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  138926. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  138927. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  138928. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  138929. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  138930. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  138931. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  138932. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  138933. return SceneComponentConstants;
  138934. }());
  138935. /**
  138936. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  138937. * @hidden
  138938. */
  138939. var Stage = /** @class */ (function (_super) {
  138940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  138941. /**
  138942. * Hide ctor from the rest of the world.
  138943. * @param items The items to add.
  138944. */
  138945. function Stage(items) {
  138946. return _super.apply(this, items) || this;
  138947. }
  138948. /**
  138949. * Creates a new Stage.
  138950. * @returns A new instance of a Stage
  138951. */
  138952. Stage.Create = function () {
  138953. return Object.create(Stage.prototype);
  138954. };
  138955. /**
  138956. * Registers a step in an ordered way in the targeted stage.
  138957. * @param index Defines the position to register the step in
  138958. * @param component Defines the component attached to the step
  138959. * @param action Defines the action to launch during the step
  138960. */
  138961. Stage.prototype.registerStep = function (index, component, action) {
  138962. var i = 0;
  138963. var maxIndex = Number.MAX_VALUE;
  138964. for (; i < this.length; i++) {
  138965. var step = this[i];
  138966. maxIndex = step.index;
  138967. if (index < maxIndex) {
  138968. break;
  138969. }
  138970. }
  138971. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  138972. };
  138973. /**
  138974. * Clears all the steps from the stage.
  138975. */
  138976. Stage.prototype.clear = function () {
  138977. this.length = 0;
  138978. };
  138979. return Stage;
  138980. }(Array));
  138981. /***/ })
  138982. /******/ });
  138983. });
  138984. //# sourceMappingURL=babylon.max.js.map